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 | |
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/TODO | 2 | ||||
-rw-r--r-- | core/pim/today/changelog | 8 | ||||
-rw-r--r-- | core/pim/today/opie-today.control | 2 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 132 | ||||
-rw-r--r-- | core/pim/today/today.h | 5 | ||||
-rw-r--r-- | core/pim/today/today.pro | 6 |
6 files changed, 52 insertions, 103 deletions
diff --git a/core/pim/today/TODO b/core/pim/today/TODO index a3b01d2..0ff4758 100644 --- a/core/pim/today/TODO +++ b/core/pim/today/TODO | |||
@@ -5,10 +5,8 @@ TODO for today: | |||
5 | * show alarm icons on alarm events (partly done) | 5 | * show alarm icons on alarm events (partly done) |
6 | 6 | ||
7 | * add am/pm mode instead of 24 h, take system default | 7 | * add am/pm mode instead of 24 h, take system default |
8 | 8 | ||
9 | * qcop integration for updating events? | 9 | * qcop integration for updating events? |
10 | 10 | ||
11 | * sort todos by pri. | ||
12 | |||
13 | * make Opiezilla a clickable label wich is allway on the far right side of | 11 | * make Opiezilla a clickable label wich is allway on the far right side of |
14 | the screen , klick will open credits ,) \ No newline at end of file | 12 | the screen , klick will open credits ,) \ No newline at end of file |
diff --git a/core/pim/today/changelog b/core/pim/today/changelog index d0dd966..8ccff3c 100644 --- a/core/pim/today/changelog +++ b/core/pim/today/changelog | |||
@@ -1,6 +1,14 @@ | |||
1 | 0.3.0 | ||
2 | |||
3 | * today uses now tododb from libopie. So major changes in the todo part: | ||
4 | - overdue items on top | ||
5 | - then sorted by date, then by priority | ||
6 | * some cleanups | ||
7 | * speed optimisations | ||
8 | |||
1 | 0.2.9 | 9 | 0.2.9 |
2 | 10 | ||
3 | * Many bugfixes. | 11 | * Many bugfixes. |
4 | * Today now apparently sorts the dates _allways_ right, i would assume it | 12 | * Today now apparently sorts the dates _allways_ right, i would assume it |
5 | to be a qt bug | 13 | to be a qt bug |
6 | 14 | ||
diff --git a/core/pim/today/opie-today.control b/core/pim/today/opie-today.control index 0c55e59..9d8444e 100644 --- a/core/pim/today/opie-today.control +++ b/core/pim/today/opie-today.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Files: bin/today apps/Applications/today.desktop pics/today | 1 | Files: bin/today apps/Applications/today.desktop pics/today |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Maximilian Reiß <max.reiss@gmx.de> | 4 | Maintainer: Maximilian Reiß <max.reiss@gmx.de> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: 0.2.9-$SUB_VERSION | 6 | Version: 0.3.0-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | License: GPL | 8 | License: GPL |
9 | Description: today screen | 9 | Description: today screen |
10 | A short overview over current appointments and tasks. | 10 | A short overview over current appointments and tasks. |
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 | |||
@@ -15,16 +15,13 @@ | |||
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | 19 | ||
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> |
26 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
27 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
28 | #include <qpe/qprocess.h> | 25 | #include <qpe/qprocess.h> |
29 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
30 | #include <qpe/contact.h> | 27 | #include <qpe/contact.h> |
@@ -53,14 +50,14 @@ int MAX_CHAR_CLIP; | |||
53 | int MAX_LINES_MEET; | 50 | int MAX_LINES_MEET; |
54 | int SHOW_LOCATION; | 51 | int SHOW_LOCATION; |
55 | int SHOW_NOTES; | 52 | int SHOW_NOTES; |
56 | // show only later dates | 53 | // show only later dates |
57 | int ONLY_LATER; | 54 | int ONLY_LATER; |
58 | int AUTOSTART; | 55 | int AUTOSTART; |
59 | |||
60 | int NEW_START=1; | 56 | int NEW_START=1; |
57 | |||
61 | /* | 58 | /* |
62 | * Constructs a Example which is a child of 'parent', with the | 59 | * Constructs a Example which is a child of 'parent', with the |
63 | * name 'name' and widget flags set to 'f' | 60 | * name 'name' and widget flags set to 'f' |
64 | */ | 61 | */ |
65 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 62 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
66 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { | 63 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { |
@@ -74,14 +71,16 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) | |||
74 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); | 71 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); |
75 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 72 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
76 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); | 73 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); |
77 | #endif | 74 | #endif |
78 | #endif | 75 | #endif |
79 | 76 | ||
80 | draw(); | ||
81 | setOwnerField(); | 77 | setOwnerField(); |
78 | todo = new ToDoDB; | ||
79 | getTodo(); | ||
80 | draw(); | ||
82 | autoStart(); | 81 | autoStart(); |
83 | } | 82 | } |
84 | 83 | ||
85 | /* | 84 | /* |
86 | * Qcop receive method. | 85 | * Qcop receive method. |
87 | */ | 86 | */ |
@@ -141,15 +140,21 @@ void Today::autoStart() { | |||
141 | * Repaint method. Reread all fields. | 140 | * Repaint method. Reread all fields. |
142 | */ | 141 | */ |
143 | void Today::draw() { | 142 | void Today::draw() { |
144 | init(); | 143 | init(); |
145 | getDates(); | 144 | getDates(); |
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 | } |
151 | 156 | ||
152 | /* | 157 | /* |
153 | * Check if the todolist.xml was modified (if there are new entries. | 158 | * Check if the todolist.xml was modified (if there are new entries. |
154 | * Returns true if it was modified. | 159 | * Returns true if it was modified. |
155 | */ | 160 | */ |
@@ -179,13 +184,13 @@ bool Today::checkIfModified() { | |||
179 | * Init stuff needed for today. Reads the config file. | 184 | * Init stuff needed for today. Reads the config file. |
180 | */ | 185 | */ |
181 | void Today::init() { | 186 | void Today::init() { |
182 | QDate date = QDate::currentDate(); | 187 | QDate date = QDate::currentDate(); |
183 | QString time = (tr( date.toString()) ); | 188 | QString time = (tr( date.toString()) ); |
184 | 189 | ||
185 | TextLabel1->setText(time); | 190 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); |
186 | db = new DateBookDB; | 191 | db = new DateBookDB; |
187 | 192 | ||
188 | // read config | 193 | // read config |
189 | Config cfg("today"); | 194 | Config cfg("today"); |
190 | cfg.setGroup("BaseConfig"); | 195 | cfg.setGroup("BaseConfig"); |
191 | 196 | ||
@@ -319,76 +324,12 @@ void Today::getDates() { | |||
319 | 324 | ||
320 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 325 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
321 | sv1->addChild(AllDateBookEvents); | 326 | sv1->addChild(AllDateBookEvents); |
322 | AllDateBookEvents->show(); | 327 | AllDateBookEvents->show(); |
323 | } | 328 | } |
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 | ||
390 | void Today::getMail() { | 331 | void Today::getMail() { |
391 | Config cfg("opiemail"); | 332 | Config cfg("opiemail"); |
392 | cfg.setGroup("today"); | 333 | cfg.setGroup("today"); |
393 | 334 | ||
394 | // how many lines should be showed in the task section | 335 | // how many lines should be showed in the task section |
@@ -403,41 +344,45 @@ void Today::getMail() { | |||
403 | 344 | ||
404 | /* | 345 | /* |
405 | * Get the todos | 346 | * Get the todos |
406 | */ | 347 | */ |
407 | void Today::getTodo() { | 348 | 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; |
417 | QString tmpout; | 351 | QString tmpout; |
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 | } |
436 | } | 380 | } |
437 | 381 | ||
382 | |||
438 | if (count > 0) { | 383 | if (count > 0) { |
439 | if( count == 1 ) { | 384 | if( count == 1 ) { |
440 | output = tr("There is <b> 1</b> active task: <br>" ); | 385 | output = tr("There is <b> 1</b> active task: <br>" ); |
441 | } else { | 386 | } else { |
442 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 387 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
443 | } | 388 | } |
@@ -500,13 +445,13 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | |||
500 | QWidget* parent = 0, | 445 | QWidget* parent = 0, |
501 | const char* name = 0, | 446 | const char* name = 0, |
502 | WFlags fl = 0) : | 447 | WFlags fl = 0) : |
503 | ClickableLabel(parent,name,fl), event(ev) { | 448 | ClickableLabel(parent,name,fl), event(ev) { |
504 | 449 | ||
505 | QString msg; | 450 | QString msg; |
506 | QTime time = QTime::currentTime(); | 451 | //QTime time = QTime::currentTime(); |
507 | 452 | ||
508 | if (!ONLY_LATER) { | 453 | if (!ONLY_LATER) { |
509 | msg += "<B>" + (ev).description() + "</B>"; | 454 | msg += "<B>" + (ev).description() + "</B>"; |
510 | if ( (ev).event().hasAlarm() ) { | 455 | if ( (ev).event().hasAlarm() ) { |
511 | msg += " <b>[with alarm]</b>"; | 456 | msg += " <b>[with alarm]</b>"; |
512 | } | 457 | } |
@@ -568,15 +513,12 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | |||
568 | // include possible note or not | 513 | // include possible note or not |
569 | if (SHOW_NOTES == 1) { | 514 | if (SHOW_NOTES == 1) { |
570 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 515 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
571 | } | 516 | } |
572 | } | 517 | } |
573 | 518 | ||
574 | // if (msg.isEmpty()) { | ||
575 | // msg = tr("No more appointments today"); | ||
576 | // } | ||
577 | setText(msg); | 519 | setText(msg); |
578 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 520 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
579 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 521 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
580 | } | 522 | } |
581 | 523 | ||
582 | 524 | ||
diff --git a/core/pim/today/today.h b/core/pim/today/today.h index 6dec2c2..6048781 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h | |||
@@ -21,16 +21,17 @@ | |||
21 | #ifndef TODAY_H | 21 | #ifndef TODAY_H |
22 | #define TODAY_H | 22 | #define TODAY_H |
23 | 23 | ||
24 | #include <qpe/datebookdb.h> | 24 | #include <qpe/datebookdb.h> |
25 | #include <qpe/event.h> | 25 | #include <qpe/event.h> |
26 | 26 | ||
27 | #include <opie/tododb.h> | ||
28 | |||
27 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
28 | #include <qlist.h> | 30 | #include <qlist.h> |
29 | 31 | ||
30 | #include "TodoItem.h" | ||
31 | #include "todayconfig.h" | 32 | #include "todayconfig.h" |
32 | #include "todaybase.h" | 33 | #include "todaybase.h" |
33 | #include "clickablelabel.h" | 34 | #include "clickablelabel.h" |
34 | 35 | ||
35 | class QVBoxLayout; | 36 | class QVBoxLayout; |
36 | 37 | ||
@@ -54,18 +55,18 @@ class Today : public TodayBase { | |||
54 | void getTodo(); | 55 | void getTodo(); |
55 | void getMail(); | 56 | void getMail(); |
56 | void autoStart(); | 57 | void autoStart(); |
57 | bool checkIfModified(); | 58 | bool checkIfModified(); |
58 | void setOwnerField(); | 59 | void setOwnerField(); |
59 | void setOwnerField(QString &string); | 60 | void setOwnerField(QString &string); |
60 | QList<TodoItem> loadTodo(const char *filename); | ||
61 | private slots: | 61 | private slots: |
62 | void channelReceived(const QCString &msg, const QByteArray & data); | 62 | void channelReceived(const QCString &msg, const QByteArray & data); |
63 | 63 | ||
64 | private: | 64 | private: |
65 | DateBookDB *db; | 65 | DateBookDB *db; |
66 | ToDoDB *todo; | ||
66 | todayconfig *conf; | 67 | todayconfig *conf; |
67 | QWidget* AllDateBookEvents; | 68 | QWidget* AllDateBookEvents; |
68 | //Config cfg; | 69 | //Config cfg; |
69 | int MAX_LINES_TASK; | 70 | int MAX_LINES_TASK; |
70 | int MAX_CHAR_CLIP; | 71 | int MAX_CHAR_CLIP; |
71 | int MAX_LINES_MEET; | 72 | int MAX_LINES_MEET; |
diff --git a/core/pim/today/today.pro b/core/pim/today/today.pro index e61480c..b20baea 100644 --- a/core/pim/today/today.pro +++ b/core/pim/today/today.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | #CONFIG = qt warn_on debug | 2 | #CONFIG = qt warn_on debug |
3 | CONFIG = qt warn_on release | 3 | CONFIG = qt warn_on release |
4 | HEADERS = today.h TodoItem.h minidom.h todaybase.h todayconfig.h clickablelabel.h | 4 | HEADERS = today.h todaybase.h todayconfig.h clickablelabel.h |
5 | SOURCES = main.cpp today.cpp todaybase.cpp todayconfig.cpp minidom.c TodoItem.cpp clickablelabel.cpp | 5 | SOURCES = main.cpp today.cpp todaybase.cpp todayconfig.cpp clickablelabel.cpp |
6 | 6 | ||
7 | INCLUDEPATH+= $(OPIEDIR)/include | 7 | INCLUDEPATH+= $(OPIEDIR)/include |
8 | DEPENDPATH+= $(OPIEDIR)/include | 8 | DEPENDPATH+= $(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe -lopie |
10 | INTERFACES= | 10 | INTERFACES= |
11 | TARGET = today | 11 | TARGET = today |
12 | DESTDIR = $(OPIEDIR)/bin | 12 | DESTDIR = $(OPIEDIR)/bin |
13 | TRANSLATIONS = ../i18n/pt_BR/today.ts | 13 | TRANSLATIONS = ../i18n/pt_BR/today.ts |