kdganttgraphicsview.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 KDGANTTGRAPHICSVIEW_H
00026 #define KDGANTTGRAPHICSVIEW_H
00027 
00028 #include <QGraphicsView>
00029 
00030 #include "kdganttglobal.h"
00031 
00032 class QModelIndex;
00033 class QAbstractItemModel;
00034 class QAbstractProxyModel;
00035 class QItemSelectionModel;
00036 
00037 namespace KDGantt {
00038     class AbstractRowController;
00039     class AbstractGrid;
00040     class GraphicsItem;
00041     class ConstraintModel;
00042     class ItemDelegate;
00043 
00044     class KDCHART_EXPORT GraphicsView : public QGraphicsView {
00045         Q_OBJECT
00046         KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC(GraphicsView)
00047 
00048         Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
00049 
00050         Q_PRIVATE_SLOT( d, void slotGridChanged() )
00051         Q_PRIVATE_SLOT( d, void slotHorizontalScrollValueChanged( int ) )
00052         Q_PRIVATE_SLOT( d, void slotHeaderContextMenuRequested( const QPoint& ) )
00053         /* slots for QAbstractItemModel signals */
00054         Q_PRIVATE_SLOT( d, void slotColumnsInserted( const QModelIndex& parent,  int start, int end ) )
00055         Q_PRIVATE_SLOT( d, void slotColumnsRemoved( const QModelIndex& parent,  int start, int end ) )
00056         Q_PRIVATE_SLOT( d, void slotDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight ) )
00057         Q_PRIVATE_SLOT( d, void slotLayoutChanged() )
00058         Q_PRIVATE_SLOT( d, void slotModelReset() )
00059         Q_PRIVATE_SLOT( d, void slotRowsInserted( const QModelIndex& parent,  int start, int end ) )
00060         Q_PRIVATE_SLOT( d, void slotRowsAboutToBeRemoved( const QModelIndex& parent,  int start, int end ) )
00061         Q_PRIVATE_SLOT( d, void slotRowsRemoved( const QModelIndex& parent,  int start, int end ) )
00062 
00063         Q_PRIVATE_SLOT( d, void slotItemClicked( const QModelIndex& idx ) )
00064         Q_PRIVATE_SLOT( d, void slotItemDoubleClicked( const QModelIndex& idx ) )
00065     public:
00066 
00067         explicit GraphicsView( QWidget* parent=0 );
00068         virtual ~GraphicsView();
00069 
00070         QAbstractItemModel* model() const;
00071         QAbstractProxyModel* summaryHandlingModel() const;
00072         ConstraintModel* constraintModel() const;
00073         QModelIndex rootIndex() const;
00074         QItemSelectionModel* selectionModel() const;
00075         AbstractRowController* rowController() const;
00076         AbstractGrid* grid() const;
00077         ItemDelegate* itemDelegate() const;
00078 
00079         bool isReadOnly() const;
00080 
00081         void setHeaderContextMenuPolicy( Qt::ContextMenuPolicy );
00082         Qt::ContextMenuPolicy headerContextMenuPolicy() const;
00083 
00084         QModelIndex indexAt( const QPoint& pos ) const;
00085 
00086         virtual void addConstraint( const QModelIndex& from,
00087                                     const QModelIndex& to,
00088                                     Qt::KeyboardModifiers modifiers );
00089 
00090         void clearItems();
00091         void updateRow( const QModelIndex& );
00092         void updateScene();
00093 
00094     public Q_SLOTS:
00095         void updateSceneRect();
00096 
00097     public:
00098         void deleteSubtree( const QModelIndex& );
00099 
00100         void print( QPrinter* printer, bool drawRowLabels = true );
00101         void print( QPrinter* printer, qreal start, qreal end, bool drawRowLabels = true );
00102         void print( QPainter* painter, const QRectF& target = QRectF(), bool drawRowLabels = true );
00103         void print( QPainter* painter, qreal start, qreal end, 
00104                     const QRectF& target = QRectF(), bool drawRowLabels = true );
00105 
00106     public Q_SLOTS:
00107         void setModel( QAbstractItemModel* );
00108         void setSummaryHandlingModel( QAbstractProxyModel* model );
00109         void setConstraintModel( ConstraintModel* );
00110         void setRootIndex( const QModelIndex& );
00111         void setSelectionModel( QItemSelectionModel* );
00112         void setRowController( AbstractRowController* );
00113         void setGrid( AbstractGrid* );
00114         void setItemDelegate( ItemDelegate* delegate );
00115         void setReadOnly( bool );
00116 
00117     Q_SIGNALS:
00118         void activated( const QModelIndex & index );
00119         void clicked( const QModelIndex & index );
00120         void doubleClicked( const QModelIndex & index );
00121         void entered( const QModelIndex & index );
00122         void pressed( const QModelIndex & index );
00123         void headerContextMenuRequested( const QPoint& pt );
00124 
00125     protected:
00126         /*reimp*/void resizeEvent( QResizeEvent* );
00127     private:
00128         friend class View;
00129 
00130         GraphicsItem* createItem( ItemType type ) const;
00131     };
00132 }
00133 
00134 #endif /* KDGANTTGRAPHICSVIEW_H */
00135 

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