KD Chart 2  [rev.2.7]
kdganttgraphicsscene.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef KDGANTTGRAPHICSSCENE_H
24 #define KDGANTTGRAPHICSSCENE_H
25 
26 #include <QDateTime>
27 #include <QList>
28 #include <QGraphicsScene>
29 #include <QModelIndex>
30 
31 #include "kdganttglobal.h"
32 
33 QT_BEGIN_NAMESPACE
35 class QItemSelectionModel;
36 class QPrinter;
37 QT_END_NAMESPACE
38 
39 namespace KDGantt {
40  class AbstractGrid;
41  class AbstractRowController;
42  class GraphicsItem;
43  class Constraint;
44  class ConstraintModel;
45  class ConstraintGraphicsItem;
46  class ItemDelegate;
47 
48  class KDGANTT_EXPORT GraphicsScene : public QGraphicsScene {
49  Q_OBJECT
51  public:
52  explicit GraphicsScene( QObject* parent=0 );
53  ~GraphicsScene() override;
54 
55  //qreal dateTimeToSceneX( const QDateTime& dt ) const;
56  //QDateTime sceneXtoDateTime( qreal x ) const;
57 
58  static QModelIndex mainIndex( const QModelIndex& idx );
59  static QModelIndex dataIndex( const QModelIndex& idx );
60 
61  QAbstractItemModel* model() const;
62  QAbstractProxyModel* summaryHandlingModel() const;
63  QModelIndex rootIndex() const;
64  ConstraintModel* constraintModel() const;
65  QItemSelectionModel* selectionModel() const;
66 
67  void insertItem( const QPersistentModelIndex&, GraphicsItem* );
68  void removeItem( const QModelIndex& );
69  using QGraphicsScene::removeItem;
70  GraphicsItem* findItem( const QModelIndex& ) const;
71  GraphicsItem* findItem( const QPersistentModelIndex& ) const;
72 
73  void updateItems();
74  void clearItems();
75  void deleteSubtree( const QModelIndex& );
76 
77  ConstraintGraphicsItem* findConstraintItem( const Constraint& ) const;
78  void clearConstraintItems();
79 
80  void setItemDelegate( ItemDelegate* );
81  ItemDelegate* itemDelegate() const;
82 
83  void setRowController( AbstractRowController* rc );
84  AbstractRowController* rowController() const;
85 
86  void setGrid( AbstractGrid* grid );
87  AbstractGrid* grid() const;
88 
89  bool isReadOnly() const;
90 
91  void updateRow( const QModelIndex& idx );
92  GraphicsItem* createItem( ItemType type ) const;
93 
94  /* used by GraphicsItem */
95  void itemEntered( const QModelIndex& );
96  void itemPressed( const QModelIndex& );
97  void itemClicked( const QModelIndex& );
98  void itemDoubleClicked( const QModelIndex& );
99  void setDragSource( GraphicsItem* item );
100  GraphicsItem* dragSource() const;
101 
102  /* Printing */
103  void print( QPrinter* printer, bool drawRowLabels = true, bool drawColumnLabels = true );
104  void print( QPrinter* printer, qreal start, qreal end, bool drawRowLabels = true, bool drawColumnLabels = true );
105  void print( QPainter* painter, const QRectF& target = QRectF(), bool drawRowLabels=true, bool drawColumnLabels = true );
106  void print( QPainter* painter, qreal start, qreal end, const QRectF& target = QRectF(), bool drawRowLabels=true, bool drawColumnLabels = true );
107 
108  Q_SIGNALS:
109  void gridChanged();
110 
111  void clicked( const QModelIndex & index );
112  void qrealClicked( const QModelIndex & index );
113  void entered( const QModelIndex & index );
114  void pressed( const QModelIndex & index );
115 
116  protected:
117  /*reimp*/ void helpEvent( QGraphicsSceneHelpEvent *helpEvent ) override;
118  /*reimp*/ void drawBackground( QPainter* painter, const QRectF& rect ) override;
119  /*reimp*/ void drawForeground( QPainter* painter, const QRectF& rect ) override;
120 
121  public Q_SLOTS:
122  void setModel( QAbstractItemModel* );
123  void setSummaryHandlingModel( QAbstractProxyModel* );
124  void setConstraintModel( ConstraintModel* );
125  void setRootIndex( const QModelIndex& idx );
126  void setSelectionModel( QItemSelectionModel* selectionmodel );
127  void setReadOnly( bool );
128 
129  private Q_SLOTS:
130  /* slots for ConstraintModel */
131  void slotConstraintAdded( const KDGantt::Constraint& );
132  void slotConstraintRemoved( const KDGantt::Constraint& );
133  void slotGridChanged();
134  private:
135  void doPrint( QPainter* painter, const QRectF& targetRect,
136  qreal start, qreal end,
137  QPrinter* printer, bool drawRowLabels, bool drawColumnLabels );
138  };
139 }
140 
141 #endif /* KDGANTTGRAPHICSSCENE_H */
#define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC(X)
Abstract baseclass for grids. A grid is used to convert between QModelIndex&#39;es and gantt chart values...
A class used to represent a dependency.
Class used to render gantt items in a KDGantt::GraphicsView.
Class only listed here to document inheritance of some KDChart classes.
Class only listed here to document inheritance of some KDChart classes.
Abstract baseclass for row controllers. A row controller is used by the GraphicsView to nagivate the ...

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/

https://www.kdab.com/development-resources/qt-tools/kd-chart/