author | harlekin <harlekin> | 2002-04-10 16:51:46 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-04-10 16:51:46 (UTC) |
commit | 34e0e7af48992314d461be1a5a573dc0967fe260 (patch) (side-by-side diff) | |
tree | e3e8bbf44ebf767f28de3fe89eced38e785a7b55 /core | |
parent | 1d32fda5b67e89321ecbd0c8700edb8292b9ca90 (diff) | |
download | opie-34e0e7af48992314d461be1a5a573dc0967fe260.zip opie-34e0e7af48992314d461be1a5a573dc0967fe260.tar.gz opie-34e0e7af48992314d461be1a5a573dc0967fe260.tar.bz2 |
am/pm support, ugly
-rw-r--r-- | core/pim/today/TODO | 2 | ||||
-rw-r--r-- | core/pim/today/changelog | 2 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 62 | ||||
-rw-r--r-- | core/pim/today/today.h | 4 | ||||
-rw-r--r-- | core/pim/today/todaybase.cpp | 24 |
5 files changed, 74 insertions, 20 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 @@ -2,8 +2,6 @@ TODO for today: * show alarm icons on alarm events (partly done) -* add am/pm mode instead of 24 h, take system default - * qcop integration for updating events? * make Opiezilla a clickable label wich is allway on the far right side of 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,3 +1,5 @@ +* am/pm time optinal (autodetect) + 0.3.1 * fixed the wrong color of the buttons 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()); } 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 @@ -88,7 +88,9 @@ signals: private slots: void editMe(); private: + QString ampmTime(QTime); const EffectiveEvent event; + bool ampm; }; class DateBookEventLater: public ClickableLabel { @@ -105,7 +107,9 @@ signals: private slots: void editMe(); private: + QString ampmTime(QTime); const EffectiveEvent event; + bool ampm; }; #endif // TODAY_H 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 @@ -45,13 +45,13 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) QPixmap config = Resource::loadPixmap( "today/config" ); // config icon QPixmap mail = Resource::loadPixmap( "today/mail" ); // mail icon - QPalette pal = this->palette(); - QColor col = pal.color(QPalette::Active, QColorGroup::Background); - pal.setColor(QPalette::Active, QColorGroup::Button, col); - pal.setColor(QPalette::Inactive, QColorGroup::Button, col); - pal.setColor(QPalette::Normal, QColorGroup::Button, col); - pal.setColor(QPalette::Disabled, QColorGroup::Button, col); - this->setPalette(pal); + //QPalette pal = this->palette(); + // QColor col = pal.color(QPalette::Active, QColorGroup::Background); + //pal.setColor(QPalette::Active, QColorGroup::Button, col); + //pal.setColor(QPalette::Inactive, QColorGroup::Button, col); + //pal.setColor(QPalette::Normal, QColorGroup::Button, col); + //pal.setColor(QPalette::Disabled, QColorGroup::Button, col); + //this->setPalette(pal); QWidget *d = QApplication::desktop(); @@ -95,7 +95,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) // --- dates section --- Frame4 = new QFrame( this, "Frame4" ); - Frame4->setPalette( pal ); +// Frame4->setPalette( pal ); Frame4->setFrameShape( QScrollView::StyledPanel ); Frame4->setFrameShadow( QScrollView::Sunken ); Frame4->setBackgroundOrigin( QScrollView::ParentOrigin ); @@ -112,7 +112,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) DatesButton = new QPushButton (Frame4, "DatesButton" ); DatesButton->setGeometry( QRect( 2, 4, 36, 32 ) ); DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin ); - DatesButton->setPalette( pal ); +// DatesButton->setPalette( pal ); DatesButton->setPixmap( datebook ); DatesButton->setFlat( TRUE ); @@ -128,7 +128,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) MailButton = new QPushButton (MailFrame, "MailButton" ); MailButton->setGeometry( QRect( 2, 3, 36, 19 ) ); - MailButton->setPalette( pal ); +// MailButton->setPalette( pal ); MailButton->setPixmap( mail ); MailButton->setFlat( TRUE ); @@ -150,7 +150,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) TodoButton = new QPushButton (Frame15, "TodoButton" ); TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) ); - TodoButton->setPalette( pal ); +// TodoButton->setPalette( pal ); TodoButton->setPixmap( todo ); TodoButton->setFlat( TRUE ); @@ -169,7 +169,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) PushButton1 = new QPushButton (Frame15, "PushButton1" ); PushButton1->setGeometry( QRect( 2, 68, 25, 21 ) ); PushButton1->setPixmap( config ); - PushButton1->setPalette( pal ); +// PushButton1->setPalette( pal ); PushButton1->setAutoDefault( TRUE ); PushButton1->setFlat( TRUE ); |