KD Chart 2  [rev.2.7]
kdganttabstractgrid.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #include "kdganttabstractgrid.h"
24 #include "kdganttabstractgrid_p.h"
25 
26 #include <QRectF>
27 
28 using namespace KDGantt;
29 
42  : QObject( parent ),
43  _d( new Private )
44 {
45 }
46 
49 {
50  delete _d;
51 }
52 
53 #define d d_func()
54 
58 void AbstractGrid::setModel( QAbstractItemModel* model )
59 {
60  d->model = model;
61 }
62 
64 QAbstractItemModel* AbstractGrid::model() const
65 {
66  return d->model;
67 }
68 
72 void AbstractGrid::setRootIndex( const QModelIndex& idx )
73 {
74  d->root = idx;
75 }
76 
78 QModelIndex AbstractGrid::rootIndex() const
79 {
80  return d->root;
81 }
82 
87 {
88  // First check if the data is valid,
89  // TODO: review if true is the right choice
90  if ( !c.startIndex().isValid() || !c.endIndex().isValid() ) return true;
91 
92  Span ss = mapToChart( c.startIndex() );
93  Span es = mapToChart( c.endIndex() );
94  return ( ss.end() <= es.start() );
95 }
96 
102 qreal AbstractGrid::mapToChart( const QVariant& value ) const
103 {
104  Q_UNUSED( value );
105  return -1.0;
106 }
107 
112 QVariant AbstractGrid::mapFromChart( qreal x ) const
113 {
114  Q_UNUSED( x );
115  return QVariant();
116 }
117 
154 void AbstractGrid::drawBackground(QPainter* paint, const QRectF& rect)
155 {
156  Q_UNUSED(paint);
157  Q_UNUSED(rect);
158 }
159 
163 void AbstractGrid::drawForeground(QPainter* paint, const QRectF& rect)
164 {
165  Q_UNUSED(paint);
166  Q_UNUSED(rect);
167 }
168 
169 
170 #include "moc_kdganttabstractgrid.cpp"
171 
A class used to represent a dependency.
virtual void drawBackground(QPainter *paint, const QRectF &rect)
A class representing a start point and a length.
bool isSatisfiedConstraint(const Constraint &c) const
virtual void setModel(QAbstractItemModel *model)
QAbstractItemModel * model() const
#define d
QModelIndex rootIndex() const
QModelIndex endIndex() const
virtual Span mapToChart(const QModelIndex &idx) const =0
AbstractGrid(QObject *parent=0)
Class only listed here to document inheritance of some KDChart classes.
virtual bool mapFromChart(const Span &span, const QModelIndex &idx, const QList< Constraint > &constraints=QList< Constraint >()) const =0
virtual void drawForeground(QPainter *paint, const QRectF &rect)
qreal end() const
QModelIndex startIndex() const
virtual void setRootIndex(const QModelIndex &idx)

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/