The GraphicsView class provides a model/view implementation of a gantt chart. More...
#include <KDGanttGraphicsView>
Public Slots | |
void | setConstraintModel (ConstraintModel *) |
void | setGrid (AbstractGrid *) |
void | setItemDelegate (ItemDelegate *delegate) |
void | setModel (QAbstractItemModel *) |
void | setReadOnly (bool) |
void | setRootIndex (const QModelIndex &) |
void | setRowController (AbstractRowController *) |
void | setSelectionModel (QItemSelectionModel *) |
void | setSummaryHandlingModel (QAbstractProxyModel *model) |
void | updateSceneRect () |
Signals | |
void | activated (const QModelIndex &index) |
void | clicked (const QModelIndex &index) |
void | doubleClicked (const QModelIndex &index) |
void | entered (const QModelIndex &index) |
void | headerContextMenuRequested (const QPoint &pt) |
void | pressed (const QModelIndex &index) |
Public Member Functions | |
virtual void | addConstraint (const QModelIndex &from, const QModelIndex &to, Qt::KeyboardModifiers modifiers) |
void | clearItems () |
ConstraintModel * | constraintModel () const |
void | deleteSubtree (const QModelIndex &) |
GraphicsView (QWidget *parent=0) | |
AbstractGrid * | grid () const |
Qt::ContextMenuPolicy | headerContextMenuPolicy () const |
QModelIndex | indexAt (const QPoint &pos) const |
bool | isReadOnly () const |
ItemDelegate * | itemDelegate () const |
QAbstractItemModel * | model () const |
void | print (QPrinter *printer, qreal start, qreal end, bool drawRowLabels=true) |
void | print (QPainter *painter, qreal start, qreal end, const QRectF &target=QRectF(), bool drawRowLabels=true) |
void | print (QPrinter *printer, bool drawRowLabels=true) |
void | print (QPainter *painter, const QRectF &target=QRectF(), bool drawRowLabels=true) |
QModelIndex | rootIndex () const |
AbstractRowController * | rowController () const |
QItemSelectionModel * | selectionModel () const |
void | setHeaderContextMenuPolicy (Qt::ContextMenuPolicy) |
QAbstractProxyModel * | summaryHandlingModel () const |
void | updateRow (const QModelIndex &) |
void | updateScene () |
virtual | ~GraphicsView () |
Protected Member Functions | |
void | resizeEvent (QResizeEvent *) |
Properties | |
bool | readOnly |
The GraphicsView class provides a model/view implementation of a gantt chart.
Definition at line 42 of file kdganttgraphicsview.h.
GraphicsView::GraphicsView | ( | QWidget * | parent = 0 |
) | [explicit] |
void GraphicsView::activated( const QModelIndex & index )
void GraphicsView::clicked( const QModelIndex & index );
void GraphicsView::doubleClicked( const QModelIndex & index );
void GraphicsView::entered( const QModelIndex & index );
void GraphicsView::pressed( const QModelIndex & index );
void GraphicsView::headerContextMenuRequested( const QPoint& pt ) This signal is emitted when the header has contextMenuPolicy Qt::CustomContextMenu and the widget wants to show a contextmenu for the header. Unlike in QWidget::customContextMenuRequested() signal, pt is here in global coordinates.
Constructor. Creates a new KDGantt::GraphicsView with parent parent.
Definition at line 337 of file kdganttgraphicsview.cpp.
References clicked(), doubleClicked(), entered(), pressed(), setSummaryHandlingModel(), and updateSceneRect().
GraphicsView::~GraphicsView | ( | ) | [virtual] |
Destroys this view.
Definition at line 373 of file kdganttgraphicsview.cpp.
void KDGantt::GraphicsView::activated | ( | const QModelIndex & | index | ) | [signal] |
void GraphicsView::addConstraint | ( | const QModelIndex & | from, | |
const QModelIndex & | to, | |||
Qt::KeyboardModifiers | modifiers | |||
) | [virtual] |
Adds a constraint from from to to. modifiers are the keyboard modifiers pressed by the user when the action is invoked.
Override this to control how contraints are added. The default implementation adds a soft constraint unless the Shift key is pressed, in that case it adds a hard constraint. If a constraint is already present, it is removed and nothing is added.
Definition at line 589 of file kdganttgraphicsview.cpp.
References KDGantt::ConstraintModel::addConstraint(), constraintModel(), KDGantt::ConstraintModel::hasConstraint(), isReadOnly(), KDGantt::ConstraintModel::removeConstraint(), KDGantt::Constraint::TypeHard, and KDGantt::Constraint::TypeSoft.
Referenced by KDGantt::GraphicsItem::mouseReleaseEvent().
void GraphicsView::clearItems | ( | ) |
void KDGantt::GraphicsView::clicked | ( | const QModelIndex & | index | ) | [signal] |
Referenced by GraphicsView().
ConstraintModel * GraphicsView::constraintModel | ( | ) | const |
Definition at line 450 of file kdganttgraphicsview.cpp.
References d.
Referenced by addConstraint().
void GraphicsView::deleteSubtree | ( | const QModelIndex & | idx | ) |
Definition at line 710 of file kdganttgraphicsview.cpp.
References d.
void KDGantt::GraphicsView::doubleClicked | ( | const QModelIndex & | index | ) | [signal] |
Referenced by GraphicsView().
void KDGantt::GraphicsView::entered | ( | const QModelIndex & | index | ) | [signal] |
Referenced by GraphicsView().
AbstractGrid * GraphicsView::grid | ( | ) | const |
Definition at line 540 of file kdganttgraphicsview.cpp.
References d.
Qt::ContextMenuPolicy GraphicsView::headerContextMenuPolicy | ( | ) | const |
Definition at line 576 of file kdganttgraphicsview.cpp.
References d.
void KDGantt::GraphicsView::headerContextMenuRequested | ( | const QPoint & | pt | ) | [signal] |
QModelIndex GraphicsView::indexAt | ( | const QPoint & | pos | ) | const |
This is useful for for example contextmenus.
Definition at line 633 of file kdganttgraphicsview.cpp.
References d.
bool GraphicsView::isReadOnly | ( | ) | const |
Definition at line 555 of file kdganttgraphicsview.cpp.
References d.
Referenced by addConstraint().
ItemDelegate * GraphicsView::itemDelegate | ( | ) | const |
Definition at line 502 of file kdganttgraphicsview.cpp.
References d.
QAbstractItemModel * GraphicsView::model | ( | ) | const |
Definition at line 407 of file kdganttgraphicsview.cpp.
References d.
Referenced by updateScene().
void KDGantt::GraphicsView::pressed | ( | const QModelIndex & | index | ) | [signal] |
Referenced by GraphicsView().
void GraphicsView::print | ( | QPrinter * | printer, | |
bool | drawRowLabels = true | |||
) |
Print the Gantt chart using printer. If drawRowLabels is true (the default), each row will have it's label printed on the left side.
This version of print() will print multiple pages.
Definition at line 721 of file kdganttgraphicsview.cpp.
References d.
Referenced by KDGantt::View::print().
void GraphicsView::print | ( | QPrinter * | printer, | |
qreal | start, | |||
qreal | end, | |||
bool | drawRowLabels = true | |||
) |
Print part of the Gantt chart from start to end using printer. If drawRowLabels is true (the default), each row will have it's label printed on the left side.
This version of print() will print multiple pages.
To print a certain range of a chart with a DateTimeGrid, use qreal DateTimeGrid::mapFromDateTime( const QDateTime& dt) const to figure out the values for start and end.
Definition at line 736 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::print | ( | QPainter * | painter, | |
const QRectF & | targetRect = QRectF() , |
|||
bool | drawRowLabels = true | |||
) |
Render the GanttView inside the rectangle target using the painter painter. If drawRowLabels is true (the default), each row will have it's label printed on the left side.
Definition at line 745 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::print | ( | QPainter * | painter, | |
qreal | start, | |||
qreal | end, | |||
const QRectF & | targetRect = QRectF() , |
|||
bool | drawRowLabels = true | |||
) |
Render the GanttView inside the rectangle target using the painter painter. If drawRowLabels is true (the default), each row will have it's label printed on the left side.
To print a certain range of a chart with a DateTimeGrid, use qreal DateTimeGrid::mapFromDateTime( const QDateTime& dt) const to figure out the values for start and end.
Definition at line 758 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::resizeEvent | ( | QResizeEvent * | ev | ) | [protected] |
Definition at line 601 of file kdganttgraphicsview.cpp.
References d, rowController(), and KDGantt::AbstractRowController::totalHeight().
QModelIndex GraphicsView::rootIndex | ( | ) | const |
Definition at line 472 of file kdganttgraphicsview.cpp.
References d.
Referenced by updateScene().
AbstractRowController * GraphicsView::rowController | ( | ) | const |
Definition at line 522 of file kdganttgraphicsview.cpp.
References d.
Referenced by resizeEvent(), updateScene(), and updateSceneRect().
QItemSelectionModel * GraphicsView::selectionModel | ( | ) | const |
Definition at line 487 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::setConstraintModel | ( | ConstraintModel * | cmodel | ) | [slot] |
Sets the constraintmodel displayed by this view.
Definition at line 443 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::setGrid | ( | AbstractGrid * | grid | ) | [slot] |
Sets the AbstractGrid for this view. The grid is an object that controls how QModelIndexes are mapped to and from the view and how the background and header is rendered.
Definition at line 532 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::setHeaderContextMenuPolicy | ( | Qt::ContextMenuPolicy | p | ) |
Sets the context menu policy for the header. The default value Qt::DefaultContextMenu results in a standard context menu on the header that allows the user to set the scale and zoom.
Setting this to Qt::CustomContextMenu will cause the signal headerContextMenuRequested(const QPoint& pt) to be emitted instead.
Definition at line 569 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::setItemDelegate | ( | ItemDelegate * | delegate | ) | [slot] |
Sets the KDGantt::ItemDelegate used for rendering items on this view.
Definition at line 495 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::setModel | ( | QAbstractItemModel * | model | ) | [slot] |
Sets the model to be displayed in this view to model. The view does not take ownership of the model.
To make a model work well with GraphicsView it must have a certain layout. Whether the model is flat or has a treestrucure is not important, as long as an AbstractRowController is provided that can navigate the model.
GraphicsView operates per row in the model. The data is always taken from the _last_ item in the row. The ItemRoles used are Qt::DisplayRole and the roles defined in KDGantt::ItemDataRole.
Definition at line 393 of file kdganttgraphicsview.cpp.
References d, updateScene(), and updateSceneRect().
void GraphicsView::setReadOnly | ( | bool | ro | ) | [slot] |
Sets the view to read-only mode if to is true. The default is read/write if the model permits it.
Definition at line 548 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::setRootIndex | ( | const QModelIndex & | idx | ) | [slot] |
Sets the root index of the model displayed by this view. Similar to QAbstractItemView::setRootIndex, default is QModelIndex().
Definition at line 465 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::setRowController | ( | AbstractRowController * | rowcontroller | ) | [slot] |
Sets the AbstractRowController used by this view. The AbstractRowController deals with the height and position of each row and with which parts of the model are displayed.
Definition at line 512 of file kdganttgraphicsview.cpp.
References d, and updateScene().
void GraphicsView::setSelectionModel | ( | QItemSelectionModel * | model | ) | [slot] |
Sets the QItemSelectionModel used by this view to manage selections. Similar to QAbstractItemView::setSelectionModel
Definition at line 480 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::setSummaryHandlingModel | ( | QAbstractProxyModel * | model | ) | [slot] |
Definition at line 412 of file kdganttgraphicsview.cpp.
References d, and updateScene().
Referenced by GraphicsView().
QAbstractProxyModel * GraphicsView::summaryHandlingModel | ( | ) | const |
Definition at line 457 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::updateRow | ( | const QModelIndex & | idx | ) |
void GraphicsView::updateScene | ( | ) |
Definition at line 688 of file kdganttgraphicsview.cpp.
References clearItems(), model(), rootIndex(), rowController(), updateRow(), and updateSceneRect().
Referenced by setModel(), setRowController(), and setSummaryHandlingModel().
void GraphicsView::updateSceneRect | ( | ) | [slot] |
Definition at line 658 of file kdganttgraphicsview.cpp.
References d, rowController(), and KDGantt::AbstractRowController::totalHeight().
Referenced by GraphicsView(), setModel(), and updateScene().
bool KDGantt::GraphicsView::readOnly [read, write] |
Definition at line 46 of file kdganttgraphicsview.h.