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 <qdict.h>
00027 #include <qptrstack.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 QDateTime;
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 QString load(TaskView* taskview, const Preferences* preferences, QString fileName="" );
00104
00105 QString buildTaskView(KCal::ResourceCalendar *rc, TaskView *view);
00106
00107
00108 void closeStorage(TaskView* view);
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 QString save(TaskView* taskview);
00121
00135 QString loadFromFlatFile(TaskView* taskview, const QString& filename);
00136
00145 QString loadFromFlatFileCumulative(TaskView* taskview,
00146 const QString& filename);
00147
00151 QString report( TaskView *taskview, const ReportCriteria &rc );
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 void changeTime(const Task* task, const long deltaSeconds);
00179
00196 bool bookTime(const Task* task, const QDateTime& startDateTime,
00197 long durationInSeconds);
00198
00210 void setName(const Task* task, const QString& oldname) { Q_UNUSED(task); Q_UNUSED(oldname); }
00211
00212
00221 void startTimer(const Task* task) { Q_UNUSED(task); }
00222
00232 void stopTimer(const Task* task);
00233
00243 void addComment(const Task* task, const QString& comment);
00244
00245
00254 bool removeTask(Task* task);
00255
00268 QString addTask(const Task* task, const Task* parent);
00269
00275 bool isEmpty();
00276
00287 bool isNewStorage(const Preferences* preferences) const;
00288
00290 QValueList<HistoryEvent> getHistory(const QDate& from, const QDate& to);
00291
00292 private:
00293 static KarmStorage *_instance;
00294 KCal::ResourceCalendar *_calendar;
00295 QString _icalfile;
00296
00297 KarmStorage();
00298 void adjustFromLegacyFileFormat(Task* task);
00299 bool parseLine(QString line, long *time, QString *name, int *level,
00300 DesktopList* desktopList);
00301 QString writeTaskAsTodo
00302 (Task* task, const int level, QPtrStack< KCal::Todo >& parents);
00303 bool saveCalendar();
00304
00305 KCal::Event* baseEvent(const Task*);
00306 bool remoteResource( const QString& file ) const;
00307
00315 QString exportcsvFile( TaskView *taskview, const ReportCriteria &rc );
00316
00320 QString exportcsvHistory (
00321 TaskView* taskview,
00322 const QDate& from,
00323 const QDate& to,
00324 const ReportCriteria &rc
00325 );
00326
00327 long printTaskHistory (
00328 const Task *task,
00329 const QMap<QString,long>& taskdaytotals,
00330 QMap<QString,long>& daytotals,
00331 const QDate& from,
00332 const QDate& to,
00333 const int level,
00334 std::vector <QString> &matrix,
00335 const ReportCriteria &rc
00336 );
00337 };
00338
00346 class HistoryEvent
00347 {
00348 public:
00350 HistoryEvent() {}
00351 HistoryEvent(QString uid, QString name, long duration,
00352 QDateTime start, QDateTime stop, QString todoUid);
00353 QString uid() {return _uid; }
00354 QString name() {return _name; }
00356 long duration() {return _duration; }
00357 QDateTime start() {return _start; }
00358 QDateTime stop() { return _stop; }
00359 QString todoUid() {return _todoUid; }
00360
00361 private:
00362 QString _uid;
00363 QString _todoUid;
00364 QString _name;
00365 long _duration;
00366 QDateTime _start;
00367 QDateTime _stop;
00368
00369 };
00370
00371 #endif // KARM_STORAGE_H