00001 #ifndef TASKMANAGERDATA_H 00002 #define TASKMANAGERDATA_H 00003 00004 #include "resource.h" 00005 #include "task.h" 00006 00007 #include <tools/global.h> 00008 00009 #include <QObject> 00010 00011 namespace domain 00012 { 00013 00014 struct Requirement; 00015 00016 00017 struct Field; 00018 00019 00020 class Duration; 00021 class StorableData; 00022 class Task; 00023 class Reservation; 00024 class User; 00025 class Project; 00026 class Schedule; 00027 class Type; 00028 class UserType; 00029 class ResourceType; 00030 class TaskType; 00031 class Clock; 00032 00033 struct TaskManagerDataPrivate; 00034 00073 class DOMAIN_EXPORT TaskManagerData : public QObject 00074 { 00075 Q_OBJECT 00076 00077 friend Task::Task(TaskType* type, User*, const Schedule&, 00078 TaskState::SettableState, const QList<Task*>&, 00079 const QList<InvitationData>&, 00080 const QList<ReservationData>&); 00081 00082 public: 00083 00087 static TaskManagerData* instance(); 00088 00092 Clock* clock() const; 00093 00097 QList<Task*> tasks() const; 00098 00102 QList<Task*> tasksForUser(const User* user) const; 00103 00108 QList<Reservation*> reservations() const; 00109 00113 QList<User*> users() const; 00114 00121 QList<User*> allUsers() const; 00122 00126 User* adminUser() const; 00127 00131 QList<Invitation*> invitations() const; 00132 00137 QList<Resource*> resources() const; 00138 00143 QList<Project*> projects() const; 00144 00154 Task* task(const Task* task) const; 00155 00165 Resource* resource(const Resource* resource); 00166 00176 Project* project(const Project* project); 00177 00187 User* user(const User* user); 00188 00198 Invitation* invitation(const Invitation* invitation); 00199 00207 Task* createTask(TaskType* type, const User* user, 00208 const Schedule& schedule, 00209 TaskState::SettableState state = TaskState::Unfinished, 00210 const QList<Task*>& subTasks = QList<Task*>(), 00211 const QList<InvitationData>& invitations = QList<InvitationData>(), 00212 const QList<ReservationData>& reservations = QList<ReservationData>()); 00213 00221 Reservation* createReservation(const Task* task, const Resource* resource, 00222 const QDateTime& time, const Duration& duration); 00223 00231 User* createUser(UserType* type, const QString& name); 00232 00240 Invitation* createInvitation(const Task* task, const User* user); 00241 00249 Resource* createResource(const QString& description, 00250 ResourceType* type); 00251 00259 Project* createProject(const QString& description); 00260 00271 void removeData(const StorableData* data); 00272 00278 void clear(); 00279 00284 void clearTheme(); 00285 00291 TaskType* createTaskType(QString id, QString name); 00292 00298 UserType* createUserType(QString id, QString name); 00299 00305 ResourceType* createResourceType(QString id, QString name); 00306 00311 QList<UserType*> userTypes() const; 00312 00317 QList<TaskType*> taskTypes() const; 00318 00323 QList<ResourceType*> resourceTypes() const; 00324 00329 Type* typeById(const QString& id) const; 00330 00336 bool hasData() const; 00337 00341 bool hasTheme() const; 00342 00343 Q_SIGNALS: 00344 00350 void timeChanged(const QDateTime& newTime); 00351 00362 void dataChanged(); 00363 00369 void tasksChanged(); 00370 00376 void usersChanged(); 00377 00383 void resourcesChanged(); 00384 00390 void reservationsChanged(); 00391 00397 void projectsChanged(); 00398 00404 void invitationsChanged(); 00405 00406 00407 private: 00408 00412 TaskManagerData(); 00413 00417 ~TaskManagerData(); 00418 00419 TaskManagerData(const TaskManagerData& other); 00420 TaskManagerData& operator=(const TaskManagerData& other); 00421 00428 Invitation* _createInvitation(Task* task, User* user); 00429 00436 Reservation* _createReservation(Task* task, Resource* resource, 00437 const QDateTime& time, const Duration& duration); 00438 00446 void addType(Type* type); 00447 00448 TaskManagerDataPrivate* const d; 00449 }; 00450 00451 } 00452 00453 #endif