KD Chart 2
[rev.2.5]
|
00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 00003 ** 00004 ** This file is part of the KD Chart library. 00005 ** 00006 ** Licensees holding valid commercial KD Chart licenses may use this file in 00007 ** accordance with the KD Chart Commercial License Agreement provided with 00008 ** the Software. 00009 ** 00010 ** 00011 ** This file may be distributed and/or modified under the terms of the 00012 ** GNU General Public License version 2 and version 3 as published by the 00013 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** Contact info@kdab.com if any conditions of this licensing are not 00019 ** clear to you. 00020 ** 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 QT_BEGIN_NAMESPACE 00034 class QAbstractProxyModel; 00035 class QItemSelectionModel; 00036 class QPrinter; 00037 QT_END_NAMESPACE 00038 00039 namespace KDGantt { 00040 class AbstractGrid; 00041 class AbstractRowController; 00042 class GraphicsItem; 00043 class Constraint; 00044 class ConstraintModel; 00045 class ConstraintGraphicsItem; 00046 class ItemDelegate; 00047 00048 class KDCHART_EXPORT GraphicsScene : public QGraphicsScene { 00049 Q_OBJECT 00050 KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( GraphicsScene ) 00051 public: 00052 explicit GraphicsScene( QObject* parent=0 ); 00053 virtual ~GraphicsScene(); 00054 00055 //qreal dateTimeToSceneX( const QDateTime& dt ) const; 00056 //QDateTime sceneXtoDateTime( qreal x ) const; 00057 00058 static QModelIndex mainIndex( const QModelIndex& idx ); 00059 static QModelIndex dataIndex( const QModelIndex& idx ); 00060 00061 QAbstractItemModel* model() const; 00062 QAbstractProxyModel* summaryHandlingModel() const; 00063 QModelIndex rootIndex() const; 00064 ConstraintModel* constraintModel() const; 00065 QItemSelectionModel* selectionModel() const; 00066 00067 void insertItem( const QPersistentModelIndex&, GraphicsItem* ); 00068 void removeItem( const QModelIndex& ); 00069 using QGraphicsScene::removeItem; 00070 GraphicsItem* findItem( const QModelIndex& ) const; 00071 GraphicsItem* findItem( const QPersistentModelIndex& ) const; 00072 00073 void updateItems(); 00074 void clearItems(); 00075 void deleteSubtree( const QModelIndex& ); 00076 00077 ConstraintGraphicsItem* findConstraintItem( const Constraint& ) const; 00078 QList<ConstraintGraphicsItem*> findConstraintItems( const QModelIndex& idx ) const; 00079 void clearConstraintItems(); 00080 00081 void setItemDelegate( ItemDelegate* ); 00082 ItemDelegate* itemDelegate() const; 00083 00084 void setRowController( AbstractRowController* rc ); 00085 AbstractRowController* rowController() const; 00086 00087 void setGrid( AbstractGrid* grid ); 00088 AbstractGrid* grid() const; 00089 00090 bool isReadOnly() const; 00091 00092 void updateRow( const QModelIndex& idx ); 00093 GraphicsItem* createItem( ItemType type ) const; 00094 00095 /* used by GraphicsItem */ 00096 void itemEntered( const QModelIndex& ); 00097 void itemPressed( const QModelIndex& ); 00098 void itemClicked( const QModelIndex& ); 00099 void itemDoubleClicked( const QModelIndex& ); 00100 void setDragSource( GraphicsItem* item ); 00101 GraphicsItem* dragSource() const; 00102 00103 /* Printing */ 00104 void print( QPrinter* printer, bool drawRowLabels = true, bool drawColumnLabels = true ); 00105 void print( QPrinter* printer, qreal start, qreal end, bool drawRowLabels = true, bool drawColumnLabels = true ); 00106 void print( QPainter* painter, const QRectF& target = QRectF(), bool drawRowLabels=true, bool drawColumnLabels = true ); 00107 void print( QPainter* painter, qreal start, qreal end, const QRectF& target = QRectF(), bool drawRowLabels=true, bool drawColumnLabels = true ); 00108 00109 Q_SIGNALS: 00110 void gridChanged(); 00111 00112 void clicked( const QModelIndex & index ); 00113 void qrealClicked( const QModelIndex & index ); 00114 void entered( const QModelIndex & index ); 00115 void pressed( const QModelIndex & index ); 00116 00117 protected: 00118 /*reimp*/ void helpEvent( QGraphicsSceneHelpEvent *helpEvent ); 00119 /*reimp*/ void drawBackground( QPainter* painter, const QRectF& rect ); 00120 /*reimp*/ void drawForeground( QPainter* painter, const QRectF& rect ); 00121 00122 public Q_SLOTS: 00123 void setModel( QAbstractItemModel* ); 00124 void setSummaryHandlingModel( QAbstractProxyModel* ); 00125 void setConstraintModel( ConstraintModel* ); 00126 void setRootIndex( const QModelIndex& idx ); 00127 void setSelectionModel( QItemSelectionModel* selectionmodel ); 00128 void setReadOnly( bool ); 00129 00130 private Q_SLOTS: 00131 /* slots for ConstraintModel */ 00132 void slotConstraintAdded( const KDGantt::Constraint& ); 00133 void slotConstraintRemoved( const KDGantt::Constraint& ); 00134 void slotGridChanged(); 00135 private: 00136 void doPrint( QPainter* painter, const QRectF& targetRect, 00137 qreal start, qreal end, 00138 QPrinter* printer, bool drawRowLabels, bool drawColumnLabels ); 00139 }; 00140 } 00141 00142 #endif /* KDGANTTGRAPHICSSCENE_H */