F:/KPlato/koffice/kplato/kptappointment.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Dag Andersen <danders@get2net.dk>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation;
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KPTAPPOINTMENT_H
00021 #define KPTAPPOINTMENT_H
00022 
00023 #include "kptduration.h"
00024 #include "kptdatetime.h"
00025 
00026 #include <QString>
00027 #include <QList>
00028 
00029 #include <kdebug.h>
00030 
00031 class QDomElement;
00032 class QTime;
00033 
00034 namespace KPlato
00035 {
00036 
00037 class Risk;
00038 class Effort;
00039 class Appointment;
00040 class Task;
00041 class Node;
00042 class Project;
00043 class Resource;
00044 class ResourceRequest;
00045 class ResourceGroupRequest;
00046 class Calendar;
00047 class ResourceRequestCollection;
00048 class EffortCostMap;
00049 class Schedule;
00050 
00051 
00052 
00053 class AppointmentInterval {
00054 public:
00055     AppointmentInterval();
00056     AppointmentInterval(const AppointmentInterval &AppointmentInterval);
00057     AppointmentInterval(const DateTime &start, const DateTime end, double load=100);
00058     ~AppointmentInterval();
00059     
00060     void set(DateTime &start, DateTime &end, double load=100);
00061     void set(DateTime &start, Duration &duration, double load=100);
00062     
00063     Duration effort() const { return (m_end - m_start) * m_load / 100; }
00064     Duration effort(const DateTime &start, const DateTime end) const;
00065     Duration effort(const DateTime &time, bool upto) const;
00066     
00067     bool loadXML(QDomElement &element);
00068     void saveXML(QDomElement &element) const;
00069     
00070     const DateTime &startTime() const { return m_start; }
00071     void setStartTime(const DateTime &time) { m_start = time; }
00072     const DateTime &endTime() const { return m_end; }
00073     void setEndTime(const DateTime &time) { m_end = time; }
00074     double load() const { return m_load; }
00075     void setLoad(double load) { m_load = load; }
00076     
00077     bool isValid() const;
00078     AppointmentInterval firstInterval(const AppointmentInterval &interval, const DateTime &from) const;
00079 
00080     void inSort(AppointmentInterval *a);
00081 
00082 private:
00083     DateTime m_start;
00084     DateTime m_end;
00085     double m_load; //percent
00086 };
00087 
00088 
00094 class AppointmentIntervalList : public QList<AppointmentInterval*> {
00095 public:
00096     static bool compareItems(AppointmentInterval &i1, AppointmentInterval &i2) {
00097         if (i1.startTime() < i2.startTime()) {
00098             return true;
00099         }
00100         if (i1.startTime() > i2.startTime()) {
00101             return false;
00102         }
00103         if (i1.endTime() < i2.endTime()) {
00104             return true;
00105         }
00106         if (i1.endTime() > i2.endTime()) {
00107             return false;
00108         }
00109         return true;
00110     }
00111     
00112     void inSort(AppointmentInterval *a) {
00113         append(a);
00114         qSort(*this);
00115     }
00116 };
00117 typedef QListIterator<AppointmentInterval*> AppointmentIntervalListIterator;
00118 
00130 class Appointment {
00131 public:
00132     Appointment();
00133     Appointment(Schedule *resource, Schedule *node, DateTime start, DateTime end, double load);
00134     Appointment(Schedule *resource, Schedule *node, DateTime start, Duration duration, double load);
00135     ~Appointment();
00136 
00137     // get/set member values.
00138     Schedule *node() const { return m_node; }
00139     void setNode(Schedule *n) { m_node = n; }
00140 
00141     Schedule *resource() const { return m_resource; }
00142     void setResource(Schedule *r) { m_resource = r; }
00143 
00144     DateTime startTime() const;
00145     DateTime endTime() const;
00146     double maxLoad() const;
00147     
00148     const Duration &repeatInterval() const {return m_repeatInterval;}
00149     void setRepeatInterval(Duration ri) {m_repeatInterval=ri;}
00150 
00151     int repeatCount() const { return m_repeatCount; }
00152     void setRepeatCount(int rc) { m_repeatCount=rc; }
00153 
00154     void deleteAppointmentFromRepeatList(DateTime time);
00155     void addAppointmentToRepeatList(DateTime time);
00156 
00157     bool isBusy(const DateTime &start, const DateTime &end);
00158 
00160     bool attach();
00162     void detach();
00163     
00164     void addInterval(AppointmentInterval *a);
00165     void addInterval(AppointmentInterval &a) 
00166         { addInterval(new AppointmentInterval(a)); }
00167     void addInterval(const DateTime &start, const DateTime &end, double load=100);
00168     void addInterval(const DateTime &start, const Duration &duration, double load=100);
00169     
00170     const AppointmentIntervalList &intervals() const { return m_intervals; }
00171 
00172     bool loadXML(QDomElement &element, Project &project, Schedule &sch);
00173     void saveXML(QDomElement &element) const;
00174 
00179     EffortCostMap plannedPrDay(const QDate& start, const QDate& end) const;
00180     
00182     Duration effort(const DateTime &start, const DateTime &end) const;
00184     Duration effort(const DateTime &start, const Duration &duration) const;
00186     Duration effortFrom(const DateTime &time) const;
00187     
00189     Duration plannedEffort() const;
00191     Duration plannedEffort(const QDate &date) const;
00193     Duration plannedEffortTo(const QDate &date) const;
00194 
00196     Duration actualEffort() const;
00198     Duration actualEffort(const QDate &date) const;
00200     Duration actualEffortTo(const QDate &date) const;
00201 
00203     double plannedCost();
00205     double plannedCost(const QDate &date);
00207     double plannedCostTo(const QDate &date);
00208 
00210     double actualCost();
00212     double actualCost(const QDate &date);
00214     double actualCostTo(const QDate &date);
00215 
00216     Appointment &operator=(const Appointment &app);
00217     Appointment &operator+=(const Appointment &app);
00218     Appointment operator+(const Appointment &app);
00219     
00220     void addActualEffort(QDate date, Duration effort, bool overtime=false);
00221     
00222 private:
00223     Schedule *m_node;
00224     Schedule *m_resource;
00225     
00226     Duration m_repeatInterval;
00227     int m_repeatCount;
00228     QList<Duration*> m_extraRepeats;
00229     QList<Duration*> m_skipRepeats;
00230 
00231     AppointmentIntervalList m_intervals;
00232     
00233     class UsedEffortItem {
00234     public:
00235         UsedEffortItem(QDate date, Duration effort, bool overtime=false);
00236         QDate date();
00237         Duration effort();
00238         bool isOvertime();
00239     private:
00240         QDate m_date;
00241         Duration m_effort;
00242         bool m_overtime;
00243     };
00244     class UsedEffort : QList<UsedEffortItem*> {
00245     public:
00246         UsedEffort();
00247         ~UsedEffort();
00248         void inSort(QDate date, Duration effort, bool overtime=false);
00249         Duration usedEffort(bool includeOvertime=true) const;
00250         Duration usedEffort(const QDate &date, bool includeOvertime=true) const;
00251         Duration usedEffortTo(const QDate &date, bool includeOvertime=true) const;
00252         Duration usedOvertime() const;
00253         Duration usedOvertime(const QDate &date) const;
00254         Duration usedOvertimeTo(const QDate &date) const;
00255         bool load(QDomElement &element);
00256         void save(QDomElement &element) const;
00257     };
00258     
00259     UsedEffort m_actualEffort;
00260 
00261 #ifndef NDEBUG
00262 public:
00263         void printDebug(QString ident);
00264 #endif
00265 };
00266 
00267 
00268 }  //KPlato namespace
00269 
00270 #endif

Généré le Wed Nov 22 23:40:55 2006 pour KPlato par  doxygen 1.5.1-p1