author | harlekin <harlekin> | 2002-03-08 23:41:05 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-03-08 23:41:05 (UTC) |
commit | bc79d3f4a7503c4298a5396b80c65a3e268f4be3 (patch) (unidiff) | |
tree | ba27d1565f91458241a792091539683148086b2e /core/pim/today/today.cpp | |
parent | 432eeb6cedecc0ee4dff3654803c18ebbac1f4d7 (diff) | |
download | opie-bc79d3f4a7503c4298a5396b80c65a3e268f4be3.zip opie-bc79d3f4a7503c4298a5396b80c65a3e268f4be3.tar.gz opie-bc79d3f4a7503c4298a5396b80c65a3e268f4be3.tar.bz2 |
check before parse
-rw-r--r-- | core/pim/today/today.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index af1d4e4..d715fc1 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -35,17 +35,19 @@ | |||
35 | #include <qcheckbox.h> | 35 | #include <qcheckbox.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qfileinfo.h> | ||
41 | 42 | ||
42 | //#include <iostream.h> | 43 | //#include <iostream.h> |
43 | //#include <unistd.h> | 44 | //#include <unistd.h> |
44 | #include <stdlib.h> | 45 | #include <stdlib.h> |
45 | 46 | ||
47 | |||
46 | int MAX_LINES_TASK; | 48 | int MAX_LINES_TASK; |
47 | int MAX_CHAR_CLIP; | 49 | int MAX_CHAR_CLIP; |
48 | int MAX_LINES_MEET; | 50 | int MAX_LINES_MEET; |
49 | int SHOW_LOCATION; | 51 | int SHOW_LOCATION; |
50 | int SHOW_NOTES; | 52 | int SHOW_NOTES; |
51 | // show only later dates | 53 | // show only later dates |
@@ -86,15 +88,42 @@ void Today::autoStart() { | |||
86 | void Today::draw() { | 88 | void Today::draw() { |
87 | init(); | 89 | init(); |
88 | getDates(); | 90 | getDates(); |
89 | getMail(); | 91 | getMail(); |
90 | getTodo(); | 92 | getTodo(); |
91 | // how often refresh | 93 | // how often refresh |
92 | QTimer::singleShot( 5*1000, this, SLOT(draw()) ); | 94 | QTimer::singleShot( 30*1000, this, SLOT(draw()) ); |
95 | } | ||
96 | |||
97 | |||
98 | /* | ||
99 | * Check if the todolist.xml was modified (if there are new entries. | ||
100 | * Returns true if it was modified. | ||
101 | */ | ||
102 | bool Today::checkIfModified() { | ||
103 | |||
104 | QDir dir; | ||
105 | QString homedir = dir.homeDirPath (); | ||
106 | QString time; | ||
107 | |||
108 | Config cfg("today"); | ||
109 | cfg.setGroup("Files"); | ||
110 | time = cfg.readEntry("todolisttimestamp", ""); | ||
111 | |||
112 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); | ||
113 | QDateTime fileTime = file.lastModified(); | ||
114 | if (time.compare(fileTime.toString()) == 0) { | ||
115 | return false; | ||
116 | } else { | ||
117 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); | ||
118 | cfg.write(); | ||
119 | return true; | ||
120 | } | ||
93 | } | 121 | } |
94 | 122 | ||
123 | |||
95 | void Today::init() { | 124 | void Today::init() { |
96 | QDate date = QDate::currentDate(); | 125 | QDate date = QDate::currentDate(); |
97 | QString time = (tr( date.toString()) ); | 126 | QString time = (tr( date.toString()) ); |
98 | // QString time = (tr( date.toString()) , white); | 127 | // QString time = (tr( date.toString()) , white); |
99 | 128 | ||
100 | TextLabel1->setText(time); | 129 | TextLabel1->setText(time); |
@@ -337,12 +366,18 @@ void Today::getMail() { | |||
337 | 366 | ||
338 | /* | 367 | /* |
339 | * Get the todos | 368 | * Get the todos |
340 | * | 369 | * |
341 | */ | 370 | */ |
342 | void Today::getTodo() { | 371 | void Today::getTodo() { |
372 | |||
373 | // if the todolist.xml file was not modified in between, do not parse it. | ||
374 | if (!checkIfModified()) { | ||
375 | return; | ||
376 | } | ||
377 | |||
343 | QString output; | 378 | QString output; |
344 | QString tmpout; | 379 | QString tmpout; |
345 | int count = 0; | 380 | int count = 0; |
346 | 381 | ||
347 | QDir dir; | 382 | QDir dir; |
348 | QString homedir = dir.homeDirPath (); | 383 | QString homedir = dir.homeDirPath (); |