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
00106
00107
00108 QString icalfile();
00109
00110
00111
00112
00113
00114
00115 QString 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 QString save(TaskView* taskview);
00131
00145 QString loadFromFlatFile(TaskView* taskview, const QString& filename);
00146
00155 QString loadFromFlatFileCumulative(TaskView* taskview,
00156 const QString& filename);
00157
00161 QString report( TaskView *taskview, const ReportCriteria &rc );
00162
00188 void changeTime(const Task* task, const long deltaSeconds);
00189
00206 bool bookTime(const Task* task, const QDateTime& startDateTime,
00207 long durationInSeconds);
00208
00220 void setName(const Task* task, const QString& 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, QDateTime when=QDateTime::currentDateTime());
00243
00253 void addComment(const Task* task, const QString& comment);
00254
00255
00264 bool removeTask(Task* task);
00265
00278 QString addTask(const Task* task, const Task* parent);
00279
00285 bool isEmpty();
00286
00297 bool isNewStorage(const Preferences* preferences) const;
00298
00300 QValueList<HistoryEvent> getHistory(const QDate& from, const QDate& to);
00301
00302 private:
00303 static KarmStorage *_instance;
00304 KCal::ResourceCalendar *_calendar;
00305 QString _icalfile;
00306
00307 KarmStorage();
00308 void adjustFromLegacyFileFormat(Task* task);
00309 bool parseLine(QString line, long *time, QString *name, int *level,
00310 DesktopList* desktopList);
00311 QString writeTaskAsTodo
00312 (Task* task, const int level, QPtrStack< KCal::Todo >& parents);
00313 bool saveCalendar();
00314
00315 KCal::Event* baseEvent(const Task*);
00316 bool remoteResource( const QString& file ) const;
00317
00325 QString exportcsvFile( TaskView *taskview, const ReportCriteria &rc );
00326
00330 QString exportcsvHistory (
00331 TaskView* taskview,
00332 const QDate& from,
00333 const QDate& to,
00334 const ReportCriteria &rc
00335 );
00336
00337 long printTaskHistory (
00338 const Task *task,
00339 const QMap<QString,long>& taskdaytotals,
00340 QMap<QString,long>& daytotals,
00341 const QDate& from,
00342 const QDate& to,
00343 const int level,
00344 std::vector <QString> &matrix,
00345 const ReportCriteria &rc
00346 );
00347 };
00348
00356 class HistoryEvent
00357 {
00358 public:
00360 HistoryEvent() {}
00361 HistoryEvent(QString uid, QString name, long duration,
00362 QDateTime start, QDateTime stop, QString todoUid);
00363 QString uid() {return _uid; }
00364 QString name() {return _name; }
00366 long duration() {return _duration; }
00367 QDateTime start() {return _start; }
00368 QDateTime stop() { return _stop; }
00369 QString todoUid() {return _todoUid; }
00370
00371 private:
00372 QString _uid;
00373 QString _todoUid;
00374 QString _name;
00375 long _duration;
00376 QDateTime _start;
00377 QDateTime _stop;
00378
00379 };
00380
00381 #endif // KARM_STORAGE_H