karm

task.h
1#ifndef KARM_TASK_H
2#define KARM_TASK_H
3
4// Required b/c TQPtrList is a struct, not a class.
5#include <tqptrlist.h>
6
7// Requred b/c/ TQPtrVector is a template (?)
8#include <tqptrvector.h>
9
10#include <tqdatetime.h>
11
12// Required b/c DesktopList is a typedef not a class.
13#include "desktoplist.h"
14
15// Required b/c of static cast below? (How else can compiler know that a
16// TaskView is a subclass or TQListView?)
17#include "taskview.h"
18
19class TQFile;
20class TQString;
21class KarmStorage;
22
23class TQTimer;
24class TQObject;
25class TQPixmap;
26
28
41class Task : public TQObject, public TQListViewItem
42{
43 TQ_OBJECT
44
45
46 public:
48 Task( const TQString& taskame, long minutes, long sessionTime,
49 DesktopList desktops, TaskView* parent = 0);
50 Task( const TQString& taskame, long minutes, long sessionTime,
51 DesktopList desktops, Task* parent = 0);
52 Task( KCal::Todo* incident, TaskView* parent );
54 /* destructor */
55 ~Task();
56
60 Task* firstChild() const { return (Task*)TQListViewItem::firstChild(); }
61 Task* nextSibling() const { return (Task*)TQListViewItem::nextSibling(); }
62 Task* parent() const { return (Task*)TQListViewItem::parent(); }
63
65 TaskView* taskView() const {
66 return static_cast<TaskView *>( listView() );
67 }
68
70 TQString uid() const { return _uid; }
71
79 void setUid(const TQString uid);
80
82 void cut();
85 void move(Task* destination);
87 void paste(Task* destination);
88
90 int compare ( TQListViewItem * i, int col, bool ascending ) const;
91
93
101 void changeTime( long minutes, KarmStorage* storage );
102
111 void changeTimes
112 ( long minutesSession, long minutes, KarmStorage* storage=0);
113
119 void changeTotalTimes( long minutesSession, long minutes );
120
124 void resetTimes();
125
129 long time() const { return _time; };
130 long totalTime() const { return _totalTime; };
131 long sessionTime() const { return _sessionTime; };
132 long totalSessionTime() const { return _totalSessionTime; };
133
137 TQDateTime startTime() const { return _lastStart; };
138
140 void startNewSession() { changeTimes( -_sessionTime, 0 ); };
142
144
145 void setDesktopList ( DesktopList dl );
146 DesktopList getDesktops() const { return _desktops;}
147
148 TQString getDesktopStr() const;
150
152
157 void setName( const TQString& name, KarmStorage* storage );
158
162 TQString name() const { return _name; };
163
169 TQString fullName() const;
171
173 void update();
174
176
185 void setRunning( bool on, KarmStorage* storage, TQDateTime whenStarted=TQDateTime::currentDateTime(), TQDateTime whenStopped=TQDateTime::currentDateTime());
186
190 bool isRunning() const;
192
193 bool parseIncidence(KCal::Incidence*, long& minutes,
194 long& sessionMinutes, TQString& name, DesktopList& desktops,
195 int& percent_complete);
196
200 KCal::Todo* asTodo(KCal::Todo* calendar) const;
201
203 void addComment( TQString comment, KarmStorage* storage );
204
206 TQString comment() const;
207
209 bool isRoot() const { return parent() == 0; }
210
215 bool remove( TQPtrList<Task>& activeTasks, KarmStorage* storage );
216
224 void setPercentComplete(const int percent, KarmStorage *storage);
225
226
229 void setPixmapProgress();
230
232 bool isComplete();
233
235 void removeFromView();
236
238 TQDateTime lastStart() { return _lastStart; }
239
240 protected:
241 void changeParentTotalTimes( long minutesSession, long minutes );
242
243 signals:
244 void totalTimesChanged( long minutesSession, long minutes);
246 void deletingTask(Task* thisTask);
247
248 protected slots:
250 void updateActiveIcon();
251
252 private:
253
255 TQString _uid;
256
258 TQString _comment;
259
260 int _percentcomplete;
261
262 long totalTimeInSeconds() const { return _totalTime * 60; }
263
265 void noNegativeTimes();
266
268 void init( const TQString& taskame, long minutes, long sessionTime,
269 DesktopList desktops, int percent_complete);
270
271
273 TQString _name;
274
276 TQDateTime _lastStart;
277
279 long _totalTime;
280 long _totalSessionTime;
282
284 long _time;
285 long _sessionTime;
287 DesktopList _desktops;
288 TQTimer *_timer;
289 int _currentPic;
290 static TQPtrVector<TQPixmap> *icons;
291
293 bool _removing;
294
295};
296
297#endif // KARM_TASK_H
Singleton to store/retrieve KArm data to/from persistent storage.
Definition: karmstorage.h:68
Container and interface for the tasks.
Definition: taskview.h:43
A class representing a task.
Definition: task.h:42
void addComment(TQString comment, KarmStorage *storage)
Add a comment to this task.
Definition: task.cpp:420
TQDateTime lastStart()
delivers when the task was started last
Definition: task.h:238
void changeTimes(long minutesSession, long minutes, KarmStorage *storage=0)
Add minutes to time and session time, and write to storage.
Definition: task.cpp:213
TaskView * taskView() const
Return task view for this task.
Definition: task.h:65
void resetTimes()
Reset all times to 0.
Definition: task.cpp:236
void setRunning(bool on, KarmStorage *storage, TQDateTime whenStarted=TQDateTime::currentDateTime(), TQDateTime whenStopped=TQDateTime::currentDateTime())
starts or stops a task
Definition: task.cpp:97
bool isComplete()
Return true if task is complete (percent complete equals 100).
Definition: task.cpp:194
void changeTime(long minutes, KarmStorage *storage)
Change task time.
Definition: task.cpp:208
void update()
Update the display of the task (all columns) in the UI.
Definition: task.cpp:411
void removeFromView()
Remove current task and all it's children from the view.
Definition: task.cpp:196
TQString name() const
returns the name of this task.
Definition: task.h:162
TQDateTime startTime() const
Return time the task was started.
Definition: task.h:137
KCal::Todo * asTodo(KCal::Todo *calendar) const
Load the todo passed in with this tasks info.
Definition: task.cpp:296
void updateActiveIcon()
animate the active icon
Definition: task.cpp:282
void setName(const TQString &name, KarmStorage *storage)
sets the name of the task
Definition: task.cpp:137
TQString fullName() const
Returns that task name, prefixed by parent tree up to root.
Definition: task.cpp:288
void setPixmapProgress()
Sets an appropriate icon for this task based on its level of completion.
Definition: task.cpp:184
bool isRoot() const
tells you whether this task is the root of the task tree
Definition: task.h:209
void changeTotalTimes(long minutesSession, long minutes)
adds minutes to total and session time
Definition: task.cpp:224
TQString uid() const
Return unique iCalendar Todo ID for this task.
Definition: task.h:70
void setPercentComplete(const int percent, KarmStorage *storage)
Update percent complete for this task.
Definition: task.cpp:149
int compare(TQListViewItem *i, int col, bool ascending) const
Sort times numerically, not alphabetically.
Definition: task.cpp:431
void move(Task *destination)
cut Task out of parent Task or the TaskView and into the destination Task
Definition: task.cpp:399
void paste(Task *destination)
insert Task into the destination Task
Definition: task.cpp:405
bool isRunning() const
return the state of a task - if it's running or not
Definition: task.cpp:132
Task * firstChild() const
return parent Task or null in case of TaskView.
Definition: task.h:60
void cut()
cut Task out of parent Task or the TaskView
Definition: task.cpp:389
bool remove(TQPtrList< Task > &activeTasks, KarmStorage *storage)
remove Task with all it's children
Definition: task.cpp:258
TQString comment() const
Retrieve the entire comment for the task.
Definition: task.cpp:426
void deletingTask(Task *thisTask)
signal that we're about to delete a task
void startNewSession()
sets session time to zero.
Definition: task.h:140
void setUid(const TQString uid)
Set unique id for the task.
Definition: task.cpp:128