1
/* This file is part of the Calligra project
2
* Copyright (c) 2008 Dag Andersen <danders@get2net.dk>
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public License
15
* along with this library; see the file COPYING.LIB. If not, write to
16
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#ifndef KPTNODECHARTMODEL_H
21
#define KPTNODECHARTMODEL_H
23
#include "kplatomodels_export.h"
25
#include "kptitemmodelbase.h"
27
#include "kpteffortcostmap.h"
29
#include <QSortFilterProxyModel>
33
#include <KChartGlobal>
40
class ScheduleManager;
43
class KPLATOMODELS_EXPORT ChartProxyModel : public QSortFilterProxyModel
47
explicit ChartProxyModel(QObject *parent = 0) : QSortFilterProxyModel( parent ) {}
49
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const {
50
//if ( role == Qt::DisplayRole && orientation == Qt::Vertical ) debugPlan<<"fetch:"<<orientation<<section<<mapToSource( index(0, section) ).column()<<m_rejects;
51
return QSortFilterProxyModel::headerData( section, orientation, role );
54
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const {
55
if ( role == Qt::DisplayRole && ! m_zerocolumns.isEmpty() ) {
56
int column = mapToSource( index ).column();
57
if ( m_zerocolumns.contains( column ) ) {
58
//debugPlan<<"zero:"<<index.column()<<mapToSource( index ).column();
62
//if ( role == Qt::DisplayRole ) debugPlan<<"fetch:"<<index.column()<<mapToSource( index ).column()<<m_rejects;
63
QVariant v = QSortFilterProxyModel::data( index, role );
64
//if ( role == Qt::DisplayRole ) debugPlan<<index.row()<<","<<index.column()<<"("<<columnCount()<<")"<<v;
67
void setRejectColumns( const QList<int> &columns ) { m_rejects = columns; invalidateFilter(); }
68
QList<int> rejectColumns() const { return m_rejects; }
69
void setZeroColumns( const QList<int> &columns ) { m_zerocolumns = columns; }
70
QList<int> zeroColumns() const { return m_zerocolumns; }
72
void reset() { beginResetModel(); endResetModel(); }
75
bool filterAcceptsColumn ( int source_column, const QModelIndex &/*source_parent */) const {
76
//debugPlan<<this<<source_column<<m_rejects<<(! m_rejects.contains( source_column ));
77
return ! m_rejects.contains( source_column );
82
QList<int> m_zerocolumns;
85
class KPLATOMODELS_EXPORT ChartItemModel : public ItemModelBase
102
const QMetaEnum columnMap() const;
104
explicit ChartItemModel(QObject *parent = 0);
107
// virtual Qt::ItemFlags flags( const QModelIndex & index ) const;
109
virtual QModelIndex parent( const QModelIndex & index ) const;
110
virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
112
virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
113
virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
115
virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
117
virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
120
const EffortCostMap &bcwp() const { return m_bcws; }
121
const EffortCostMap &acwp() const { return m_acwp; }
123
void setProject( Project *project );
125
void setNodes( const QList<Node*> &nodes );
126
void addNode( Node *node );
128
QDate startDate() const;
129
QDate endDate() const;
132
void setLocalizeValues( bool on );
135
void setScheduleManager( ScheduleManager *sm );
136
void slotNodeRemoved( Node *node );
137
void slotNodeChanged( Node *node );
138
void slotResourceChanged( Resource *resource );
139
void slotResourceChanged( const Resource *resource );
142
double bcwsEffort( int day ) const;
143
double bcwpEffort( int day ) const;
144
double acwpEffort( int day ) const;
145
double bcwsCost( int day ) const;
146
double bcwpCost( int day ) const;
147
double acwpCost( int day ) const;
148
double spiEffort( int day ) const;
149
double cpiEffort( int day ) const;
150
double spiCost( int day ) const;
151
double cpiCost( int day ) const;
154
QList<Node*> m_nodes;
155
EffortCostMap m_bcws;
156
EffortCostMap m_acwp;
157
bool m_localizeValues;
160
class KPLATOMODELS_EXPORT PerformanceDataCurrentDateModel : public ChartItemModel
164
explicit PerformanceDataCurrentDateModel(QObject *parent);
166
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
167
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
168
QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
169
QVariant data( const QModelIndex &proxyIndex, int role = Qt::DisplayRole ) const;
170
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
172
QModelIndex mapIndex( const QModelIndex &idx ) const;