summaryrefslogtreecommitdiff
path: root/core/pim/today
Unidiff
Diffstat (limited to 'core/pim/today') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/TODO2
-rw-r--r--core/pim/today/changelog2
-rw-r--r--core/pim/today/today.cpp186
-rw-r--r--core/pim/today/today.h42
-rw-r--r--core/pim/today/todaybase.cpp24
5 files changed, 155 insertions, 101 deletions
diff --git a/core/pim/today/TODO b/core/pim/today/TODO
index 48e8d20..6acbf5a 100644
--- a/core/pim/today/TODO
+++ b/core/pim/today/TODO
@@ -1,10 +1,8 @@
1TODO for today: 1TODO for today:
2 2
3* show alarm icons on alarm events (partly done) 3* show alarm icons on alarm events (partly done)
4 4
5* add am/pm mode instead of 24 h, take system default
6
7* qcop integration for updating events? 5* qcop integration for updating events?
8 6
9* make Opiezilla a clickable label wich is allway on the far right side of 7* make Opiezilla a clickable label wich is allway on the far right side of
10the screen , klick will open credits ,) \ No newline at end of file 8the screen , klick will open credits ,) \ No newline at end of file
diff --git a/core/pim/today/changelog b/core/pim/today/changelog
index b3da1fb..f04ff78 100644
--- a/core/pim/today/changelog
+++ b/core/pim/today/changelog
@@ -1,6 +1,8 @@
1* am/pm time optinal (autodetect)
2
10.3.1 30.3.1
2 4
3* fixed the wrong color of the buttons 5* fixed the wrong color of the buttons
4* better translation (thanks carsten and others) 6* better translation (thanks carsten and others)
5* fixes memory leaks 7* fixes memory leaks
6* bugfixes in calendar part, now location and note are working again. 8* bugfixes in calendar part, now location and note are working again.
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 7cef035..028947d 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -18,22 +18,22 @@
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>
@@ -53,31 +53,33 @@ int SHOW_LOCATION;
53int SHOW_NOTES; 53int SHOW_NOTES;
54// show only later dates 54// show only later dates
55int ONLY_LATER; 55int ONLY_LATER;
56int AUTOSTART; 56int AUTOSTART;
57int NEW_START=1; 57int NEW_START=1;
58 58
59/* 59/*
60 * Constructs a Example which is a child of 'parent', with the 60 * Constructs a Example which is a child of 'parent', with the
61 * name 'name' and widget flags set to 'f' 61 * name 'name' and widget flags set to 'f'
62 */ 62 */
63Today::Today( QWidget* parent, const char* name, WFlags fl ) 63Today::Today( QWidget* parent, const char* name, WFlags fl )
64 : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { 64 : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) {
65 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); 65 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) );
66 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); 66 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) );
67 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); 67 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) );
68 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); 68 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
69 69
70#if defined(Q_WS_QWS) 70#if defined(Q_WS_QWS)
71#if !defined(QT_NO_COP) 71#if !defined(QT_NO_COP)
72 QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); 72 QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this );
73 connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), 73 connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)),
74 this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); 74 this, SLOT ( channelReceived(const QCString &, const QByteArray &)) );
75#endif 75#endif
76#endif 76#endif
77 77
78
79
78 db = NULL; 80 db = NULL;
79 setOwnerField(); 81 setOwnerField();
80 todo = new ToDoDB; 82 todo = new ToDoDB;
81 getTodo(); 83 getTodo();
82 draw(); 84 draw();
83 autoStart(); 85 autoStart();
@@ -95,13 +97,13 @@ void Today::channelReceived(const QCString &msg, const QByteArray & data) {
95 } 97 }
96 98
97} 99}
98 100
99/* 101/*
100 * Initialises the owner field with the default value, the username 102 * Initialises the owner field with the default value, the username
101 */ 103 */
102void Today::setOwnerField() { 104void Today::setOwnerField() {
103 QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); 105 QString file = Global::applicationFileName("addressbook", "businesscard.vcf");
104 if (QFile::exists(file)) { 106 if (QFile::exists(file)) {
105 Contact cont = Contact::readVCard(file)[0]; 107 Contact cont = Contact::readVCard(file)[0];
106 QString returnString = cont.fullName(); 108 QString returnString = cont.fullName();
107 OwnerField->setText( tr ("<b>Owned by " + returnString + "</b>")); 109 OwnerField->setText( tr ("<b>Owned by " + returnString + "</b>"));
@@ -114,21 +116,21 @@ void Today::setOwnerField() {
114 * Set the owner field with a given QString, for example per qcop. 116 * Set the owner field with a given QString, for example per qcop.
115 */ 117 */
116void Today::setOwnerField(QString &message) { 118void Today::setOwnerField(QString &message) {
117 if (!message.isEmpty()) { 119 if (!message.isEmpty()) {
118 OwnerField->setText("<b>" + message + "</b>"); 120 OwnerField->setText("<b>" + message + "</b>");
119 } 121 }
120} 122}
121 123
122/* 124/*
123 * Autostart, uses the new (opie only) autostart method in the launcher code. 125 * Autostart, uses the new (opie only) autostart method in the launcher code.
124 * If registered against that today ist started on each resume. 126 * If registered against that today ist started on each resume.
125 */ 127 */
126void Today::autoStart() { 128void Today::autoStart() {
127 Config cfg("today"); 129 Config cfg("today");
128 cfg.setGroup("Autostart"); 130 cfg.setGroup("Autostart");
129 AUTOSTART = cfg.readNumEntry("autostart",1); 131 AUTOSTART = cfg.readNumEntry("autostart",1);
130 if (AUTOSTART) { 132 if (AUTOSTART) {
131 QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); 133 QCopEnvelope e("QPE/System", "autoStart(QString,QString)");
132 e << QString("add"); 134 e << QString("add");
133 e << QString("today"); 135 e << QString("today");
134 } else { 136 } else {
@@ -142,13 +144,13 @@ void Today::autoStart() {
142 * Repaint method. Reread all fields. 144 * Repaint method. Reread all fields.
143 */ 145 */
144void Today::draw() { 146void Today::draw() {
145 init(); 147 init();
146 getDates(); 148 getDates();
147 getMail(); 149 getMail();
148 150
149 // if the todolist.xml file was not modified in between, do not parse it. 151 // if the todolist.xml file was not modified in between, do not parse it.
150 if (checkIfModified()) { 152 if (checkIfModified()) {
151 if (todo) delete todo; 153 if (todo) delete todo;
152 todo = new ToDoDB; 154 todo = new ToDoDB;
153 getTodo(); 155 getTodo();
154 } 156 }
@@ -218,16 +220,16 @@ void Today::init() {
218 */ 220 */
219void Today::startConfig() { 221void Today::startConfig() {
220 222
221 conf = new todayconfig ( this, "", true ); 223 conf = new todayconfig ( this, "", true );
222 // read the config 224 // read the config
223 Config cfg("today"); 225 Config cfg("today");
224 cfg.setGroup("BaseConfig"); 226 cfg.setGroup("BaseConfig");
225 227
226 //init(); 228 //init();
227 229
228 conf->SpinBox1->setValue(MAX_LINES_MEET); 230 conf->SpinBox1->setValue(MAX_LINES_MEET);
229 // location show box 231 // location show box
230 conf->CheckBox1->setChecked(SHOW_LOCATION); 232 conf->CheckBox1->setChecked(SHOW_LOCATION);
231 // notes show box 233 // notes show box
232 conf->CheckBox2->setChecked(SHOW_NOTES); 234 conf->CheckBox2->setChecked(SHOW_NOTES);
233 // task lines 235 // task lines
@@ -237,32 +239,32 @@ void Today::startConfig() {
237 // only later 239 // only later
238 conf->CheckBox3->setChecked(ONLY_LATER); 240 conf->CheckBox3->setChecked(ONLY_LATER);
239 // if today should be autostarted 241 // if today should be autostarted
240 conf->CheckBoxAuto->setChecked(AUTOSTART); 242 conf->CheckBoxAuto->setChecked(AUTOSTART);
241 243
242 conf->exec(); 244 conf->exec();
243 245
244 int maxlinestask = conf->SpinBox2->value(); 246 int maxlinestask = conf->SpinBox2->value();
245 int maxmeet = conf->SpinBox1->value(); 247 int maxmeet = conf->SpinBox1->value();
246 int location = conf->CheckBox1->isChecked(); 248 int location = conf->CheckBox1->isChecked();
247 int notes = conf->CheckBox2->isChecked(); 249 int notes = conf->CheckBox2->isChecked();
248 int maxcharclip = conf->SpinBox7->value(); 250 int maxcharclip = conf->SpinBox7->value();
249 int onlylater = conf->CheckBox3->isChecked(); 251 int onlylater = conf->CheckBox3->isChecked();
250 int autostart =conf->CheckBoxAuto->isChecked(); 252 int autostart =conf->CheckBoxAuto->isChecked();
251 253
252 cfg.writeEntry("maxlinestask",maxlinestask); 254 cfg.writeEntry("maxlinestask",maxlinestask);
253 cfg.writeEntry("maxcharclip", maxcharclip); 255 cfg.writeEntry("maxcharclip", maxcharclip);
254 cfg.writeEntry("maxlinesmeet",maxmeet); 256 cfg.writeEntry("maxlinesmeet",maxmeet);
255 cfg.writeEntry("showlocation",location); 257 cfg.writeEntry("showlocation",location);
256 cfg.writeEntry("shownotes", notes); 258 cfg.writeEntry("shownotes", notes);
257 cfg.writeEntry("onlylater", onlylater); 259 cfg.writeEntry("onlylater", onlylater);
258 cfg.setGroup("Autostart"); 260 cfg.setGroup("Autostart");
259 cfg.writeEntry("autostart", autostart); 261 cfg.writeEntry("autostart", autostart);
260 262
261 // sync it to "disk" 263 // sync it to "disk"
262 cfg.write(); 264 cfg.write();
263 NEW_START=1; 265 NEW_START=1;
264 draw(); 266 draw();
265 autoStart(); 267 autoStart();
266} 268}
267 269
268 270
@@ -276,88 +278,88 @@ void Today::getDates() {
276 AllDateBookEvents = new QWidget( ); 278 AllDateBookEvents = new QWidget( );
277 QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); 279 QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents);
278 280
279 if (db) { 281 if (db) {
280 delete db; 282 delete db;
281 } 283 }
282 db = new DateBookDB; 284 db = new DateBookDB;
283 285
284 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); 286 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date);
285 287
286 qBubbleSort(list); 288 qBubbleSort(list);
287 // printf("Get dates\n"); 289 // printf("Get dates\n");
288 290
289 Config config( "qpe" ); 291 Config config( "qpe" );
290 // if 24 h format 292 // if 24 h format
291 //bool ampm = config.readBoolEntry( "AMPM", TRUE ); 293 //bool ampm = config.readBoolEntry( "AMPM", TRUE );
292 294
293 int count=0; 295 int count=0;
294 296
295 if ( list.count() > 0 ) { 297 if ( list.count() > 0 ) {
296 298
297 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 299 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
298 it!=list.end(); ++it ) { 300 it!=list.end(); ++it ) {
299 301
300 302
301 if ( count <= MAX_LINES_MEET ) { 303 if ( count <= MAX_LINES_MEET ) {
302 304
303 QTime time = QTime::currentTime(); 305 QTime time = QTime::currentTime();
304 306
305 if (!ONLY_LATER) { 307 if (!ONLY_LATER) {
306 count++; 308 count++;
307 DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); 309 DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES);
308 layoutDates->addWidget(l); 310 layoutDates->addWidget(l);
309 connect (l, SIGNAL(editEvent(const Event &)), 311 connect (l, SIGNAL(editEvent(const Event &)),
310 this, SLOT(editEvent(const Event &))); 312 this, SLOT(editEvent(const Event &)));
311 } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { 313 } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) {
312 count++; 314 count++;
313 315
314 // show only later appointments 316 // show only later appointments
315 DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); 317 DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES);
316 layoutDates->addWidget(l); 318 layoutDates->addWidget(l);
317 connect (l, SIGNAL(editEvent(const Event &)), 319 connect (l, SIGNAL(editEvent(const Event &)),
318 this, SLOT(editEvent(const Event &))); 320 this, SLOT(editEvent(const Event &)));
319 } 321 }
320 } 322 }
321 } 323 }
322 if (ONLY_LATER && count==0) { 324 if (ONLY_LATER && count==0) {
323 QLabel* noMoreEvents = new QLabel(AllDateBookEvents); 325 QLabel* noMoreEvents = new QLabel(AllDateBookEvents);
324 noMoreEvents->setText(tr("No more appointments today")); 326 noMoreEvents->setText(tr("No more appointments today"));
325 layoutDates->addWidget(noMoreEvents); 327 layoutDates->addWidget(noMoreEvents);
326 } 328 }
327 } else { 329 } else {
328 QLabel* noEvents = new QLabel(AllDateBookEvents); 330 QLabel* noEvents = new QLabel(AllDateBookEvents);
329 noEvents->setText(tr("No appointments today")); 331 noEvents->setText(tr("No appointments today"));
330 layoutDates->addWidget(noEvents); 332 layoutDates->addWidget(noEvents);
331 } 333 }
332 334
333 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 335 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
334 sv1->addChild(AllDateBookEvents); 336 sv1->addChild(AllDateBookEvents);
335 AllDateBookEvents->show(); 337 AllDateBookEvents->show();
336} 338}
337 339
338 340
339void Today::getMail() { 341void Today::getMail() {
340 Config cfg("opiemail"); 342 Config cfg("opiemail");
341 cfg.setGroup("today"); 343 cfg.setGroup("today");
342 344
343 // how many lines should be showed in the task section 345 // how many lines should be showed in the task section
344 int NEW_MAILS = cfg.readNumEntry("newmails",0); 346 int NEW_MAILS = cfg.readNumEntry("newmails",0);
345 int OUTGOING = cfg.readNumEntry("outgoing",0); 347 int OUTGOING = cfg.readNumEntry("outgoing",0);
346 348
347 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); 349 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
348 350
349 MailField->setText(output); 351 MailField->setText(output);
350} 352}
351 353
352 354
353/* 355/*
354 * Get the todos 356 * Get the todos
355 */ 357 */
356void Today::getTodo() { 358void Today::getTodo() {
357 359
358 QString output; 360 QString output;
359 QString tmpout; 361 QString tmpout;
360 int count = 0; 362 int count = 0;
361 int ammount = 0; 363 int ammount = 0;
362 364
363 // get overdue todos first 365 // get overdue todos first
@@ -367,69 +369,69 @@ void Today::getTodo() {
367 it!=overDueList.end(); ++it ) { 369 it!=overDueList.end(); ++it ) {
368 if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { 370 if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) {
369 tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; 371 tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>";
370 ammount++; 372 ammount++;
371 } 373 }
372 } 374 }
373 375
374 // get total number of still open todos 376 // get total number of still open todos
375 QValueList<ToDoEvent> open = todo->rawToDos(); 377 QValueList<ToDoEvent> open = todo->rawToDos();
376 qBubbleSort(open); 378 qBubbleSort(open);
377 for ( QValueList<ToDoEvent>::Iterator it=open.begin(); 379 for ( QValueList<ToDoEvent>::Iterator it=open.begin();
378 it!=open.end(); ++it ) { 380 it!=open.end(); ++it ) {
379 if (!(*it).isCompleted()){ 381 if (!(*it).isCompleted()){
380 count +=1; 382 count +=1;
381 // not the overdues, we allready got them, and not if we are 383 // not the overdues, we allready got them, and not if we are
382 // over the maxlines 384 // over the maxlines
383 if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { 385 if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) {
384 tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; 386 tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>";
385 ammount++; 387 ammount++;
386 } 388 }
387 } 389 }
388 } 390 }
389 391
390 392
391 if (count > 0) { 393 if (count > 0) {
392 if( count == 1 ) { 394 if( count == 1 ) {
393 output = tr("There is <b> 1</b> active task: <br>" ); 395 output = tr("There is <b> 1</b> active task: <br>" );
394 } else { 396 } else {
395 output = tr("There are <b> %1</b> active tasks: <br>").arg(count); 397 output = tr("There are <b> %1</b> active tasks: <br>").arg(count);
396 } 398 }
397 output += tmpout; 399 output += tmpout;
398 } else { 400 } else {
399 output = tr("No active tasks"); 401 output = tr("No active tasks");
400 } 402 }
401 403
402 TodoField->setText(tr(output)); 404 TodoField->setText(tr(output));
403} 405}
404 406
405/* 407/*
406 * launches datebook 408 * launches datebook
407 */ 409 */
408void Today::startDatebook() { 410void Today::startDatebook() {
409 QCopEnvelope e("QPE/System", "execute(QString)"); 411 QCopEnvelope e("QPE/System", "execute(QString)");
410 e << QString("datebook"); 412 e << QString("datebook");
411} 413}
412 414
413/* 415/*
414 * starts the edit dialog as known from datebook 416 * starts the edit dialog as known from datebook
415 */ 417 */
416 418
417extern QPEApplication *todayApp; 419extern QPEApplication *todayApp;
418 420
419void Today::editEvent(const Event &e) { 421void Today::editEvent(const Event &e) {
420 startDatebook(); 422 startDatebook();
421 423
422 while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); 424 while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents();
423 QCopEnvelope env("QPE/Datebook", "editEvent(int)"); 425 QCopEnvelope env("QPE/Datebook", "editEvent(int)");
424 env << e.uid(); 426 env << e.uid();
425} 427}
426 428
427/* 429/*
428 * launches todolist 430 * launches todolist
429 */ 431 */
430void Today::startTodo() { 432void Today::startTodo() {
431 QCopEnvelope e("QPE/System", "execute(QString)"); 433 QCopEnvelope e("QPE/System", "execute(QString)");
432 e << QString("todolist"); 434 e << QString("todolist");
433} 435}
434 436
435/* 437/*
@@ -441,100 +443,148 @@ void Today::startMail() {
441} 443}
442 444
443 445
444Today::~Today() { 446Today::~Today() {
445} 447}
446 448
447
448
449/* 449/*
450 * Gets the events for the current day, if it should get all dates 450 * Gets the events for the current day, if it should get all dates
451 */ 451 */
452DateBookEvent::DateBookEvent(const EffectiveEvent &ev, 452DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
453 QWidget* parent = 0, 453 QWidget* parent = 0,
454 int SHOW_LOCATION = 0, 454 int SHOW_LOCATION = 0,
455 int SHOW_NOTES = 0, 455 int SHOW_NOTES = 0,
456 const char* name = 0, 456 const char* name = 0,
457 WFlags fl = 0) : 457 WFlags fl = 0) :
458 ClickableLabel(parent,name,fl), event(ev) { 458 ClickableLabel(parent,name,fl), event(ev) {
459 459
460 QString msg; 460 QString msg;
461 //QTime time = QTime::currentTime(); 461 //QTime time = QTime::currentTime();
462 462
463 Config config( "qpe" );
464 // if 24 h format
465 ampm = config.readBoolEntry( "AMPM", TRUE );
466
467
463 if (!ONLY_LATER) { 468 if (!ONLY_LATER) {
464 msg += "<B>" + (ev).description() + "</B>"; 469 msg += "<B>" + (ev).description() + "</B>";
465 if ( (ev).event().hasAlarm() ) { 470 if ( (ev).event().hasAlarm() ) {
466 msg += " <b>[with alarm]</b>"; 471 msg += " <b>[with alarm]</b>";
467 } 472 }
468 // include location or not 473 // include location or not
469 if (SHOW_LOCATION == 1) { 474 if (SHOW_LOCATION == 1) {
470 msg += "<BR><i>" + (ev).location() + "</i>"; 475 msg += "<BR><i>" + (ev).location() + "</i>";
471 } 476 }
472 477
473 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 478 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
474 msg += "<br>All day"; 479 msg += "<br>All day";
475 } else { 480 } else {
476 // start time of event 481 // start time of event
477 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) 482 msg += "<br>" + ampmTime(QTime((ev).event().start().time()) );
478 // end time of event 483 // end time of event
479 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); 484 + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) );
480 } 485 }
481 486
482 // include possible note or not 487 // include possible note or not
483 if (SHOW_NOTES == 1) { 488 if (SHOW_NOTES == 1) {
484 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); 489 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP);
485 } 490 }
486 } 491 }
487 setText(msg); 492 setText(msg);
488 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 493 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
489 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 494 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
490} 495}
491 496
492 497
493DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, 498QString DateBookEvent::ampmTime(QTime tm) {
494 QWidget* parent = 0, 499
500 QString s;
501 if( ampm ) {
502 int hour = tm.hour();
503 if (hour == 0)
504 hour = 12;
505 if (hour > 12)
506 hour -= 12;
507 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
508 (tm.hour() >= 12) ? "PM" : "AM" );
509 return s;
510 } else {
511 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
512 return s;
513 }
514
515}
516
517
518DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
519 QWidget* parent = 0,
495 int SHOW_LOCATION = 0, 520 int SHOW_LOCATION = 0,
496 int SHOW_NOTES = 0, 521 int SHOW_NOTES = 0,
497 const char* name = 0, 522 const char* name = 0,
498 WFlags fl = 0) : 523 WFlags fl = 0) :
499 ClickableLabel(parent,name,fl), event(ev) { 524 ClickableLabel(parent,name,fl), event(ev) {
500 525
501 QString msg; 526 QString msg;
502 QTime time = QTime::currentTime(); 527 QTime time = QTime::currentTime();
503 528
529 Config config( "qpe" );
530 // if 24 h format
531 ampm = config.readBoolEntry( "AMPM", TRUE );
532
533
504 if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { 534 if ((time.toString() <= TimeString::dateString((ev).event().end())) ) {
505 // show only later appointments 535 // show only later appointments
506 msg += "<B>" + (ev).description() + "</B>"; 536 msg += "<B>" + (ev).description() + "</B>";
507 if ( (ev).event().hasAlarm() ) { 537 if ( (ev).event().hasAlarm() ) {
508 msg += " <b>[with alarm]</b>"; 538 msg += " <b>[with alarm]</b>";
509 } 539 }
510 // include location or not 540 // include location or not
511 if (SHOW_LOCATION == 1) { 541 if (SHOW_LOCATION == 1) {
512 msg += "<BR><i>" + (ev).location() + "</i>"; 542 msg += "<BR><i>" + (ev).location() + "</i>";
513 } 543 }
514 544
515 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 545 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
516 msg += "<br>All day"; 546 msg += "<br>All day";
517 } else { 547 } else {
518 // start time of event 548 // start time of event
519 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) 549 msg += "<br>" + ampmTime(QTime((ev).event().start().time()) )
520 // end time of event 550 // end time of event
521 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); 551 + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) );
522 } 552 }
523 // include possible note or not 553 // include possible note or not
524 if (SHOW_NOTES == 1) { 554 if (SHOW_NOTES == 1) {
525 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); 555 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP);
526 } 556 }
527 } 557 }
528 558
529 setText(msg); 559 setText(msg);
530 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 560 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
531 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 561 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
532} 562}
533 563
534 564
565QString DateBookEventLater::ampmTime(QTime tm) {
566
567 QString s;
568 if( ampm ) {
569 int hour = tm.hour();
570 if (hour == 0)
571 hour = 12;
572 if (hour > 12)
573 hour -= 12;
574 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
575 (tm.hour() >= 12) ? "PM" : "AM" );
576 return s;
577 } else {
578 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
579 return s;
580 }
581
582}
583
584
535void DateBookEvent::editMe() { 585void DateBookEvent::editMe() {
536 emit editEvent(event.event()); 586 emit editEvent(event.event());
537} 587}
538 588
539void DateBookEventLater::editMe() { 589void DateBookEventLater::editMe() {
540 emit editEvent(event.event()); 590 emit editEvent(event.event());
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index 090e8f9..d265d67 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -24,27 +24,27 @@
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 28
29#include <qdatetime.h> 29#include <qdatetime.h>
30#include <qlist.h> 30#include <qlist.h>
31 31
32#include "todayconfig.h" 32#include "todayconfig.h"
33#include "todaybase.h" 33#include "todaybase.h"
34#include "clickablelabel.h" 34#include "clickablelabel.h"
35 35
36class QVBoxLayout; 36class QVBoxLayout;
37 37
38class Today : public TodayBase { 38class 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 startMail(); 49 void startMail();
50 void draw(); 50 void draw();
@@ -55,58 +55,62 @@ class Today : public TodayBase {
55 void getTodo(); 55 void getTodo();
56 void getMail(); 56 void getMail();
57 void autoStart(); 57 void autoStart();
58 bool checkIfModified(); 58 bool checkIfModified();
59 void setOwnerField(); 59 void setOwnerField();
60 void setOwnerField(QString &string); 60 void setOwnerField(QString &string);
61 private slots: 61 private slots:
62 void channelReceived(const QCString &msg, const QByteArray & data); 62 void channelReceived(const QCString &msg, const QByteArray & data);
63 63
64 private: 64 private:
65 DateBookDB *db; 65 DateBookDB *db;
66 ToDoDB *todo; 66 ToDoDB *todo;
67 todayconfig *conf; 67 todayconfig *conf;
68 QWidget* AllDateBookEvents; 68 QWidget* AllDateBookEvents;
69 //Config cfg; 69 //Config cfg;
70 int MAX_LINES_TASK; 70 int MAX_LINES_TASK;
71 int MAX_CHAR_CLIP; 71 int MAX_CHAR_CLIP;
72 int MAX_LINES_MEET; 72 int MAX_LINES_MEET;
73 int SHOW_LOCATION; 73 int SHOW_LOCATION;
74 int SHOW_NOTES; 74 int SHOW_NOTES;
75}; 75};
76 76
77class DateBookEvent: public ClickableLabel { 77class DateBookEvent: public ClickableLabel {
78 Q_OBJECT 78 Q_OBJECT
79public: 79public:
80 DateBookEvent(const EffectiveEvent &ev, 80 DateBookEvent(const EffectiveEvent &ev,
81 QWidget* parent = 0, 81 QWidget* parent = 0,
82 int SHOW_LOCATION = 0, 82 int SHOW_LOCATION = 0,
83 int SHOW_NOTES = 0, 83 int SHOW_NOTES = 0,
84 const char* name = 0, 84 const char* name = 0,
85 WFlags fl = 0); 85 WFlags fl = 0);
86signals: 86signals:
87 void editEvent(const Event &e); 87 void editEvent(const Event &e);
88private slots: 88private slots:
89 void editMe(); 89 void editMe();
90private: 90private:
91 QString ampmTime(QTime);
91 const EffectiveEvent event; 92 const EffectiveEvent event;
93 bool ampm;
92}; 94};
93 95
94class DateBookEventLater: public ClickableLabel { 96class DateBookEventLater: public ClickableLabel {
95 Q_OBJECT 97 Q_OBJECT
96public: 98public:
97 DateBookEventLater(const EffectiveEvent &ev, 99 DateBookEventLater(const EffectiveEvent &ev,
98 QWidget* parent = 0, 100 QWidget* parent = 0,
99 int SHOW_LOCATION = 0, 101 int SHOW_LOCATION = 0,
100 int SHOW_NOTES = 0, 102 int SHOW_NOTES = 0,
101 const char* name = 0, 103 const char* name = 0,
102 WFlags fl = 0); 104 WFlags fl = 0);
103signals: 105signals:
104 void editEvent(const Event &e); 106 void editEvent(const Event &e);
105private slots: 107private slots:
106 void editMe(); 108 void editMe();
107private: 109private:
110 QString ampmTime(QTime);
108 const EffectiveEvent event; 111 const EffectiveEvent event;
112 bool ampm;
109}; 113};
110 114
111#endif // TODAY_H 115#endif // TODAY_H
112 116
diff --git a/core/pim/today/todaybase.cpp b/core/pim/today/todaybase.cpp
index 755c860..ae8763b 100644
--- a/core/pim/today/todaybase.cpp
+++ b/core/pim/today/todaybase.cpp
@@ -42,19 +42,19 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
42 QPixmap logo = Resource::loadPixmap( "today/today_logo"); // logo 42 QPixmap logo = Resource::loadPixmap( "today/today_logo"); // logo
43 QPixmap datebook = Resource::loadPixmap("DateBook"); // datebook 43 QPixmap datebook = Resource::loadPixmap("DateBook"); // datebook
44 QPixmap todo = Resource::loadPixmap( "TodoList" ); // todo 44 QPixmap todo = Resource::loadPixmap( "TodoList" ); // todo
45 QPixmap config = Resource::loadPixmap( "today/config" ); // config icon 45 QPixmap config = Resource::loadPixmap( "today/config" ); // config icon
46 QPixmap mail = Resource::loadPixmap( "today/mail" ); // mail icon 46 QPixmap mail = Resource::loadPixmap( "today/mail" ); // mail icon
47 47
48 QPalette pal = this->palette(); 48 //QPalette pal = this->palette();
49 QColor col = pal.color(QPalette::Active, QColorGroup::Background); 49 // QColor col = pal.color(QPalette::Active, QColorGroup::Background);
50 pal.setColor(QPalette::Active, QColorGroup::Button, col); 50 //pal.setColor(QPalette::Active, QColorGroup::Button, col);
51 pal.setColor(QPalette::Inactive, QColorGroup::Button, col); 51 //pal.setColor(QPalette::Inactive, QColorGroup::Button, col);
52 pal.setColor(QPalette::Normal, QColorGroup::Button, col); 52 //pal.setColor(QPalette::Normal, QColorGroup::Button, col);
53 pal.setColor(QPalette::Disabled, QColorGroup::Button, col); 53 //pal.setColor(QPalette::Disabled, QColorGroup::Button, col);
54 this->setPalette(pal); 54 //this->setPalette(pal);
55 55
56 56
57 QWidget *d = QApplication::desktop(); 57 QWidget *d = QApplication::desktop();
58 int w=d->width(); 58 int w=d->width();
59 int h=d->height(); 59 int h=d->height();
60 resize( w , h ); 60 resize( w , h );
@@ -92,13 +92,13 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
92 OwnerField->setGeometry(QRect(0,0, this->width(), 12 )); 92 OwnerField->setGeometry(QRect(0,0, this->width(), 12 ));
93 OwnerField->setAlignment(int (QLabel::AlignTop | QLabel::AlignLeft ) ); 93 OwnerField->setAlignment(int (QLabel::AlignTop | QLabel::AlignLeft ) );
94 OwnerField->setMaximumHeight(12); 94 OwnerField->setMaximumHeight(12);
95 95
96 // --- dates section --- 96 // --- dates section ---
97 Frame4 = new QFrame( this, "Frame4" ); 97 Frame4 = new QFrame( this, "Frame4" );
98 Frame4->setPalette( pal ); 98// Frame4->setPalette( pal );
99 Frame4->setFrameShape( QScrollView::StyledPanel ); 99 Frame4->setFrameShape( QScrollView::StyledPanel );
100 Frame4->setFrameShadow( QScrollView::Sunken ); 100 Frame4->setFrameShadow( QScrollView::Sunken );
101 Frame4->setBackgroundOrigin( QScrollView::ParentOrigin ); 101 Frame4->setBackgroundOrigin( QScrollView::ParentOrigin );
102 Frame4->setFrameStyle( QFrame::NoFrame ); 102 Frame4->setFrameStyle( QFrame::NoFrame );
103 Frame4->setGeometry (QRect( 0, 8, this->width() , this->height()) ); 103 Frame4->setGeometry (QRect( 0, 8, this->width() , this->height()) );
104 104
@@ -109,13 +109,13 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
109 sv1->setGeometry (QRect( 40, 2, Frame4->width()-40 , (Frame4->height()/3)+20 ) ); 109 sv1->setGeometry (QRect( 40, 2, Frame4->width()-40 , (Frame4->height()/3)+20 ) );
110 sv1->setFrameShape(QFrame::NoFrame); 110 sv1->setFrameShape(QFrame::NoFrame);
111 111
112 DatesButton = new QPushButton (Frame4, "DatesButton" ); 112 DatesButton = new QPushButton (Frame4, "DatesButton" );
113 DatesButton->setGeometry( QRect( 2, 4, 36, 32 ) ); 113 DatesButton->setGeometry( QRect( 2, 4, 36, 32 ) );
114 DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin ); 114 DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin );
115 DatesButton->setPalette( pal ); 115// DatesButton->setPalette( pal );
116 DatesButton->setPixmap( datebook ); 116 DatesButton->setPixmap( datebook );
117 DatesButton->setFlat( TRUE ); 117 DatesButton->setFlat( TRUE );
118 118
119 // --- mail section ---) 119 // --- mail section ---)
120 MailFrame = new QFrame( this ,"MailFrame" ); 120 MailFrame = new QFrame( this ,"MailFrame" );
121 MailFrame->setBackgroundOrigin( QScrollView::ParentOrigin ); 121 MailFrame->setBackgroundOrigin( QScrollView::ParentOrigin );
@@ -125,13 +125,13 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
125 QFrame* Line1 = new QFrame( MailFrame); 125 QFrame* Line1 = new QFrame( MailFrame);
126 Line1->setGeometry( QRect( -5, 0, MailFrame->width()+5, 5 ) ); 126 Line1->setGeometry( QRect( -5, 0, MailFrame->width()+5, 5 ) );
127 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 127 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
128 128
129 MailButton = new QPushButton (MailFrame, "MailButton" ); 129 MailButton = new QPushButton (MailFrame, "MailButton" );
130 MailButton->setGeometry( QRect( 2, 3, 36, 19 ) ); 130 MailButton->setGeometry( QRect( 2, 3, 36, 19 ) );
131 MailButton->setPalette( pal ); 131// MailButton->setPalette( pal );
132 MailButton->setPixmap( mail ); 132 MailButton->setPixmap( mail );
133 MailButton->setFlat( TRUE ); 133 MailButton->setFlat( TRUE );
134 134
135 MailField = new QLabel( MailFrame, "MailField" ); 135 MailField = new QLabel( MailFrame, "MailField" );
136 MailField->setGeometry( QRect( 40, 4, MailFrame->width(), 12) ); 136 MailField->setGeometry( QRect( 40, 4, MailFrame->width(), 12) );
137 MailField->setText( tr( "Opiemail not installed" ) ); 137 MailField->setText( tr( "Opiemail not installed" ) );
@@ -147,13 +147,13 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
147 QFrame* Line2 = new QFrame( Frame15); 147 QFrame* Line2 = new QFrame( Frame15);
148 Line2->setGeometry( QRect( -5, 0, MailFrame->width()+5, 5 ) ); 148 Line2->setGeometry( QRect( -5, 0, MailFrame->width()+5, 5 ) );
149 Line2->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 149 Line2->setFrameStyle( QFrame::HLine | QFrame::Sunken );
150 150
151 TodoButton = new QPushButton (Frame15, "TodoButton" ); 151 TodoButton = new QPushButton (Frame15, "TodoButton" );
152 TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) ); 152 TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) );
153 TodoButton->setPalette( pal ); 153// TodoButton->setPalette( pal );
154 TodoButton->setPixmap( todo ); 154 TodoButton->setPixmap( todo );
155 TodoButton->setFlat( TRUE ); 155 TodoButton->setFlat( TRUE );
156 156
157 QScrollView* sv2 = new QScrollView( Frame15 ); 157 QScrollView* sv2 = new QScrollView( Frame15 );
158 sv2->setResizePolicy(QScrollView::AutoOneFit); 158 sv2->setResizePolicy(QScrollView::AutoOneFit);
159 sv2->setHScrollBarMode( QScrollView::AlwaysOff ); 159 sv2->setHScrollBarMode( QScrollView::AlwaysOff );
@@ -166,13 +166,13 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
166 //TodoField->setText( tr( "No current todos" ) ); 166 //TodoField->setText( tr( "No current todos" ) );
167 TodoField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); 167 TodoField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) );
168 168
169 PushButton1 = new QPushButton (Frame15, "PushButton1" ); 169 PushButton1 = new QPushButton (Frame15, "PushButton1" );
170 PushButton1->setGeometry( QRect( 2, 68, 25, 21 ) ); 170 PushButton1->setGeometry( QRect( 2, 68, 25, 21 ) );
171 PushButton1->setPixmap( config ); 171 PushButton1->setPixmap( config );
172 PushButton1->setPalette( pal ); 172// PushButton1->setPalette( pal );
173 PushButton1->setAutoDefault( TRUE ); 173 PushButton1->setAutoDefault( TRUE );
174 PushButton1->setFlat( TRUE ); 174 PushButton1->setFlat( TRUE );
175 175
176 // -- layout -- 176 // -- layout --
177 layout->addWidget(Frame); 177 layout->addWidget(Frame);
178 layout->addWidget(OwnerField); 178 layout->addWidget(OwnerField);