kplato

kptproject.h
1/* This file is part of the KDE project
2 Copyright (C) 2001 Thomas Zander zander@kde.org
3 Copyright (C) 2004 - 2006 Dag Andersen <danders@get2net.dk>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KPTPROJECT_H
22#define KPTPROJECT_H
23
24#include "kptnode.h"
25
26#include "kptaccount.h"
27#include "kptcalendar.h"
28#include "kptdatetime.h"
29#include "kptduration.h"
30#include "kptresource.h"
31
32#include <tqmap.h>
33#include <tqptrlist.h>
34#include <tqdict.h>
35
36#include <tdelistview.h>
37#include <tdelocale.h>
38
39namespace KPlato
40{
41
42class Part;
43class Schedule;
44class StandardWorktime;
45
46//#define DEBUGPERT
52class Project : public Node {
53public:
54 Project(Node *parent = 0);
55 ~Project();
56
58 virtual int type() const;
59
65 void calculate(Schedule *scedule);
71 void calculate(Effort::Use use);
73 void calculate();
74
75 virtual bool calcCriticalPath(bool fromEnd);
76
77 virtual DateTime startTime() const;
78 virtual DateTime endTime() const;
79
82
89
90 virtual bool load(TQDomElement &element);
91 virtual void save(TQDomElement &element) const;
92
93 TQPtrList<ResourceGroup> &resourceGroups();
94 virtual void addResourceGroup(ResourceGroup *resource);
95 virtual void insertResourceGroup(unsigned int index, ResourceGroup *resource);
96 void removeResourceGroup(ResourceGroup *resource);
97 void removeResourceGroup(int number);
98 ResourceGroup *takeResourceGroup(ResourceGroup *resource)
99 { return m_resourceGroups.take(m_resourceGroups.findRef(resource)); }
100
101 bool addTask( Node* task, Node* position );
102 bool addSubTask( Node* task, Node* position );
103 bool addSubTask( Node* task, int index, Node* parent );
104 void delTask(Node *node);
105 bool canIndentTask(Node* node);
106 bool indentTask( Node* node );
107 bool canUnindentTask( Node* node );
108 bool unindentTask( Node* node );
109 bool canMoveTaskUp( Node* node );
110 bool moveTaskUp( Node* node );
111 bool canMoveTaskDown( Node* node );
112 bool moveTaskDown( Node* node );
113 Task *createTask(Node* parent);
114 Task *createTask(Task &def, Node* parent);
115
117 ResourceGroup *group(TQString id);
119 Resource *resource(TQString id);
120
121 virtual EffortCostMap plannedEffortCostPrDay(const TQDate &start, const TQDate &end) const;
122
124 virtual Duration plannedEffort();
126 virtual Duration plannedEffort(const TQDate &date);
128 virtual Duration plannedEffortTo(const TQDate &date);
129
131 virtual Duration actualEffort();
133 virtual Duration actualEffort(const TQDate &date);
135 virtual Duration actualEffortTo(const TQDate &date);
139 virtual double plannedCost();
141 virtual double plannedCost(const TQDate &date);
143 virtual double plannedCostTo(const TQDate &date);
144
148 virtual double actualCost();
150 virtual double actualCost(const TQDate &date);
152 virtual double actualCostTo(const TQDate &date);
153
154 Calendar *defaultCalendar() { return m_standardWorktime->calendar(); }
155 TQPtrList<Calendar> calendars();
156 void addCalendar(Calendar *calendar);
158 Calendar *calendar(const TQString id) const;
159
166 StandardWorktime *standardWorktime() { return m_standardWorktime; }
167 void setStandardWorktime(StandardWorktime * worktime);
168
170 bool legalToLink(Node *par, Node *child);
171
172 virtual const TQDict<Node> &nodeDict() { return nodeIdDict; }
173
175 virtual Node *findNode(const TQString &id) const
176 { return (m_parent ? m_parent->findNode(id) : nodeIdDict.find(id)); }
178 virtual bool removeId(const TQString &id);
180 virtual void insertId(const TQString &id, const Node *node);
182 bool registerNodeId(Node *node);
184 TQString uniqueNodeId(int seed=1);
185
186 ResourceGroup *findResourceGroup(const TQString &id) const
187 { return resourceGroupIdDict.find(id); }
189 bool removeResourceGroupId(const TQString &id)
190 { return resourceGroupIdDict.remove(id); }
192 void insertResourceGroupId(const TQString &id, const ResourceGroup* group)
193 { resourceGroupIdDict.insert(id, group); }
194
195 Resource *findResource(const TQString &id) const
196 { return resourceIdDict.find(id); }
198 bool removeResourceId(const TQString &id)
199 { return resourceIdDict.remove(id); }
201 void insertResourceId(const TQString &id, const Resource *resource)
202 { resourceIdDict.insert(id, resource); }
203
205 virtual Calendar *findCalendar(const TQString &id) const
206 { return id.isEmpty() ? 0 : calendarIdDict.find(id); }
208 virtual bool removeCalendarId(const TQString &id);
210 virtual void insertCalendarId(const TQString &id, const Calendar *calendar);
211
216 void setBaselined(bool on) { m_baselined = on; }
220 bool isBaselined() const { return m_baselined; }
221
222 void generateWBS(int count, WBSDefinition &def, TQString wbs=TQString());
223
224 Accounts &accounts() { return m_accounts; }
225
227 virtual void setCurrentSchedule(long id);
229 MainSchedule *createSchedule(TQString name, Schedule::Type type);
231 virtual void setParentSchedule(Schedule *sch);
232
233protected:
234 Accounts m_accounts;
235 TQPtrList<ResourceGroup> m_resourceGroups;
236
237 TQPtrList<Calendar> m_calendars;
238
239 StandardWorktime *m_standardWorktime;
240
241 DateTime calculateForward(int use);
242 DateTime calculateBackward(int use);
243 DateTime scheduleForward(const DateTime &earliest, int use);
244 DateTime scheduleBackward(const DateTime &latest, int use);
245 void adjustSummarytask();
246
247 void initiateCalculation(Schedule &sch);
248 void initiateCalculationLists(TQPtrList<Node> &startnodes, TQPtrList<Node> &endnodes, TQPtrList<Node> &summarytasks);
249
250 bool legalParents(Node *par, Node *child);
251 bool legalChildren(Node *par, Node *child);
252
253private:
254 void init();
255
256 TQPtrList<Node> m_startNodes;
257 TQPtrList<Node> m_endNodes;
258 TQPtrList<Node> m_summarytasks;
259
260 bool m_baselined;
261
262 TQDict<ResourceGroup> resourceGroupIdDict;
263 TQDict<Resource> resourceIdDict;
264 TQDict<Node> nodeIdDict;
265 TQDict<Calendar> calendarIdDict;
266
267#ifndef NDEBUG
268#include <tqcstring.h>
269public:
270 void printDebug(bool children, TQCString indent);
271 void printCalendarDebug(TQCString indent="");
272#ifdef DEBUGPERT
273 static void pert_test();
274 static void printTree(Node *n, TQString s);
275#endif
276#endif
277};
278
279} //KPlato namespace
280
281#endif
Accounts administrates all accounts.
Definition kptaccount.h:180
Calendar defines the working and nonworking days and hours.
DateTime is a TQDateTime which knows about Duration.
Definition kptdatetime.h:33
The duration class can be used to store a timespan in a convenient format.
Definition kptduration.h:34
This class represents any node in the project, a node can be a project or a subproject or any task.
Definition kptnode.h:57
virtual Node * findNode() const
Find the node with my id.
Definition kptnode.h:399
virtual bool removeId()
Remove myself from the id register.
Definition kptnode.h:404
Project is the main node in a project, it contains child nodes and possibly sub-projects.
Definition kptproject.h:52
virtual double plannedCost()
Returns the total planned cost for this project.
virtual void setCurrentSchedule(long id)
Set current schedule to schedule with identity id, for me and my children.
ResourceGroup * group(TQString id)
Returns the resourcegroup with identity id.
void setBaselined(bool on)
Setting a project to be baselined means the project data can not be edited anymore.
Definition kptproject.h:216
bool removeResourceGroupId(const TQString &id)
Remove the resourcegroup with identity id from the register.
Definition kptproject.h:189
virtual bool removeCalendarId(const TQString &id)
Remove the calendar with identity id from the register.
TQString uniqueNodeId(int seed=1)
Create a unique id.
virtual void setParentSchedule(Schedule *sch)
Set parent schedule for my children.
virtual Duration plannedEffort()
Returns the total planned effort for this project (or subproject)
virtual Duration actualEffortTo(const TQDate &date)
Returns the actual effort up to and including date.
Resource * resource(TQString id)
Returns the resource with identity id.
void insertResourceId(const TQString &id, const Resource *resource)
Insert the resource with identity id.
Definition kptproject.h:201
bool isBaselined() const
Definition kptproject.h:220
virtual double plannedCostTo(const TQDate &date)
Planned cost up to and including date.
Duration * getExpectedDuration()
Returns the duration calculated as latestFinish - earliestStart.
bool registerNodeId(Node *node)
Register node. The nodes id must be unique and non-empty.
void calculate()
Calculate current schedule.
bool legalToLink(Node *par, Node *child)
Check if node par can be linked to node child.
virtual Calendar * findCalendar(const TQString &id) const
Find the calendar with identity id.
Definition kptproject.h:205
void insertResourceGroupId(const TQString &id, const ResourceGroup *group)
Insert the resourcegroup with identity id.
Definition kptproject.h:192
Calendar * calendar(const TQString id) const
Returns the calendar with identity id.
virtual DateTime startTime() const
Return the scheduled start time.
virtual double actualCostTo(const TQDate &date)
Actual cost up to and including date.
virtual Duration actualEffort()
Returns the actual effort.
void generateWBS(int count, WBSDefinition &def, TQString wbs=TQString())
Generate WBS.
virtual Duration plannedEffortTo(const TQDate &date)
Returns the planned effort up to and including date.
virtual DateTime endTime() const
Return the scheduled end time.
virtual Node * findNode(const TQString &id) const
Find the node with identity id.
Definition kptproject.h:175
MainSchedule * createSchedule(TQString name, Schedule::Type type)
Create new schedule with unique id.
virtual void insertId(const TQString &id, const Node *node)
Insert the node with identity id.
bool removeResourceId(const TQString &id)
Remove the resource with identity id from the register.
Definition kptproject.h:198
Duration * getRandomDuration()
Instead of using the expected duration, generate a random value using the Distribution of each Task.
virtual int type() const
Returns the node type. Can be Type_Project or Type_Subproject.
virtual double actualCost()
Returns the actually reported cost for this project.
virtual void insertCalendarId(const TQString &id, const Calendar *calendar)
Insert the calendar with identity id.
StandardWorktime * standardWorktime()
Defines the length of days, weeks, months and years and the standard working week.
Definition kptproject.h:166
This class represents a group of similar resources to be assigned to a task e.g.
Definition kptresource.h:66
Any resource that is used by a task.
The Schedule class holds data calculated during project calculation and scheduling,...
Definition kptschedule.h:55
A task in the scheduling software is represented by this class.
Definition kpttask.h:40