2 * TaskScenario.h - TaskJuggler
4 * Copyright (c) 2002 by Chris Schlaeger <cs@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
13 #include "TaskScenario.h"
15 #include "ResourceTreeIterator.h"
19 TaskScenario::TaskScenario() :
40 pathCriticalness(0.0),
41 isOnCriticalPath(false),
42 reportedCompletion(-1.0),
43 containerCompletion(-1.0),
44 completionDegree(0.0),
47 specifiedScheduled(false),
49 startCanBeDetermined(false),
50 endCanBeDetermined(false),
51 specifiedBookedResources(),
58 TaskScenario::calcCompletionDegree(time_t now)
62 completionDegree = 100.0;
63 status = reportedCompletion >= 0 && reportedCompletion < 100 ?
66 else if (now <= start)
68 completionDegree = 0.0;
69 status = reportedCompletion > 0 ? InProgressEarly : NotStarted;
76 completionDegree = (100.0 / effort) *
77 task->getLoad(index, Interval(start, now));
79 else if (length > 0.0)
81 completionDegree = (100.0 /
82 task->getProject()->calcWorkingDays(Interval(start, end))) *
83 task->getProject()->calcWorkingDays(Interval(start, now));
86 completionDegree = (100.0 / (end - start + 1)) * (now - start);
88 if (reportedCompletion >= 0.0)
90 if (reportedCompletion < completionDegree)
91 status = InProgressLate;
92 else if (reportedCompletion > completionDegree)
93 status = InProgressEarly;
98 bool TaskScenario::isDutyOf(const Resource* r) const
100 for (ConstResourceTreeIterator rti(r); *rti; ++rti)
101 if (bookedResources.containsRef(*rti) > 0)