kdganttabstractgrid.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD Chart library.
00005 **
00006 ** Licensees holding valid commercial KD Chart licenses may use this file in
00007 ** accordance with the KD Chart Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL included.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
00020 **
00021 **********************************************************************/
00022 
00023 #include "kdganttabstractgrid.h"
00024 #include "kdganttabstractgrid_p.h"
00025 
00026 #include <QRectF>
00027 
00028 using namespace KDGantt;
00029 
00041 AbstractGrid::AbstractGrid( QObject* parent )
00042     : QObject( parent ),
00043       _d( new Private )
00044 {
00045 }
00046 
00048 AbstractGrid::~AbstractGrid()
00049 {
00050     delete _d;
00051 }
00052 
00053 #define d d_func()
00054 
00058 void AbstractGrid::setModel( QAbstractItemModel* model )
00059 {
00060     d->model = model;
00061 }
00062 
00064 QAbstractItemModel* AbstractGrid::model() const
00065 {
00066     return d->model;
00067 }
00068 
00072 void AbstractGrid::setRootIndex( const QModelIndex& idx )
00073 {
00074     d->root = idx;
00075 }
00076 
00078 QModelIndex AbstractGrid::rootIndex() const
00079 {
00080     return d->root;
00081 }
00082 
00086 bool AbstractGrid::isSatisfiedConstraint( const Constraint& c ) const
00087 {
00088     // First check if the data is valid,
00089     // TODO: review if true is the right choice
00090     if ( !c.startIndex().isValid() || !c.endIndex().isValid() ) return true;
00091 
00092     Span ss = mapToChart( c.startIndex() );
00093     Span es = mapToChart( c.endIndex() );
00094     return ( ss.end() <= es.start() );
00095 }
00096 
00102 qreal AbstractGrid::mapToChart( const QVariant& value ) const
00103 {
00104     Q_UNUSED( value );
00105     return -1.0;
00106 }
00107 
00112 QVariant AbstractGrid::mapFromChart( qreal x ) const
00113 {
00114     Q_UNUSED( x );
00115     return QVariant();
00116 }
00117 
00154 void AbstractGrid::drawBackground(QPainter* paint, const QRectF& rect)
00155 {
00156     Q_UNUSED(paint);
00157     Q_UNUSED(rect);
00158 }
00159 
00163 void AbstractGrid::drawForeground(QPainter* paint, const QRectF& rect)
00164 {
00165     Q_UNUSED(paint);
00166     Q_UNUSED(rect);
00167 }
00168 
00169 
00170 #include "moc_kdganttabstractgrid.cpp"
00171