KD Chart 2  [rev.2.8]
Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
KDGantt::GraphicsView Class Reference

The GraphicsView class provides a model/view implementation of a gantt chart. More...

#include <KDGanttGraphicsView>

Inheritance diagram for KDGantt::GraphicsView:
Inheritance graph
[legend]
Collaboration diagram for KDGantt::GraphicsView:
Collaboration graph
[legend]

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 entered (const QModelIndex &index)
 
void headerContextMenuRequested (const QPoint &pt)
 
void pressed (const QModelIndex &index)
 
void qrealClicked (const QModelIndex &index)
 

Public Member Functions

virtual void addConstraint (const QModelIndex &from, const QModelIndex &to, Qt::KeyboardModifiers modifiers)
 
void clearItems ()
 
ConstraintModelconstraintModel () 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
 
ItemDelegateitemDelegate () const
 
QAbstractItemModel * model () const
 
void print (QPainter *painter, const QRectF &target=QRectF(), bool drawRowLabels=true, bool drawColumnLabels=true)
 
void print (QPainter *painter, qreal start, qreal end, const QRectF &target=QRectF(), bool drawRowLabels=true, bool drawColumnLabels=true)
 
void print (QPrinter *printer, bool drawRowLabels=true, bool drawColumnLabels=true)
 
void print (QPrinter *printer, qreal start, qreal end, bool drawRowLabels=true, bool drawColumnLabels=true)
 
QModelIndex rootIndex () const
 
AbstractRowControllerrowController () const
 
QItemSelectionModel * selectionModel () const
 
void setHeaderContextMenuPolicy (Qt::ContextMenuPolicy)
 
QAbstractProxyModelsummaryHandlingModel () const
 
void updateRow (const QModelIndex &)
 
void updateScene ()
 
 ~GraphicsView () override
 

Protected Member Functions

void resizeEvent (QResizeEvent *) override
 

Properties

bool readOnly
 

Detailed Description

The GraphicsView class provides a model/view implementation of a gantt chart.

Definition at line 45 of file kdganttgraphicsview.h.

Constructor & Destructor Documentation

◆ GraphicsView()

GraphicsView::GraphicsView ( QWidget parent = 0)
explicit

Constructor. Creates a new KDGantt::GraphicsView with parent parent.

Definition at line 334 of file kdganttgraphicsview.cpp.

References clicked(), entered(), pressed(), qrealClicked(), setSummaryHandlingModel(), and updateSceneRect().

◆ ~GraphicsView()

GraphicsView::~GraphicsView ( )
override

Destroys this view.

Definition at line 370 of file kdganttgraphicsview.cpp.

Member Function Documentation

◆ activated

void GraphicsView::activated ( const QModelIndex &  index)
signal

◆ addConstraint()

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 586 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().

◆ clearItems()

void GraphicsView::clearItems ( )

Definition at line 641 of file kdganttgraphicsview.cpp.

References d.

Referenced by updateScene().

◆ clicked

void GraphicsView::clicked ( const QModelIndex &  index)
signal

Referenced by GraphicsView().

◆ constraintModel()

ConstraintModel * GraphicsView::constraintModel ( ) const
Returns
the KDGantt::ConstraintModel displayed by this view.

Definition at line 447 of file kdganttgraphicsview.cpp.

References d.

Referenced by addConstraint().

◆ deleteSubtree()

void GraphicsView::deleteSubtree ( const QModelIndex &  idx)

Definition at line 707 of file kdganttgraphicsview.cpp.

References d.

◆ entered

void GraphicsView::entered ( const QModelIndex &  index)
signal

Referenced by GraphicsView().

◆ grid()

AbstractGrid * GraphicsView::grid ( ) const
Returns
the AbstractGrid used by this view.

Definition at line 537 of file kdganttgraphicsview.cpp.

References d.

Referenced by KDGantt::View::setGraphicsView(), and setGrid().

◆ headerContextMenuPolicy()

Qt::ContextMenuPolicy GraphicsView::headerContextMenuPolicy ( ) const
Returns
the context menu policy for the header

Definition at line 573 of file kdganttgraphicsview.cpp.

References d.

◆ headerContextMenuRequested

void GraphicsView::headerContextMenuRequested ( const QPoint &  pt)
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.

◆ indexAt()

QModelIndex GraphicsView::indexAt ( const QPoint &  pos) const
Returns
The QModelIndex for the item located at position pos in the view or an invalid index if no item was present at that position.

This is useful for example contextmenus.

Definition at line 630 of file kdganttgraphicsview.cpp.

References d.

◆ isReadOnly()

bool GraphicsView::isReadOnly ( ) const
Returns
true iff the view is in read-only mode

Definition at line 552 of file kdganttgraphicsview.cpp.

References d.

Referenced by addConstraint().

◆ itemDelegate()

ItemDelegate * GraphicsView::itemDelegate ( ) const
Returns
the ItemDelegate used by this view to render items

Definition at line 499 of file kdganttgraphicsview.cpp.

References d.

◆ model()

QAbstractItemModel * GraphicsView::model ( ) const
Returns
the current model displayed by this view

Definition at line 404 of file kdganttgraphicsview.cpp.

References d.

Referenced by setModel(), setSelectionModel(), and updateScene().

◆ pressed

void GraphicsView::pressed ( const QModelIndex &  index)
signal

Referenced by GraphicsView().

◆ print() [1/4]

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 748 of file kdganttgraphicsview.cpp.

References d.

◆ print() [2/4]

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 763 of file kdganttgraphicsview.cpp.

References d.

◆ print() [3/4]

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 720 of file kdganttgraphicsview.cpp.

References d.

Referenced by KDGantt::View::print().

◆ print() [4/4]

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 737 of file kdganttgraphicsview.cpp.

References d.

◆ qrealClicked

void GraphicsView::qrealClicked ( const QModelIndex &  index)
signal

Referenced by GraphicsView().

◆ resizeEvent()

void GraphicsView::resizeEvent ( QResizeEvent *  ev)
overrideprotected

◆ rootIndex()

QModelIndex GraphicsView::rootIndex ( ) const
Returns
the rootindex for this view.

Definition at line 469 of file kdganttgraphicsview.cpp.

References d.

Referenced by updateScene().

◆ rowController()

AbstractRowController * GraphicsView::rowController ( ) const
Returns
the AbstractRowController for this view.
See also
setRowController

Definition at line 519 of file kdganttgraphicsview.cpp.

References d.

Referenced by resizeEvent(), updateScene(), and updateSceneRect().

◆ selectionModel()

QItemSelectionModel * GraphicsView::selectionModel ( ) const
Returns
the QItemSelectionModel used by this view

Definition at line 484 of file kdganttgraphicsview.cpp.

References d.

◆ setConstraintModel

void GraphicsView::setConstraintModel ( ConstraintModel cmodel)
slot

Sets the constraintmodel displayed by this view.

See also
KDGantt::ConstraintModel.

Definition at line 440 of file kdganttgraphicsview.cpp.

References d.

◆ setGrid

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.

See also
AbstractGrid and DateTimeGrid.

Definition at line 529 of file kdganttgraphicsview.cpp.

References d, and grid().

◆ setHeaderContextMenuPolicy()

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.

See also
QWidget::setContextMenuPolicy( Qt::ContextMenuPolicy )

Definition at line 566 of file kdganttgraphicsview.cpp.

References d.

◆ setItemDelegate

void GraphicsView::setItemDelegate ( ItemDelegate delegate)
slot

Sets the KDGantt::ItemDelegate used for rendering items on this view.

See also
ItemDelegate and QAbstractItemDelegate.

Definition at line 492 of file kdganttgraphicsview.cpp.

References d.

◆ setModel

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 390 of file kdganttgraphicsview.cpp.

References d, model(), updateScene(), and updateSceneRect().

Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().

◆ setReadOnly

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 545 of file kdganttgraphicsview.cpp.

References d.

◆ setRootIndex

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 462 of file kdganttgraphicsview.cpp.

References d.

◆ setRowController

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.

See also
AbstractRowController

Definition at line 509 of file kdganttgraphicsview.cpp.

References d, and updateScene().

Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().

◆ setSelectionModel

void GraphicsView::setSelectionModel ( QItemSelectionModel *  model)
slot

Sets the QItemSelectionModel used by this view to manage selections. Similar to QAbstractItemView::setSelectionModel

Definition at line 477 of file kdganttgraphicsview.cpp.

References d, and model().

◆ setSummaryHandlingModel

void GraphicsView::setSummaryHandlingModel ( QAbstractProxyModel model)
slot

Definition at line 409 of file kdganttgraphicsview.cpp.

References d, and updateScene().

Referenced by GraphicsView().

◆ summaryHandlingModel()

QAbstractProxyModel * GraphicsView::summaryHandlingModel ( ) const
Returns
the KDGantt::SummaryHandlingProxyModel used by this view.

Definition at line 454 of file kdganttgraphicsview.cpp.

References d.

◆ updateRow()

void GraphicsView::updateRow ( const QModelIndex &  idx)

Definition at line 647 of file kdganttgraphicsview.cpp.

References d.

Referenced by updateScene().

◆ updateScene()

void GraphicsView::updateScene ( )

◆ updateSceneRect

void GraphicsView::updateSceneRect ( )
slot

Property Documentation

◆ readOnly

bool KDGantt::GraphicsView::readOnly
readwrite

Definition at line 36 of file kdganttgraphicsview.h.


The documentation for this class was generated from the following files:

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/

https://www.kdab.com/development-resources/qt-tools/kd-chart/