author | harlekin <harlekin> | 2002-03-20 09:26:50 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-03-20 09:26:50 (UTC) |
commit | 79d96ab3393af185b0f0d705e1b7ae74ee801241 (patch) (unidiff) | |
tree | 9875a386bfb159701840024d3975d5091aac1d59 /core/pim/today/today.cpp | |
parent | ad91f15243333bf968ef5788d12c780746fcffb3 (diff) | |
download | opie-79d96ab3393af185b0f0d705e1b7ae74ee801241.zip opie-79d96ab3393af185b0f0d705e1b7ae74ee801241.tar.gz opie-79d96ab3393af185b0f0d705e1b7ae74ee801241.tar.bz2 |
ported todoy to tododb wich is now in libopie
-rw-r--r-- | core/pim/today/today.cpp | 132 |
1 files changed, 37 insertions, 95 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 1936518..2dc96fc 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -20,6 +20,3 @@ | |||
20 | #include "today.h" | 20 | #include "today.h" |
21 | #include "minidom.h" | ||
22 | #include "TodoItem.h" | ||
23 | 21 | ||
24 | #include <qpe/datebookdb.h> | ||
25 | #include <qpe/timestring.h> | 22 | #include <qpe/timestring.h> |
@@ -58,4 +55,4 @@ int ONLY_LATER; | |||
58 | int AUTOSTART; | 55 | int AUTOSTART; |
59 | |||
60 | int NEW_START=1; | 56 | int NEW_START=1; |
57 | |||
61 | /* | 58 | /* |
@@ -79,4 +76,6 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) | |||
79 | 76 | ||
80 | draw(); | ||
81 | setOwnerField(); | 77 | setOwnerField(); |
78 | todo = new ToDoDB; | ||
79 | getTodo(); | ||
80 | draw(); | ||
82 | autoStart(); | 81 | autoStart(); |
@@ -146,5 +145,11 @@ void Today::draw() { | |||
146 | getMail(); | 145 | getMail(); |
146 | |||
147 | // if the todolist.xml file was not modified in between, do not parse it. | ||
148 | if (checkIfModified()) { | ||
149 | todo = new ToDoDB; | ||
147 | getTodo(); | 150 | getTodo(); |
151 | } | ||
152 | |||
148 | // how often refresh | 153 | // how often refresh |
149 | QTimer::singleShot( 10*1000, this, SLOT(draw() ) ); | 154 | QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); |
150 | } | 155 | } |
@@ -184,3 +189,3 @@ void Today::init() { | |||
184 | 189 | ||
185 | TextLabel1->setText(time); | 190 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); |
186 | db = new DateBookDB; | 191 | db = new DateBookDB; |
@@ -324,66 +329,2 @@ void Today::getDates() { | |||
324 | 329 | ||
325 | /* | ||
326 | * Parse in the todolist.xml | ||
327 | */ | ||
328 | QList<TodoItem> Today::loadTodo(const char *filename) { | ||
329 | DOM *todo; | ||
330 | ELE *tasks; | ||
331 | ELE **tasklist; | ||
332 | ATT **attlist; | ||
333 | int i, j; | ||
334 | char *description; | ||
335 | int completed; | ||
336 | int priority; | ||
337 | TodoItem *tmp; | ||
338 | QList<TodoItem> loadtodolist; | ||
339 | |||
340 | todo = minidom_load(filename); | ||
341 | |||
342 | tasks = todo->el; | ||
343 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ | ||
344 | if(tasks) { | ||
345 | tasklist = tasks->el; | ||
346 | i = 0; | ||
347 | while((tasklist) && (tasklist[i])) { | ||
348 | attlist = tasklist[i]->at; | ||
349 | j = 0; | ||
350 | description = NULL; | ||
351 | priority = -1; | ||
352 | completed = -1; | ||
353 | while((attlist) && (attlist[j])) { | ||
354 | if(!attlist[j]->name) { | ||
355 | continue; | ||
356 | } | ||
357 | if(!strcmp(attlist[j]->name, "Description")) { | ||
358 | description = attlist[j]->value; | ||
359 | } | ||
360 | // get Completed tag (0 or 1) | ||
361 | if(!strcmp(attlist[j]->name, "Completed")) { | ||
362 | QString s = attlist[j]->name; | ||
363 | if(s == "Completed") { | ||
364 | completed = QString(attlist[j]->value).toInt(); | ||
365 | } | ||
366 | } | ||
367 | // get Priority (1 to 5) | ||
368 | if(!strcmp(attlist[j]->name, "Priority")) { | ||
369 | QString s = attlist[j]->name; | ||
370 | if(s == "Priority") { | ||
371 | priority = QString(attlist[j]->value).toInt(); | ||
372 | } | ||
373 | } | ||
374 | j++; | ||
375 | } | ||
376 | if(description) { | ||
377 | tmp = new TodoItem(description, completed, priority); | ||
378 | loadtodolist.append(tmp); | ||
379 | } | ||
380 | i++; | ||
381 | } | ||
382 | } | ||
383 | |||
384 | minidom_free(todo); | ||
385 | |||
386 | return loadtodolist; | ||
387 | } | ||
388 | |||
389 | 330 | ||
@@ -408,9 +349,2 @@ void Today::getTodo() { | |||
408 | 349 | ||
409 | // if the todolist.xml file was not modified in between, do not parse it. | ||
410 | if (!checkIfModified() && !NEW_START) { | ||
411 | return; | ||
412 | } | ||
413 | // since it was the new start or the return from config dialog, set it to 0 again. | ||
414 | NEW_START=0; | ||
415 | |||
416 | QString output; | 350 | QString output; |
@@ -418,18 +352,28 @@ void Today::getTodo() { | |||
418 | int count = 0; | 352 | int count = 0; |
353 | int ammount = 0; | ||
419 | 354 | ||
420 | QDir dir; | 355 | // get overdue todos first |
421 | QString homedir = dir.homeDirPath (); | 356 | QValueList<ToDoEvent> overDueList = todo->overDue(); |
422 | // see if todolist.xml does exist. | 357 | qBubbleSort(overDueList); |
423 | QFile f(homedir +"/Applications/todolist/todolist.xml"); | 358 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); |
424 | if ( f.exists() ) { | 359 | it!=overDueList.end(); ++it ) { |
425 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); | 360 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { |
426 | 361 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; | |
427 | TodoItem *item; | 362 | ammount++; |
428 | for( item = todolist.first(); item; item = todolist.next()) { | ||
429 | if (!(item->getCompleted() == 1) ) { | ||
430 | count++; | ||
431 | if (count <= MAX_LINES_TASK) { | ||
432 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); | ||
433 | } | 363 | } |
434 | } | 364 | } |
365 | |||
366 | // get total number of still open todos | ||
367 | QValueList<ToDoEvent> open = todo->rawToDos(); | ||
368 | qBubbleSort(open); | ||
369 | for ( QValueList<ToDoEvent>::Iterator it=open.begin(); | ||
370 | it!=open.end(); ++it ) { | ||
371 | if (!(*it).isCompleted()){ | ||
372 | count +=1; | ||
373 | // not the overdues, we allready got them, and not if we are | ||
374 | // over the maxlines | ||
375 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { | ||
376 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; | ||
377 | ammount++; | ||
378 | } | ||
435 | } | 379 | } |
@@ -437,2 +381,3 @@ void Today::getTodo() { | |||
437 | 381 | ||
382 | |||
438 | if (count > 0) { | 383 | if (count > 0) { |
@@ -505,3 +450,3 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | |||
505 | QString msg; | 450 | QString msg; |
506 | QTime time = QTime::currentTime(); | 451 | //QTime time = QTime::currentTime(); |
507 | 452 | ||
@@ -573,5 +518,2 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | |||
573 | 518 | ||
574 | // if (msg.isEmpty()) { | ||
575 | // msg = tr("No more appointments today"); | ||
576 | // } | ||
577 | setText(msg); | 519 | setText(msg); |