1
/* This file is part of the KDE project
2
Copyright (C) 2007, 2011 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 KPTUSEDEFFORTEDITOR_H
21
#define KPTUSEDEFFORTEDITOR_H
23
#include "kplatoui_export.h"
26
#include <QAbstractItemModel>
38
class KPLATOUI_EXPORT UsedEffortItemModel : public QAbstractItemModel
42
explicit UsedEffortItemModel(QWidget *parent = 0);
44
void setProject( Project *project ) { m_project = project; }
46
virtual Qt::ItemFlags flags( const QModelIndex & index ) const;
47
virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
48
virtual bool setData( const QModelIndex &index, const QVariant & value, int role = Qt::EditRole );
49
virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
50
virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
51
virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
52
virtual QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
53
QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
55
void setCompletion( Completion *completion );
56
const Resource *resource(const QModelIndex &index ) const;
57
Completion::UsedEffort *usedEffort(const QModelIndex &index ) const;
58
void setCurrentMonday( const QDate &date );
61
QMap<QString, const Resource*> freeResources() const;
63
void setReadOnly( bool ro ) { m_readonly = ro; }
64
bool readOnly() const { return m_readonly; }
67
void rowInserted( const QModelIndex& );
76
Completion *m_completion;
78
QStringList m_headers;
79
QList<const Resource*> m_resourcelist;
80
QMap<QString, const Resource*> m_editlist;
84
class KPLATOUI_EXPORT UsedEffortEditor : public QTableView
88
explicit UsedEffortEditor(QWidget *parent);
89
void setProject( Project *project );
90
void setCompletion( Completion *completion );
91
void setCurrentMonday( const QDate &date );
94
bool hasFreeResources() const;
96
UsedEffortItemModel *model() const { return static_cast<UsedEffortItemModel*>( QTableView::model() ); }
100
void resourceAdded();
106
//--------------------------------------------
107
class KPLATOUI_EXPORT CompletionEntryItemModel : public QAbstractItemModel
112
Property_Date, /// Date of entry
113
Property_Completion, /// % Completed
114
Property_UsedEffort, /// Used Effort
115
Property_RemainingEffort, /// Remaining Effort
116
Property_PlannedEffort /// Planned Effort
119
explicit CompletionEntryItemModel(QObject *parent = 0);
121
void setTask( Task *t );
123
virtual Qt::ItemFlags flags( const QModelIndex & index ) const;
124
virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
125
virtual bool setData( const QModelIndex &index, const QVariant & value, int role = Qt::EditRole );
126
virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
127
virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
128
virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
129
virtual QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
130
QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
132
void setCompletion( Completion *completion );
133
const Resource *resource(const QModelIndex &index ) const;
134
Completion::UsedEffort *usedEffort(const QModelIndex &index ) const;
135
void setCurrentMonday( const QDate &date );
137
QModelIndex addRow();
138
void removeRow( int row );
140
/// These flags are in addition to flags return from QAbstractItemModel::flags()
141
void setFlags( int col, Qt::ItemFlags flags ) { m_flags[ col ] = flags; }
143
long id() const { return m_manager == 0 ? -1 : m_manager->scheduleId(); }
146
void rowInserted( const QDate& );
147
void rowRemoved( const QDate& );
153
void slotDataChanged();
154
void setManager( ScheduleManager *sm );
157
QVariant date ( int row, int role = Qt::DisplayRole ) const;
158
QVariant percentFinished ( int row, int role ) const;
159
QVariant remainingEffort ( int row, int role ) const;
160
virtual QVariant actualEffort ( int row, int role ) const;
161
QVariant plannedEffort ( int row, int role ) const;
163
void removeEntry( const QDate& date );
164
void addEntry( const QDate& date );
167
QList<qint64> scales() const;
172
ScheduleManager *m_manager;
173
Completion *m_completion;
174
QList<QDate> m_dates;
175
QStringList m_headers;
176
QList<QDate> m_datelist;
177
QList<Qt::ItemFlags> m_flags;
180
class KPLATOUI_EXPORT CompletionEntryEditor : public QTableView
184
explicit CompletionEntryEditor(QWidget *parent);
185
void setCompletion( Completion *completion );
187
CompletionEntryItemModel *model() const { return static_cast<CompletionEntryItemModel*>( QTableView::model() ); }
188
void setCompletionModel( CompletionEntryItemModel *m );
192
void rowInserted( const QDate& );
193
void rowRemoved( const QDate& );
194
void selectionChanged( const QItemSelection&, const QItemSelection& );
207
#endif // KPTUSEDEFFORTEDITOR_H