KD Chart API Documentation  3.1
kdganttabstractgrid.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Chart library.
4 **
5 ** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: MIT
8 **
9 ****************************************************************************/
10 
11 #include "kdganttabstractgrid.h"
12 #include "kdganttabstractgrid_p.h"
13 
14 #include <QRectF>
15 
16 using namespace KDGantt;
17 
30  : QObject(parent)
31  , _d(new Private)
32 {
33 }
34 
37 {
38  delete _d;
39 }
40 
41 #define d d_func()
42 
46 void AbstractGrid::setModel(QAbstractItemModel *model)
47 {
48  d->model = model;
49 }
50 
52 QAbstractItemModel *AbstractGrid::model() const
53 {
54  return d->model;
55 }
56 
60 void AbstractGrid::setRootIndex(const QModelIndex &idx)
61 {
62  d->root = idx;
63 }
64 
66 QModelIndex AbstractGrid::rootIndex() const
67 {
68  return d->root;
69 }
70 
75 {
76  // First check if the data is valid,
77  // TODO: review if true is the right choice
78  if (!c.startIndex().isValid() || !c.endIndex().isValid())
79  return true;
80 
81  Span ss = mapToChart(c.startIndex());
82  Span es = mapToChart(c.endIndex());
83  return (ss.end() <= es.start());
84 }
85 
91 qreal AbstractGrid::mapToChart(const QVariant &value) const
92 {
93  Q_UNUSED(value);
94  return -1.0;
95 }
96 
101 QVariant AbstractGrid::mapFromChart(qreal x) const
102 {
103  Q_UNUSED(x);
104  return QVariant();
105 }
106 
143 void AbstractGrid::drawBackground(QPainter *paint, const QRectF &rect)
144 {
145  Q_UNUSED(paint);
146  Q_UNUSED(rect);
147 }
148 
152 void AbstractGrid::drawForeground(QPainter *paint, const QRectF &rect)
153 {
154  Q_UNUSED(paint);
155  Q_UNUSED(rect);
156 }
157 
158 #include "moc_kdganttabstractgrid.cpp"
~AbstractGrid() override
Destructor.
virtual Span mapToChart(const QModelIndex &idx) const =0
Implement this to map from the data in the model to the location of the corresponding item in the vie...
QAbstractItemModel * model() const
virtual void setRootIndex(const QModelIndex &idx)
Sets the root index used by this grid implementation.
virtual void drawForeground(QPainter *paint, const QRectF &rect)
virtual void drawBackground(QPainter *paint, const QRectF &rect)
bool isSatisfiedConstraint(const Constraint &c) const
QModelIndex rootIndex() const
virtual void setModel(QAbstractItemModel *model)
Sets the QAbstractItemModel used by this grid implementation.
AbstractGrid(QObject *parent=nullptr)
Constructor.
virtual bool mapFromChart(const Span &span, const QModelIndex &idx, const QList< Constraint > &constraints=QList< Constraint >()) const =0
Implement this to update the model data based on the location of the item.
A class used to represent a dependency.
QModelIndex endIndex() const
QModelIndex startIndex() const
A class representing a start point and a length.
qreal end() const
qreal start() const
#define d

© 2001 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/
Generated by doxygen 1.9.1