-rw-r--r-- | core/pim/today/today.cpp | 18 | ||||
-rw-r--r-- | core/pim/today/today.h | 1 |
2 files changed, 12 insertions, 7 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 9e9d31f..ad1ec90 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -232,396 +232,400 @@ void Today::init() { | |||
232 | void Today::startConfig() { | 232 | void Today::startConfig() { |
233 | 233 | ||
234 | conf = new todayconfig ( this, "", true ); | 234 | conf = new todayconfig ( this, "", true ); |
235 | // read the config | 235 | // read the config |
236 | Config cfg("today"); | 236 | Config cfg("today"); |
237 | cfg.setGroup("BaseConfig"); | 237 | cfg.setGroup("BaseConfig"); |
238 | 238 | ||
239 | //init(); | 239 | //init(); |
240 | 240 | ||
241 | conf->SpinBox1->setValue(MAX_LINES_MEET); | 241 | conf->SpinBox1->setValue(MAX_LINES_MEET); |
242 | // location show box | 242 | // location show box |
243 | conf->CheckBox1->setChecked(SHOW_LOCATION); | 243 | conf->CheckBox1->setChecked(SHOW_LOCATION); |
244 | // notes show box | 244 | // notes show box |
245 | conf->CheckBox2->setChecked(SHOW_NOTES); | 245 | conf->CheckBox2->setChecked(SHOW_NOTES); |
246 | // task lines | 246 | // task lines |
247 | conf->SpinBox2->setValue(MAX_LINES_TASK); | 247 | conf->SpinBox2->setValue(MAX_LINES_TASK); |
248 | // clip when? | 248 | // clip when? |
249 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); | 249 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); |
250 | // only later | 250 | // only later |
251 | conf->CheckBox3->setChecked(ONLY_LATER); | 251 | conf->CheckBox3->setChecked(ONLY_LATER); |
252 | // if today should be autostarted | 252 | // if today should be autostarted |
253 | conf->CheckBoxAuto->setChecked(AUTOSTART); | 253 | conf->CheckBoxAuto->setChecked(AUTOSTART); |
254 | // autostart only if device has been suspended for X minutes | 254 | // autostart only if device has been suspended for X minutes |
255 | conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); | 255 | conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); |
256 | 256 | ||
257 | conf->exec(); | 257 | conf->exec(); |
258 | 258 | ||
259 | int maxlinestask = conf->SpinBox2->value(); | 259 | int maxlinestask = conf->SpinBox2->value(); |
260 | int maxmeet = conf->SpinBox1->value(); | 260 | int maxmeet = conf->SpinBox1->value(); |
261 | int location = conf->CheckBox1->isChecked(); | 261 | int location = conf->CheckBox1->isChecked(); |
262 | int notes = conf->CheckBox2->isChecked(); | 262 | int notes = conf->CheckBox2->isChecked(); |
263 | int maxcharclip = conf->SpinBox7->value(); | 263 | int maxcharclip = conf->SpinBox7->value(); |
264 | int onlylater = conf->CheckBox3->isChecked(); | 264 | int onlylater = conf->CheckBox3->isChecked(); |
265 | int autostart = conf->CheckBoxAuto->isChecked(); | 265 | int autostart = conf->CheckBoxAuto->isChecked(); |
266 | int autostartdelay = conf->SpinBoxTime->value(); | 266 | int autostartdelay = conf->SpinBoxTime->value(); |
267 | 267 | ||
268 | 268 | ||
269 | cfg.writeEntry("maxlinestask",maxlinestask); | 269 | cfg.writeEntry("maxlinestask",maxlinestask); |
270 | cfg.writeEntry("maxcharclip", maxcharclip); | 270 | cfg.writeEntry("maxcharclip", maxcharclip); |
271 | cfg.writeEntry("maxlinesmeet",maxmeet); | 271 | cfg.writeEntry("maxlinesmeet",maxmeet); |
272 | cfg.writeEntry("showlocation",location); | 272 | cfg.writeEntry("showlocation",location); |
273 | cfg.writeEntry("shownotes", notes); | 273 | cfg.writeEntry("shownotes", notes); |
274 | cfg.writeEntry("onlylater", onlylater); | 274 | cfg.writeEntry("onlylater", onlylater); |
275 | cfg.setGroup("Autostart"); | 275 | cfg.setGroup("Autostart"); |
276 | cfg.writeEntry("autostart", autostart); | 276 | cfg.writeEntry("autostart", autostart); |
277 | cfg.writeEntry("autostartdelay", autostartdelay); | 277 | cfg.writeEntry("autostartdelay", autostartdelay); |
278 | 278 | ||
279 | // sync it to "disk" | 279 | // sync it to "disk" |
280 | cfg.write(); | 280 | cfg.write(); |
281 | NEW_START=1; | 281 | NEW_START=1; |
282 | draw(); | 282 | draw(); |
283 | AUTOSTART=autostart; | 283 | AUTOSTART=autostart; |
284 | autoStart(); | 284 | autoStart(); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | /* | 288 | /* |
289 | * Get all events that are in the datebook xml file for today | 289 | * Get all events that are in the datebook xml file for today |
290 | */ | 290 | */ |
291 | void Today::getDates() { | 291 | void Today::getDates() { |
292 | QDate date = QDate::currentDate(); | 292 | QDate date = QDate::currentDate(); |
293 | 293 | ||
294 | if (AllDateBookEvents) delete AllDateBookEvents; | 294 | if (AllDateBookEvents) delete AllDateBookEvents; |
295 | AllDateBookEvents = new QWidget( ); | 295 | AllDateBookEvents = new QWidget( ); |
296 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); | 296 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); |
297 | 297 | ||
298 | if (db) { | 298 | if (db) { |
299 | delete db; | 299 | delete db; |
300 | } | 300 | } |
301 | db = new DateBookDB; | 301 | db = new DateBookDB; |
302 | 302 | ||
303 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 303 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
304 | 304 | ||
305 | qBubbleSort(list); | 305 | qBubbleSort(list); |
306 | // printf("Get dates\n"); | 306 | // printf("Get dates\n"); |
307 | 307 | ||
308 | Config config( "qpe" ); | 308 | Config config( "qpe" ); |
309 | // if 24 h format | 309 | // if 24 h format |
310 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | 310 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); |
311 | 311 | ||
312 | int count=0; | 312 | int count=0; |
313 | 313 | ||
314 | if ( list.count() > 0 ) { | 314 | if ( list.count() > 0 ) { |
315 | 315 | ||
316 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 316 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
317 | it!=list.end(); ++it ) { | 317 | it!=list.end(); ++it ) { |
318 | 318 | ||
319 | 319 | ||
320 | if ( count <= MAX_LINES_MEET ) { | 320 | if ( count <= MAX_LINES_MEET ) { |
321 | 321 | ||
322 | QTime time = QTime::currentTime(); | 322 | QTime time = QTime::currentTime(); |
323 | 323 | ||
324 | if (!ONLY_LATER) { | 324 | if (!ONLY_LATER) { |
325 | count++; | 325 | count++; |
326 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 326 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); |
327 | layoutDates->addWidget(l); | 327 | layoutDates->addWidget(l); |
328 | connect (l, SIGNAL(editEvent(const Event &)), | 328 | connect (l, SIGNAL(editEvent(const Event &)), |
329 | this, SLOT(editEvent(const Event &))); | 329 | this, SLOT(editEvent(const Event &))); |
330 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { | 330 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { |
331 | count++; | 331 | count++; |
332 | 332 | ||
333 | // show only later appointments | 333 | // show only later appointments |
334 | DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 334 | DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); |
335 | layoutDates->addWidget(l); | 335 | layoutDates->addWidget(l); |
336 | connect (l, SIGNAL(editEvent(const Event &)), | 336 | connect (l, SIGNAL(editEvent(const Event &)), |
337 | this, SLOT(editEvent(const Event &))); | 337 | this, SLOT(editEvent(const Event &))); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | } | 340 | } |
341 | if (ONLY_LATER && count==0) { | 341 | if (ONLY_LATER && count==0) { |
342 | QLabel* noMoreEvents = new QLabel(AllDateBookEvents); | 342 | QLabel* noMoreEvents = new QLabel(AllDateBookEvents); |
343 | noMoreEvents->setText(tr("No more appointments today")); | 343 | noMoreEvents->setText(tr("No more appointments today")); |
344 | layoutDates->addWidget(noMoreEvents); | 344 | layoutDates->addWidget(noMoreEvents); |
345 | } | 345 | } |
346 | } else { | 346 | } else { |
347 | QLabel* noEvents = new QLabel(AllDateBookEvents); | 347 | QLabel* noEvents = new QLabel(AllDateBookEvents); |
348 | noEvents->setText(tr("No appointments today")); | 348 | noEvents->setText(tr("No appointments today")); |
349 | layoutDates->addWidget(noEvents); | 349 | layoutDates->addWidget(noEvents); |
350 | } | 350 | } |
351 | 351 | ||
352 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 352 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
353 | sv1->addChild(AllDateBookEvents); | 353 | sv1->addChild(AllDateBookEvents); |
354 | AllDateBookEvents->show(); | 354 | AllDateBookEvents->show(); |
355 | } | 355 | } |
356 | 356 | ||
357 | 357 | ||
358 | void Today::getMail() { | 358 | void Today::getMail() { |
359 | Config cfg("opiemail"); | 359 | Config cfg("opiemail"); |
360 | cfg.setGroup("today"); | 360 | cfg.setGroup("today"); |
361 | 361 | ||
362 | // how many lines should be showed in the task section | 362 | // how many lines should be showed in the task section |
363 | int NEW_MAILS = cfg.readNumEntry("newmails",0); | 363 | int NEW_MAILS = cfg.readNumEntry("newmails",0); |
364 | int OUTGOING = cfg.readNumEntry("outgoing",0); | 364 | int OUTGOING = cfg.readNumEntry("outgoing",0); |
365 | 365 | ||
366 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | 366 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); |
367 | 367 | ||
368 | MailField->setText(output); | 368 | MailField->setText(output); |
369 | } | 369 | } |
370 | 370 | ||
371 | 371 | ||
372 | /* | 372 | /* |
373 | * Get the todos | 373 | * Get the todos |
374 | */ | 374 | */ |
375 | void Today::getTodo() { | 375 | void Today::getTodo() { |
376 | 376 | ||
377 | QString output; | 377 | QString output; |
378 | QString tmpout; | 378 | QString tmpout; |
379 | int count = 0; | 379 | int count = 0; |
380 | int ammount = 0; | 380 | int ammount = 0; |
381 | 381 | ||
382 | // get overdue todos first | 382 | // get overdue todos first |
383 | QValueList<ToDoEvent> overDueList = todo->overDue(); | 383 | QValueList<ToDoEvent> overDueList = todo->overDue(); |
384 | qBubbleSort(overDueList); | 384 | qBubbleSort(overDueList); |
385 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); | 385 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); |
386 | it!=overDueList.end(); ++it ) { | 386 | it!=overDueList.end(); ++it ) { |
387 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { | 387 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { |
388 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; | 388 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; |
389 | ammount++; | 389 | ammount++; |
390 | } | 390 | } |
391 | } | 391 | } |
392 | 392 | ||
393 | // get total number of still open todos | 393 | // get total number of still open todos |
394 | QValueList<ToDoEvent> openTodo = todo->rawToDos(); | 394 | QValueList<ToDoEvent> openTodo = todo->rawToDos(); |
395 | qBubbleSort(openTodo); | 395 | qBubbleSort(openTodo); |
396 | for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin(); | 396 | for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin(); |
397 | it!=openTodo.end(); ++it ) { | 397 | it!=openTodo.end(); ++it ) { |
398 | if (!(*it).isCompleted()){ | 398 | if (!(*it).isCompleted()){ |
399 | count +=1; | 399 | count +=1; |
400 | // not the overdues, we allready got them, and not if we are | 400 | // not the overdues, we allready got them, and not if we are |
401 | // over the maxlines | 401 | // over the maxlines |
402 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { | 402 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { |
403 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 403 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
404 | ammount++; | 404 | ammount++; |
405 | } | 405 | } |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | 409 | ||
410 | if (count > 0) { | 410 | if (count > 0) { |
411 | if( count == 1 ) { | 411 | if( count == 1 ) { |
412 | output = tr("There is <b> 1</b> active task: <br>" ); | 412 | output = tr("There is <b> 1</b> active task: <br>" ); |
413 | } else { | 413 | } else { |
414 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 414 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
415 | } | 415 | } |
416 | output += tmpout; | 416 | output += tmpout; |
417 | } else { | 417 | } else { |
418 | output = tr("No active tasks"); | 418 | output = tr("No active tasks"); |
419 | } | 419 | } |
420 | 420 | ||
421 | TodoField->setText(tr(output)); | 421 | TodoField->setText(tr(output)); |
422 | } | 422 | } |
423 | 423 | ||
424 | |||
425 | void Today::startAddressbook() { | ||
426 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
427 | e << QString("addressbook"); | ||
428 | } | ||
429 | |||
430 | extern QPEApplication *todayApp; | ||
431 | |||
424 | /* | 432 | /* |
425 | * launch addressbook (personal card) | 433 | * launch addressbook (personal card) |
426 | */ | 434 | */ |
427 | void Today::editCard() { | 435 | void Today::editCard() { |
428 | QCopEnvelope w("QPE/System", "execute(QString)"); | ||
429 | w << QString("addressbook"); | ||
430 | 436 | ||
431 | // while( !QCopChannel::isRegistered("QPE/Addressbook")) | 437 | startAddressbook(); |
438 | |||
439 | while( !QCopChannel::isRegistered("QPE/Addressbook")) todayApp->processEvents(); | ||
432 | QCopEnvelope v("QPE/Addressbook", "editPersonalAndClose()"); | 440 | QCopEnvelope v("QPE/Addressbook", "editPersonalAndClose()"); |
433 | } | 441 | } |
434 | 442 | ||
435 | /* | 443 | /* |
436 | * launches datebook | 444 | * launches datebook |
437 | */ | 445 | */ |
438 | void Today::startDatebook() { | 446 | void Today::startDatebook() { |
439 | QCopEnvelope e("QPE/System", "execute(QString)"); | 447 | QCopEnvelope e("QPE/System", "execute(QString)"); |
440 | e << QString("datebook"); | 448 | e << QString("datebook"); |
441 | } | 449 | } |
442 | 450 | ||
443 | /* | 451 | /* |
444 | * starts the edit dialog as known from datebook | 452 | * starts the edit dialog as known from datebook |
445 | */ | 453 | */ |
446 | |||
447 | |||
448 | extern QPEApplication *todayApp; | ||
449 | |||
450 | void Today::editEvent(const Event &e) { | 454 | void Today::editEvent(const Event &e) { |
451 | startDatebook(); | 455 | startDatebook(); |
452 | 456 | ||
453 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); | 457 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); |
454 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); | 458 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); |
455 | env << e.uid(); | 459 | env << e.uid(); |
456 | } | 460 | } |
457 | 461 | ||
458 | /* | 462 | /* |
459 | * launches todolist | 463 | * launches todolist |
460 | */ | 464 | */ |
461 | void Today::startTodo() { | 465 | void Today::startTodo() { |
462 | QCopEnvelope e("QPE/System", "execute(QString)"); | 466 | QCopEnvelope e("QPE/System", "execute(QString)"); |
463 | e << QString("todolist"); | 467 | e << QString("todolist"); |
464 | } | 468 | } |
465 | 469 | ||
466 | /* | 470 | /* |
467 | * launch opiemail | 471 | * launch opiemail |
468 | */ | 472 | */ |
469 | void Today::startMail() { | 473 | void Today::startMail() { |
470 | QCopEnvelope e("QPE/System", "execute(QString)"); | 474 | QCopEnvelope e("QPE/System", "execute(QString)"); |
471 | e << QString("opiemail"); | 475 | e << QString("opiemail"); |
472 | //Right now start both, maybe decide which to rum via config file .. | 476 | //Right now start both, maybe decide which to rum via config file .. |
473 | QCopEnvelope f("QPE/System", "execute(QString)"); | 477 | QCopEnvelope f("QPE/System", "execute(QString)"); |
474 | f << QString("qtmail"); | 478 | f << QString("qtmail"); |
475 | } | 479 | } |
476 | 480 | ||
477 | 481 | ||
478 | Today::~Today() { | 482 | Today::~Today() { |
479 | } | 483 | } |
480 | 484 | ||
481 | /* | 485 | /* |
482 | * Gets the events for the current day, if it should get all dates | 486 | * Gets the events for the current day, if it should get all dates |
483 | */ | 487 | */ |
484 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | 488 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, |
485 | QWidget* parent, | 489 | QWidget* parent, |
486 | int SHOW_LOCATION, | 490 | int SHOW_LOCATION, |
487 | int SHOW_NOTES, | 491 | int SHOW_NOTES, |
488 | const char* name, | 492 | const char* name, |
489 | WFlags fl) : | 493 | WFlags fl) : |
490 | OClickableLabel(parent,name,fl), event(ev) { | 494 | OClickableLabel(parent,name,fl), event(ev) { |
491 | 495 | ||
492 | QString msg; | 496 | QString msg; |
493 | //QTime time = QTime::currentTime(); | 497 | //QTime time = QTime::currentTime(); |
494 | 498 | ||
495 | Config config( "qpe" ); | 499 | Config config( "qpe" ); |
496 | config.setGroup( "Time" ); | 500 | config.setGroup( "Time" ); |
497 | // if 24 h format | 501 | // if 24 h format |
498 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 502 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
499 | 503 | ||
500 | 504 | ||
501 | if (!ONLY_LATER) { | 505 | if (!ONLY_LATER) { |
502 | msg += "<B>" + (ev).description() + "</B>"; | 506 | msg += "<B>" + (ev).description() + "</B>"; |
503 | if ( (ev).event().hasAlarm() ) { | 507 | if ( (ev).event().hasAlarm() ) { |
504 | msg += " <b>[with alarm]</b>"; | 508 | msg += " <b>[with alarm]</b>"; |
505 | } | 509 | } |
506 | // include location or not | 510 | // include location or not |
507 | if (SHOW_LOCATION == 1) { | 511 | if (SHOW_LOCATION == 1) { |
508 | msg += "<BR><i>" + (ev).location() + "</i>"; | 512 | msg += "<BR><i>" + (ev).location() + "</i>"; |
509 | } | 513 | } |
510 | 514 | ||
511 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 515 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
512 | msg += "<br>All day"; | 516 | msg += "<br>All day"; |
513 | } else { | 517 | } else { |
514 | // start time of event | 518 | // start time of event |
515 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 519 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
516 | // end time of event | 520 | // end time of event |
517 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 521 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
518 | } | 522 | } |
519 | 523 | ||
520 | // include possible note or not | 524 | // include possible note or not |
521 | if (SHOW_NOTES == 1) { | 525 | if (SHOW_NOTES == 1) { |
522 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | 526 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); |
523 | } | 527 | } |
524 | } | 528 | } |
525 | setText(msg); | 529 | setText(msg); |
526 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 530 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
527 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 531 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
528 | } | 532 | } |
529 | 533 | ||
530 | 534 | ||
531 | QString DateBookEvent::ampmTime(QTime tm) { | 535 | QString DateBookEvent::ampmTime(QTime tm) { |
532 | 536 | ||
533 | QString s; | 537 | QString s; |
534 | if( ampm ) { | 538 | if( ampm ) { |
535 | int hour = tm.hour(); | 539 | int hour = tm.hour(); |
536 | if (hour == 0) | 540 | if (hour == 0) |
537 | hour = 12; | 541 | hour = 12; |
538 | if (hour > 12) | 542 | if (hour > 12) |
539 | hour -= 12; | 543 | hour -= 12; |
540 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 544 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
541 | (tm.hour() >= 12) ? "PM" : "AM" ); | 545 | (tm.hour() >= 12) ? "PM" : "AM" ); |
542 | return s; | 546 | return s; |
543 | } else { | 547 | } else { |
544 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 548 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
545 | return s; | 549 | return s; |
546 | } | 550 | } |
547 | 551 | ||
548 | } | 552 | } |
549 | 553 | ||
550 | 554 | ||
551 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | 555 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, |
552 | QWidget* parent, | 556 | QWidget* parent, |
553 | int SHOW_LOCATION, | 557 | int SHOW_LOCATION, |
554 | int SHOW_NOTES, | 558 | int SHOW_NOTES, |
555 | const char* name, | 559 | const char* name, |
556 | WFlags fl) : | 560 | WFlags fl) : |
557 | OClickableLabel(parent,name,fl), event(ev) { | 561 | OClickableLabel(parent,name,fl), event(ev) { |
558 | 562 | ||
559 | QString msg; | 563 | QString msg; |
560 | QTime time = QTime::currentTime(); | 564 | QTime time = QTime::currentTime(); |
561 | 565 | ||
562 | Config config( "qpe" ); | 566 | Config config( "qpe" ); |
563 | config.setGroup( "Time" ); | 567 | config.setGroup( "Time" ); |
564 | // if 24 h format | 568 | // if 24 h format |
565 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 569 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
566 | 570 | ||
567 | 571 | ||
568 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { | 572 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { |
569 | // show only later appointments | 573 | // show only later appointments |
570 | msg += "<B>" + (ev).description() + "</B>"; | 574 | msg += "<B>" + (ev).description() + "</B>"; |
571 | if ( (ev).event().hasAlarm() ) { | 575 | if ( (ev).event().hasAlarm() ) { |
572 | msg += " <b>[with alarm]</b>"; | 576 | msg += " <b>[with alarm]</b>"; |
573 | } | 577 | } |
574 | // include location or not | 578 | // include location or not |
575 | if (SHOW_LOCATION == 1) { | 579 | if (SHOW_LOCATION == 1) { |
576 | msg += "<BR><i>" + (ev).location() + "</i>"; | 580 | msg += "<BR><i>" + (ev).location() + "</i>"; |
577 | } | 581 | } |
578 | 582 | ||
579 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 583 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
580 | msg += "<br>All day"; | 584 | msg += "<br>All day"; |
581 | } else { | 585 | } else { |
582 | // start time of event | 586 | // start time of event |
583 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 587 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
584 | // end time of event | 588 | // end time of event |
585 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 589 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
586 | } | 590 | } |
587 | // include possible note or not | 591 | // include possible note or not |
588 | if (SHOW_NOTES == 1) { | 592 | if (SHOW_NOTES == 1) { |
589 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | 593 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); |
590 | } | 594 | } |
591 | } | 595 | } |
592 | 596 | ||
593 | setText(msg); | 597 | setText(msg); |
594 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 598 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
595 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 599 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
596 | } | 600 | } |
597 | 601 | ||
598 | 602 | ||
599 | QString DateBookEventLater::ampmTime(QTime tm) { | 603 | QString DateBookEventLater::ampmTime(QTime tm) { |
600 | 604 | ||
601 | QString s; | 605 | QString s; |
602 | if( ampm ) { | 606 | if( ampm ) { |
603 | int hour = tm.hour(); | 607 | int hour = tm.hour(); |
604 | if (hour == 0) | 608 | if (hour == 0) |
605 | hour = 12; | 609 | hour = 12; |
606 | if (hour > 12) | 610 | if (hour > 12) |
607 | hour -= 12; | 611 | hour -= 12; |
608 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 612 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
609 | (tm.hour() >= 12) ? "PM" : "AM" ); | 613 | (tm.hour() >= 12) ? "PM" : "AM" ); |
610 | return s; | 614 | return s; |
611 | } else { | 615 | } else { |
612 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 616 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
613 | return s; | 617 | return s; |
614 | } | 618 | } |
615 | 619 | ||
616 | } | 620 | } |
617 | 621 | ||
618 | 622 | ||
619 | void DateBookEvent::editMe() { | 623 | void DateBookEvent::editMe() { |
620 | emit editEvent(event.event()); | 624 | emit editEvent(event.event()); |
621 | } | 625 | } |
622 | 626 | ||
623 | void DateBookEventLater::editMe() { | 627 | void DateBookEventLater::editMe() { |
624 | emit editEvent(event.event()); | 628 | emit editEvent(event.event()); |
625 | } | 629 | } |
626 | 630 | ||
627 | 631 | ||
diff --git a/core/pim/today/today.h b/core/pim/today/today.h index 54f31cc..f28c029 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h | |||
@@ -1,117 +1,118 @@ | |||
1 | /* | 1 | /* |
2 | * today.h | 2 | * today.h |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * begin : Sun 10 17:20:00 CEST 2002 | 6 | * begin : Sun 10 17:20:00 CEST 2002 |
7 | * copyright : (c) 2002 by Maximilian Reiß | 7 | * copyright : (c) 2002 by Maximilian Reiß |
8 | * email : max.reiss@gmx.de | 8 | * email : max.reiss@gmx.de |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
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 | 20 | ||
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> | 27 | #include <opie/tododb.h> |
28 | #include <opie/oclickablelabel.h> | 28 | #include <opie/oclickablelabel.h> |
29 | 29 | ||
30 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
31 | #include <qlist.h> | 31 | #include <qlist.h> |
32 | 32 | ||
33 | #include "todayconfig.h" | 33 | #include "todayconfig.h" |
34 | #include "todaybase.h" | 34 | #include "todaybase.h" |
35 | 35 | ||
36 | class QVBoxLayout; | 36 | class QVBoxLayout; |
37 | 37 | ||
38 | class Today : public TodayBase { | 38 | class Today : public TodayBase { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | 40 | ||
41 | public: | 41 | public: |
42 | Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 42 | Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
43 | ~Today(); | 43 | ~Today(); |
44 | 44 | ||
45 | private slots: | 45 | private slots: |
46 | void startConfig(); | 46 | void startConfig(); |
47 | void startTodo(); | 47 | void startTodo(); |
48 | void startDatebook(); | 48 | void startDatebook(); |
49 | void startAddressbook(); | ||
49 | void startMail(); | 50 | void startMail(); |
50 | void editCard(); | 51 | void editCard(); |
51 | void draw(); | 52 | void draw(); |
52 | void editEvent(const Event &e); | 53 | void editEvent(const Event &e); |
53 | private: | 54 | private: |
54 | void init(); | 55 | void init(); |
55 | void getDates(); | 56 | void getDates(); |
56 | void getTodo(); | 57 | void getTodo(); |
57 | void getMail(); | 58 | void getMail(); |
58 | void autoStart(); | 59 | void autoStart(); |
59 | bool checkIfModified(); | 60 | bool checkIfModified(); |
60 | void setOwnerField(); | 61 | void setOwnerField(); |
61 | void setOwnerField(QString &string); | 62 | void setOwnerField(QString &string); |
62 | private slots: | 63 | private slots: |
63 | void channelReceived(const QCString &msg, const QByteArray & data); | 64 | void channelReceived(const QCString &msg, const QByteArray & data); |
64 | 65 | ||
65 | private: | 66 | private: |
66 | DateBookDB *db; | 67 | DateBookDB *db; |
67 | ToDoDB *todo; | 68 | ToDoDB *todo; |
68 | todayconfig *conf; | 69 | todayconfig *conf; |
69 | QWidget* AllDateBookEvents; | 70 | QWidget* AllDateBookEvents; |
70 | //Config cfg; | 71 | //Config cfg; |
71 | int MAX_LINES_TASK; | 72 | int MAX_LINES_TASK; |
72 | int MAX_CHAR_CLIP; | 73 | int MAX_CHAR_CLIP; |
73 | int MAX_LINES_MEET; | 74 | int MAX_LINES_MEET; |
74 | int SHOW_LOCATION; | 75 | int SHOW_LOCATION; |
75 | int SHOW_NOTES; | 76 | int SHOW_NOTES; |
76 | }; | 77 | }; |
77 | 78 | ||
78 | class DateBookEvent: public OClickableLabel { | 79 | class DateBookEvent: public OClickableLabel { |
79 | Q_OBJECT | 80 | Q_OBJECT |
80 | public: | 81 | public: |
81 | DateBookEvent(const EffectiveEvent &ev, | 82 | DateBookEvent(const EffectiveEvent &ev, |
82 | QWidget* parent = 0, | 83 | QWidget* parent = 0, |
83 | int SHOW_LOCATION = 0, | 84 | int SHOW_LOCATION = 0, |
84 | int SHOW_NOTES = 0, | 85 | int SHOW_NOTES = 0, |
85 | const char* name = 0, | 86 | const char* name = 0, |
86 | WFlags fl = 0); | 87 | WFlags fl = 0); |
87 | signals: | 88 | signals: |
88 | void editEvent(const Event &e); | 89 | void editEvent(const Event &e); |
89 | private slots: | 90 | private slots: |
90 | void editMe(); | 91 | void editMe(); |
91 | private: | 92 | private: |
92 | QString ampmTime(QTime); | 93 | QString ampmTime(QTime); |
93 | const EffectiveEvent event; | 94 | const EffectiveEvent event; |
94 | bool ampm; | 95 | bool ampm; |
95 | }; | 96 | }; |
96 | 97 | ||
97 | class DateBookEventLater: public OClickableLabel { | 98 | class DateBookEventLater: public OClickableLabel { |
98 | Q_OBJECT | 99 | Q_OBJECT |
99 | public: | 100 | public: |
100 | DateBookEventLater(const EffectiveEvent &ev, | 101 | DateBookEventLater(const EffectiveEvent &ev, |
101 | QWidget* parent = 0, | 102 | QWidget* parent = 0, |
102 | int SHOW_LOCATION = 0, | 103 | int SHOW_LOCATION = 0, |
103 | int SHOW_NOTES = 0, | 104 | int SHOW_NOTES = 0, |
104 | const char* name = 0, | 105 | const char* name = 0, |
105 | WFlags fl = 0); | 106 | WFlags fl = 0); |
106 | signals: | 107 | signals: |
107 | void editEvent(const Event &e); | 108 | void editEvent(const Event &e); |
108 | private slots: | 109 | private slots: |
109 | void editMe(); | 110 | void editMe(); |
110 | private: | 111 | private: |
111 | QString ampmTime(QTime); | 112 | QString ampmTime(QTime); |
112 | const EffectiveEvent event; | 113 | const EffectiveEvent event; |
113 | bool ampm; | 114 | bool ampm; |
114 | }; | 115 | }; |
115 | 116 | ||
116 | #endif // TODAY_H | 117 | #endif // TODAY_H |
117 | 118 | ||