KD Chart 2  [rev.2.5]
kdganttgraphicsview.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2012 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 QT_BEGIN_NAMESPACE
00031 class QModelIndex;
00032 class QAbstractItemModel;
00033 class QAbstractProxyModel;
00034 class QItemSelectionModel;
00035 QT_END_NAMESPACE
00036 
00037 namespace KDGantt {
00038     class AbstractRowController;
00039     class AbstractGrid;
00040     class GraphicsItem;
00041     class ConstraintModel;
00042     class ItemDelegate;
00043 
00044     class KDGANTT_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, bool drawColumnLabels = true );
00101         void print( QPrinter* printer, qreal start, qreal end, bool drawRowLabels = true, bool drawColumnLabels = true );
00102         void print( QPainter* painter, const QRectF& target = QRectF(), bool drawRowLabels = true, bool drawColumnLabels = true );
00103         void print( QPainter* painter, qreal start, qreal end,
00104                     const QRectF& target = QRectF(), bool drawRowLabels = true, bool drawColumnLabels = 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 qrealClicked( 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 
 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/