author | harlekin <harlekin> | 2002-04-10 16:51:46 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-04-10 16:51:46 (UTC) |
commit | 34e0e7af48992314d461be1a5a573dc0967fe260 (patch) (unidiff) | |
tree | e3e8bbf44ebf767f28de3fe89eced38e785a7b55 /core/pim/today | |
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: | |||
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 |
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 @@ | |||
1 | * am/pm time optinal (autodetect) | ||
2 | |||
1 | 0.3.1 | 3 | 0.3.1 |
2 | 4 | ||
3 | * fixed the wrong color of the buttons | 5 | * 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 ) | |||
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; |
@@ -444,8 +446,6 @@ void Today::startMail() { | |||
444 | Today::~Today() { | 446 | Today::~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 | */ |
@@ -460,6 +460,11 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | |||
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() ) { |
@@ -474,9 +479,9 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | |||
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 |
@@ -490,6 +495,26 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | |||
490 | } | 495 | } |
491 | 496 | ||
492 | 497 | ||
498 | QString DateBookEvent::ampmTime(QTime tm) { | ||
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 | |||
493 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | 518 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, |
494 | QWidget* parent = 0, | 519 | QWidget* parent = 0, |
495 | int SHOW_LOCATION = 0, | 520 | int SHOW_LOCATION = 0, |
@@ -501,6 +526,11 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | |||
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>"; |
@@ -516,9 +546,9 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | |||
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) { |
@@ -532,6 +562,26 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | |||
532 | } | 562 | } |
533 | 563 | ||
534 | 564 | ||
565 | QString 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 | |||
535 | void DateBookEvent::editMe() { | 585 | void DateBookEvent::editMe() { |
536 | emit editEvent(event.event()); | 586 | emit editEvent(event.event()); |
537 | } | 587 | } |
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: | |||
88 | private slots: | 88 | private slots: |
89 | void editMe(); | 89 | void editMe(); |
90 | private: | 90 | private: |
91 | QString ampmTime(QTime); | ||
91 | const EffectiveEvent event; | 92 | const EffectiveEvent event; |
93 | bool ampm; | ||
92 | }; | 94 | }; |
93 | 95 | ||
94 | class DateBookEventLater: public ClickableLabel { | 96 | class DateBookEventLater: public ClickableLabel { |
@@ -105,7 +107,9 @@ signals: | |||
105 | private slots: | 107 | private slots: |
106 | void editMe(); | 108 | void editMe(); |
107 | private: | 109 | private: |
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 |
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 ) | |||
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(); |
@@ -95,7 +95,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) | |||
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 ); |
@@ -112,7 +112,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) | |||
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 | ||
@@ -128,7 +128,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) | |||
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 | ||
@@ -150,7 +150,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) | |||
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 | ||
@@ -169,7 +169,7 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) | |||
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 | ||