00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef KARM_STORAGE_H
00024 #define KARM_STORAGE_H
00025
00026 #include <tqdict.h>
00027 #include <tqptrstack.h>
00028
00029 #include "journal.h"
00030 #include "reportcriteria.h"
00031
00032 #include "desktoplist.h"
00033
00034 #include <calendarresources.h>
00035 #include <vector>
00036 #include "resourcecalendar.h"
00037 #include <kdepimmacros.h>
00038
00039 class TQDateTime;
00040 class Preferences;
00041 class Task;
00042 class TaskView;
00043 class HistoryEvent;
00044
00067 class KarmStorage
00068 {
00069 public:
00070
00071
00072
00073
00074
00075
00076 static KarmStorage *instance();
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 TQString load(TaskView* taskview, const Preferences* preferences, TQString fileName="" );
00103
00104
00105
00106
00107 TQString icalfile();
00108
00109
00110
00111
00112
00113
00114 TQString buildTaskView(KCal::ResourceCalendar *rc, TaskView *view);
00115
00116
00117 void closeStorage(TaskView* view);
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 TQString save(TaskView* taskview);
00130
00144 TQString loadFromFlatFile(TaskView* taskview, const TQString& filename);
00145
00154 TQString loadFromFlatFileCumulative(TaskView* taskview,
00155 const TQString& filename);
00156
00160 TQString report( TaskView *taskview, const ReportCriteria &rc );
00161
00187 void changeTime(const Task* task, const long deltaSeconds);
00188
00205 bool bookTime(const Task* task, const TQDateTime& startDateTime,
00206 long durationInSeconds);
00207
00219 void setName(const Task* task, const TQString& oldname) { Q_UNUSED(task); Q_UNUSED(oldname); }
00220
00221
00230 void startTimer(const Task* task) { Q_UNUSED(task); }
00231
00241 void stopTimer(const Task* task, TQDateTime when=TQDateTime::currentDateTime());
00242
00252 void addComment(const Task* task, const TQString& comment);
00253
00254
00263 bool removeTask(Task* task);
00264
00277 TQString addTask(const Task* task, const Task* parent);
00278
00284 bool isEmpty();
00285
00296 bool isNewStorage(const Preferences* preferences) const;
00297
00299 TQValueList<HistoryEvent> getHistory(const TQDate& from, const TQDate& to);
00300
00301 private:
00302 static KarmStorage *_instance;
00303 KCal::ResourceCalendar *_calendar;
00304 TQString _icalfile;
00305
00306 KarmStorage();
00307 void adjustFromLegacyFileFormat(Task* task);
00308 bool parseLine(TQString line, long *time, TQString *name, int *level,
00309 DesktopList* desktopList);
00310 TQString writeTaskAsTodo
00311 (Task* task, const int level, TQPtrStack< KCal::Todo >& parents);
00312 bool saveCalendar();
00313
00314 KCal::Event* baseEvent(const Task*);
00315 bool remoteResource( const TQString& file ) const;
00316
00324 TQString exportcsvFile( TaskView *taskview, const ReportCriteria &rc );
00325
00329 TQString exportcsvHistory (
00330 TaskView* taskview,
00331 const TQDate& from,
00332 const TQDate& to,
00333 const ReportCriteria &rc
00334 );
00335
00336 long printTaskHistory (
00337 const Task *task,
00338 const TQMap<TQString,long>& taskdaytotals,
00339 TQMap<TQString,long>& daytotals,
00340 const TQDate& from,
00341 const TQDate& to,
00342 const int level,
00343 std::vector <TQString> &matrix,
00344 const ReportCriteria &rc
00345 );
00346 };
00347
00355 class HistoryEvent
00356 {
00357 public:
00359 HistoryEvent() {}
00360 HistoryEvent(TQString uid, TQString name, long duration,
00361 TQDateTime start, TQDateTime stop, TQString todoUid);
00362 TQString uid() {return _uid; }
00363 TQString name() {return _name; }
00365 long duration() {return _duration; }
00366 TQDateTime start() {return _start; }
00367 TQDateTime stop() { return _stop; }
00368 TQString todoUid() {return _todoUid; }
00369
00370 private:
00371 TQString _uid;
00372 TQString _todoUid;
00373 TQString _name;
00374 long _duration;
00375 TQDateTime _start;
00376 TQDateTime _stop;
00377
00378 };
00379
00380 #endif // KARM_STORAGE_H