KD Chart API Documentation  3.1
kdganttgraphicsscene.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Chart library.
4 **
5 ** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: MIT
8 **
9 ****************************************************************************/
10 
11 #ifndef KDGANTTGRAPHICSSCENE_H
12 #define KDGANTTGRAPHICSSCENE_H
13 
14 #include <QDateTime>
15 #include <QGraphicsScene>
16 #include <QList>
17 #include <QModelIndex>
18 
19 #include "kdganttglobal.h"
20 
21 QT_BEGIN_NAMESPACE
22 class QAbstractProxyModel;
23 class QItemSelectionModel;
24 class QPrinter;
25 QT_END_NAMESPACE
26 
27 namespace KDGantt {
28 class AbstractGrid;
29 class AbstractRowController;
30 class GraphicsItem;
31 class Constraint;
32 class ConstraintModel;
33 class ConstraintGraphicsItem;
34 class ItemDelegate;
35 
36 class KDGANTT_EXPORT GraphicsScene : public QGraphicsScene
37 {
38  Q_OBJECT
40 public:
41  explicit GraphicsScene(QObject *parent = nullptr);
42  ~GraphicsScene() override;
43 
44  // qreal dateTimeToSceneX( const QDateTime& dt ) const;
45  // QDateTime sceneXtoDateTime( qreal x ) const;
46 
47  static QModelIndex mainIndex(const QModelIndex &idx);
48  static QModelIndex dataIndex(const QModelIndex &idx);
49 
50  QAbstractItemModel *model() const;
51  QAbstractProxyModel *summaryHandlingModel() const;
52  QModelIndex rootIndex() const;
53  ConstraintModel *constraintModel() const;
54  QItemSelectionModel *selectionModel() const;
55 
56  void insertItem(const QPersistentModelIndex &, GraphicsItem *);
57  void removeItem(const QModelIndex &);
58  using QGraphicsScene::removeItem;
59  GraphicsItem *findItem(const QModelIndex &) const;
60  GraphicsItem *findItem(const QPersistentModelIndex &) const;
61 
62  void updateItems();
63  void clearItems();
64  void deleteSubtree(const QModelIndex &);
65 
66  ConstraintGraphicsItem *findConstraintItem(const Constraint &) const;
67  void clearConstraintItems();
68 
69  void setItemDelegate(ItemDelegate *);
70  ItemDelegate *itemDelegate() const;
71 
72  void setRowController(AbstractRowController *rc);
73  AbstractRowController *rowController() const;
74 
75  void setGrid(AbstractGrid *grid);
76  AbstractGrid *grid() const;
77 
78  bool isReadOnly() const;
79 
80  void updateRow(const QModelIndex &idx);
81  GraphicsItem *createItem(ItemType type) const;
82 
83  /* used by GraphicsItem */
84  void itemEntered(const QModelIndex &);
85  void itemPressed(const QModelIndex &);
86  void itemClicked(const QModelIndex &);
87  void itemDoubleClicked(const QModelIndex &);
88  void setDragSource(GraphicsItem *item);
89  GraphicsItem *dragSource() const;
90 
91  /* Printing */
92  void print(QPrinter *printer, bool drawRowLabels = true, bool drawColumnLabels = true);
93  void print(QPrinter *printer, qreal start, qreal end, bool drawRowLabels = true, bool drawColumnLabels = true);
94  void print(QPainter *painter, const QRectF &target = QRectF(), bool drawRowLabels = true, bool drawColumnLabels = true);
95  void print(QPainter *painter, qreal start, qreal end, const QRectF &target = QRectF(), bool drawRowLabels = true, bool drawColumnLabels = true);
96 
97 Q_SIGNALS:
98  void gridChanged();
99 
100  void clicked(const QModelIndex &index);
101  void qrealClicked(const QModelIndex &index);
102  void entered(const QModelIndex &index);
103  void pressed(const QModelIndex &index);
104 
105 protected:
106  /*reimp*/ void helpEvent(QGraphicsSceneHelpEvent *helpEvent) override;
107  /*reimp*/ void drawBackground(QPainter *painter, const QRectF &rect) override;
108  /*reimp*/ void drawForeground(QPainter *painter, const QRectF &rect) override;
109 
110 public Q_SLOTS:
111  void setModel(QAbstractItemModel *);
112  void setSummaryHandlingModel(QAbstractProxyModel *);
113  void setConstraintModel(ConstraintModel *);
114  void setRootIndex(const QModelIndex &idx);
115  void setSelectionModel(QItemSelectionModel *selectionmodel);
116  void setReadOnly(bool);
117 
118 private Q_SLOTS:
119  /* slots for ConstraintModel */
120  void slotConstraintAdded(const KDGantt::Constraint &);
121  void slotConstraintRemoved(const KDGantt::Constraint &);
122  void slotGridChanged();
123 
124 private:
125  void doPrint(QPainter *painter, const QRectF &targetRect,
126  qreal start, qreal end,
127  QPrinter *printer, bool drawRowLabels, bool drawColumnLabels);
128 };
129 }
130 
131 #endif /* KDGANTTGRAPHICSSCENE_H */
Abstract baseclass for grids.
Abstract baseclass for row controllers.
The ConstraintModel keeps track of the interdependencies between gantt items in a View.
A class used to represent a dependency.
void entered(const QModelIndex &index)
void clicked(const QModelIndex &index)
void qrealClicked(const QModelIndex &index)
void pressed(const QModelIndex &index)
Class used to render gantt items in a KDGantt::GraphicsView.
Contains KDGantt macros.
#define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC(X)
ItemType
The values of this enum are used to represent the different types of gantt items that KDGantt underst...

© 2001 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/
Generated by doxygen 1.9.1