-rw-r--r-- | core/pim/today/today.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 69bcb68..d10082f 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -182,297 +182,296 @@ void Today::startConfig() { | |||
182 | int maxmeet = conf->SpinBox1->value(); | 182 | int maxmeet = conf->SpinBox1->value(); |
183 | int location = conf->CheckBox1->isChecked(); | 183 | int location = conf->CheckBox1->isChecked(); |
184 | int notes = conf->CheckBox2->isChecked(); | 184 | int notes = conf->CheckBox2->isChecked(); |
185 | int maxcharclip = conf->SpinBox7->value(); | 185 | int maxcharclip = conf->SpinBox7->value(); |
186 | int onlylater = conf->CheckBox3->isChecked(); | 186 | int onlylater = conf->CheckBox3->isChecked(); |
187 | int autostart =conf->CheckBoxAuto->isChecked(); | 187 | int autostart =conf->CheckBoxAuto->isChecked(); |
188 | 188 | ||
189 | cfg.writeEntry("maxlinestask",maxlinestask); | 189 | cfg.writeEntry("maxlinestask",maxlinestask); |
190 | cfg.writeEntry("maxcharclip", maxcharclip); | 190 | cfg.writeEntry("maxcharclip", maxcharclip); |
191 | cfg.writeEntry("maxlinesmeet",maxmeet); | 191 | cfg.writeEntry("maxlinesmeet",maxmeet); |
192 | cfg.writeEntry("showlocation",location); | 192 | cfg.writeEntry("showlocation",location); |
193 | cfg.writeEntry("shownotes", notes); | 193 | cfg.writeEntry("shownotes", notes); |
194 | cfg.writeEntry("onlylater", onlylater); | 194 | cfg.writeEntry("onlylater", onlylater); |
195 | cfg.setGroup("Autostart"); | 195 | cfg.setGroup("Autostart"); |
196 | cfg.writeEntry("autostart", autostart); | 196 | cfg.writeEntry("autostart", autostart); |
197 | // sync it to "disk" | 197 | // sync it to "disk" |
198 | cfg.write(); | 198 | cfg.write(); |
199 | autoStart(); | 199 | autoStart(); |
200 | draw(); | 200 | draw(); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | /* | 204 | /* |
205 | * Get all events that are in the datebook xml file for today | 205 | * Get all events that are in the datebook xml file for today |
206 | */ | 206 | */ |
207 | void Today::getDates() { | 207 | void Today::getDates() { |
208 | QDate date = QDate::currentDate(); | 208 | QDate date = QDate::currentDate(); |
209 | QWidget* AllDateBookEvents = new QWidget( ); | 209 | QWidget* AllDateBookEvents = new QWidget( ); |
210 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); | 210 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); |
211 | //QTime time = QTime::currentTime(); | 211 | //QTime time = QTime::currentTime(); |
212 | 212 | ||
213 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 213 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
214 | 214 | ||
215 | Config config( "qpe" ); | 215 | Config config( "qpe" ); |
216 | // if 24 h format | 216 | // if 24 h format |
217 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | 217 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); |
218 | 218 | ||
219 | int count=0; | 219 | int count=0; |
220 | 220 | ||
221 | if ( list.count() > 0 ) { | 221 | if ( list.count() > 0 ) { |
222 | QString msg; | 222 | QString msg; |
223 | 223 | ||
224 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 224 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
225 | it!=list.end(); ++it ) { | 225 | it!=list.end(); ++it ) { |
226 | 226 | ||
227 | count++; | 227 | count++; |
228 | 228 | ||
229 | if ( count <= MAX_LINES_MEET ) { | 229 | if ( count <= MAX_LINES_MEET ) { |
230 | 230 | ||
231 | 231 | ||
232 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents); | 232 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents); |
233 | layoutDates->addWidget(l); | 233 | layoutDates->addWidget(l); |
234 | connect (l, SIGNAL(editEvent(const Event &)), | 234 | connect (l, SIGNAL(editEvent(const Event &)), |
235 | this, SIGNAL(editEvent(const Event &))); | 235 | this, SIGNAL(editEvent(const Event &))); |
236 | } | 236 | } |
237 | 237 | ||
238 | } | 238 | } |
239 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 239 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
240 | sv1->addChild(AllDateBookEvents); | 240 | sv1->addChild(AllDateBookEvents); |
241 | 241 | ||
242 | //if (msg.isEmpty()) { | 242 | //if (msg.isEmpty()) { |
243 | // msg = tr("No more appointments today"); | 243 | // msg = tr("No more appointments today"); |
244 | //} | 244 | //} |
245 | //DatesField->setText(msg); | 245 | //DatesField->setText(msg); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | /* | 249 | /* |
250 | * Parse in the todolist.xml | 250 | * Parse in the todolist.xml |
251 | */ | 251 | */ |
252 | QList<TodoItem> Today::loadTodo(const char *filename) { | 252 | QList<TodoItem> Today::loadTodo(const char *filename) { |
253 | DOM *todo; | 253 | DOM *todo; |
254 | ELE *tasks; | 254 | ELE *tasks; |
255 | ELE **tasklist; | 255 | ELE **tasklist; |
256 | ATT **attlist; | 256 | ATT **attlist; |
257 | int i, j; | 257 | int i, j; |
258 | char *description; | 258 | char *description; |
259 | int completed; | 259 | int completed; |
260 | int priority; | 260 | int priority; |
261 | TodoItem *tmp; | 261 | TodoItem *tmp; |
262 | QList<TodoItem> loadtodolist; | 262 | QList<TodoItem> loadtodolist; |
263 | 263 | ||
264 | todo = minidom_load(filename); | 264 | todo = minidom_load(filename); |
265 | 265 | ||
266 | tasks = todo->el; | 266 | tasks = todo->el; |
267 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ | 267 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ |
268 | if(tasks) { | 268 | if(tasks) { |
269 | tasklist = tasks->el; | 269 | tasklist = tasks->el; |
270 | i = 0; | 270 | i = 0; |
271 | while((tasklist) && (tasklist[i])) { | 271 | while((tasklist) && (tasklist[i])) { |
272 | attlist = tasklist[i]->at; | 272 | attlist = tasklist[i]->at; |
273 | j = 0; | 273 | j = 0; |
274 | description = NULL; | 274 | description = NULL; |
275 | priority = -1; | 275 | priority = -1; |
276 | completed = -1; | 276 | completed = -1; |
277 | while((attlist) && (attlist[j])) { | 277 | while((attlist) && (attlist[j])) { |
278 | if(!attlist[j]->name) { | 278 | if(!attlist[j]->name) { |
279 | continue; | 279 | continue; |
280 | } | 280 | } |
281 | if(!strcmp(attlist[j]->name, "Description")) { | 281 | if(!strcmp(attlist[j]->name, "Description")) { |
282 | description = attlist[j]->value; | 282 | description = attlist[j]->value; |
283 | } | 283 | } |
284 | // get Completed tag (0 or 1) | 284 | // get Completed tag (0 or 1) |
285 | if(!strcmp(attlist[j]->name, "Completed")) { | 285 | if(!strcmp(attlist[j]->name, "Completed")) { |
286 | QString s = attlist[j]->name; | 286 | QString s = attlist[j]->name; |
287 | if(s == "Completed") { | 287 | if(s == "Completed") { |
288 | completed = QString(attlist[j]->value).toInt(); | 288 | completed = QString(attlist[j]->value).toInt(); |
289 | } | 289 | } |
290 | } | 290 | } |
291 | // get Priority (1 to 5) | 291 | // get Priority (1 to 5) |
292 | if(!strcmp(attlist[j]->name, "Priority")) { | 292 | if(!strcmp(attlist[j]->name, "Priority")) { |
293 | QString s = attlist[j]->name; | 293 | QString s = attlist[j]->name; |
294 | if(s == "Priority") { | 294 | if(s == "Priority") { |
295 | priority = QString(attlist[j]->value).toInt(); | 295 | priority = QString(attlist[j]->value).toInt(); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | j++; | 298 | j++; |
299 | } | 299 | } |
300 | if(description) { | 300 | if(description) { |
301 | tmp = new TodoItem(description, completed, priority); | 301 | tmp = new TodoItem(description, completed, priority); |
302 | loadtodolist.append(tmp); | 302 | loadtodolist.append(tmp); |
303 | } | 303 | } |
304 | i++; | 304 | i++; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | minidom_free(todo); | 308 | minidom_free(todo); |
309 | 309 | ||
310 | return loadtodolist; | 310 | return loadtodolist; |
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | void Today::getMail() { | 314 | void Today::getMail() { |
315 | Config cfg("opiemail"); | 315 | Config cfg("opiemail"); |
316 | cfg.setGroup("today"); | 316 | cfg.setGroup("today"); |
317 | 317 | ||
318 | // how many lines should be showed in the task section | 318 | // how many lines should be showed in the task section |
319 | int NEW_MAILS = cfg.readNumEntry("newmails",0); | 319 | int NEW_MAILS = cfg.readNumEntry("newmails",0); |
320 | int OUTGOING = cfg.readNumEntry("outgoing",0); | 320 | int OUTGOING = cfg.readNumEntry("outgoing",0); |
321 | 321 | ||
322 | 322 | ||
323 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | 323 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); |
324 | 324 | ||
325 | 325 | ||
326 | MailField->setText(output); | 326 | MailField->setText(output); |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | /* | 330 | /* |
331 | * Get the todos | 331 | * Get the todos |
332 | * | 332 | * |
333 | */ | 333 | */ |
334 | void Today::getTodo() { | 334 | void Today::getTodo() { |
335 | 335 | ||
336 | // if the todolist.xml file was not modified in between, do not parse it. | 336 | // if the todolist.xml file was not modified in between, do not parse it. |
337 | if (!checkIfModified() && !NEW_START) { | 337 | if (!checkIfModified() && !NEW_START) { |
338 | return; | 338 | return; |
339 | } | 339 | } |
340 | NEW_START=0; | 340 | NEW_START=0; |
341 | 341 | ||
342 | QString output; | 342 | QString output; |
343 | QString tmpout; | 343 | QString tmpout; |
344 | int count = 0; | 344 | int count = 0; |
345 | 345 | ||
346 | QDir dir; | 346 | QDir dir; |
347 | QString homedir = dir.homeDirPath (); | 347 | QString homedir = dir.homeDirPath (); |
348 | // see if todolist.xml does exist. | 348 | // see if todolist.xml does exist. |
349 | QFile f(homedir +"/Applications/todolist/todolist.xml"); | 349 | QFile f(homedir +"/Applications/todolist/todolist.xml"); |
350 | if ( f.exists() ) { | 350 | if ( f.exists() ) { |
351 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); | 351 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); |
352 | 352 | ||
353 | TodoItem *item; | 353 | TodoItem *item; |
354 | for( item = todolist.first(); item; item = todolist.next()) { | 354 | for( item = todolist.first(); item; item = todolist.next()) { |
355 | if (!(item->getCompleted() == 1) ) { | 355 | if (!(item->getCompleted() == 1) ) { |
356 | count++; | 356 | count++; |
357 | if (count <= MAX_LINES_TASK) { | 357 | if (count <= MAX_LINES_TASK) { |
358 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); | 358 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | if (count > 0) { | 364 | if (count > 0) { |
365 | if( count == 1 ) { | 365 | if( count == 1 ) { |
366 | output = tr("There is <b> 1</b> active task: <br>" ); | 366 | output = tr("There is <b> 1</b> active task: <br>" ); |
367 | } else { | 367 | } else { |
368 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 368 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
369 | } | 369 | } |
370 | output += tmpout; | 370 | output += tmpout; |
371 | } else { | 371 | } else { |
372 | output = tr("No active tasks"); | 372 | output = tr("No active tasks"); |
373 | } | 373 | } |
374 | 374 | ||
375 | TodoField->setText(tr(output)); | 375 | TodoField->setText(tr(output)); |
376 | } | 376 | } |
377 | 377 | ||
378 | /* | 378 | /* |
379 | * launches datebook | 379 | * launches datebook |
380 | */ | 380 | */ |
381 | void Today::startDatebook() { | 381 | void Today::startDatebook() { |
382 | QCopEnvelope e("QPE/System", "execute(QString)"); | 382 | QCopEnvelope e("QPE/System", "execute(QString)"); |
383 | e << QString("datebook"); | 383 | e << QString("datebook"); |
384 | } | 384 | } |
385 | 385 | ||
386 | /* | 386 | /* |
387 | * launches todolist | 387 | * launches todolist |
388 | */ | 388 | */ |
389 | void Today::startTodo() { | 389 | void Today::startTodo() { |
390 | QCopEnvelope e("QPE/System", "execute(QString)"); | 390 | QCopEnvelope e("QPE/System", "execute(QString)"); |
391 | e << QString("todolist"); | 391 | e << QString("todolist"); |
392 | } | 392 | } |
393 | 393 | ||
394 | /* | 394 | /* |
395 | * launch opiemail | 395 | * launch opiemail |
396 | */ | 396 | */ |
397 | void Today::startMail() { | 397 | void Today::startMail() { |
398 | QCopEnvelope e("QPE/System", "execute(QString)"); | 398 | QCopEnvelope e("QPE/System", "execute(QString)"); |
399 | e << QString("opiemail"); | 399 | e << QString("opiemail"); |
400 | } | 400 | } |
401 | 401 | ||
402 | /* | 402 | /* |
403 | * Destroys the object and frees any allocated resources | 403 | * Destroys the object and frees any allocated resources |
404 | */ | 404 | */ |
405 | Today::~Today() { | 405 | Today::~Today() { |
406 | // no need to delete child widgets, Qt does it all for us | 406 | // no need to delete child widgets, Qt does it all for us |
407 | } | 407 | } |
408 | 408 | ||
409 | 409 | ||
410 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | 410 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, |
411 | QWidget* parent = 0, | 411 | QWidget* parent = 0, |
412 | const char* name = 0, | 412 | const char* name = 0, |
413 | WFlags fl = 0) : | 413 | WFlags fl = 0) : |
414 | ClickableLabel(parent,name,fl), event(ev) { | 414 | ClickableLabel(parent,name,fl), event(ev) { |
415 | 415 | ||
416 | QString msg; | 416 | QString msg; |
417 | QTime time = QTime::currentTime(); | 417 | QTime time = QTime::currentTime(); |
418 | 418 | ||
419 | if (!ONLY_LATER) { | 419 | if (!ONLY_LATER) { |
420 | msg += "<B>" + (ev).description() + "</B>"; | 420 | msg += "<B>" + (ev).description() + "</B>"; |
421 | if ( (ev).event().hasAlarm() ) { | 421 | if ( (ev).event().hasAlarm() ) { |
422 | msg += " <b>[with alarm]</b>"; | 422 | msg += " <b>[with alarm]</b>"; |
423 | } | 423 | } |
424 | // include location or not | 424 | // include location or not |
425 | if (SHOW_LOCATION == 1) { | 425 | if (SHOW_LOCATION == 1) { |
426 | msg += "<BR><i>" + (ev).location(); | 426 | msg += "<BR><i>" + (ev).location(); |
427 | msg += "</i>"; | 427 | msg += "</i>"; |
428 | } | 428 | } |
429 | 429 | ||
430 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 430 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
431 | msg += "<br>All day"; | 431 | msg += "<br>All day"; |
432 | } else { | 432 | } else { |
433 | // start time of event | 433 | // start time of event |
434 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) | 434 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) |
435 | // end time of event | 435 | // end time of event |
436 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); | 436 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); |
437 | } | 437 | } |
438 | msg += "<BR>"; | ||
439 | // include possible note or not | 438 | // include possible note or not |
440 | if (SHOW_NOTES == 1) { | 439 | if (SHOW_NOTES == 1) { |
441 | msg += " <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 440 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
442 | } | 441 | } |
443 | } else if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { | 442 | } else if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { |
444 | msg += "<B>" + (ev).description() + "</B>"; | 443 | msg += "<B>" + (ev).description() + "</B>"; |
445 | if ( (ev).event().hasAlarm() ) { | 444 | if ( (ev).event().hasAlarm() ) { |
446 | msg += " <b>[with alarm]</b>"; | 445 | msg += " <b>[with alarm]</b>"; |
447 | } | 446 | } |
448 | // include location or not | 447 | // include location or not |
449 | if (SHOW_LOCATION == 1) { | 448 | if (SHOW_LOCATION == 1) { |
450 | msg+= "<BR><i>" + (ev).location(); | 449 | msg += "<BR><i>" + (ev).location(); |
451 | msg += "</i>"; | 450 | msg += "</i>"; |
452 | } | 451 | } |
453 | 452 | ||
454 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 453 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
455 | msg += "<br>All day"; | 454 | msg += "<br>All day"; |
456 | } else { | 455 | } else { |
457 | // start time of event | 456 | // start time of event |
458 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) | 457 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) |
459 | // end time of event | 458 | // end time of event |
460 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); | 459 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); |
461 | } | 460 | } |
462 | // include possible note or not | 461 | // include possible note or not |
463 | if (SHOW_NOTES == 1) { | 462 | if (SHOW_NOTES == 1) { |
464 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 463 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
465 | } | 464 | } |
466 | } | 465 | } |
467 | 466 | ||
468 | setText(msg); | 467 | setText(msg); |
469 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 468 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
470 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 469 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
471 | } | 470 | } |
472 | 471 | ||
473 | void DateBookEvent::editMe() { | 472 | void DateBookEvent::editMe() { |
474 | emit editEvent(event.event()); | 473 | emit editEvent(event.event()); |
475 | } | 474 | } |
476 | 475 | ||
477 | 476 | ||
478 | 477 | ||