File indexing completed on 2024-05-12 15:54:21
0001 /* 0002 * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KGantt library. 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of 0009 * the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 0018 */ 0019 0020 #include "kganttabstractgrid.h" 0021 #include "kganttabstractgrid_p.h" 0022 0023 #include <QRectF> 0024 0025 using namespace KGantt; 0026 0027 0028 AbstractGrid::AbstractGrid( QObject* parent ) 0029 : QObject( parent ), 0030 _d( new Private ) 0031 { 0032 } 0033 0034 AbstractGrid::~AbstractGrid() 0035 { 0036 delete _d; 0037 } 0038 0039 #define d d_func() 0040 0041 void AbstractGrid::setModel( QAbstractItemModel* model ) 0042 { 0043 d->model = model; 0044 } 0045 0046 QAbstractItemModel* AbstractGrid::model() const 0047 { 0048 return d->model; 0049 } 0050 0051 void AbstractGrid::setRootIndex( const QModelIndex& idx ) 0052 { 0053 d->root = idx; 0054 } 0055 0056 QModelIndex AbstractGrid::rootIndex() const 0057 { 0058 return d->root; 0059 } 0060 0061 bool AbstractGrid::isSatisfiedConstraint( const Constraint& c ) const 0062 { 0063 // First check if the data is valid, 0064 // TODO: review if true is the right choice 0065 if ( !c.startIndex().isValid() || !c.endIndex().isValid() ) return true; 0066 0067 Span ss = mapToChart( c.startIndex() ); 0068 Span es = mapToChart( c.endIndex() ); 0069 return ( ss.end() <= es.start() ); 0070 } 0071 0072 qreal AbstractGrid::mapToChart( const QVariant& value ) const 0073 { 0074 Q_UNUSED( value ); 0075 return -1.0; 0076 } 0077 0078 QVariant AbstractGrid::mapFromChart( qreal x ) const 0079 { 0080 Q_UNUSED( x ); 0081 return QVariant(); 0082 } 0083 0084 void AbstractGrid::drawBackground(QPainter* paint, const QRectF& rect) 0085 { 0086 Q_UNUSED(paint); 0087 Q_UNUSED(rect); 0088 } 0089 0090 void AbstractGrid::drawForeground(QPainter* paint, const QRectF& rect) 0091 { 0092 Q_UNUSED(paint); 0093 Q_UNUSED(rect); 0094 } 0095 0096 0097 #include "moc_kganttabstractgrid.cpp" 0098