summaryrefslogtreecommitdiff
path: root/core/pim/today/today.cpp
authorharlekin <harlekin>2002-04-10 16:51:46 (UTC)
committer harlekin <harlekin>2002-04-10 16:51:46 (UTC)
commit34e0e7af48992314d461be1a5a573dc0967fe260 (patch) (unidiff)
treee3e8bbf44ebf767f28de3fe89eced38e785a7b55 /core/pim/today/today.cpp
parent1d32fda5b67e89321ecbd0c8700edb8292b9ca90 (diff)
downloadopie-34e0e7af48992314d461be1a5a573dc0967fe260.zip
opie-34e0e7af48992314d461be1a5a573dc0967fe260.tar.gz
opie-34e0e7af48992314d461be1a5a573dc0967fe260.tar.bz2
am/pm support, ugly
Diffstat (limited to 'core/pim/today/today.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp186
1 files changed, 118 insertions, 68 deletions
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
@@ -21,7 +21,7 @@
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>
@@ -30,7 +30,7 @@
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>
@@ -56,9 +56,9 @@ int 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) {
@@ -66,15 +66,17 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
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;
@@ -98,7 +100,7 @@ void Today::channelReceived(const QCString &msg, const QByteArray & data) {
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)) {
@@ -117,7 +119,7 @@ void 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.
@@ -125,7 +127,7 @@ void Today::setOwnerField(QString &message) {
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)");
@@ -145,7 +147,7 @@ void 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;
@@ -221,10 +223,10 @@ void Today::startConfig() {
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);
@@ -240,7 +242,7 @@ void Today::startConfig() {
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();
@@ -248,18 +250,18 @@ void Today::startConfig() {
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();
@@ -279,7 +281,7 @@ void Today::getDates() {
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
@@ -289,19 +291,19 @@ void Today::getDates() {
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);
@@ -310,42 +312,42 @@ void Today::getDates() {
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
@@ -354,7 +356,7 @@ void Today::getMail() {
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;
@@ -370,7 +372,7 @@ void Today::getTodo() {
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);
@@ -378,7 +380,7 @@ void Today::getTodo() {
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>";
@@ -386,8 +388,8 @@ void Today::getTodo() {
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>" );
@@ -398,27 +400,27 @@ void Today::getTodo() {
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();
@@ -426,7 +428,7 @@ void Today::editEvent(const Event &e) {
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");
@@ -444,22 +446,25 @@ void Today::startMail() {
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() ) {
@@ -469,16 +474,16 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
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);
@@ -490,17 +495,42 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
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>";
@@ -511,27 +541,47 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
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}