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 KDGANTTGRAPHICSSCENE_H
26 #define KDGANTTGRAPHICSSCENE_H
30 #include <QGraphicsScene>
31 #include <QModelIndex>
33 #include "kdganttglobal.h"
35 class QAbstractProxyModel
;
36 class QItemSelectionModel
;
41 class AbstractRowController
;
44 class ConstraintModel
;
45 class ConstraintGraphicsItem
;
48 class GraphicsScene
: public QGraphicsScene
{
50 KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( GraphicsScene
)
52 explicit GraphicsScene( QObject
* parent
=0 );
53 virtual ~GraphicsScene();
55 //qreal dateTimeToSceneX( const QDateTime& dt ) const;
56 //QDateTime sceneXtoDateTime( qreal x ) const;
58 static QModelIndex
mainIndex( const QModelIndex
& idx
);
59 static QModelIndex
dataIndex( const QModelIndex
& idx
);
61 QAbstractItemModel
* model() const;
62 QAbstractProxyModel
* summaryHandlingModel() const;
63 QModelIndex
rootIndex() const;
64 ConstraintModel
* constraintModel() const;
65 QItemSelectionModel
* selectionModel() const;
67 void insertItem( const QPersistentModelIndex
&, GraphicsItem
* );
68 void removeItem( const QModelIndex
& );
69 using QGraphicsScene::removeItem
;
70 GraphicsItem
* findItem( const QModelIndex
& ) const;
71 GraphicsItem
* findItem( const QPersistentModelIndex
& ) const;
75 void deleteSubtree( const QModelIndex
& );
77 ConstraintGraphicsItem
* findConstraintItem( const Constraint
& ) const;
78 QList
<ConstraintGraphicsItem
*> findConstraintItems( const QModelIndex
& idx
) const;
79 void clearConstraintItems();
81 void setItemDelegate( ItemDelegate
* );
82 ItemDelegate
* itemDelegate() const;
84 void setRowController( AbstractRowController
* rc
);
85 AbstractRowController
* rowController() const;
87 void setGrid( AbstractGrid
* grid
);
88 AbstractGrid
* grid() const;
90 bool isReadOnly() const;
92 void updateRow( const QModelIndex
& idx
);
93 GraphicsItem
* createItem( ItemType type
) const;
95 /* used by GraphicsItem */
96 void itemEntered( const QModelIndex
& );
97 void itemPressed( const QModelIndex
& );
98 void itemClicked( const QModelIndex
& );
99 void itemDoubleClicked( const QModelIndex
& );
100 void setDragSource( GraphicsItem
* item
);
101 GraphicsItem
* dragSource() const;
104 void print( QPrinter
* printer
, bool drawRowLabels
= true );
105 void print( QPrinter
* printer
, qreal start
, qreal end
, bool drawRowLabels
= true );
106 void print( QPainter
* painter
, const QRectF
& target
= QRectF(), bool drawRowLabels
=true );
107 void print( QPainter
* painter
, qreal start
, qreal end
, const QRectF
& target
= QRectF(), bool drawRowLabels
=true );
112 void clicked( const QModelIndex
& index
);
113 void doubleClicked( const QModelIndex
& index
);
114 void entered( const QModelIndex
& index
);
115 void pressed( const QModelIndex
& index
);
118 /*reimp*/ void helpEvent( QGraphicsSceneHelpEvent
*helpEvent
);
119 /*reimp*/ void drawBackground( QPainter
* painter
, const QRectF
& rect
);
122 void setModel( QAbstractItemModel
* );
123 void setSummaryHandlingModel( QAbstractProxyModel
* );
124 void setConstraintModel( ConstraintModel
* );
125 void setRootIndex( const QModelIndex
& idx
);
126 void setSelectionModel( QItemSelectionModel
* selectionmodel
);
127 void setReadOnly( bool );
130 /* slots for ConstraintModel */
131 void slotConstraintAdded( const Constraint
& );
132 void slotConstraintRemoved( const Constraint
& );
133 void slotGridChanged();
135 void doPrint( QPainter
* painter
, const QRectF
& targetRect
,
136 qreal start
, qreal end
,
137 QPrinter
* printer
, bool drawRowLabels
);
141 #endif /* KDGANTTGRAPHICSSCENE_H */