-rw-r--r-- | core/pim/today/today.cpp | 294 |
1 files changed, 127 insertions, 167 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index c63a9ef..6a0e9fc 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -56,6 +56,5 @@ int ONLY_LATER; | |||
56 | */ | 56 | */ |
57 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 57 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
58 | : TodayBase( parent, name, fl ) | 58 | : TodayBase( parent, name, fl ) { |
59 | { | ||
60 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 59 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); |
61 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 60 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); |
@@ -67,6 +66,5 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) | |||
67 | 66 | ||
68 | 67 | ||
69 | void Today::draw() | 68 | void Today::draw() { |
70 | { | ||
71 | init(); | 69 | init(); |
72 | getDates(); | 70 | getDates(); |
@@ -75,9 +73,7 @@ void Today::draw() | |||
75 | // how often refresh | 73 | // how often refresh |
76 | QTimer::singleShot( 5*1000, this, SLOT(draw()) ); | 74 | QTimer::singleShot( 5*1000, this, SLOT(draw()) ); |
77 | |||
78 | } | 75 | } |
79 | 76 | ||
80 | void Today::init() | 77 | void Today::init() { |
81 | { | ||
82 | QDate date = QDate::currentDate(); | 78 | QDate date = QDate::currentDate(); |
83 | QString time = (date.toString()); | 79 | QString time = (date.toString()); |
@@ -104,6 +100,5 @@ void Today::init() | |||
104 | } | 100 | } |
105 | 101 | ||
106 | void Today::startConfig() | 102 | void Today::startConfig() { |
107 | { | ||
108 | conf = new todayconfig ( this, "", true ); | 103 | conf = new todayconfig ( this, "", true ); |
109 | 104 | ||
@@ -154,6 +149,5 @@ void Today::startConfig() | |||
154 | * Get all events that are in the datebook xml file for today | 149 | * Get all events that are in the datebook xml file for today |
155 | */ | 150 | */ |
156 | void Today::getDates() | 151 | void Today::getDates() { |
157 | { | ||
158 | QDate date = QDate::currentDate(); | 152 | QDate date = QDate::currentDate(); |
159 | QTime time = QTime::currentTime(); | 153 | QTime time = QTime::currentTime(); |
@@ -174,80 +168,63 @@ void Today::getDates() | |||
174 | count++; | 168 | count++; |
175 | 169 | ||
176 | if ( count <= MAX_LINES_MEET ) | 170 | if ( count <= MAX_LINES_MEET ) { |
177 | { | 171 | //cout << time.toString() << endl; |
178 | //cout << time.toString() << endl; | 172 | //cout << TimeString::dateString((*it).event().end()) << endl; |
179 | //cout << TimeString::dateString((*it).event().end()) << endl; | 173 | |
174 | // decide if to get all day or only later appointments | ||
175 | if (!ONLY_LATER) { | ||
176 | msg += "<B>" + (*it).description() + "</B>"; | ||
177 | if ( (*it).event().hasAlarm() ) { | ||
178 | msg += " <b>[with alarm]</b>"; | ||
179 | } | ||
180 | // include location or not | ||
181 | if (SHOW_LOCATION == 1) { | ||
182 | msg += "<BR><i>" + (*it).location(); | ||
183 | msg += "</i>"; | ||
184 | } | ||
185 | |||
186 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) { | ||
187 | msg += "<br>All day"; | ||
188 | } else { | ||
189 | // start time of event | ||
190 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) | ||
191 | // end time of event | ||
192 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); | ||
193 | } | ||
194 | msg += "<BR>"; | ||
195 | // include possible note or not | ||
196 | if (SHOW_NOTES == 1) { | ||
197 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | ||
198 | } | ||
199 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { | ||
200 | msg += "<B>" + (*it).description() + "</B>"; | ||
201 | if ( (*it).event().hasAlarm() ) { | ||
202 | msg += " <b>[with alarm]</b>"; | ||
203 | } | ||
204 | // include location or not | ||
205 | if (SHOW_LOCATION == 1) { | ||
206 | msg+= "<BR><i>" + (*it).location(); | ||
207 | msg += "</i>"; | ||
208 | } | ||
180 | 209 | ||
181 | // decide if to get all day or only later appointments | 210 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) { |
182 | if (!ONLY_LATER) | 211 | msg += "<br>All day"; |
183 | { | 212 | } else { |
184 | msg += "<B>" + (*it).description() + "</B>"; | 213 | // start time of event |
185 | if ( (*it).event().hasAlarm() ) | 214 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) |
186 | { | 215 | // end time of event |
187 | msg += " <b>[with alarm]</b>"; | 216 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); |
188 | } | 217 | } |
189 | // include location or not | 218 | msg += "<BR>"; |
190 | if (SHOW_LOCATION == 1) | 219 | // include possible note or not |
191 | { | 220 | if (SHOW_NOTES == 1) { |
192 | msg += "<BR><i>" + (*it).location(); | 221 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
193 | msg += "</i>"; | 222 | } |
194 | } | ||
195 | |||
196 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) | ||
197 | { | ||
198 | msg += "<br>All day"; | ||
199 | } | ||
200 | else | ||
201 | { | ||
202 | // start time of event | ||
203 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) | ||
204 | // end time of event | ||
205 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); | ||
206 | } | ||
207 | msg += "<BR>"; | ||
208 | // include possible note or not | ||
209 | if (SHOW_NOTES == 1) | ||
210 | { | ||
211 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | ||
212 | } | ||
213 | } | ||
214 | else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) | ||
215 | { | ||
216 | msg += "<B>" + (*it).description() + "</B>"; | ||
217 | if ( (*it).event().hasAlarm() ) | ||
218 | { | ||
219 | msg += " <b>[with alarm]</b>"; | ||
220 | } | ||
221 | // include location or not | ||
222 | if (SHOW_LOCATION == 1) | ||
223 | { | ||
224 | msg+= "<BR><i>" + (*it).location(); | ||
225 | msg += "</i>"; | ||
226 | } | ||
227 | |||
228 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) | ||
229 | { | ||
230 | msg += "<br>All day"; | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | // start time of event | ||
235 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) | ||
236 | // end time of event | ||
237 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); | ||
238 | } | ||
239 | msg += "<BR>"; | ||
240 | // include possible note or not | ||
241 | if (SHOW_NOTES == 1) | ||
242 | { | ||
243 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | ||
244 | } | ||
245 | } | ||
246 | } | 223 | } |
247 | } | ||
248 | if (msg.isEmpty()) | ||
249 | { | ||
250 | msg = "No more appointments today"; | ||
251 | } | 224 | } |
225 | } | ||
226 | if (msg.isEmpty()) { | ||
227 | msg = "No more appointments today"; | ||
228 | } | ||
252 | DatesField->setText(msg); | 229 | DatesField->setText(msg); |
253 | } | 230 | } |
@@ -257,6 +234,5 @@ void Today::getDates() | |||
257 | * Parse in the todolist.xml | 234 | * Parse in the todolist.xml |
258 | */ | 235 | */ |
259 | QList<TodoItem> Today::loadTodo(const char *filename) | 236 | QList<TodoItem> Today::loadTodo(const char *filename) { |
260 | { | ||
261 | DOM *todo; | 237 | DOM *todo; |
262 | ELE *tasks; | 238 | ELE *tasks; |
@@ -274,52 +250,44 @@ QList<TodoItem> Today::loadTodo(const char *filename) | |||
274 | tasks = todo->el; | 250 | tasks = todo->el; |
275 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ | 251 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ |
276 | if(tasks) | 252 | if(tasks) { |
277 | { | 253 | tasklist = tasks->el; |
278 | tasklist = tasks->el; | 254 | i = 0; |
279 | i = 0; | 255 | while((tasklist) && (tasklist[i])) { |
280 | while((tasklist) && (tasklist[i])) | 256 | attlist = tasklist[i]->at; |
281 | { | 257 | j = 0; |
282 | attlist = tasklist[i]->at; | 258 | description = NULL; |
283 | j = 0; | 259 | priority = -1; |
284 | description = NULL; | 260 | completed = -1; |
285 | priority = -1; | 261 | while((attlist) && (attlist[j])) { |
286 | completed = -1; | 262 | if(!attlist[j]->name) { |
287 | while((attlist) && (attlist[j])) | 263 | continue; |
288 | { | ||
289 | // SEGFAULT HERE WITH MORE THAN 7 ENTRIES | ||
290 | if(!attlist[j]->name) continue; | ||
291 | if(!strcmp(attlist[j]->name, "Description")) | ||
292 | { | ||
293 | description = attlist[j]->value; | ||
294 | } | ||
295 | // get Completed tag (0 or 1) | ||
296 | if(!strcmp(attlist[j]->name, "Completed")) | ||
297 | { | ||
298 | QString s = attlist[j]->name; | ||
299 | if(s == "Completed") | ||
300 | { | ||
301 | completed = QString(attlist[j]->value).toInt(); | ||
302 | } | ||
303 | } | ||
304 | // get Priority (1 to 5) | ||
305 | if(!strcmp(attlist[j]->name, "Priority")) | ||
306 | { | ||
307 | QString s = attlist[j]->name; | ||
308 | if(s == "Priority") | ||
309 | { | ||
310 | priority = QString(attlist[j]->value).toInt(); | ||
311 | } | ||
312 | } | ||
313 | j++; | ||
314 | } | ||
315 | if(description) | ||
316 | { | ||
317 | tmp = new TodoItem(description, completed, priority); | ||
318 | loadtodolist.append(tmp); | ||
319 | } | ||
320 | i++; | ||
321 | } | 264 | } |
265 | if(!strcmp(attlist[j]->name, "Description")) { | ||
266 | description = attlist[j]->value; | ||
267 | } | ||
268 | // get Completed tag (0 or 1) | ||
269 | if(!strcmp(attlist[j]->name, "Completed")) { | ||
270 | QString s = attlist[j]->name; | ||
271 | if(s == "Completed") { | ||
272 | completed = QString(attlist[j]->value).toInt(); | ||
273 | } | ||
274 | } | ||
275 | // get Priority (1 to 5) | ||
276 | if(!strcmp(attlist[j]->name, "Priority")) { | ||
277 | QString s = attlist[j]->name; | ||
278 | if(s == "Priority") { | ||
279 | priority = QString(attlist[j]->value).toInt(); | ||
280 | } | ||
281 | } | ||
282 | j++; | ||
283 | } | ||
284 | if(description) { | ||
285 | tmp = new TodoItem(description, completed, priority); | ||
286 | loadtodolist.append(tmp); | ||
287 | } | ||
288 | i++; | ||
322 | } | 289 | } |
323 | 290 | } | |
291 | |||
324 | minidom_free(todo); | 292 | minidom_free(todo); |
325 | 293 | ||
@@ -328,6 +296,5 @@ QList<TodoItem> Today::loadTodo(const char *filename) | |||
328 | 296 | ||
329 | 297 | ||
330 | void Today::getMail() | 298 | void Today::getMail() { |
331 | { | ||
332 | Config cfg("opiemail"); | 299 | Config cfg("opiemail"); |
333 | cfg.setGroup("today"); | 300 | cfg.setGroup("today"); |
@@ -337,5 +304,6 @@ void Today::getMail() | |||
337 | int OUTGOING = cfg.readNumEntry("outgoing",0); | 304 | int OUTGOING = cfg.readNumEntry("outgoing",0); |
338 | 305 | ||
339 | QString output = tr("<b>%1</b> new mails, <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | 306 | |
307 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | ||
340 | 308 | ||
341 | 309 | ||
@@ -348,6 +316,5 @@ void Today::getMail() | |||
348 | * | 316 | * |
349 | */ | 317 | */ |
350 | void Today::getTodo() | 318 | void Today::getTodo() { |
351 | { | ||
352 | QString output; | 319 | QString output; |
353 | QString tmpout; | 320 | QString tmpout; |
@@ -358,31 +325,28 @@ void Today::getTodo() | |||
358 | // see if todolist.xml does exist. | 325 | // see if todolist.xml does exist. |
359 | QFile f(homedir +"/Applications/todolist/todolist.xml"); | 326 | QFile f(homedir +"/Applications/todolist/todolist.xml"); |
360 | if ( f.exists() ) | 327 | if ( f.exists() ) { |
361 | { | 328 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); |
362 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); | 329 | |
363 | 330 | TodoItem *item; | |
364 | TodoItem *item; | 331 | for( item = todolist.first(); item; item = todolist.next()) { |
365 | for( item = todolist.first(); item; item = todolist.next()) | 332 | if (!(item->getCompleted() == 1) ) { |
366 | { | 333 | count++; |
367 | if (!(item->getCompleted() == 1) ) | 334 | if (count <= MAX_LINES_TASK) { |
368 | { | 335 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); |
369 | count++; | ||
370 | if (count <= MAX_LINES_TASK) | ||
371 | { | ||
372 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); | ||
373 | } | ||
374 | } | ||
375 | } | 336 | } |
337 | } | ||
376 | } | 338 | } |
339 | } | ||
377 | 340 | ||
378 | if (count > 0) | 341 | if (count > 0) { |
379 | { | 342 | if( count == 1 ) { |
343 | output = QString("There is <b> 1</b> active task: <br>" ); | ||
344 | } else { | ||
380 | output = QString("There are <b> %1</b> active tasks: <br>").arg(count); | 345 | output = QString("There are <b> %1</b> active tasks: <br>").arg(count); |
381 | output += tmpout; | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | output = ("No active tasks"); | ||
386 | } | 346 | } |
347 | output += tmpout; | ||
348 | } else { | ||
349 | output = ("No active tasks"); | ||
350 | } | ||
387 | 351 | ||
388 | TodoField->setText(output); | 352 | TodoField->setText(output); |
@@ -392,6 +356,5 @@ void Today::getTodo() | |||
392 | * launches datebook | 356 | * launches datebook |
393 | */ | 357 | */ |
394 | void Today::startDatebook() | 358 | void Today::startDatebook() { |
395 | { | ||
396 | QCopEnvelope e("QPE/System", "execute(QString)"); | 359 | QCopEnvelope e("QPE/System", "execute(QString)"); |
397 | e << QString("datebook"); | 360 | e << QString("datebook"); |
@@ -401,6 +364,5 @@ void Today::startDatebook() | |||
401 | * launches todolist | 364 | * launches todolist |
402 | */ | 365 | */ |
403 | void Today::startTodo() | 366 | void Today::startTodo() { |
404 | { | ||
405 | QCopEnvelope e("QPE/System", "execute(QString)"); | 367 | QCopEnvelope e("QPE/System", "execute(QString)"); |
406 | e << QString("todolist"); | 368 | e << QString("todolist"); |
@@ -410,6 +372,5 @@ void Today::startTodo() | |||
410 | * launch opiemail | 372 | * launch opiemail |
411 | */ | 373 | */ |
412 | void Today::startMail() | 374 | void Today::startMail() { |
413 | { | ||
414 | QCopEnvelope e("QPE/System", "execute(QString)"); | 375 | QCopEnvelope e("QPE/System", "execute(QString)"); |
415 | e << QString("opiemail"); | 376 | e << QString("opiemail"); |
@@ -419,6 +380,5 @@ void Today::startMail() | |||
419 | * Destroys the object and frees any allocated resources | 380 | * Destroys the object and frees any allocated resources |
420 | */ | 381 | */ |
421 | Today::~Today() | 382 | Today::~Today() { |
422 | { | ||
423 | // no need to delete child widgets, Qt does it all for us | 383 | // no need to delete child widgets, Qt does it all for us |
424 | } | 384 | } |