kdgantt
kdganttgraphicsscene.h
Go to the documentation of this file.00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB. All rights reserved. 00003 ** 00004 ** This file is part of the KD Gantt library. 00005 ** 00006 ** This file may be used under the terms of the GNU General Public 00007 ** License versions 2.0 or 3.0 as published by the Free Software 00008 ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 00009 ** included in the packaging of this file. Alternatively you may (at 00010 ** your option) use any later version of the GNU General Public 00011 ** License if such license has been publicly approved by 00012 ** Klarälvdalens Datakonsult AB (or its successors, if any). 00013 ** 00014 ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, 00015 ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR 00016 ** A PARTICULAR PURPOSE. Klarälvdalens Datakonsult AB reserves all rights 00017 ** not expressly granted herein. 00018 ** 00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00021 ** 00022 **********************************************************************/ 00023 #ifndef KDGANTTGRAPHICSSCENE_H 00024 #define KDGANTTGRAPHICSSCENE_H 00025 00026 #include <QDateTime> 00027 #include <QList> 00028 #include <QGraphicsScene> 00029 #include <QModelIndex> 00030 00031 #include "kdganttglobal.h" 00032 00033 class QAbstractProxyModel; 00034 class QItemSelectionModel; 00035 00036 namespace KDGantt { 00037 class AbstractGrid; 00038 class AbstractRowController; 00039 class GraphicsItem; 00040 class Constraint; 00041 class ConstraintModel; 00042 class ConstraintGraphicsItem; 00043 class ItemDelegate; 00044 class GraphicsView; 00045 00046 class GraphicsScene : public QGraphicsScene { 00047 Q_OBJECT 00048 KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( GraphicsScene ) 00049 public: 00050 explicit GraphicsScene( QObject* parent=0 ); 00051 virtual ~GraphicsScene(); 00052 00053 //qreal dateTimeToSceneX( const QDateTime& dt ) const; 00054 //QDateTime sceneXtoDateTime( qreal x ) const; 00055 00056 static QModelIndex mainIndex( const QModelIndex& idx ); 00057 static QModelIndex dataIndex( const QModelIndex& idx ); 00058 00059 QAbstractItemModel* model() const; 00060 QAbstractProxyModel* summaryHandlingModel() const; 00061 QModelIndex rootIndex() const; 00062 ConstraintModel* constraintModel() const; 00063 QItemSelectionModel* selectionModel() const; 00064 00065 void insertItem( const QPersistentModelIndex&, GraphicsItem* ); 00066 void removeItem( const QModelIndex& ); 00067 GraphicsItem* findItem( const QModelIndex& ) const; 00068 GraphicsItem* findItem( const QPersistentModelIndex& ) const; 00069 00070 void updateItems(); 00071 void clearItems(); 00072 void deleteSubtree( const QModelIndex& ); 00073 00074 ConstraintGraphicsItem* findConstraintItem( const Constraint& ) const; 00075 QList<ConstraintGraphicsItem*> findConstraintItems( const QModelIndex& idx ) const; 00076 void clearConstraintItems(); 00077 00078 void setItemDelegate( ItemDelegate* ); 00079 ItemDelegate* itemDelegate() const; 00080 00081 void setRowController( AbstractRowController* rc ); 00082 AbstractRowController* rowController() const; 00083 00084 void setGrid( AbstractGrid* grid ); 00085 AbstractGrid* grid() const; 00086 00087 bool isReadOnly() const; 00088 00089 void updateRow( const QModelIndex& idx ); 00090 GraphicsItem* createItem( ItemType type ) const; 00091 00092 /* used by GraphicsItem */ 00093 void itemEntered( const QModelIndex& ); 00094 void itemPressed( const QModelIndex& ); 00095 void itemClicked( const QModelIndex& ); 00096 void itemDoubleClicked( const QModelIndex& ); 00097 void setDragSource( GraphicsItem* item ); 00098 GraphicsItem* dragSource() const; 00099 00100 /* Printing */ 00101 void print( QPainter* painter, const QRectF& target = QRectF(), const QRectF& source = QRectF(), bool drawRowLabels=true, GraphicsView *view=0 ); 00102 QRectF printRect(bool drawRowLabels=true ); 00103 00104 Q_SIGNALS: 00105 void gridChanged(); 00106 00107 void clicked( const QModelIndex & index ); 00108 void doubleClicked( const QModelIndex & index ); 00109 void entered( const QModelIndex & index ); 00110 void pressed( const QModelIndex & index ); 00111 00112 protected: 00113 /*reimp*/ void helpEvent( QGraphicsSceneHelpEvent *helpEvent ); 00114 /*reimp*/ void drawBackground( QPainter* painter, const QRectF& rect ); 00115 00116 public Q_SLOTS: 00117 void setModel( QAbstractItemModel* ); 00118 void setSummaryHandlingModel( QAbstractProxyModel* ); 00119 void setConstraintModel( ConstraintModel* ); 00120 void setRootIndex( const QModelIndex& idx ); 00121 void setSelectionModel( QItemSelectionModel* selectionmodel ); 00122 void setReadOnly( bool ); 00123 00124 private Q_SLOTS: 00125 /* slots for ConstraintModel */ 00126 void slotConstraintAdded( const Constraint& ); 00127 void slotConstraintRemoved( const Constraint& ); 00128 void slotGridChanged(); 00129 }; 00130 } 00131 00132 #endif /* KDGANTTGRAPHICSSCENE_H */
KDE 4.2 API Reference