Fix assert when Mail-Followup-To contains two emails, as Ossi's Mutt does
[kdepim.git] / kdgantt2 / kdganttabstractgrid.cpp
blobb078374607dba65f732ccf92b5efa01636f922bb
1 /****************************************************************************
2 ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Gantt library.
5 **
6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file.
11 ** Licensees holding valid commercial KD Gantt licenses may use this file in
12 ** accordance with the KD Gantt Commercial License Agreement provided with
13 ** the Software.
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.
18 ** See http://www.kdab.net/kdgantt for
19 ** information about KD Gantt Commercial License Agreements.
21 ** Contact info@kdab.net if any conditions of this
22 ** licensing are not clear to you.
24 **********************************************************************/
25 #include "kdganttabstractgrid.h"
26 #include "kdganttabstractgrid_p.h"
28 using namespace KDGantt;
30 /*!\class KDGantt::AbstractGrid kdganttabstractgrid.h KDGanttAbstractGrid
31 * \ingroup KDGantt
32 * \brief Abstract baseclass for grids. A grid is used to convert between
33 * QModelIndex'es and gantt chart values (doubles) and to paint the
34 * background and header of the view.
36 * \see KDGantt::DateTimeGrid
39 /*! Constructor. Creates an AbstractGrid with parent \a parent.
40 * The QObject parent is not used for anything internally. */
41 AbstractGrid::AbstractGrid( QObject* parent )
42 : QObject( parent ),
43 _d( new Private )
47 /*! Destructor. Does nothing */
48 AbstractGrid::~AbstractGrid()
50 delete _d;
53 #define d d_func()
55 /*! Sets the QAbstractItemModel used by this grid implementation.
56 * This is called by the view, you should never need to call this
57 * from client code. */
58 void AbstractGrid::setModel( QAbstractItemModel* model )
60 d->model = model;
63 /*!\returns The QAbstractItemModel used by this grid */
64 QAbstractItemModel* AbstractGrid::model() const
66 return d->model;
69 /*! Sets the root index used by this grid implementation.
70 * This is called by the view, you should never need to call this
71 * from client code. */
72 void AbstractGrid::setRootIndex( const QModelIndex& idx )
74 d->root = idx;
77 /*!\returns the current root index for this grid */
78 QModelIndex AbstractGrid::rootIndex() const
80 return d->root;
83 /*!\returns true if the startpoint is before the endpoint
84 * of the constraint \a c.
86 bool AbstractGrid::isSatisfiedConstraint( const Constraint& c ) const
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;
92 Span ss = mapToChart( c.startIndex() );
93 Span es = mapToChart( c.endIndex() );
94 return ( ss.end() <= es.start() );
97 /*!\fn virtual Span AbstractGrid::mapToChart( const QModelIndex& idx ) const
98 * Implement this to map from the data in the model to the location of
99 * the corresponding item in the view.
102 /*!\fn virtual bool AbstractGrid::mapFromChart( const Span& span, const QModelIndex& idx, const QList<Constraint>& constraints ) const
103 * Implement this to update the model data based on the location of the item. Check
104 * against the \a constraints list to make sure no hard constraints are violated by
105 * writing back to the model.
106 * \returns true if the update succeeded.
109 /*!\fn virtual void AbstractGrid::paintGrid( QPainter* painter, const QRectF& sceneRect, const QRectF& exposedRect, AbstractRowController* rowController=0, QWidget* widget=0 )
111 * Implement this to paint the background of the view -- typically
112 * with some grid lines.
113 * \param painter -- the QPainter to paint with.
114 * \param sceneRect -- the total bounding rectangle of the scene.
115 * \param exposedRect -- the rectangle that needs to be painted.
116 * \param rowController -- the row controller used by the view -- may be 0.
117 * \param widget -- the widget used by the view -- may be 0.
120 /*!\fn virtual void AbstractGrid::paintHeader( QPainter* painter, const QRectF& headerRect, const QRectF& exposedRect, qreal offset, QWidget* widget=0 )
122 * Implement this to paint the header part of the view.
123 * \param painter -- the QPainter to paint with.
124 * \param headerRect -- the total rectangle occupied by the header.
125 * \param exposedRect -- the rectangle that needs to be painted.
126 * \param offset -- the horizontal scroll offset of the view.
127 * \param widget -- the widget used by the view -- may be 0.
130 #include "moc_kdganttabstractgrid.cpp"