File indexing completed on 2024-05-12 16:39:26
0001 /* This file is part of the KDE project 0002 Copyright (C) 2009, 2011 Dag Andersen <danders@get2net.dk> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version.. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef TASKWORKPACKAGEMODEL_H 0021 #define TASKWORKPACKAGEMODEL_H 0022 0023 #include "planwork_export.h" 0024 0025 #include "kptitemmodelbase.h" 0026 #include "kptnodeitemmodel.h" 0027 #include "kptschedule.h" 0028 0029 #include <QMetaEnum> 0030 0031 0032 class QModelIndex; 0033 class QAbstractItemDelegate; 0034 0035 namespace KPlato 0036 { 0037 0038 class Project; 0039 class Node; 0040 class Resource; 0041 class Document; 0042 0043 } 0044 0045 using namespace KPlato; 0046 0047 /// The main namespace 0048 namespace KPlatoWork 0049 { 0050 0051 class Part; 0052 class WorkPackage; 0053 0054 /** 0055 * The TaskWorkPackageModel class gives access to workpackage status 0056 * for the resources assigned to the task in this package. 0057 * 0058 * The model stores a nodes parentNode() in the index's internalPointer(). 0059 */ 0060 class PLANWORK_EXPORT TaskWorkPackageModel : public ItemModelBase 0061 { 0062 Q_OBJECT 0063 public: 0064 explicit TaskWorkPackageModel(Part *part, QObject *parent = 0); 0065 ~TaskWorkPackageModel() override {} 0066 0067 enum Properties { 0068 NodeName = 0, 0069 NodeType, 0070 NodeResponsible, 0071 NodeDescription, 0072 0073 // After scheduling 0074 NodeStartTime, 0075 NodeEndTime, 0076 NodeAssignments, 0077 0078 // Completion 0079 NodeCompleted, 0080 NodeActualEffort, 0081 NodeRemainingEffort, 0082 NodePlannedEffort, 0083 NodeActualStart, 0084 NodeStarted, 0085 NodeActualFinish, 0086 NodeFinished, 0087 NodeStatus, 0088 NodeStatusNote, 0089 0090 ProjectName, 0091 ProjectManager 0092 }; 0093 Q_ENUM(Properties) 0094 const QMetaEnum columnMap() const override 0095 { 0096 return metaObject()->enumerator(metaObject()->indexOfEnumerator("Properties")); 0097 } 0098 0099 WorkPackage *workPackage(int index) const; 0100 0101 Qt::ItemFlags flags(const QModelIndex &index) const override; 0102 QModelIndex parent(const QModelIndex &index) const override; 0103 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; 0104 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0105 bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override; 0106 0107 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0108 0109 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0110 int columnCount(const QModelIndex &index = QModelIndex()) const override; 0111 0112 Node *nodeForIndex(const QModelIndex &index) const; 0113 QModelIndex indexForNode(Node *node) const; 0114 0115 QAbstractItemDelegate *createDelegate(int column, QWidget *parent) const override; 0116 0117 Document *documentForIndex(const QModelIndex &idx) const; 0118 0119 WorkPackage *ptrToWorkPackage(const QModelIndex &idx) const; 0120 Node *ptrToNode(const QModelIndex &idx) const; 0121 0122 bool isNode(const QModelIndex &idx) const; 0123 bool isDocument(const QModelIndex &idx) const; 0124 0125 public Q_SLOTS: 0126 void addWorkPackage(KPlatoWork::WorkPackage *package, int row); 0127 void removeWorkPackage(KPlatoWork::WorkPackage *package, int row); 0128 0129 protected Q_SLOTS: 0130 void slotNodeChanged(KPlato::Node*); 0131 void slotNodeToBeInserted(KPlato::Node *node, int row); 0132 void slotNodeInserted(KPlato::Node *node); 0133 void slotNodeToBeRemoved(KPlato::Node *node); 0134 void slotNodeRemoved(KPlato::Node *node); 0135 0136 void slotDocumentAdded(KPlato::Node *node, KPlato::Document *doc, int index); 0137 void slotDocumentRemoved(KPlato::Node *node, KPlato::Document *doc, int index); 0138 void slotDocumentChanged(KPlato::Node *node, KPlato::Document *doc, int index); 0139 0140 protected: 0141 QVariant nodeData(Node *node, int column, int role) const; 0142 QVariant documentData(Document *doc, int column, int role) const; 0143 0144 QVariant name(const Resource *r, int role) const; 0145 QVariant email(const Resource *r, int role) const; 0146 QVariant sendStatus(const Resource *r, int role) const; 0147 QVariant sendTime(const Resource *r, int role) const; 0148 QVariant responseType(const Resource *r, int role) const; 0149 QVariant requiredTime(const Resource *r, int role) const; 0150 QVariant responseStatus(const Resource *r, int role) const; 0151 QVariant responseTime(const Resource *r, int role) const; 0152 QVariant lastAction(const Resource *r, int role) const; 0153 QVariant projectName(const Node *n, int role) const; 0154 QVariant projectManager(const Node *n, int role) const; 0155 0156 bool setCompletion(Node *node, const QVariant &value, int role); 0157 bool setRemainingEffort(Node *node, const QVariant &value, int role); 0158 bool setActualEffort(Node *node, const QVariant &value, int role); 0159 bool setStartedTime(Node *node, const QVariant &value, int role); 0160 bool setFinishedTime(Node *node, const QVariant &value, int role); 0161 0162 QVariant actualStart(Node *n, int role) const; 0163 QVariant actualFinish(Node *n, int role) const; 0164 QVariant plannedEffort(Node *n, int role) const; 0165 0166 QVariant status(Node *n, int role) const; 0167 0168 private: 0169 NodeModel m_nodemodel; 0170 Part *m_part; 0171 QList<WorkPackage*> m_packages; 0172 }; 0173 0174 0175 } //namespace KPlato 0176 0177 #endif //WORKPACKAGEMODEL_H