1
/* This file is part of the KDE project
2
Copyright (C) 2007 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 TASKSTATUSMODEL_H
21
#define TASKSTATUSMODEL_H
23
#include "kplatomodels_export.h"
25
#include "kptitemmodelbase.h"
26
#include "kptnodeitemmodel.h"
35
typedef QMap<QString, Node*> NodeMap;
37
class KPLATOMODELS_EXPORT TaskStatusItemModel : public ItemModelBase
41
explicit TaskStatusItemModel( QObject *parent = 0 );
42
~TaskStatusItemModel();
44
enum PeriodType { UseCurrentDate, UseWeekday };
45
int periodType() const { return m_periodType; }
46
void setPeriodType( int type ) { m_periodType = type; }
48
/// Returns a column number/- name map for this model
49
virtual const QMetaEnum columnMap() const { return m_nodemodel.columnMap(); }
51
virtual void setProject( Project *project );
53
virtual Qt::ItemFlags flags( const QModelIndex & index ) const;
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;
60
virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
61
virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
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 );
67
virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
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 );
74
NodeMap *list( const QModelIndex &index ) const;
75
Node *node( const QModelIndex &index ) const;
76
QAbstractItemDelegate *createDelegate( int column, QWidget *parent ) const;
78
NodeMap nodeList( QDataStream &stream );
79
using ItemModelBase::dropAllowed;
80
bool dropAllowed( Node *on, const QMimeData *data );
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; }
90
/// Return the sortorder to be used for @p column
91
virtual int sortRole( int column ) const;
94
virtual void setScheduleManager( ScheduleManager *sm );
95
virtual void refresh();
98
void slotAboutToBeReset();
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 );
109
void slotWbsDefinitionChanged();
110
void slotLayoutChanged();
114
// keep in sync with order in m_top
116
TaskUnknownStatus = -1,
123
QVariant alignment( int column ) const;
125
QVariant name( int row, int role ) const;
126
TaskStatusItemModel::TaskStatus taskStatus(const Task *task, const QDate &begin, const QDate &end);
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 );
135
NodeModel m_nodemodel;
136
QStringList m_topNames;
137
QStringList m_topTips;
138
QList<NodeMap*> m_top;
139
NodeMap m_notstarted;
144
long m_id; // schedule id
145
int m_period; // days