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 class KCal::Todo;
00045
00068 class KarmStorage
00069 {
00070 public:
00071
00072
00073
00074
00075
00076
00077 static KarmStorage *instance();
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
00103 TQString load(TaskView* taskview, const Preferences* preferences, TQString fileName="" );
00104
00105
00106
00107
00108 TQString icalfile();
00109
00110
00111
00112
00113
00114
00115 TQString buildTaskView(KCal::ResourceCalendar *rc, TaskView *view);
00116
00117
00118 void closeStorage(TaskView* view);
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 TQString save(TaskView* taskview);
00131
00145 TQString loadFromFlatFile(TaskView* taskview, const TQString& filename);
00146
00155 TQString loadFromFlatFileCumulative(TaskView* taskview,
00156 const TQString& filename);
00157
00161 TQString report( TaskView *taskview, const ReportCriteria &rc );
00162
00188 void changeTime(const Task* task, const long deltaSeconds);
00189
00206 bool bookTime(const Task* task, const TQDateTime& startDateTime,
00207 long durationInSeconds);
00208
00220 void setName(const Task* task, const TQString& oldname) { Q_UNUSED(task); Q_UNUSED(oldname); }
00221
00222
00231 void startTimer(const Task* task) { Q_UNUSED(task); }
00232
00242 void stopTimer(const Task* task, TQDateTime when=TQDateTime::currentDateTime());
00243
00253 void addComment(const Task* task, const TQString& comment);
00254
00255
00264 bool removeTask(Task* task);
00265
00278 TQString addTask(const Task* task, const Task* parent);
00279
00285 bool isEmpty();
00286
00297 bool isNewStorage(const Preferences* preferences) const;
00298
00300 TQValueList<HistoryEvent> getHistory(const TQDate& from, const TQDate& to);
00301
00302 private:
00303 static KarmStorage *_instance;
00304 KCal::ResourceCalendar *_calendar;
00305 TQString _icalfile;
00306
00307 KarmStorage();
00308 void adjustFromLegacyFileFormat(Task* task);
00309 bool parseLine(TQString line, long *time, TQString *name, int *level,
00310 DesktopList* desktopList);
00311 TQString writeTaskAsTodo
00312 (Task* task, const int level, TQPtrStack< KCal::Todo >& parents);
00313 bool saveCalendar();
00314
00315 KCal::Event* baseEvent(const Task*);
00316 bool remoteResource( const TQString& file ) const;
00317
00325 TQString exportcsvFile( TaskView *taskview, const ReportCriteria &rc );
00326
00330 TQString exportcsvHistory (
00331 TaskView* taskview,
00332 const TQDate& from,
00333 const TQDate& to,
00334 const ReportCriteria &rc
00335 );
00336
00337 long printTaskHistory (
00338 const Task *task,
00339 const TQMap<TQString,long>& taskdaytotals,
00340 TQMap<TQString,long>& daytotals,
00341 const TQDate& from,
00342 const TQDate& to,
00343 const int level,
00344 std::vector <TQString> &matrix,
00345 const ReportCriteria &rc
00346 );
00347 };
00348
00356 class HistoryEvent
00357 {
00358 public:
00360 HistoryEvent() {}
00361 HistoryEvent(TQString uid, TQString name, long duration,
00362 TQDateTime start, TQDateTime stop, TQString todoUid);
00363 TQString uid() {return _uid; }
00364 TQString name() {return _name; }
00366 long duration() {return _duration; }
00367 TQDateTime start() {return _start; }
00368 TQDateTime stop() { return _stop; }
00369 TQString todoUid() {return _todoUid; }
00370
00371 private:
00372 TQString _uid;
00373 TQString _todoUid;
00374 TQString _name;
00375 long _duration;
00376 TQDateTime _start;
00377 TQDateTime _stop;
00378
00379 };
00380
00381 #endif // KARM_STORAGE_H