-rw-r--r-- | core/pim/today/today.cpp | 62 |
1 files changed, 56 insertions, 6 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 @@ -75,6 +75,8 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) #endif #endif + + db = NULL; setOwnerField(); todo = new ToDoDB; @@ -444,8 +446,6 @@ void Today::startMail() { Today::~Today() { } - - /* * Gets the events for the current day, if it should get all dates */ @@ -460,6 +460,11 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, QString msg; //QTime time = QTime::currentTime(); + Config config( "qpe" ); + // if 24 h format + ampm = config.readBoolEntry( "AMPM", TRUE ); + + if (!ONLY_LATER) { msg += "<B>" + (ev).description() + "</B>"; if ( (ev).event().hasAlarm() ) { @@ -474,9 +479,9 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, msg += "<br>All day"; } else { // start time of event - msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) + msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ); // end time of event - + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); + + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); } // include possible note or not @@ -490,6 +495,26 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, } +QString DateBookEvent::ampmTime(QTime tm) { + + QString s; + if( ampm ) { + int hour = tm.hour(); + if (hour == 0) + hour = 12; + if (hour > 12) + hour -= 12; + s.sprintf( "%2d:%02d %s", hour, tm.minute(), + (tm.hour() >= 12) ? "PM" : "AM" ); + return s; + } else { + s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); + return s; + } + +} + + DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, QWidget* parent = 0, int SHOW_LOCATION = 0, @@ -501,6 +526,11 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, QString msg; QTime time = QTime::currentTime(); + Config config( "qpe" ); + // if 24 h format + ampm = config.readBoolEntry( "AMPM", TRUE ); + + if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { // show only later appointments msg += "<B>" + (ev).description() + "</B>"; @@ -516,9 +546,9 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, msg += "<br>All day"; } else { // start time of event - msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) + msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) // end time of event - + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); + + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); } // include possible note or not if (SHOW_NOTES == 1) { @@ -532,6 +562,26 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, } +QString DateBookEventLater::ampmTime(QTime tm) { + + QString s; + if( ampm ) { + int hour = tm.hour(); + if (hour == 0) + hour = 12; + if (hour > 12) + hour -= 12; + s.sprintf( "%2d:%02d %s", hour, tm.minute(), + (tm.hour() >= 12) ? "PM" : "AM" ); + return s; + } else { + s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); + return s; + } + +} + + void DateBookEvent::editMe() { emit editEvent(event.event()); } |