karbon

vdocumentdocker.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, 2002, 2003 The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __VDOCUMENTDOCKER_H__
00021 #define __VDOCUMENTDOCKER_H__
00022 
00023 #include <qlistview.h>
00024 #include <qptrdict.h>
00025 
00026 class QHButtonGroup;
00027 class QPoint;
00028 class QLabel;
00029 class QPixmap;
00030 class QCheckBox;
00031 
00032 class VDocument;
00033 class VLayer;
00034 class KarbonView;
00035 
00036 /*************************************************************************
00037  *  Document Tab                                                         *
00038  *************************************************************************/
00039 
00040 class VDocumentPreview : public QWidget
00041 {
00042     Q_OBJECT
00043 
00044     public:
00045         VDocumentPreview( KarbonView* view, QWidget* parent = 0 );
00046         ~VDocumentPreview();
00047 
00048         void reset();
00049 
00050     protected:
00051         void paintEvent( QPaintEvent* e );
00052         virtual bool eventFilter( QObject* object, QEvent* event );
00053 
00054     private:
00055         VDocument   *m_document;
00056         KarbonView  *m_view;
00057         KoPoint     m_firstPoint;
00058         KoPoint     m_lastPoint;
00059         bool        m_dragging;
00060         QPixmap     *m_docpixmap;
00061 }; // VDocumentPreview
00062 
00063 class VDocumentTab : public QWidget
00064 {
00065     Q_OBJECT
00066 
00067     public:
00068         VDocumentTab( KarbonView* view, QWidget* parent );
00069         ~VDocumentTab();
00070 
00071     public slots:
00072         void updateDocumentInfo();
00073         void slotCommandAdded( VCommand* command );
00074         void slotZoomChanged( double );
00075         void slotViewportChanged();
00076         void slotCommandExecuted();
00077 
00078     private:
00079         VDocumentPreview*   m_documentPreview;
00080         QLabel*             m_height;
00081         QLabel*             m_width;
00082         QLabel*             m_layers;
00083         QLabel*             m_format;
00084 
00085         KarbonView*         m_view;
00086 }; // VDocumentTab
00087 
00088 /*************************************************************************
00089  *  Layers Tab                                                           *
00090  *************************************************************************/
00091 
00092 class VLayerListViewItem : public QCheckListItem
00093 {
00094 public:
00095     VLayerListViewItem( QListView* parent, VLayer* layer, VDocument *doc, QPtrDict<VLayerListViewItem> *map );
00096     virtual ~VLayerListViewItem();
00097 
00098     VLayer* layer() { return m_layer; }
00099     int pos();
00100     void update();
00101     virtual QString key( int column, bool ascending ) const;
00102     virtual int compare( QListViewItem *i, int col, bool ascending ) const;
00103     void setKey( uint key ) { m_key = key; }
00104 
00105 protected:
00106     virtual void stateChange( bool on );
00107 
00108 private:
00109     VLayer      *m_layer;
00110     VDocument   *m_document;
00111     uint         m_key;
00112     QPtrDict<VLayerListViewItem> *m_map;
00113 }; // VLayerListViewItem
00114 
00115 class VObjectListViewItem : public QListViewItem
00116 {
00117 public:
00118     VObjectListViewItem( QListViewItem* parent, VObject* object, VDocument *doc, uint key, QPtrDict<VObjectListViewItem> *map );
00119     virtual ~VObjectListViewItem();
00120 
00121     VObject* object() { return m_object; }
00122     void update();
00123     virtual QString key( int column, bool ascending ) const;
00124     virtual int compare( QListViewItem *i, int col, bool ascending ) const;
00125     void setKey( uint key ) { m_key = key; }
00126 private:
00127     VObject     *m_object;
00128     VDocument   *m_document;
00129     uint         m_key;
00130     QPtrDict<VObjectListViewItem> *m_map;
00131 };
00132 
00133 class VLayersTab : public QWidget
00134 {
00135 Q_OBJECT
00136 
00137 public:
00138     VLayersTab( KarbonView* view, QWidget* parent = 0 );
00139     ~VLayersTab();
00140 
00141 public slots:
00142     void updatePreviews();
00143     void updateLayers();
00144 
00145     void itemClicked( QListViewItem* item, const QPoint&, int col );
00146     void selectionChangedFromList();
00147     void selectionChangedFromTool();
00148     void renameItem( QListViewItem* item, const QPoint&, int col );
00149     void addLayer();
00150     void raiseItem();
00151     void lowerItem();
00152     void deleteItem();
00153     void slotCommandExecuted( VCommand* command );
00154 
00155 private slots:
00156     void slotButtonClicked( int ID );
00157     void removeDeletedObjectsFromList();
00158     void updateChildItems( QListViewItem *item );
00159     void toggleState( VObject *obj, int col );
00160 
00161 protected:
00162     VLayerListViewItem* listItem( int pos );
00163     void updateObjects( VObject *object, QListViewItem *item );
00164     void resetSelection();
00165     void selectActiveLayer();
00166 
00167 private:
00168     QListView                       *m_layersListView;
00169     QHButtonGroup                   *m_buttonGroup;
00170     KarbonView                      *m_view;
00171     VDocument                       *m_document;
00172     QPtrDict<VLayerListViewItem>    m_layers;
00173     QPtrDict<VObjectListViewItem>   m_objects;
00174 }; // VLayersTab
00175 
00176 /*************************************************************************
00177  *  History Tab                                                          *
00178  *************************************************************************/
00179 
00180 class VHistoryItem;
00181  
00182 class VHistoryGroupItem : public QListViewItem
00183 {
00184     public:
00185         VHistoryGroupItem( VHistoryItem* item, QListView* parent, QListViewItem* after );
00186         ~VHistoryGroupItem();
00187 
00188         void paintCell( QPainter* p, const QColorGroup& cg, int column, int width, int align );
00189         void paintFocus( QPainter*, const QColorGroup&, const QRect& );
00190 
00191         virtual QString key( int, bool ) const { return m_key; }
00192         virtual int rtti() const { return 1001; }
00193 
00194     private:
00195         QString m_key;
00196 }; // VHistoryGroupItem
00197  
00198 class VHistoryItem : public QListViewItem
00199 {
00200     public:
00201         VHistoryItem( VCommand* command, QListView* parent, QListViewItem* after );
00202         VHistoryItem( VCommand* command, VHistoryGroupItem* parent, QListViewItem* after );
00203         ~VHistoryItem();
00204 
00205         VCommand* command() { return m_command; }
00206 
00207         void paintCell( QPainter* p, const QColorGroup& cg, int column, int width, int align );
00208         void paintFocus( QPainter*, const QColorGroup&, const QRect& );
00209 
00210         virtual QString key( int, bool ) const { return m_key; }
00211         virtual int rtti() const { return 1002; }
00212 
00213     private:
00214         void init();
00215 
00216         QString     m_key;
00217         VCommand*   m_command;
00218 }; // VHistoryItem
00219 
00220 class VHistoryTab : public QWidget
00221 {
00222     Q_OBJECT
00223 
00224     public:
00225         VHistoryTab( KarbonPart* part, QWidget* parent );
00226         ~VHistoryTab();
00227 
00228         bool groupingEnabled();
00229 
00230     public slots:
00231         void historyCleared();
00232         void commandExecuted( VCommand* command );
00233         void slotCommandAdded( VCommand* command );
00234         void removeFirstCommand();
00235         void removeLastCommand();
00236 
00237         void commandClicked( int button, QListViewItem* item, const QPoint& point, int col );
00238         void groupingChanged( int );
00239 
00240     signals:
00241         void undoCommand( VCommand* command );
00242         void redoCommand( VCommand* command );
00243         void undoCommandsTo( VCommand* command );
00244         void redoCommandsTo( VCommand* command );
00245 
00246     private:
00247         QListView*      m_history;
00248         QListViewItem*  m_lastCommand;
00249         QCheckBox*      m_groupCommands;
00250         long            m_lastCommandIndex;
00251 
00252         KarbonPart*     m_part;
00253 }; // VHistoryTab
00254 
00255 #endif
00256 
KDE Home | KDE Accessibility Home | Description of Access Keys