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

« back to all changes in this revision

Viewing changes to src/libs/models/kpttaskstatusmodel.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 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 TASKSTATUSMODEL_H
 
21
#define TASKSTATUSMODEL_H
 
22
 
 
23
#include "kplatomodels_export.h"
 
24
 
 
25
#include "kptitemmodelbase.h"
 
26
#include "kptnodeitemmodel.h"
 
27
 
 
28
namespace KPlato
 
29
{
 
30
 
 
31
class Project;
 
32
class Node;
 
33
class Task;
 
34
 
 
35
typedef QMap<QString, Node*> NodeMap;
 
36
 
 
37
class KPLATOMODELS_EXPORT TaskStatusItemModel : public ItemModelBase
 
38
{
 
39
    Q_OBJECT
 
40
public:
 
41
    explicit TaskStatusItemModel( QObject *parent = 0 );
 
42
    ~TaskStatusItemModel();
 
43
    
 
44
    enum PeriodType { UseCurrentDate, UseWeekday };
 
45
    int periodType() const { return m_periodType; }
 
46
    void setPeriodType( int type ) { m_periodType = type; }
 
47
    
 
48
    /// Returns a column number/- name map for this model
 
49
    virtual const QMetaEnum columnMap() const { return m_nodemodel.columnMap(); }
 
50
 
 
51
    virtual void setProject( Project *project );
 
52
    
 
53
    virtual Qt::ItemFlags flags( const QModelIndex & index ) const;
 
54
    
 
55
    virtual QModelIndex parent( const QModelIndex & index ) const;
 
56
    virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
 
57
    virtual QModelIndex index( const Node *node ) const;
 
58
    virtual QModelIndex index( const NodeMap *lst ) const;
 
59
    
 
60
    virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const; 
 
61
    virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const; 
 
62
    
 
63
    virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; 
 
64
    virtual bool setData( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
 
65
 
 
66
    
 
67
    virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
 
68
    
 
69
    virtual QMimeData * mimeData( const QModelIndexList & indexes ) const;
 
70
    virtual QStringList mimeTypes () const;
 
71
    virtual Qt::DropActions supportedDropActions() const;
 
72
    virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
 
73
 
 
74
    NodeMap *list( const QModelIndex &index ) const;
 
75
    Node *node( const QModelIndex &index ) const;
 
76
    QAbstractItemDelegate *createDelegate( int column, QWidget *parent ) const;
 
77
    
 
78
    NodeMap nodeList( QDataStream &stream );
 
79
    using ItemModelBase::dropAllowed;
 
80
    bool dropAllowed( Node *on, const QMimeData *data );
 
81
    
 
82
    void clear();
 
83
    
 
84
    void setNow();
 
85
    void setPeriod( int days ) { m_period = days; }
 
86
    int period() const { return m_period; }
 
87
    void setWeekday( int day ) { m_weekday = day; }
 
88
    int weekday() const { return m_weekday; }
 
89
    
 
90
    /// Return the sortorder to be used for @p column
 
91
    virtual int sortRole( int column ) const;
 
92
 
 
93
public Q_SLOTS:
 
94
    virtual void setScheduleManager( ScheduleManager *sm );
 
95
    virtual void refresh();
 
96
 
 
97
protected Q_SLOTS:
 
98
    void slotAboutToBeReset();
 
99
    void slotReset();
 
100
 
 
101
    void slotNodeChanged( Node* );
 
102
    void slotNodeToBeInserted( Node *node, int row );
 
103
    void slotNodeInserted( Node *node );
 
104
    void slotNodeToBeRemoved( Node *node );
 
105
    void slotNodeRemoved( Node *node );
 
106
    void slotNodeToBeMoved( Node *node, int pos, Node *newParent, int newPos );
 
107
    void slotNodeMoved( Node *node );
 
108
 
 
109
    void slotWbsDefinitionChanged();
 
110
    void slotLayoutChanged();
 
111
 
 
112
protected:
 
113
 
 
114
    // keep in sync with order in m_top
 
115
    enum TaskStatus {
 
116
        TaskUnknownStatus = -1,
 
117
        TaskNotStarted = 0,
 
118
        TaskRunning = 1,
 
119
        TaskFinished = 2,
 
120
        TaskUpcoming = 3
 
121
    };
 
122
 
 
123
    QVariant alignment( int column ) const;
 
124
 
 
125
    QVariant name( int row, int role ) const;
 
126
    TaskStatusItemModel::TaskStatus taskStatus(const Task *task, const QDate &begin, const QDate &end);
 
127
 
 
128
    bool setCompletion( Node *node, const QVariant &value, int role );
 
129
    bool setRemainingEffort( Node *node, const QVariant &value, int role );
 
130
    bool setActualEffort( Node *node, const QVariant &value, int role );
 
131
    bool setStartedTime( Node *node, const QVariant &value, int role );
 
132
    bool setFinishedTime( Node *node, const QVariant &value, int role );
 
133
 
 
134
private:
 
135
    NodeModel m_nodemodel;
 
136
    QStringList m_topNames;
 
137
    QStringList m_topTips;
 
138
    QList<NodeMap*> m_top;
 
139
    NodeMap m_notstarted;
 
140
    NodeMap m_running;
 
141
    NodeMap m_finished;
 
142
    NodeMap m_upcoming;
 
143
    
 
144
    long m_id; // schedule id
 
145
    int m_period; // days
 
146
    int m_periodType;
 
147
    int m_weekday;
 
148
 
 
149
};
 
150
 
 
151
} //namespace KPlato
 
152
 
 
153
 
 
154
#endif