KD Chart 2  [rev.2.5.1]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
kdganttgraphicsview.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2013 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 KDGANTTGRAPHICSVIEW_H
24 #define KDGANTTGRAPHICSVIEW_H
25 
26 #include <QGraphicsView>
27 #include <QPrinter>
28 
29 #include "kdganttglobal.h"
30 
31 QT_BEGIN_NAMESPACE
32 class QModelIndex;
33 class QAbstractItemModel;
35 class QItemSelectionModel;
36 QT_END_NAMESPACE
37 
38 namespace KDGantt {
39  class AbstractRowController;
40  class AbstractGrid;
41  class GraphicsItem;
42  class ConstraintModel;
43  class ItemDelegate;
44 
45  class KDGANTT_EXPORT GraphicsView : public QGraphicsView {
46  Q_OBJECT
48 
49  Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
50 
51  Q_PRIVATE_SLOT( d, void slotGridChanged() )
52  Q_PRIVATE_SLOT( d, void slotHorizontalScrollValueChanged( int ) )
53  Q_PRIVATE_SLOT( d, void slotHeaderContextMenuRequested( const QPoint& ) )
54  /* slots for QAbstractItemModel signals */
55  Q_PRIVATE_SLOT( d, void slotColumnsInserted( const QModelIndex& parent, int start, int end ) )
56  Q_PRIVATE_SLOT( d, void slotColumnsRemoved( const QModelIndex& parent, int start, int end ) )
57  Q_PRIVATE_SLOT( d, void slotDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight ) )
58  Q_PRIVATE_SLOT( d, void slotLayoutChanged() )
59  Q_PRIVATE_SLOT( d, void slotModelReset() )
60  Q_PRIVATE_SLOT( d, void slotRowsInserted( const QModelIndex& parent, int start, int end ) )
61  Q_PRIVATE_SLOT( d, void slotRowsAboutToBeRemoved( const QModelIndex& parent, int start, int end ) )
62  Q_PRIVATE_SLOT( d, void slotRowsRemoved( const QModelIndex& parent, int start, int end ) )
63 
64  Q_PRIVATE_SLOT( d, void slotItemClicked( const QModelIndex& idx ) )
65  Q_PRIVATE_SLOT( d, void slotItemDoubleClicked( const QModelIndex& idx ) )
66  public:
67 
68  explicit GraphicsView( QWidget* parent=0 );
69  virtual ~GraphicsView();
70 
71  QAbstractItemModel* model() const;
72  QAbstractProxyModel* summaryHandlingModel() const;
73  ConstraintModel* constraintModel() const;
74  QModelIndex rootIndex() const;
75  QItemSelectionModel* selectionModel() const;
76  AbstractRowController* rowController() const;
77  AbstractGrid* grid() const;
78  ItemDelegate* itemDelegate() const;
79 
80  bool isReadOnly() const;
81 
82  void setHeaderContextMenuPolicy( Qt::ContextMenuPolicy );
83  Qt::ContextMenuPolicy headerContextMenuPolicy() const;
84 
85  QModelIndex indexAt( const QPoint& pos ) const;
86 
87  virtual void addConstraint( const QModelIndex& from,
88  const QModelIndex& to,
89  Qt::KeyboardModifiers modifiers );
90 
91  void clearItems();
92  void updateRow( const QModelIndex& );
93  void updateScene();
94 
95  public Q_SLOTS:
96  void updateSceneRect();
97 
98  public:
99  void deleteSubtree( const QModelIndex& );
100 
101  void print( QPrinter* printer, bool drawRowLabels = true, bool drawColumnLabels = true );
102  void print( QPrinter* printer, qreal start, qreal end, bool drawRowLabels = true, bool drawColumnLabels = true );
103  void print( QPainter* painter, const QRectF& target = QRectF(), bool drawRowLabels = true, bool drawColumnLabels = true );
104  void print( QPainter* painter, qreal start, qreal end,
105  const QRectF& target = QRectF(), bool drawRowLabels = true, bool drawColumnLabels = true );
106 
107  public Q_SLOTS:
108  void setModel( QAbstractItemModel* );
109  void setSummaryHandlingModel( QAbstractProxyModel* model );
110  void setConstraintModel( ConstraintModel* );
111  void setRootIndex( const QModelIndex& );
112  void setSelectionModel( QItemSelectionModel* );
113  void setRowController( AbstractRowController* );
114  void setGrid( AbstractGrid* );
115  void setItemDelegate( ItemDelegate* delegate );
116  void setReadOnly( bool );
117 
118  Q_SIGNALS:
119  void activated( const QModelIndex & index );
120  void clicked( const QModelIndex & index );
121  void qrealClicked( const QModelIndex & index );
122  void entered( const QModelIndex & index );
123  void pressed( const QModelIndex & index );
124  void headerContextMenuRequested( const QPoint& pt );
125 
126  protected:
127  /*reimp*/void resizeEvent( QResizeEvent* );
128  private:
129  friend class View;
130 
131  GraphicsItem* createItem( ItemType type ) const;
132  };
133 }
134 
135 #endif /* KDGANTTGRAPHICSVIEW_H */
136 

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/