1 /****************************************************************************
2 ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB. All rights reserved.
4 ** This file is part of the KD Gantt library.
6 ** This file may be used under the terms of the GNU General Public
7 ** License versions 2.0 or 3.0 as published by the Free Software
8 ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
9 ** included in the packaging of this file. Alternatively you may (at
10 ** your option) use any later version of the GNU General Public
11 ** License if such license has been publicly approved by
12 ** Klarälvdalens Datakonsult AB (or its successors, if any).
14 ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
15 ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
16 ** A PARTICULAR PURPOSE. Klarälvdalens Datakonsult AB reserves all rights
17 ** not expressly granted herein.
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 **********************************************************************/
23 #ifndef KDGANTTGRAPHICSVIEW_H
24 #define KDGANTTGRAPHICSVIEW_H
26 #include <QGraphicsView>
28 #include "kdganttglobal.h"
31 class QAbstractItemModel
;
32 class QAbstractProxyModel
;
33 class QItemSelectionModel
;
36 class AbstractRowController
;
39 class ConstraintModel
;
42 class KDGANTT_EXPORT GraphicsView
: public QGraphicsView
{
44 KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC(GraphicsView
)
46 Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly
)
48 Q_PRIVATE_SLOT( d
, void slotGridChanged() )
49 Q_PRIVATE_SLOT( d
, void slotHorizontalScrollValueChanged( int ) )
50 /* slots for QAbstractItemModel signals */
51 Q_PRIVATE_SLOT( d
, void slotColumnsInserted( const QModelIndex
& parent
, int start
, int end
) )
52 Q_PRIVATE_SLOT( d
, void slotColumnsRemoved( const QModelIndex
& parent
, int start
, int end
) )
53 Q_PRIVATE_SLOT( d
, void slotDataChanged( const QModelIndex
& topLeft
, const QModelIndex
& bottomRight
) )
54 Q_PRIVATE_SLOT( d
, void slotLayoutChanged() )
55 Q_PRIVATE_SLOT( d
, void slotModelReset() )
56 Q_PRIVATE_SLOT( d
, void slotRowsInserted( const QModelIndex
& parent
, int start
, int end
) )
57 Q_PRIVATE_SLOT( d
, void slotRowsAboutToBeRemoved( const QModelIndex
& parent
, int start
, int end
) )
58 Q_PRIVATE_SLOT( d
, void slotRowsRemoved( const QModelIndex
& parent
, int start
, int end
) )
60 Q_PRIVATE_SLOT( d
, void slotItemClicked( const QModelIndex
& idx
) )
61 Q_PRIVATE_SLOT( d
, void slotItemDoubleClicked( const QModelIndex
& idx
) )
64 explicit GraphicsView( QWidget
* parent
=0 );
65 virtual ~GraphicsView();
67 QAbstractItemModel
* model() const;
68 QAbstractProxyModel
* summaryHandlingModel() const;
69 ConstraintModel
* constraintModel() const;
70 QModelIndex
rootIndex() const;
71 QItemSelectionModel
* selectionModel() const;
72 AbstractRowController
* rowController() const;
73 AbstractGrid
* grid() const;
74 ItemDelegate
* itemDelegate() const;
76 bool isReadOnly() const;
78 QModelIndex
indexAt( const QPoint
& pos
) const;
80 virtual void addConstraint( const QModelIndex
& from
,
81 const QModelIndex
& to
,
82 Qt::KeyboardModifiers modifiers
);
85 void updateRow( const QModelIndex
& );
87 void updateSceneRect();
88 void deleteSubtree( const QModelIndex
& );
90 void print( QPainter
* painter
, const QRectF
& target
= QRectF(), const QRectF
& source
= QRectF(), bool drawRowLabels
=true, bool drawHeader
=true );
91 QRectF
printRect(bool drawRowLabels
=true );
92 void renderHeader( QPainter
* painter
, const QRectF
& target
, const QRectF
& source
, Qt::AspectRatioMode aspectRatioMode
= Qt::KeepAspectRatio
);
93 qreal
headerHeight() const;
96 void setModel( QAbstractItemModel
* );
97 void setSummaryHandlingModel( QAbstractProxyModel
* model
);
98 void setConstraintModel( ConstraintModel
* );
99 void setRootIndex( const QModelIndex
& );
100 void setSelectionModel( QItemSelectionModel
* );
101 void setRowController( AbstractRowController
* );
102 void setGrid( AbstractGrid
* );
103 void setItemDelegate( ItemDelegate
* delegate
);
104 void setReadOnly( bool );
107 void activated( const QModelIndex
& index
);
108 void clicked( const QModelIndex
& index
);
109 void doubleClicked( const QModelIndex
& index
);
110 void entered( const QModelIndex
& index
);
111 void pressed( const QModelIndex
& index
);
114 /*reimp*/void resizeEvent( QResizeEvent
* );
118 GraphicsItem
* createItem( ItemType type
) const;
122 #endif /* KDGANTTGRAPHICSVIEW_H */