~ubuntu-branches/debian/sid/calligraplan/sid

« back to all changes in this revision

Viewing changes to src/libs/ui/kptusedefforteditor.h

  • Committer: Package Import Robot
  • Author(s): Pino Toscano
  • Date: 2018-02-01 18:20:19 UTC
  • Revision ID: package-import@ubuntu.com-20180201182019-1qo7qaim5wejm5k9
Tags: upstream-3.1.0
ImportĀ upstreamĀ versionĀ 3.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2007, 2011 Dag Andersen <danders@get2net.dk>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
 
 
20
#ifndef KPTUSEDEFFORTEDITOR_H
 
21
#define KPTUSEDEFFORTEDITOR_H
 
22
 
 
23
#include "kplatoui_export.h"
 
24
 
 
25
#include <QTableView>
 
26
#include <QAbstractItemModel>
 
27
 
 
28
#include "kpttask.h"
 
29
 
 
30
 
 
31
namespace KPlato
 
32
{
 
33
 
 
34
class Completion;
 
35
class Resource;
 
36
class Project;
 
37
 
 
38
class KPLATOUI_EXPORT UsedEffortItemModel : public QAbstractItemModel
 
39
{
 
40
    Q_OBJECT
 
41
public:
 
42
    explicit UsedEffortItemModel(QWidget *parent = 0);
 
43
 
 
44
    void setProject( Project *project ) { m_project = project; }
 
45
 
 
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;
 
54
 
 
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 );
 
59
 
 
60
    QModelIndex addRow();
 
61
    QMap<QString, const Resource*> freeResources() const;
 
62
 
 
63
    void setReadOnly( bool ro ) { m_readonly = ro; }
 
64
    bool readOnly() const { return m_readonly; }
 
65
 
 
66
Q_SIGNALS:
 
67
    void rowInserted( const QModelIndex& );
 
68
    void changed();
 
69
 
 
70
public Q_SLOTS:
 
71
    bool submit();
 
72
    void revert();
 
73
 
 
74
private:
 
75
    Project *m_project;
 
76
    Completion *m_completion;
 
77
    QList<QDate> m_dates;
 
78
    QStringList m_headers;
 
79
    QList<const Resource*> m_resourcelist;
 
80
    QMap<QString, const Resource*> m_editlist;
 
81
    bool m_readonly;
 
82
};
 
83
 
 
84
class KPLATOUI_EXPORT UsedEffortEditor : public QTableView
 
85
{
 
86
    Q_OBJECT
 
87
public:
 
88
    explicit UsedEffortEditor(QWidget *parent);
 
89
    void setProject( Project *project );
 
90
    void setCompletion( Completion *completion );
 
91
    void setCurrentMonday( const QDate &date );
 
92
    void addResource();
 
93
 
 
94
    bool hasFreeResources() const;
 
95
 
 
96
    UsedEffortItemModel *model() const { return static_cast<UsedEffortItemModel*>( QTableView::model() ); }
 
97
 
 
98
Q_SIGNALS:
 
99
    void changed();
 
100
    void resourceAdded();
 
101
 
 
102
private:
 
103
    
 
104
};
 
105
 
 
106
//--------------------------------------------
 
107
class KPLATOUI_EXPORT CompletionEntryItemModel : public QAbstractItemModel
 
108
{
 
109
    Q_OBJECT
 
110
public:
 
111
    enum Properties {
 
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
 
117
    };
 
118
 
 
119
    explicit CompletionEntryItemModel(QObject *parent = 0);
 
120
 
 
121
    void setTask( Task *t );
 
122
 
 
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;
 
131
 
 
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 );
 
136
 
 
137
    QModelIndex addRow();
 
138
    void removeRow( int row );
 
139
 
 
140
    /// These flags are in addition to flags return from QAbstractItemModel::flags()
 
141
    void setFlags( int col, Qt::ItemFlags flags ) { m_flags[ col ] = flags; }
 
142
 
 
143
    long id() const { return m_manager == 0 ? -1 : m_manager->scheduleId(); }
 
144
 
 
145
Q_SIGNALS:
 
146
    void rowInserted( const QDate& );
 
147
    void rowRemoved( const QDate& );
 
148
    void changed();
 
149
 
 
150
public Q_SLOTS:
 
151
    bool submit();
 
152
    void revert();
 
153
    void slotDataChanged();
 
154
    void setManager( ScheduleManager *sm );
 
155
 
 
156
protected:
 
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;
 
162
 
 
163
    void removeEntry( const QDate& date );
 
164
    void addEntry( const QDate& date );
 
165
    void refresh();
 
166
 
 
167
    QList<qint64> scales() const;
 
168
 
 
169
protected:
 
170
    Task *m_node;
 
171
    Project *m_project;
 
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;
 
178
};
 
179
 
 
180
class KPLATOUI_EXPORT CompletionEntryEditor : public QTableView
 
181
{
 
182
    Q_OBJECT
 
183
public:
 
184
    explicit CompletionEntryEditor(QWidget *parent);
 
185
    void setCompletion( Completion *completion );
 
186
 
 
187
    CompletionEntryItemModel *model() const { return static_cast<CompletionEntryItemModel*>( QTableView::model() ); }
 
188
    void setCompletionModel( CompletionEntryItemModel *m );
 
189
 
 
190
Q_SIGNALS:
 
191
    void changed();
 
192
    void rowInserted( const QDate& );
 
193
    void rowRemoved( const QDate& );
 
194
    void selectionChanged( const QItemSelection&, const QItemSelection& );
 
195
 
 
196
public Q_SLOTS:
 
197
    void addEntry();
 
198
    void removeEntry();
 
199
 
 
200
private:
 
201
    
 
202
};
 
203
 
 
204
 
 
205
}  //KPlato namespace
 
206
 
 
207
#endif // KPTUSEDEFFORTEDITOR_H