-rw-r--r-- | core/pim/today/today.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 69a0f75..06cfa01 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -12,99 +12,100 @@ | |||
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 | #include "today.h" | 20 | #include "today.h" |
21 | 21 | ||
22 | #include <qpe/timestring.h> | 22 | #include <qpe/timestring.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | //#include <qpe/qprocess.h> | 25 | //#include <qpe/qprocess.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/contact.h> | 27 | #include <qpe/contact.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | 30 | ||
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
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 | //#include <qfileinfo.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qtl.h> | 43 | #include <qtl.h> |
44 | 44 | ||
45 | 45 | ||
46 | //#include <iostream.h> | 46 | //#include <iostream.h> |
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | 49 | ||
50 | int MAX_LINES_TASK; | 50 | int MAX_LINES_TASK; |
51 | int MAX_CHAR_CLIP; | 51 | int MAX_CHAR_CLIP; |
52 | int MAX_LINES_MEET; | 52 | int MAX_LINES_MEET; |
53 | int SHOW_LOCATION; | 53 | int SHOW_LOCATION; |
54 | int SHOW_NOTES; | 54 | int SHOW_NOTES; |
55 | // show only later dates | 55 | // show only later dates |
56 | int ONLY_LATER; | 56 | int ONLY_LATER; |
57 | int AUTOSTART; | 57 | int AUTOSTART; |
58 | int NEW_START=1; | 58 | int NEW_START=1; |
59 | QString AUTOSTART_TIMER; | 59 | QString AUTOSTART_TIMER; |
60 | int NEXTDAYS=1; | ||
60 | 61 | ||
61 | /* | 62 | |
62 | * Constructs a Example which is a child of 'parent', with the | 63 | /* Constructs a Example which is a child of 'parent', with the |
63 | * name 'name' and widget flags set to 'f' | 64 | * name 'name' and widget flags set to 'f' |
64 | */ | 65 | */ |
65 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 66 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
66 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { | 67 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { |
67 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 68 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); |
68 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 69 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); |
69 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); | 70 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); |
70 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); | 71 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); |
71 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT(editCard() ) ); | 72 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT(editCard() ) ); |
72 | 73 | ||
73 | #if defined(Q_WS_QWS) | 74 | #if defined(Q_WS_QWS) |
74 | #if !defined(QT_NO_COP) | 75 | #if !defined(QT_NO_COP) |
75 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); | 76 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); |
76 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 77 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
77 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); | 78 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); |
78 | #endif | 79 | #endif |
79 | #endif | 80 | #endif |
80 | 81 | ||
81 | 82 | ||
82 | 83 | ||
83 | db = NULL; | 84 | db = NULL; |
84 | setOwnerField(); | 85 | setOwnerField(); |
85 | todo = new ToDoDB; | 86 | todo = new ToDoDB; |
86 | draw(); | 87 | draw(); |
87 | getTodo(); | 88 | getTodo(); |
88 | autoStart(); | 89 | autoStart(); |
89 | } | 90 | } |
90 | 91 | ||
91 | /* | 92 | /* |
92 | * Qcop receive method. | 93 | * Qcop receive method. |
93 | */ | 94 | */ |
94 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { | 95 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { |
95 | QDataStream stream(data, IO_ReadOnly ); | 96 | QDataStream stream(data, IO_ReadOnly ); |
96 | if ( msg == "message(QString)" ) { | 97 | if ( msg == "message(QString)" ) { |
97 | QString message; | 98 | QString message; |
98 | stream >> message; | 99 | stream >> message; |
99 | setOwnerField(message); | 100 | setOwnerField(message); |
100 | } | 101 | } |
101 | 102 | ||
102 | } | 103 | } |
103 | 104 | ||
104 | /* | 105 | /* |
105 | * Initialises the owner field with the default value, the username | 106 | * Initialises the owner field with the default value, the username |
106 | */ | 107 | */ |
107 | void Today::setOwnerField() { | 108 | void Today::setOwnerField() { |
108 | QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); | 109 | QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); |
109 | if (QFile::exists(file)) { | 110 | if (QFile::exists(file)) { |
110 | Contact cont = Contact::readVCard(file)[0]; | 111 | Contact cont = Contact::readVCard(file)[0]; |
@@ -377,115 +378,118 @@ void Today::getTodo() { | |||
377 | QString tmpout; | 378 | QString tmpout; |
378 | int count = 0; | 379 | int count = 0; |
379 | int ammount = 0; | 380 | int ammount = 0; |
380 | 381 | ||
381 | // get overdue todos first | 382 | // get overdue todos first |
382 | QValueList<ToDoEvent> overDueList = todo->overDue(); | 383 | QValueList<ToDoEvent> overDueList = todo->overDue(); |
383 | qBubbleSort(overDueList); | 384 | qBubbleSort(overDueList); |
384 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); | 385 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); |
385 | it!=overDueList.end(); ++it ) { | 386 | it!=overDueList.end(); ++it ) { |
386 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { | 387 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { |
387 | 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>"; |
388 | ammount++; | 389 | ammount++; |
389 | } | 390 | } |
390 | } | 391 | } |
391 | 392 | ||
392 | // get total number of still open todos | 393 | // get total number of still open todos |
393 | QValueList<ToDoEvent> openTodo = todo->rawToDos(); | 394 | QValueList<ToDoEvent> openTodo = todo->rawToDos(); |
394 | qBubbleSort(openTodo); | 395 | qBubbleSort(openTodo); |
395 | for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin(); | 396 | for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin(); |
396 | it!=openTodo.end(); ++it ) { | 397 | it!=openTodo.end(); ++it ) { |
397 | if (!(*it).isCompleted()){ | 398 | if (!(*it).isCompleted()){ |
398 | count +=1; | 399 | count +=1; |
399 | // 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 |
400 | // over the maxlines | 401 | // over the maxlines |
401 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { | 402 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { |
402 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 403 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
403 | ammount++; | 404 | ammount++; |
404 | } | 405 | } |
405 | } | 406 | } |
406 | } | 407 | } |
407 | 408 | ||
408 | 409 | ||
409 | if (count > 0) { | 410 | if (count > 0) { |
410 | if( count == 1 ) { | 411 | if( count == 1 ) { |
411 | output = tr("There is <b> 1</b> active task: <br>" ); | 412 | output = tr("There is <b> 1</b> active task: <br>" ); |
412 | } else { | 413 | } else { |
413 | 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); |
414 | } | 415 | } |
415 | output += tmpout; | 416 | output += tmpout; |
416 | } else { | 417 | } else { |
417 | output = tr("No active tasks"); | 418 | output = tr("No active tasks"); |
418 | } | 419 | } |
419 | 420 | ||
420 | TodoField->setText(tr(output)); | 421 | TodoField->setText(tr(output)); |
421 | } | 422 | } |
422 | 423 | ||
423 | 424 | ||
424 | /* | 425 | /* |
425 | * launch addressbook | 426 | * launch addressbook (personal card) |
426 | */ | 427 | */ |
427 | void Today::editCard() { | 428 | void Today::editCard() { |
428 | QCopEnvelope e("QPE/System", "execute(QString)"); | 429 | QCopEnvelope w("QPE/System", "execute(QString)"); |
429 | e << QString("addressbook"); | 430 | w << QString("addressbook"); |
431 | |||
432 | QCopEnvelope v("QPE/Addressbook", "editPersonalAndClose()"); | ||
430 | } | 433 | } |
431 | 434 | ||
432 | /* | 435 | /* |
433 | * launches datebook | 436 | * launches datebook |
434 | */ | 437 | */ |
435 | void Today::startDatebook() { | 438 | void Today::startDatebook() { |
436 | QCopEnvelope e("QPE/System", "execute(QString)"); | 439 | QCopEnvelope e("QPE/System", "execute(QString)"); |
437 | e << QString("datebook"); | 440 | e << QString("datebook"); |
438 | } | 441 | } |
439 | 442 | ||
440 | /* | 443 | /* |
441 | * starts the edit dialog as known from datebook | 444 | * starts the edit dialog as known from datebook |
442 | */ | 445 | */ |
443 | 446 | ||
447 | |||
444 | extern QPEApplication *todayApp; | 448 | extern QPEApplication *todayApp; |
445 | 449 | ||
446 | void Today::editEvent(const Event &e) { | 450 | void Today::editEvent(const Event &e) { |
447 | startDatebook(); | 451 | startDatebook(); |
448 | 452 | ||
449 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); | 453 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); |
450 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); | 454 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); |
451 | env << e.uid(); | 455 | env << e.uid(); |
452 | } | 456 | } |
453 | 457 | ||
454 | /* | 458 | /* |
455 | * launches todolist | 459 | * launches todolist |
456 | */ | 460 | */ |
457 | void Today::startTodo() { | 461 | void Today::startTodo() { |
458 | QCopEnvelope e("QPE/System", "execute(QString)"); | 462 | QCopEnvelope e("QPE/System", "execute(QString)"); |
459 | e << QString("todolist"); | 463 | e << QString("todolist"); |
460 | } | 464 | } |
461 | 465 | ||
462 | /* | 466 | /* |
463 | * launch opiemail | 467 | * launch opiemail |
464 | */ | 468 | */ |
465 | void Today::startMail() { | 469 | void Today::startMail() { |
466 | QCopEnvelope e("QPE/System", "execute(QString)"); | 470 | QCopEnvelope e("QPE/System", "execute(QString)"); |
467 | e << QString("opiemail"); | 471 | e << QString("opiemail"); |
468 | //Right now start both, maybe decide which to rum via config file .. | 472 | //Right now start both, maybe decide which to rum via config file .. |
469 | QCopEnvelope f("QPE/System", "execute(QString)"); | 473 | QCopEnvelope f("QPE/System", "execute(QString)"); |
470 | f << QString("qtmail"); | 474 | f << QString("qtmail"); |
471 | } | 475 | } |
472 | 476 | ||
473 | 477 | ||
474 | Today::~Today() { | 478 | Today::~Today() { |
475 | } | 479 | } |
476 | 480 | ||
477 | /* | 481 | /* |
478 | * Gets the events for the current day, if it should get all dates | 482 | * Gets the events for the current day, if it should get all dates |
479 | */ | 483 | */ |
480 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | 484 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, |
481 | QWidget* parent, | 485 | QWidget* parent, |
482 | int SHOW_LOCATION, | 486 | int SHOW_LOCATION, |
483 | int SHOW_NOTES, | 487 | int SHOW_NOTES, |
484 | const char* name, | 488 | const char* name, |
485 | WFlags fl) : | 489 | WFlags fl) : |
486 | OClickableLabel(parent,name,fl), event(ev) { | 490 | OClickableLabel(parent,name,fl), event(ev) { |
487 | 491 | ||
488 | QString msg; | 492 | QString msg; |
489 | //QTime time = QTime::currentTime(); | 493 | //QTime time = QTime::currentTime(); |
490 | 494 | ||
491 | Config config( "qpe" ); | 495 | Config config( "qpe" ); |