![]() |
KD Chart API Documentation
3.1
|
The GraphicsView class provides a model/view implementation of a gantt chart. More...
#include <KDGanttGraphicsView>
Public Slots | |
void | setConstraintModel (ConstraintModel *) |
Sets the constraintmodel displayed by this view. More... | |
void | setGrid (AbstractGrid *) |
Sets the AbstractGrid for this view. More... | |
void | setItemDelegate (ItemDelegate *delegate) |
Sets the KDGantt::ItemDelegate used for rendering items on this view. More... | |
void | setModel (QAbstractItemModel *) |
Sets the model to be displayed in this view to model. More... | |
void | setReadOnly (bool) |
Sets the view to read-only mode if to is true. More... | |
void | setRootIndex (const QModelIndex &) |
Sets the root index of the model displayed by this view. More... | |
void | setRowController (AbstractRowController *) |
Sets the AbstractRowController used by this view. More... | |
void | setSelectionModel (QItemSelectionModel *) |
Sets the QItemSelectionModel used by this view to manage selections. More... | |
void | setSummaryHandlingModel (QAbstractProxyModel *model) |
void | updateSceneRect () |
Signals | |
void | activated (const QModelIndex &index) |
void | clicked (const QModelIndex &index) |
void | entered (const QModelIndex &index) |
void | headerContextMenuRequested (const QPoint &pt) |
This signal is emitted when the header has contextMenuPolicy Qt::CustomContextMenu and the widget wants to show a context menu for the header. More... | |
void | pressed (const QModelIndex &index) |
void | qrealClicked (const QModelIndex &index) |
Public Member Functions | |
GraphicsView (QWidget *parent=nullptr) | |
Constructor. More... | |
~GraphicsView () override | |
Destroys this view. More... | |
virtual void | addConstraint (const QModelIndex &from, const QModelIndex &to, Qt::KeyboardModifiers modifiers) |
Adds a constraint from from to to. More... | |
void | clearItems () |
ConstraintModel * | constraintModel () const |
void | deleteSubtree (const QModelIndex &) |
AbstractGrid * | grid () const |
Qt::ContextMenuPolicy | headerContextMenuPolicy () const |
QModelIndex | indexAt (const QPoint &pos) const |
bool | isReadOnly () const |
ItemDelegate * | itemDelegate () const |
QAbstractItemModel * | model () const |
void | print (QPainter *painter, const QRectF &target=QRectF(), bool drawRowLabels=true, bool drawColumnLabels=true) |
Render the GanttView inside the rectangle target using the painter painter. More... | |
void | print (QPainter *painter, qreal start, qreal end, const QRectF &target=QRectF(), bool drawRowLabels=true, bool drawColumnLabels=true) |
Render the GanttView inside the rectangle target using the painter painter. More... | |
void | print (QPrinter *printer, bool drawRowLabels=true, bool drawColumnLabels=true) |
Print the Gantt chart using printer. More... | |
void | print (QPrinter *printer, qreal start, qreal end, bool drawRowLabels=true, bool drawColumnLabels=true) |
Print part of the Gantt chart from start to end using printer. More... | |
QModelIndex | rootIndex () const |
AbstractRowController * | rowController () const |
QItemSelectionModel * | selectionModel () const |
void | setHeaderContextMenuPolicy (Qt::ContextMenuPolicy) |
Sets the context menu policy for the header. More... | |
QAbstractProxyModel * | summaryHandlingModel () const |
void | updateRow (const QModelIndex &) |
void | updateScene () |
Protected Member Functions | |
void | resizeEvent (QResizeEvent *) override |
Properties | |
bool | readOnly |
The GraphicsView class provides a model/view implementation of a gantt chart.
Definition at line 33 of file kdganttgraphicsview.h.
|
explicit |
Constructor.
Creates a new KDGantt::GraphicsView with parent parent.
Definition at line 311 of file kdganttgraphicsview.cpp.
References KDGantt::GraphicsScene::clicked(), KDGantt::GraphicsScene::entered(), entered(), KDGantt::GraphicsScene::gridChanged(), KDGantt::GraphicsScene::pressed(), pressed(), KDGantt::GraphicsScene::qrealClicked(), setSummaryHandlingModel(), and updateSceneRect().
|
override |
Destroys this view.
Definition at line 357 of file kdganttgraphicsview.cpp.
|
signal |
|
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 constraints 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 588 of file kdganttgraphicsview.cpp.
References KDGantt::ConstraintModel::addConstraint(), constraintModel(), KDGantt::ConstraintModel::hasConstraint(), isReadOnly(), KDGantt::ConstraintModel::removeConstraint(), KDGantt::Constraint::TypeHard, and KDGantt::Constraint::TypeSoft.
void GraphicsView::clearItems | ( | ) |
|
signal |
ConstraintModel * GraphicsView::constraintModel | ( | ) | const |
Definition at line 449 of file kdganttgraphicsview.cpp.
References d.
Referenced by addConstraint().
void GraphicsView::deleteSubtree | ( | const QModelIndex & | idx | ) |
Definition at line 717 of file kdganttgraphicsview.cpp.
References d.
|
signal |
Referenced by GraphicsView().
AbstractGrid * GraphicsView::grid | ( | ) | const |
Definition at line 539 of file kdganttgraphicsview.cpp.
References d.
Referenced by KDGantt::View::setGraphicsView(), and setGrid().
Qt::ContextMenuPolicy GraphicsView::headerContextMenuPolicy | ( | ) | const |
Definition at line 575 of file kdganttgraphicsview.cpp.
References d.
|
signal |
This signal is emitted when the header has contextMenuPolicy Qt::CustomContextMenu and the widget wants to show a context menu for the header.
Unlike in QWidget::customContextMenuRequested() signal, pt is here in global coordinates.
QModelIndex GraphicsView::indexAt | ( | const QPoint & | pos | ) | const |
This is useful for example contextmenus.
Definition at line 635 of file kdganttgraphicsview.cpp.
References d.
bool GraphicsView::isReadOnly | ( | ) | const |
Definition at line 554 of file kdganttgraphicsview.cpp.
References d.
Referenced by addConstraint().
ItemDelegate * GraphicsView::itemDelegate | ( | ) | const |
Definition at line 501 of file kdganttgraphicsview.cpp.
References d.
QAbstractItemModel * GraphicsView::model | ( | ) | const |
Definition at line 390 of file kdganttgraphicsview.cpp.
References d.
Referenced by setModel(), setSelectionModel(), and updateScene().
|
signal |
Referenced by GraphicsView().
void GraphicsView::print | ( | QPainter * | painter, |
const QRectF & | targetRect = QRectF() , |
||
bool | drawRowLabels = true , |
||
bool | drawColumnLabels = 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. If drawColumnLabels is true (the default), each column will have it's label printed at the top side.
Definition at line 758 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::print | ( | QPainter * | painter, |
qreal | start, | ||
qreal | end, | ||
const QRectF & | targetRect = QRectF() , |
||
bool | drawRowLabels = true , |
||
bool | drawColumnLabels = 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. If drawColumnLabels is true (the default), each column will have it's label printed at the top 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 773 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::print | ( | QPrinter * | printer, |
bool | drawRowLabels = true , |
||
bool | drawColumnLabels = 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. If drawColumnLabels is true (the default), each column will have it's label printed at the top side.
This version of print() will print multiple pages.
Definition at line 730 of file kdganttgraphicsview.cpp.
References d.
Referenced by KDGantt::View::print().
void GraphicsView::print | ( | QPrinter * | printer, |
qreal | start, | ||
qreal | end, | ||
bool | drawRowLabels = true , |
||
bool | drawColumnLabels = 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. If drawColumnLabels is true (the default), each column will have it's label printed at the top 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 747 of file kdganttgraphicsview.cpp.
References d.
|
signal |
|
overrideprotected |
Definition at line 603 of file kdganttgraphicsview.cpp.
References d, rowController(), and KDGantt::AbstractRowController::totalHeight().
QModelIndex GraphicsView::rootIndex | ( | ) | const |
Definition at line 471 of file kdganttgraphicsview.cpp.
References d.
Referenced by updateScene().
AbstractRowController * GraphicsView::rowController | ( | ) | const |
Definition at line 521 of file kdganttgraphicsview.cpp.
References d.
Referenced by resizeEvent(), updateScene(), and updateSceneRect().
QItemSelectionModel * GraphicsView::selectionModel | ( | ) | const |
Definition at line 486 of file kdganttgraphicsview.cpp.
References d.
|
slot |
Sets the constraintmodel displayed by this view.
Definition at line 442 of file kdganttgraphicsview.cpp.
References d.
|
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 531 of file kdganttgraphicsview.cpp.
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 568 of file kdganttgraphicsview.cpp.
References d.
|
slot |
Sets the KDGantt::ItemDelegate used for rendering items on this view.
Definition at line 494 of file kdganttgraphicsview.cpp.
References d.
|
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 377 of file kdganttgraphicsview.cpp.
References d, model(), updateScene(), and updateSceneRect().
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
|
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 547 of file kdganttgraphicsview.cpp.
References d.
|
slot |
Sets the root index of the model displayed by this view.
Similar to QAbstractItemView::setRootIndex, default is QModelIndex().
Definition at line 464 of file kdganttgraphicsview.cpp.
References d.
|
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 511 of file kdganttgraphicsview.cpp.
References d, and updateScene().
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
|
slot |
Sets the QItemSelectionModel used by this view to manage selections.
Similar to QAbstractItemView::setSelectionModel
Definition at line 479 of file kdganttgraphicsview.cpp.
|
slot |
Definition at line 395 of file kdganttgraphicsview.cpp.
References d, and updateScene().
Referenced by GraphicsView().
QAbstractProxyModel * GraphicsView::summaryHandlingModel | ( | ) | const |
Definition at line 456 of file kdganttgraphicsview.cpp.
References d.
void GraphicsView::updateRow | ( | const QModelIndex & | idx | ) |
void GraphicsView::updateScene | ( | ) |
Definition at line 692 of file kdganttgraphicsview.cpp.
References clearItems(), model(), rootIndex(), rowController(), updateRow(), and updateSceneRect().
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE(), setModel(), setRowController(), and setSummaryHandlingModel().
|
slot |
Definition at line 660 of file kdganttgraphicsview.cpp.
References d, rowController(), and KDGantt::AbstractRowController::totalHeight().
Referenced by GraphicsView(), setModel(), and updateScene().
|
readwrite |
Definition at line 24 of file kdganttgraphicsview.h.