KD Chart 2  [rev.2.7]
kdganttitemdelegate.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 KDGANTTITEMDELEGATE_H
24 #define KDGANTTITEMDELEGATE_H
25 
26 #include <QItemDelegate>
27 #include <QBrush>
28 #include <QPen>
29 #include <QDebug>
30 
31 #include "kdganttglobal.h"
32 
33 namespace KDGantt {
34  class StyleOptionGanttItem;
35  class Constraint;
36 
37  class KDGANTT_EXPORT ItemDelegate : public QItemDelegate {
38  Q_OBJECT
40  public:
41  enum InteractionState { State_None = 0,
45  State_DragConstraint
46  };
47 
48  explicit ItemDelegate( QObject* parent = 0 );
49  ~ItemDelegate() override;
50 
51  void setDefaultBrush( ItemType type, const QBrush& brush );
52  QBrush defaultBrush( ItemType type ) const;
53 
54  void setDefaultPen( ItemType type, const QPen& pen );
55  QPen defaultPen( ItemType type ) const;
56 
57  virtual Span itemBoundingSpan(const StyleOptionGanttItem& opt, const QModelIndex& idx) const;
58  virtual QRectF constraintBoundingRect( const QPointF& start, const QPointF& end, const Constraint &constraint ) const;
59  virtual InteractionState interactionStateFor( const QPointF& pos,
60  const StyleOptionGanttItem& opt,
61  const QModelIndex& idx ) const;
62 
63  virtual void paintGanttItem( QPainter* p, const StyleOptionGanttItem& opt, const QModelIndex& idx );
64  virtual void paintConstraintItem( QPainter* p, const QStyleOptionGraphicsItem& opt,
65  const QPointF& start, const QPointF& end, const Constraint &constraint );
66 
67  virtual QString toolTip( const QModelIndex &idx ) const;
68 
69  protected:
70  void paintFinishStartConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt,
71  const QPointF& start, const QPointF& end, const Constraint &constraint );
72  QPolygonF finishStartLine( const QPointF& start, const QPointF& end ) const;
73  QPolygonF finishStartArrow( const QPointF& start, const QPointF& end ) const;
74 
75  void paintFinishFinishConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt,
76  const QPointF& start, const QPointF& end, const Constraint &constraint );
77  QPolygonF finishFinishLine( const QPointF& start, const QPointF& end ) const;
78  QPolygonF finishFinishArrow( const QPointF& start, const QPointF& end ) const;
79 
80  void paintStartStartConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt,
81  const QPointF& start, const QPointF& end, const Constraint &constraint );
82  QPolygonF startStartLine( const QPointF& start, const QPointF& end ) const;
83  QPolygonF startStartArrow( const QPointF& start, const QPointF& end ) const;
84 
85  void paintStartFinishConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt,
86  const QPointF& start, const QPointF& end, const Constraint &constraint );
87  QPolygonF startFinishLine( const QPointF& start, const QPointF& end ) const;
88  QPolygonF startFinishArrow( const QPointF& start, const QPointF& end ) const;
89 
90 
91  };
92 }
93 
94 #ifndef QT_NO_DEBUG_STREAM
96 #endif
97 
98 #endif /* KDGANTTITEMDELEGATE_H */
99 
#define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC(X)
A class used to represent a dependency.
Class used to render gantt items in a KDGantt::GraphicsView.
A class representing a start point and a length.
QDebug operator<<(QDebug dbg, KDGantt::ItemDelegate::InteractionState)
QStyleOption subclass for gantt items.
Class only listed here to document inheritance of some KDChart classes.

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/