-rw-r--r-- | core/pim/today/main.cpp | 3 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 13 |
2 files changed, 10 insertions, 6 deletions
diff --git a/core/pim/today/main.cpp b/core/pim/today/main.cpp index 552db7c..72c0a2e 100644 --- a/core/pim/today/main.cpp +++ b/core/pim/today/main.cpp | |||
@@ -1,33 +1,36 @@ | |||
1 | /* | 1 | /* |
2 | * main.cpp | 2 | * main.cpp |
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 | #include "today.h" | 20 | #include "today.h" |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | 22 | ||
23 | QPEApplication *todayApp; | ||
24 | |||
23 | int main( int argc, char ** argv ) | 25 | int main( int argc, char ** argv ) |
24 | { | 26 | { |
25 | QPEApplication a(argc, argv); | 27 | QPEApplication a(argc, argv); |
28 | todayApp=&a; | ||
26 | 29 | ||
27 | Today t; | 30 | Today t; |
28 | 31 | ||
29 | t.setCaption( Today::tr("Today") ); | 32 | t.setCaption( Today::tr("Today") ); |
30 | a.showMainWidget(&t); | 33 | a.showMainWidget(&t); |
31 | 34 | ||
32 | return a.exec(); | 35 | return a.exec(); |
33 | } | 36 | } |
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index aef0a9b..66a4152 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,92 +1,93 @@ | |||
1 | /* | 1 | /* |
2 | * today.cpp : main class | 2 | * today.cpp : main class |
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 | #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 | 30 | ||
30 | #include <qdir.h> | 31 | #include <qdir.h> |
31 | #include <qfile.h> | 32 | #include <qfile.h> |
32 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
33 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
34 | #include <qcheckbox.h> | 35 | #include <qcheckbox.h> |
35 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
36 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
37 | #include <qlabel.h> | 38 | #include <qlabel.h> |
38 | #include <qtimer.h> | 39 | #include <qtimer.h> |
39 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
40 | #include <qfileinfo.h> | 41 | #include <qfileinfo.h> |
41 | #include <qlayout.h> | 42 | #include <qlayout.h> |
42 | #include <qtl.h> | 43 | #include <qtl.h> |
43 | 44 | ||
44 | //#include <iostream.h> | 45 | //#include <iostream.h> |
45 | #include <unistd.h> | 46 | #include <unistd.h> |
46 | #include <stdlib.h> | 47 | #include <stdlib.h> |
47 | 48 | ||
48 | int MAX_LINES_TASK; | 49 | int MAX_LINES_TASK; |
49 | int MAX_CHAR_CLIP; | 50 | int MAX_CHAR_CLIP; |
50 | int MAX_LINES_MEET; | 51 | int MAX_LINES_MEET; |
51 | int SHOW_LOCATION; | 52 | int SHOW_LOCATION; |
52 | int SHOW_NOTES; | 53 | int SHOW_NOTES; |
53 | // show only later dates | 54 | // show only later dates |
54 | int ONLY_LATER; | 55 | int ONLY_LATER; |
55 | int AUTOSTART; | 56 | int AUTOSTART; |
56 | int NEW_START=1; | 57 | int NEW_START=1; |
57 | 58 | ||
58 | /* | 59 | /* |
59 | * Constructs a Example which is a child of 'parent', with the | 60 | * Constructs a Example which is a child of 'parent', with the |
60 | * name 'name' and widget flags set to 'f' | 61 | * name 'name' and widget flags set to 'f' |
61 | */ | 62 | */ |
62 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 63 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
63 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { | 64 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { |
64 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 65 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); |
65 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 66 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); |
66 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); | 67 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); |
67 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); | 68 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); |
68 | 69 | ||
69 | #if defined(Q_WS_QWS) | 70 | #if defined(Q_WS_QWS) |
70 | #if !defined(QT_NO_COP) | 71 | #if !defined(QT_NO_COP) |
71 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); | 72 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); |
72 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 73 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
73 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); | 74 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); |
74 | #endif | 75 | #endif |
75 | #endif | 76 | #endif |
76 | 77 | ||
77 | setOwnerField(); | 78 | setOwnerField(); |
78 | todo = new ToDoDB; | 79 | todo = new ToDoDB; |
79 | getTodo(); | 80 | getTodo(); |
80 | draw(); | 81 | draw(); |
81 | autoStart(); | 82 | autoStart(); |
82 | } | 83 | } |
83 | 84 | ||
84 | /* | 85 | /* |
85 | * Qcop receive method. | 86 | * Qcop receive method. |
86 | */ | 87 | */ |
87 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { | 88 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { |
88 | QDataStream stream(data, IO_ReadOnly ); | 89 | QDataStream stream(data, IO_ReadOnly ); |
89 | if ( msg == "message(QString)" ) { | 90 | if ( msg == "message(QString)" ) { |
90 | QString message; | 91 | QString message; |
91 | stream >> message; | 92 | stream >> message; |
92 | setOwnerField(message); | 93 | setOwnerField(message); |
@@ -345,137 +346,137 @@ void Today::getMail() { | |||
345 | 346 | ||
346 | /* | 347 | /* |
347 | * Get the todos | 348 | * Get the todos |
348 | */ | 349 | */ |
349 | void Today::getTodo() { | 350 | void Today::getTodo() { |
350 | 351 | ||
351 | QString output; | 352 | QString output; |
352 | QString tmpout; | 353 | QString tmpout; |
353 | int count = 0; | 354 | int count = 0; |
354 | int ammount = 0; | 355 | int ammount = 0; |
355 | 356 | ||
356 | // get overdue todos first | 357 | // get overdue todos first |
357 | QValueList<ToDoEvent> overDueList = todo->overDue(); | 358 | QValueList<ToDoEvent> overDueList = todo->overDue(); |
358 | qBubbleSort(overDueList); | 359 | qBubbleSort(overDueList); |
359 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); | 360 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); |
360 | it!=overDueList.end(); ++it ) { | 361 | it!=overDueList.end(); ++it ) { |
361 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { | 362 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { |
362 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; | 363 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; |
363 | ammount++; | 364 | ammount++; |
364 | } | 365 | } |
365 | } | 366 | } |
366 | 367 | ||
367 | // get total number of still open todos | 368 | // get total number of still open todos |
368 | QValueList<ToDoEvent> open = todo->rawToDos(); | 369 | QValueList<ToDoEvent> open = todo->rawToDos(); |
369 | qBubbleSort(open); | 370 | qBubbleSort(open); |
370 | for ( QValueList<ToDoEvent>::Iterator it=open.begin(); | 371 | for ( QValueList<ToDoEvent>::Iterator it=open.begin(); |
371 | it!=open.end(); ++it ) { | 372 | it!=open.end(); ++it ) { |
372 | if (!(*it).isCompleted()){ | 373 | if (!(*it).isCompleted()){ |
373 | count +=1; | 374 | count +=1; |
374 | // not the overdues, we allready got them, and not if we are | 375 | // not the overdues, we allready got them, and not if we are |
375 | // over the maxlines | 376 | // over the maxlines |
376 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { | 377 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { |
377 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 378 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
378 | ammount++; | 379 | ammount++; |
379 | } | 380 | } |
380 | } | 381 | } |
381 | } | 382 | } |
382 | 383 | ||
383 | 384 | ||
384 | if (count > 0) { | 385 | if (count > 0) { |
385 | if( count == 1 ) { | 386 | if( count == 1 ) { |
386 | output = tr("There is <b> 1</b> active task: <br>" ); | 387 | output = tr("There is <b> 1</b> active task: <br>" ); |
387 | } else { | 388 | } else { |
388 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 389 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
389 | } | 390 | } |
390 | output += tmpout; | 391 | output += tmpout; |
391 | } else { | 392 | } else { |
392 | output = tr("No active tasks"); | 393 | output = tr("No active tasks"); |
393 | } | 394 | } |
394 | 395 | ||
395 | TodoField->setText(tr(output)); | 396 | TodoField->setText(tr(output)); |
396 | } | 397 | } |
397 | 398 | ||
398 | /* | 399 | /* |
399 | * launches datebook | 400 | * launches datebook |
400 | */ | 401 | */ |
401 | void Today::startDatebook() { | 402 | void Today::startDatebook() { |
402 | QCopEnvelope e("QPE/System", "execute(QString)"); | 403 | QCopEnvelope e("QPE/System", "execute(QString)"); |
403 | e << QString("datebook"); | 404 | e << QString("datebook"); |
404 | } | 405 | } |
405 | 406 | ||
406 | /* | 407 | /* |
407 | * starts the edit dialog as known from datebook | 408 | * starts the edit dialog as known from datebook |
408 | */ | 409 | */ |
410 | |||
411 | extern QPEApplication *todayApp; | ||
412 | |||
409 | void Today::editEvent(const Event &e) { | 413 | void Today::editEvent(const Event &e) { |
410 | startDatebook(); | 414 | startDatebook(); |
411 | 415 | ||
412 | //Dissabled for now as uid's not working properly | 416 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); |
413 | /* | 417 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); |
414 | while(!QCopChannel::isRegistered("QPE/Datebook")) sleep(1); | 418 | env << e.uid(); |
415 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); | ||
416 | env << e.uid(); | ||
417 | */ | ||
418 | } | 419 | } |
419 | 420 | ||
420 | /* | 421 | /* |
421 | * launches todolist | 422 | * launches todolist |
422 | */ | 423 | */ |
423 | void Today::startTodo() { | 424 | void Today::startTodo() { |
424 | QCopEnvelope e("QPE/System", "execute(QString)"); | 425 | QCopEnvelope e("QPE/System", "execute(QString)"); |
425 | e << QString("todolist"); | 426 | e << QString("todolist"); |
426 | } | 427 | } |
427 | 428 | ||
428 | /* | 429 | /* |
429 | * launch opiemail | 430 | * launch opiemail |
430 | */ | 431 | */ |
431 | void Today::startMail() { | 432 | void Today::startMail() { |
432 | QCopEnvelope e("QPE/System", "execute(QString)"); | 433 | QCopEnvelope e("QPE/System", "execute(QString)"); |
433 | e << QString("opiemail"); | 434 | e << QString("opiemail"); |
434 | } | 435 | } |
435 | 436 | ||
436 | 437 | ||
437 | Today::~Today() { | 438 | Today::~Today() { |
438 | } | 439 | } |
439 | 440 | ||
440 | 441 | ||
441 | 442 | ||
442 | /* | 443 | /* |
443 | * Gets the events for the current day, if it should get all dates | 444 | * Gets the events for the current day, if it should get all dates |
444 | */ | 445 | */ |
445 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | 446 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, |
446 | QWidget* parent = 0, | 447 | QWidget* parent = 0, |
447 | int SHOW_LOCATION = 0, | 448 | int SHOW_LOCATION = 0, |
448 | int SHOW_NOTES = 0, | 449 | int SHOW_NOTES = 0, |
449 | const char* name = 0, | 450 | const char* name = 0, |
450 | WFlags fl = 0) : | 451 | WFlags fl = 0) : |
451 | ClickableLabel(parent,name,fl), event(ev) { | 452 | ClickableLabel(parent,name,fl), event(ev) { |
452 | 453 | ||
453 | QString msg; | 454 | QString msg; |
454 | //QTime time = QTime::currentTime(); | 455 | //QTime time = QTime::currentTime(); |
455 | 456 | ||
456 | if (!ONLY_LATER) { | 457 | if (!ONLY_LATER) { |
457 | msg += "<B>" + (ev).description() + "</B>"; | 458 | msg += "<B>" + (ev).description() + "</B>"; |
458 | if ( (ev).event().hasAlarm() ) { | 459 | if ( (ev).event().hasAlarm() ) { |
459 | msg += " <b>[with alarm]</b>"; | 460 | msg += " <b>[with alarm]</b>"; |
460 | } | 461 | } |
461 | // include location or not | 462 | // include location or not |
462 | if (SHOW_LOCATION == 1) { | 463 | if (SHOW_LOCATION == 1) { |
463 | msg += "<BR><i>" + (ev).location() + "</i>"; | 464 | msg += "<BR><i>" + (ev).location() + "</i>"; |
464 | } | 465 | } |
465 | 466 | ||
466 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 467 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
467 | msg += "<br>All day"; | 468 | msg += "<br>All day"; |
468 | } else { | 469 | } else { |
469 | // start time of event | 470 | // start time of event |
470 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) | 471 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) |
471 | // end time of event | 472 | // end time of event |
472 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); | 473 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); |
473 | } | 474 | } |
474 | 475 | ||
475 | // include possible note or not | 476 | // include possible note or not |
476 | if (SHOW_NOTES == 1) { | 477 | if (SHOW_NOTES == 1) { |
477 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | 478 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); |
478 | } | 479 | } |
479 | } | 480 | } |
480 | setText(msg); | 481 | setText(msg); |
481 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 482 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |