kdganttgraphicsview.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2011 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD Chart library.
00005 **
00006 ** Licensees holding valid commercial KD Chart licenses may use this file in
00007 ** accordance with the KD Chart Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
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 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
00020 **
00021 **********************************************************************/
00022 
00023 #ifndef KDGANTTGRAPHICSVIEW_H
00024 #define KDGANTTGRAPHICSVIEW_H
00025 
00026 #include <QGraphicsView>
00027 
00028 #include "kdganttglobal.h"
00029 
00030 class QModelIndex;
00031 class QAbstractItemModel;
00032 class QAbstractProxyModel;
00033 class QItemSelectionModel;
00034 
00035 namespace KDGantt {
00036     class AbstractRowController;
00037     class AbstractGrid;
00038     class GraphicsItem;
00039     class ConstraintModel;
00040     class ItemDelegate;
00041 
00042     class KDCHART_EXPORT GraphicsView : public QGraphicsView {
00043         Q_OBJECT
00044         KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC(GraphicsView)
00045 
00046         Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
00047 
00048         Q_PRIVATE_SLOT( d, void slotGridChanged() )
00049         Q_PRIVATE_SLOT( d, void slotHorizontalScrollValueChanged( int ) )
00050         Q_PRIVATE_SLOT( d, void slotHeaderContextMenuRequested( const QPoint& ) )
00051         /* slots for QAbstractItemModel signals */
00052         Q_PRIVATE_SLOT( d, void slotColumnsInserted( const QModelIndex& parent,  int start, int end ) )
00053         Q_PRIVATE_SLOT( d, void slotColumnsRemoved( const QModelIndex& parent,  int start, int end ) )
00054         Q_PRIVATE_SLOT( d, void slotDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight ) )
00055         Q_PRIVATE_SLOT( d, void slotLayoutChanged() )
00056         Q_PRIVATE_SLOT( d, void slotModelReset() )
00057         Q_PRIVATE_SLOT( d, void slotRowsInserted( const QModelIndex& parent,  int start, int end ) )
00058         Q_PRIVATE_SLOT( d, void slotRowsAboutToBeRemoved( const QModelIndex& parent,  int start, int end ) )
00059         Q_PRIVATE_SLOT( d, void slotRowsRemoved( const QModelIndex& parent,  int start, int end ) )
00060 
00061         Q_PRIVATE_SLOT( d, void slotItemClicked( const QModelIndex& idx ) )
00062         Q_PRIVATE_SLOT( d, void slotItemDoubleClicked( const QModelIndex& idx ) )
00063     public:
00064 
00065         explicit GraphicsView( QWidget* parent=0 );
00066         virtual ~GraphicsView();
00067 
00068         QAbstractItemModel* model() const;
00069         QAbstractProxyModel* summaryHandlingModel() const;
00070         ConstraintModel* constraintModel() const;
00071         QModelIndex rootIndex() const;
00072         QItemSelectionModel* selectionModel() const;
00073         AbstractRowController* rowController() const;
00074         AbstractGrid* grid() const;
00075         ItemDelegate* itemDelegate() const;
00076 
00077         bool isReadOnly() const;
00078 
00079         void setHeaderContextMenuPolicy( Qt::ContextMenuPolicy );
00080         Qt::ContextMenuPolicy headerContextMenuPolicy() const;
00081 
00082         QModelIndex indexAt( const QPoint& pos ) const;
00083 
00084         virtual void addConstraint( const QModelIndex& from,
00085                                     const QModelIndex& to,
00086                                     Qt::KeyboardModifiers modifiers );
00087 
00088         void clearItems();
00089         void updateRow( const QModelIndex& );
00090         void updateScene();
00091 
00092     public Q_SLOTS:
00093         void updateSceneRect();
00094 
00095     public:
00096         void deleteSubtree( const QModelIndex& );
00097 
00098         void print( QPrinter* printer, bool drawRowLabels = true );
00099         void print( QPrinter* printer, qreal start, qreal end, bool drawRowLabels = true );
00100         void print( QPainter* painter, const QRectF& target = QRectF(), bool drawRowLabels = true );
00101         void print( QPainter* painter, qreal start, qreal end, 
00102                     const QRectF& target = QRectF(), bool drawRowLabels = true );
00103 
00104     public Q_SLOTS:
00105         void setModel( QAbstractItemModel* );
00106         void setSummaryHandlingModel( QAbstractProxyModel* model );
00107         void setConstraintModel( ConstraintModel* );
00108         void setRootIndex( const QModelIndex& );
00109         void setSelectionModel( QItemSelectionModel* );
00110         void setRowController( AbstractRowController* );
00111         void setGrid( AbstractGrid* );
00112         void setItemDelegate( ItemDelegate* delegate );
00113         void setReadOnly( bool );
00114 
00115     Q_SIGNALS:
00116         void activated( const QModelIndex & index );
00117         void clicked( const QModelIndex & index );
00118         void doubleClicked( const QModelIndex & index );
00119         void entered( const QModelIndex & index );
00120         void pressed( const QModelIndex & index );
00121         void headerContextMenuRequested( const QPoint& pt );
00122 
00123     protected:
00124         /*reimp*/void resizeEvent( QResizeEvent* );
00125     private:
00126         friend class View;
00127 
00128         GraphicsItem* createItem( ItemType type ) const;
00129     };
00130 }
00131 
00132 #endif /* KDGANTTGRAPHICSVIEW_H */
00133 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/