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 distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file.
11 ** Licensees holding valid commercial KD Gantt licenses may use this file in
12 ** accordance with the KD Gantt Commercial License Agreement provided with
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.
18 ** See http://www.kdab.net/kdgantt for
19 ** information about KD Gantt Commercial License Agreements.
21 ** Contact info@kdab.net if any conditions of this
22 ** licensing are not clear to you.
24 **********************************************************************/
25 #ifndef KDGANTTGRAPHICSVIEW_H
26 #define KDGANTTGRAPHICSVIEW_H
28 #include <QGraphicsView>
30 #include "kdganttglobal.h"
33 class QAbstractItemModel
;
34 class QAbstractProxyModel
;
35 class QItemSelectionModel
;
38 class AbstractRowController
;
41 class ConstraintModel
;
44 class KDGANTT_EXPORT GraphicsView
: public QGraphicsView
{
46 KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC(GraphicsView
)
48 Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly
)
50 Q_PRIVATE_SLOT( d
, void slotGridChanged() )
51 Q_PRIVATE_SLOT( d
, void slotHorizontalScrollValueChanged( int ) )
52 Q_PRIVATE_SLOT( d
, void slotHeaderContextMenuRequested( const QPoint
& ) )
53 /* slots for QAbstractItemModel signals */
54 Q_PRIVATE_SLOT( d
, void slotColumnsInserted( const QModelIndex
& parent
, int start
, int end
) )
55 Q_PRIVATE_SLOT( d
, void slotColumnsRemoved( const QModelIndex
& parent
, int start
, int end
) )
56 Q_PRIVATE_SLOT( d
, void slotDataChanged( const QModelIndex
& topLeft
, const QModelIndex
& bottomRight
) )
57 Q_PRIVATE_SLOT( d
, void slotLayoutChanged() )
58 Q_PRIVATE_SLOT( d
, void slotModelReset() )
59 Q_PRIVATE_SLOT( d
, void slotRowsInserted( const QModelIndex
& parent
, int start
, int end
) )
60 Q_PRIVATE_SLOT( d
, void slotRowsAboutToBeRemoved( const QModelIndex
& parent
, int start
, int end
) )
61 Q_PRIVATE_SLOT( d
, void slotRowsRemoved( const QModelIndex
& parent
, int start
, int end
) )
63 Q_PRIVATE_SLOT( d
, void slotItemClicked( const QModelIndex
& idx
) )
64 Q_PRIVATE_SLOT( d
, void slotItemDoubleClicked( const QModelIndex
& idx
) )
67 explicit GraphicsView( QWidget
* parent
=0 );
68 virtual ~GraphicsView();
70 QAbstractItemModel
* model() const;
71 QAbstractProxyModel
* summaryHandlingModel() const;
72 ConstraintModel
* constraintModel() const;
73 QModelIndex
rootIndex() const;
74 QItemSelectionModel
* selectionModel() const;
75 AbstractRowController
* rowController() const;
76 AbstractGrid
* grid() const;
77 ItemDelegate
* itemDelegate() const;
79 bool isReadOnly() const;
81 void setHeaderContextMenuPolicy( Qt::ContextMenuPolicy
);
82 Qt::ContextMenuPolicy
headerContextMenuPolicy() const;
84 QModelIndex
indexAt( const QPoint
& pos
) const;
86 virtual void addConstraint( const QModelIndex
& from
,
87 const QModelIndex
& to
,
88 Qt::KeyboardModifiers modifiers
);
91 void updateRow( const QModelIndex
& );
95 void updateSceneRect();
98 void deleteSubtree( const QModelIndex
& );
100 void print( QPrinter
* printer
, bool drawRowLabels
= true );
101 void print( QPrinter
* printer
, qreal start
, qreal end
, bool drawRowLabels
= true );
102 void print( QPainter
* painter
, const QRectF
& target
= QRectF(), bool drawRowLabels
= true );
103 void print( QPainter
* painter
, qreal start
, qreal end
,
104 const QRectF
& target
= QRectF(), bool drawRowLabels
= true );
107 void setModel( QAbstractItemModel
* );
108 void setSummaryHandlingModel( QAbstractProxyModel
* model
);
109 void setConstraintModel( ConstraintModel
* );
110 void setRootIndex( const QModelIndex
& );
111 void setSelectionModel( QItemSelectionModel
* );
112 void setRowController( AbstractRowController
* );
113 void setGrid( AbstractGrid
* );
114 void setItemDelegate( ItemDelegate
* delegate
);
115 void setReadOnly( bool );
118 void activated( const QModelIndex
& index
);
119 void clicked( const QModelIndex
& index
);
120 void doubleClicked( const QModelIndex
& index
);
121 void entered( const QModelIndex
& index
);
122 void pressed( const QModelIndex
& index
);
123 void headerContextMenuRequested( const QPoint
& pt
);
126 /*reimp*/void resizeEvent( QResizeEvent
* );
130 GraphicsItem
* createItem( ItemType type
) const;
134 #endif /* KDGANTTGRAPHICSVIEW_H */