kdganttgraphicsscene.h

Go to the documentation of this file.
00001 /****************************************************************************
00002  ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB.  All rights reserved.
00003  **
00004  ** This file is part of the KD Gantt library.
00005  **
00006  ** This file may be distributed and/or modified under the terms of the
00007  ** GNU General Public License version 2 as published by the Free Software
00008  ** Foundation and appearing in the file LICENSE.GPL included in the
00009  ** packaging of this file.
00010  **
00011  ** Licensees holding valid commercial KD Gantt licenses may use this file in
00012  ** accordance with the KD Gantt Commercial License Agreement provided with
00013  ** the Software.
00014  **
00015  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017  **
00018  ** See http://www.kdab.net/kdgantt for
00019  **   information about KD Gantt Commercial License Agreements.
00020  **
00021  ** Contact info@kdab.net if any conditions of this
00022  ** licensing are not clear to you.
00023  **
00024  **********************************************************************/
00025 #ifndef KDGANTTGRAPHICSSCENE_H
00026 #define KDGANTTGRAPHICSSCENE_H
00027 
00028 #include <QDateTime>
00029 #include <QList>
00030 #include <QGraphicsScene>
00031 #include <QModelIndex>
00032 
00033 #include "kdganttglobal.h"
00034 
00035 class QAbstractProxyModel;
00036 class QItemSelectionModel;
00037 class QPrinter;
00038 
00039 namespace KDGantt {
00040     class AbstractGrid;
00041     class AbstractRowController;
00042     class GraphicsItem;
00043     class Constraint;
00044     class ConstraintModel;
00045     class ConstraintGraphicsItem;
00046     class ItemDelegate;
00047 
00048     class KDCHART_EXPORT GraphicsScene : public QGraphicsScene {
00049         Q_OBJECT
00050         KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( GraphicsScene )
00051     public:
00052         explicit GraphicsScene( QObject* parent=0 );
00053         virtual ~GraphicsScene();
00054 
00055         //qreal dateTimeToSceneX( const QDateTime& dt ) const;
00056         //QDateTime sceneXtoDateTime( qreal x ) const;
00057 
00058         static QModelIndex mainIndex( const QModelIndex& idx );
00059         static QModelIndex dataIndex( const QModelIndex& idx );
00060 
00061         QAbstractItemModel* model() const;
00062         QAbstractProxyModel* summaryHandlingModel() const;
00063         QModelIndex rootIndex() const;
00064         ConstraintModel* constraintModel() const;
00065         QItemSelectionModel* selectionModel() const;
00066 
00067         void insertItem( const QPersistentModelIndex&, GraphicsItem* );
00068         void removeItem( const QModelIndex& );
00069         using QGraphicsScene::removeItem;
00070         GraphicsItem* findItem( const QModelIndex& ) const;
00071         GraphicsItem* findItem( const QPersistentModelIndex& ) const;
00072 
00073         void updateItems();
00074         void clearItems();
00075         void deleteSubtree( const QModelIndex& );
00076 
00077         ConstraintGraphicsItem* findConstraintItem( const Constraint& ) const;
00078         QList<ConstraintGraphicsItem*> findConstraintItems( const QModelIndex& idx ) const;
00079         void clearConstraintItems();
00080 
00081         void setItemDelegate( ItemDelegate* );
00082         ItemDelegate* itemDelegate() const;
00083 
00084         void setRowController( AbstractRowController* rc );
00085         AbstractRowController* rowController() const;
00086 
00087         void setGrid( AbstractGrid* grid );
00088         AbstractGrid* grid() const;
00089 
00090         bool isReadOnly() const;
00091 
00092         void updateRow( const QModelIndex& idx );
00093         GraphicsItem* createItem( ItemType type ) const;
00094 
00095         /* used by GraphicsItem */
00096         void itemEntered( const QModelIndex& );
00097         void itemPressed( const QModelIndex& );
00098         void itemClicked( const QModelIndex& );
00099         void itemDoubleClicked( const QModelIndex& );
00100         void setDragSource( GraphicsItem* item );
00101         GraphicsItem* dragSource() const;
00102 
00103         /* Printing */
00104         void print( QPrinter* printer, bool drawRowLabels = true );
00105         void print( QPrinter* printer, qreal start, qreal end, bool drawRowLabels = true );
00106         void print( QPainter* painter, const QRectF& target = QRectF(), bool drawRowLabels=true );
00107         void print( QPainter* painter, qreal start, qreal end, const QRectF& target = QRectF(), bool drawRowLabels=true );
00108 
00109     Q_SIGNALS:
00110         void gridChanged();
00111 
00112         void clicked( const QModelIndex & index );
00113         void doubleClicked( const QModelIndex & index );
00114         void entered( const QModelIndex & index );
00115         void pressed( const QModelIndex & index );
00116 
00117     protected:
00118         /*reimp*/ void helpEvent( QGraphicsSceneHelpEvent *helpEvent );
00119         /*reimp*/ void drawBackground( QPainter* painter, const QRectF& rect );
00120 
00121     public Q_SLOTS:
00122         void setModel( QAbstractItemModel* );
00123         void setSummaryHandlingModel( QAbstractProxyModel* );
00124         void setConstraintModel( ConstraintModel* );
00125         void setRootIndex( const QModelIndex& idx );
00126         void setSelectionModel( QItemSelectionModel* selectionmodel );
00127         void setReadOnly( bool );
00128 
00129     private Q_SLOTS:
00130         /* slots for ConstraintModel */
00131         void slotConstraintAdded( const KDGantt::Constraint& );
00132         void slotConstraintRemoved( const KDGantt::Constraint& );
00133         void slotGridChanged();
00134     private:
00135         void doPrint( QPainter* painter, const QRectF& targetRect,
00136                       qreal start, qreal end,
00137                       QPrinter* printer, bool drawRowLabels );
00138     };
00139 }
00140 
00141 #endif /* KDGANTTGRAPHICSSCENE_H */

Generated on Thu Mar 4 23:19:13 2010 for KD Chart 2 by  doxygen 1.5.4