20#ifndef KPTAPPOINTMENT_H
21#define KPTAPPOINTMENT_H
23#include "kptduration.h"
24#include "kptdatetime.h"
46class ResourceGroupRequest;
48class ResourceRequestCollection;
54class AppointmentInterval {
56 AppointmentInterval();
57 AppointmentInterval(
const AppointmentInterval &AppointmentInterval);
58 AppointmentInterval(
const DateTime &start,
const DateTime end,
double load=100);
59 ~AppointmentInterval();
61 void set(DateTime &start, DateTime &end,
double load=100);
62 void set(DateTime &start, Duration &duration,
double load=100);
64 Duration effort()
const {
return (m_end - m_start) * m_load / 100; }
65 Duration effort(
const DateTime &start,
const DateTime end)
const;
66 Duration effort(
const DateTime &time,
bool upto)
const;
68 bool loadXML(TQDomElement &element);
69 void saveXML(TQDomElement &element)
const;
71 const DateTime &startTime()
const {
return m_start; }
72 void setStartTime(
const DateTime &time) { m_start = time; }
73 const DateTime &endTime()
const {
return m_end; }
74 void setEndTime(
const DateTime &time) { m_end = time; }
75 double load()
const {
return m_load; }
76 void setLoad(
double load) { m_load = load; }
79 AppointmentInterval firstInterval(
const AppointmentInterval &interval,
const DateTime &from)
const;
95 int compareItems(TQPtrCollection::Item item1, TQPtrCollection::Item item2) {
96 AppointmentInterval *i1 =
static_cast<AppointmentInterval*
>(item1);
97 AppointmentInterval *i2 =
static_cast<AppointmentInterval*
>(item2);
98 if (i1->startTime() < i2->startTime()) {
101 if (i1->startTime() > i2->startTime()) {
104 if (i1->endTime() < i2->endTime()) {
107 if (i1->endTime() > i2->endTime()) {
113typedef TQPtrListIterator<AppointmentInterval> AppointmentIntervalListIterator;
134 Schedule *node()
const {
return m_node; }
135 void setNode(
Schedule *n) { m_node = n; }
137 Schedule *resource()
const {
return m_resource; }
138 void setResource(
Schedule *r) { m_resource = r; }
142 double maxLoad()
const;
144 const Duration &repeatInterval()
const {
return m_repeatInterval;}
145 void setRepeatInterval(
Duration ri) {m_repeatInterval=ri;}
147 int repeatCount()
const {
return m_repeatCount; }
148 void setRepeatCount(
int rc) { m_repeatCount=rc; }
150 void deleteAppointmentFromRepeatList(
DateTime time);
151 void addAppointmentToRepeatList(
DateTime time);
160 void addInterval(AppointmentInterval *a);
161 void addInterval(AppointmentInterval &a)
162 { addInterval(
new AppointmentInterval(a)); }
163 void addInterval(
const DateTime &start,
const DateTime &end,
double load=100);
164 void addInterval(
const DateTime &start,
const Duration &duration,
double load=100);
169 void saveXML(TQDomElement &element)
const;
175 EffortCostMap
plannedPrDay(
const TQDate& start,
const TQDate& end)
const;
216 void addActualEffort(TQDate date,
Duration effort,
bool overtime=
false);
224 TQPtrList<Duration> m_extraRepeats;
225 TQPtrList<Duration> m_skipRepeats;
229 class UsedEffortItem {
231 UsedEffortItem(TQDate date,
Duration effort,
bool overtime=
false);
240 class UsedEffort : TQPtrList<UsedEffortItem> {
245 Duration usedEffort(
bool includeOvertime=
true)
const;
246 Duration usedEffort(
const TQDate &date,
bool includeOvertime=
true)
const;
247 Duration usedEffortTo(
const TQDate &date,
bool includeOvertime=
true)
const;
249 Duration usedOvertime(
const TQDate &date)
const;
250 Duration usedOvertimeTo(
const TQDate &date)
const;
251 bool load(TQDomElement &element);
252 void save(TQDomElement &element)
const;
255 int compareItems(TQPtrCollection::Item item1, TQPtrCollection::Item item2);
258 UsedEffort m_actualEffort;
262 void printDebug(TQString ident);
This list is sorted after 1) startdatetime, 2) enddatetime.
A resource (Resource) can be scheduled to be used at any time, this is represented internally with Ap...
Duration effortFrom(const DateTime &time) const
Returns the planned effort from time onwards.
void detach()
detach appointment from resource and node
EffortCostMap plannedPrDay(const TQDate &start, const TQDate &end) const
Returns the planned effort and cost for the interval start to end (inclusive).
double plannedCost()
Calculates the total planned cost for this appointment.
double actualCost()
Calculates the total actual cost for this appointment.
double actualCostTo(const TQDate &date)
Calculates the actual cost upto and including date.
Duration plannedEffort() const
Returns the total planned effort for this appointment.
bool attach()
attach appointment to resource and node
Duration actualEffortTo(const TQDate &date) const
Returns the actual effort on the date.
Duration effort(const DateTime &start, const DateTime &end) const
Returns the planned effort from start to end.
Duration plannedEffortTo(const TQDate &date) const
Returns the planned effort upto and including date.
Duration actualEffort() const
Returns the total actual effort for this appointment.
double plannedCostTo(const TQDate &date)
Calculates the planned cost upto and including date.
DateTime is a TQDateTime which knows about Duration.
The duration class can be used to store a timespan in a convenient format.
Project is the main node in a project, it contains child nodes and possibly sub-projects.
The Schedule class holds data calculated during project calculation and scheduling,...