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

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002   Copyright (C) 2001 Thomas Zander zander@kde.org
00003   Copyright (C) 2004 - 2006 Dag Andersen <danders@get2net.dk>
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Library General Public License for more details.
00014 
00015   You should have received a copy of the GNU Library General Public License
00016   along with this library; see the file COPYING.LIB.  If not, write to
00017   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018 * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KPTPROJECT_H
00022 #define KPTPROJECT_H
00023 
00024 #include "kptnode.h"
00025 
00026 #include "kptaccount.h"
00027 #include "kptcalendar.h"
00028 #include "kptdatetime.h"
00029 #include "kptduration.h"
00030 #include "kptresource.h"
00031 
00032 #include <QMap>
00033 #include <QList>
00034 #include <QHash>
00035 
00036 #include <klocale.h>
00037 
00038 namespace KPlato
00039 {
00040 
00041 class Part;
00042 class Schedule;
00043 class StandardWorktime;
00044 
00050 class Project : public Node
00051 {
00052     Q_OBJECT
00053 public:
00054     Project( Node *parent = 0 );
00055     ~Project();
00056 
00058     virtual int type() const;
00059 
00065     void calculate( Schedule *scedule );
00071     void calculate( Effort::Use use );
00073     void calculate();
00074 
00075     virtual bool calcCriticalPath( bool fromEnd );
00076 
00077     virtual DateTime startTime() const;
00078     virtual DateTime endTime() const;
00079 
00081     Duration *getExpectedDuration();
00082 
00088     Duration *getRandomDuration();
00089 
00090     virtual bool load( QDomElement &element );
00091     virtual void save( QDomElement &element ) const;
00092 
00093     QList<ResourceGroup*> &resourceGroups();
00094     virtual void addResourceGroup( ResourceGroup *resource );
00095     virtual void insertResourceGroup( unsigned int index, ResourceGroup *resource );
00096     void deleteResourceGroup( ResourceGroup *resource );
00097     void deleteResourceGroup( int number );
00098     ResourceGroup *takeResourceGroup( ResourceGroup *resource )
00099     {
00100         int i = m_resourceGroups.indexOf( resource );
00101         return i != -1 ? m_resourceGroups.takeAt( i ) : 0;
00102     }
00103 
00104     bool addTask( Node* task, Node* position );
00105     bool addSubTask( Node* task, Node* position );
00106     bool addSubTask( Node* task, int index, Node* parent );
00107     void delTask( Node *node );
00108     bool canIndentTask( Node* node );
00109     bool indentTask( Node* node, int index = -1 );
00110     bool canUnindentTask( Node* node );
00111     bool unindentTask( Node* node );
00112     bool canMoveTaskUp( Node* node );
00113     bool moveTaskUp( Node* node );
00114     bool canMoveTaskDown( Node* node );
00115     bool moveTaskDown( Node* node );
00116     Task *createTask( Node* parent );
00117     Task *createTask( Task &def, Node* parent );
00118 
00120     ResourceGroup *group( QString id );
00122     Resource *resource( QString id );
00123 
00124     virtual EffortCostMap plannedEffortCostPrDay( const QDate &start, const QDate &end ) const;
00125 
00127     virtual Duration plannedEffort();
00129     virtual Duration plannedEffort( const QDate &date );
00131     virtual Duration plannedEffortTo( const QDate &date );
00132 
00134     virtual Duration actualEffort();
00136     virtual Duration actualEffort( const QDate &date );
00138     virtual Duration actualEffortTo( const QDate &date );
00142     virtual double plannedCost();
00144     virtual double plannedCost( const QDate &date );
00146     virtual double plannedCostTo( const QDate &date );
00147 
00151     virtual double actualCost();
00153     virtual double actualCost( const QDate &date );
00155     virtual double actualCostTo( const QDate &date );
00156 
00157     Calendar *defaultCalendar() { return m_standardWorktime->calendar(); }
00158     QList<Calendar*> calendars();
00159     void addCalendar( Calendar *calendar );
00161     Calendar *calendar( const QString id ) const;
00162 
00169     StandardWorktime *standardWorktime() { return m_standardWorktime; }
00170     void setStandardWorktime( StandardWorktime * worktime );
00171     void setDefaultCalendar( Calendar *cal );
00172 
00174     bool legalToLink( Node *par, Node *child );
00175 
00176     virtual const QHash<QString, Node*> &nodeDict() { return nodeIdDict; }
00177 
00179     virtual Node *findNode( const QString &id ) const
00180     {
00181         if ( m_parent == 0 ) {
00182             if ( nodeIdDict.contains( id ) )
00183                 return nodeIdDict[ id ];
00184             return 0;
00185         }
00186         return m_parent->findNode( id );
00187     }
00189     virtual bool removeId( const QString &id );
00191     virtual void insertId( const QString &id, Node *node );
00193     bool registerNodeId( Node *node );
00195     QString uniqueNodeId( int seed = 1 );
00196 
00197     ResourceGroup *findResourceGroup( const QString &id ) const
00198     {
00199         if ( resourceGroupIdDict.contains( id ) )
00200             return resourceGroupIdDict[ id ];
00201         return 0;
00202     }
00204     bool removeResourceGroupId( const QString &id )
00205     {
00206         if ( resourceGroupIdDict.contains( id ) )
00207             return resourceGroupIdDict.remove( id );
00208         return false;
00209     }
00211     void insertResourceGroupId( const QString &id, ResourceGroup* group )
00212     {
00213         resourceGroupIdDict.insert( id, group );
00214     }
00215 
00216     Resource *findResource( const QString &id ) const
00217     {
00218         if ( resourceIdDict.contains( id ) )
00219             return resourceIdDict[ id ];
00220         return 0;
00221     }
00223     bool removeResourceId( const QString &id ) { return resourceIdDict.remove( id ); }
00225     void insertResourceId( const QString &id, Resource *resource )
00226     { resourceIdDict.insert( id, resource ); }
00227 
00229     virtual Calendar *findCalendar( const QString &id ) const
00230     {
00231         if ( id.isEmpty() || !calendarIdDict.contains( id ) )
00232             return 0;
00233         return calendarIdDict[ id ];
00234     }
00236     virtual bool removeCalendarId( const QString &id );
00238     virtual void insertCalendarId( const QString &id, Calendar *calendar );
00239 
00240     void generateWBS( int count, WBSDefinition &def, QString wbs = QString() );
00241 
00242     Accounts &accounts() { return m_accounts; }
00243 
00245     virtual void setCurrentSchedule( long id );
00247     MainSchedule *createSchedule( QString name, Schedule::Type type );
00249     virtual void setParentSchedule( Schedule *sch );
00250 
00251 signals:
00253     void nodeChanged( Node* );
00255     void nodeToBeAdded( Node* );
00257     void nodeAdded( Node* );
00259     void nodeToBeRemoved( Node* );
00261     void nodeRemoved( Node* );
00263     void nodeToBeMoved( Node* );
00265     void nodeMoved( Node* );
00266     
00267 protected:
00268     virtual void changed(Node *node);
00269     
00270     Accounts m_accounts;
00271     QList<ResourceGroup*> m_resourceGroups;
00272 
00273     QList<Calendar*> m_calendars;
00274 
00275     StandardWorktime *m_standardWorktime;
00276 
00277     DateTime calculateForward( int use );
00278     DateTime calculateBackward( int use );
00279     DateTime scheduleForward( const DateTime &earliest, int use );
00280     DateTime scheduleBackward( const DateTime &latest, int use );
00281     void adjustSummarytask();
00282 
00283     void initiateCalculation( Schedule &sch );
00284     void initiateCalculationLists( QList<Node*> &startnodes, QList<Node*> &endnodes, QList<Node*> &summarytasks );
00285 
00286     bool legalParents( Node *par, Node *child );
00287     bool legalChildren( Node *par, Node *child );
00288 
00289 private:
00290     void init();
00291 
00292     QList<Node*> m_startNodes;
00293     QList<Node*> m_endNodes;
00294     QList<Node*> m_summarytasks;
00295 
00296     QHash<QString, ResourceGroup*> resourceGroupIdDict;
00297     QHash<QString, Resource*> resourceIdDict;
00298     QHash<QString, Node*> nodeIdDict;
00299     QHash<QString, Calendar*> calendarIdDict;
00300 
00301 #ifndef NDEBUG
00302 public:
00303     void printDebug( bool children, QByteArray indent );
00304     void printCalendarDebug( QByteArray indent = "" );
00305 #endif
00306 };
00307 
00308 }  //KPlato namespace
00309 
00310 #endif

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