author | erik <erik> | 2007-04-23 20:46:34 (UTC) |
---|---|---|
committer | erik <erik> | 2007-04-23 20:46:34 (UTC) |
commit | 34975323367e4a903886cd317b34192f1271a1f2 (patch) (unidiff) | |
tree | 8898d9010cdb89b371e0bccdbf717f87359d8513 /core/pim | |
parent | d38e40fe9ee475230425fa83e924c49e5946b87c (diff) | |
download | opie-34975323367e4a903886cd317b34192f1271a1f2.zip opie-34975323367e4a903886cd317b34192f1271a1f2.tar.gz opie-34975323367e4a903886cd317b34192f1271a1f2.tar.bz2 |
Fix for bug 1844. The display of 12hour (AM/PM) time was broken. It was
because the views never bother to check.
This fix incorporates the patch submitted by harlekin. Thanks!
8 files changed, 63 insertions, 31 deletions
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp index b36bf6d..59f937f 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp | |||
@@ -11,4 +11,5 @@ | |||
11 | #include <qpe/datebookmonth.h> | 11 | #include <qpe/datebookmonth.h> |
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | #include <qpe/qpeapplication.h> | ||
13 | 14 | ||
14 | #include <qlayout.h> | 15 | #include <qlayout.h> |
@@ -69,5 +70,7 @@ void DateBookWeekLst::setDbl(bool on) { | |||
69 | } | 70 | } |
70 | 71 | ||
71 | void DateBookWeekLst::redraw() {getEvents();} | 72 | void DateBookWeekLst::redraw() { |
73 | getEvents(); | ||
74 | } | ||
72 | 75 | ||
73 | QDate DateBookWeekLst::date() { | 76 | QDate DateBookWeekLst::date() { |
@@ -107,7 +110,7 @@ void DateBookWeekLst::getEvents() { | |||
107 | if (!m_CurrentView) { | 110 | if (!m_CurrentView) { |
108 | if (dbl) { | 111 | if (dbl) { |
109 | m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | 112 | m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,ampm,scroll); |
110 | } else { | 113 | } else { |
111 | m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll); | 114 | m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,ampm,scroll); |
112 | } | 115 | } |
113 | m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 116 | m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
@@ -120,4 +123,5 @@ void DateBookWeekLst::getEvents() { | |||
120 | connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 123 | connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
121 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 124 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
125 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); | ||
122 | scroll->addChild(m_CurrentView); | 126 | scroll->addChild(m_CurrentView); |
123 | } else { | 127 | } else { |
@@ -131,4 +135,9 @@ void DateBookWeekLst::getEvents() { | |||
131 | } | 135 | } |
132 | 136 | ||
137 | void DateBookWeekLst::slotClockChanged( bool ap ) { | ||
138 | ampm = ap; | ||
139 | getEvents(); | ||
140 | } | ||
141 | |||
133 | void DateBookWeekLst::dateChanged(QDate &newdate) { | 142 | void DateBookWeekLst::dateChanged(QDate &newdate) { |
134 | dateset = true; | 143 | dateset = true; |
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.h b/core/pim/datebook/modules/weeklst/datebookweeklst.h index 505810b..53bed05 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklst.h +++ b/core/pim/datebook/modules/weeklst/datebookweeklst.h | |||
@@ -36,4 +36,5 @@ public slots: | |||
36 | protected slots: | 36 | protected slots: |
37 | void keyPressEvent(QKeyEvent *); | 37 | void keyPressEvent(QKeyEvent *); |
38 | void slotClockChanged(bool); | ||
38 | void setDbl(bool on); | 39 | void setDbl(bool on); |
39 | 40 | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp index 6389822..5182df1 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp | |||
@@ -6,8 +6,8 @@ | |||
6 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 6 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
7 | QValueList<EffectiveEvent> &ev2, | 7 | QValueList<EffectiveEvent> &ev2, |
8 | QDate &d, bool onM, | 8 | QDate &d, bool onM, bool showAmPm, |
9 | QWidget* parent, | 9 | QWidget* parent, |
10 | const char* name, WFlags fl) | 10 | const char* name, WFlags fl) |
11 | : QWidget( parent, name, fl ) | 11 | : QWidget( parent, name, fl ), ampm( showAmPm ) |
12 | { | 12 | { |
13 | m_MainLayout = new QHBoxLayout( this ); | 13 | m_MainLayout = new QHBoxLayout( this ); |
@@ -19,8 +19,8 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | |||
19 | 19 | ||
20 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 20 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
21 | QDate &d, bool onM, | 21 | QDate &d, bool onM, bool showAmPm, |
22 | QWidget* parent, | 22 | QWidget* parent, |
23 | const char* name, WFlags fl) | 23 | const char* name, WFlags fl) |
24 | : QWidget( parent, name, fl ) | 24 | : QWidget( parent, name, fl ), ampm( showAmPm ) |
25 | { | 25 | { |
26 | m_MainLayout = new QHBoxLayout( this ); | 26 | m_MainLayout = new QHBoxLayout( this ); |
@@ -36,5 +36,5 @@ void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueLis | |||
36 | setUpdatesEnabled(false); | 36 | setUpdatesEnabled(false); |
37 | if (!leftView) { | 37 | if (!leftView) { |
38 | leftView=new DateBookWeekLstView(ev1,d,onM,this); | 38 | leftView=new DateBookWeekLstView(ev1, d, onM, ampm, this); |
39 | m_MainLayout->addWidget(leftView); | 39 | m_MainLayout->addWidget(leftView); |
40 | connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 40 | connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
@@ -53,5 +53,5 @@ void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueLis | |||
53 | 53 | ||
54 | if (!rightView) { | 54 | if (!rightView) { |
55 | rightView=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 55 | rightView=new DateBookWeekLstView(ev2, d.addDays(7), onM, ampm, this); |
56 | m_MainLayout->addWidget(rightView); | 56 | m_MainLayout->addWidget(rightView); |
57 | connect (rightView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 57 | connect (rightView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
@@ -76,5 +76,5 @@ void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, | |||
76 | { | 76 | { |
77 | if (!leftView) { | 77 | if (!leftView) { |
78 | leftView=new DateBookWeekLstView(ev1,d,onM,this); | 78 | leftView=new DateBookWeekLstView(ev1, d, onM, ampm, this); |
79 | m_MainLayout->addWidget(leftView); | 79 | m_MainLayout->addWidget(leftView); |
80 | connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 80 | connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
@@ -100,5 +100,5 @@ void DateBookWeekLstDblView::setRightEvents(QValueList<EffectiveEvent> &ev1,QDat | |||
100 | { | 100 | { |
101 | if (!rightView) { | 101 | if (!rightView) { |
102 | rightView=new DateBookWeekLstView(ev1,d,onM,this); | 102 | rightView=new DateBookWeekLstView(ev1, d, onM, ampm, this); |
103 | m_MainLayout->addWidget(rightView); | 103 | m_MainLayout->addWidget(rightView); |
104 | connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 104 | connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h index 808556e..9eb17e0 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h +++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h | |||
@@ -17,9 +17,9 @@ public: | |||
17 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 17 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
18 | QValueList<EffectiveEvent> &ev2, | 18 | QValueList<EffectiveEvent> &ev2, |
19 | QDate &d, bool onM, | 19 | QDate &d, bool onM, bool showAmPm, |
20 | QWidget* parent = 0, const char* name = 0, | 20 | QWidget* parent = 0, const char* name = 0, |
21 | WFlags fl = 0 ); | 21 | WFlags fl = 0 ); |
22 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 22 | DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
23 | QDate &d, bool onM, | 23 | QDate &d, bool onM, bool showAmPm, |
24 | QWidget* parent = 0, const char* name = 0, | 24 | QWidget* parent = 0, const char* name = 0, |
25 | WFlags fl = 0 ); | 25 | WFlags fl = 0 ); |
@@ -44,4 +44,5 @@ protected: | |||
44 | QHBoxLayout*m_MainLayout; | 44 | QHBoxLayout*m_MainLayout; |
45 | DateBookWeekLstView *leftView,*rightView; | 45 | DateBookWeekLstView *leftView,*rightView; |
46 | bool ampm; | ||
46 | }; | 47 | }; |
47 | 48 | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp index 797f766..881e8f1 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp | |||
@@ -9,9 +9,9 @@ | |||
9 | #include <qpopupmenu.h> | 9 | #include <qpopupmenu.h> |
10 | 10 | ||
11 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | 11 | DateBookWeekLstEvent::DateBookWeekLstEvent(bool ap, const EffectiveEvent &ev, |
12 | int weeklistviewconfig, | 12 | int weeklistviewconfig, |
13 | QWidget* parent, | 13 | QWidget* parent, |
14 | const char* name, | 14 | const char* name, |
15 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) | 15 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev), ampm(ap) |
16 | { | 16 | { |
17 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", | 17 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", |
@@ -19,14 +19,27 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | |||
19 | 19 | ||
20 | odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; | 20 | odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; |
21 | if(weeklistviewconfig==NONE) { // No times displayed. | 21 | if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. |
22 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 22 | if ( ampm ) { |
23 | // middle.sprintf("<--->"); | 23 | int shour = ev.start().hour(); |
24 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | 24 | int smin = ev.start().minute(); |
25 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | 25 | if ( shour >= 12 ) { |
26 | } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. | 26 | if ( shour > 12 ) { |
27 | shour -= 12; | ||
28 | } | ||
29 | start.sprintf( "%.2d:%.2d PM", shour, smin ); | ||
30 | day.sprintf("%.2d:%.2d PM",shour,smin); | ||
31 | } else { | ||
32 | if ( shour == 0 ) { | ||
33 | shour = 12; | ||
34 | } | ||
35 | start.sprintf( "%.2d:%.2d AM", shour, smin ); | ||
36 | day.sprintf("%.2d:%.2d AM",shour,smin); | ||
37 | } | ||
38 | } else { | ||
27 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | 39 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); |
40 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
41 | } | ||
28 | middle.sprintf(" |---"); | 42 | middle.sprintf(" |---"); |
29 | end.sprintf("__|__"); | 43 | end.sprintf("__|__"); |
30 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
31 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. | 44 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. |
32 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 45 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); |
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.h b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h index 77f6283..1e3cd5d 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstevent.h +++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h | |||
@@ -10,5 +10,5 @@ class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel | |||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | public: | 11 | public: |
12 | DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, | 12 | DateBookWeekLstEvent(bool ampm, const EffectiveEvent &ev, int weeklistviewconfig =1, |
13 | QWidget* parent = 0, const char* name = 0, | 13 | QWidget* parent = 0, const char* name = 0, |
14 | WFlags fl = 0); | 14 | WFlags fl = 0); |
@@ -29,4 +29,5 @@ private: | |||
29 | protected: | 29 | protected: |
30 | void mousePressEvent( QMouseEvent *e ); | 30 | void mousePressEvent( QMouseEvent *e ); |
31 | bool ampm; | ||
31 | }; | 32 | }; |
32 | 33 | ||
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp index 82b9c6d..469a60a 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp | |||
@@ -8,4 +8,5 @@ | |||
8 | 8 | ||
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | #include <qpe/qpeapplication.h> | ||
10 | 11 | ||
11 | #include <qlayout.h> | 12 | #include <qlayout.h> |
@@ -13,8 +14,8 @@ | |||
13 | 14 | ||
14 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 15 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
15 | const QDate &d, bool onM, | 16 | const QDate &d, bool onM, bool showAmPm, |
16 | QWidget* parent, | 17 | QWidget* parent, |
17 | const char* name, WFlags fl) | 18 | const char* name, WFlags fl) |
18 | : QWidget( parent, name, fl ) | 19 | : QWidget( parent, name, fl ), ampm(showAmPm) |
19 | { | 20 | { |
20 | childs.clear(); | 21 | childs.clear(); |
@@ -72,9 +73,10 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate | |||
72 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 73 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
73 | tlayout->addWidget(hdr); | 74 | tlayout->addWidget(hdr); |
75 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); | ||
74 | 76 | ||
75 | // Events | 77 | // Events |
76 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 78 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
77 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. | 79 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. |
78 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,w); | 80 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(ampm,*it,weeklistviewconfig,w); |
79 | tlayout->addWidget(l); | 81 | tlayout->addWidget(l); |
80 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 82 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
@@ -88,12 +90,12 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate | |||
88 | tlayout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 90 | tlayout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
89 | m_MainLayout->addWidget(w); | 91 | m_MainLayout->addWidget(w); |
90 | /* | ||
91 | QSpacerItem * tmp = new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding); | ||
92 | m_MainLayout->addItem(tmp); | ||
93 | */ | ||
94 | } | 92 | } |
95 | setUpdatesEnabled(true); | 93 | setUpdatesEnabled(true); |
96 | } | 94 | } |
97 | 95 | ||
96 | void DateBookWeekLstView::slotClockChanged( bool ap ) { | ||
97 | ampm = ap; | ||
98 | } | ||
99 | |||
98 | DateBookWeekLstView::~DateBookWeekLstView() | 100 | DateBookWeekLstView::~DateBookWeekLstView() |
99 | {} | 101 | {} |
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.h b/core/pim/datebook/modules/weeklst/datebookweeklstview.h index 3d47842..900101d 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstview.h +++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.h | |||
@@ -16,5 +16,7 @@ class DateBookWeekLstView: public QWidget | |||
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | public: | 17 | public: |
18 | DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0, | 18 | DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, |
19 | bool onM, bool showAmPm, QWidget* parent = 0, | ||
20 | const char* name = 0, | ||
19 | WFlags fl = 0 ); | 21 | WFlags fl = 0 ); |
20 | ~DateBookWeekLstView(); | 22 | ~DateBookWeekLstView(); |
@@ -31,6 +33,8 @@ signals: | |||
31 | void addEvent(const QDateTime &start, const QDateTime &stop, | 33 | void addEvent(const QDateTime &start, const QDateTime &stop, |
32 | const QString &str, const QString &location); | 34 | const QString &str, const QString &location); |
35 | |||
33 | protected: | 36 | protected: |
34 | bool bStartOnMonday; | 37 | bool bStartOnMonday; |
38 | bool ampm; | ||
35 | QValueList<QObject*> childs; | 39 | QValueList<QObject*> childs; |
36 | 40 | ||
@@ -39,4 +43,5 @@ protected: | |||
39 | protected slots: | 43 | protected slots: |
40 | void keyPressEvent(QKeyEvent *); | 44 | void keyPressEvent(QKeyEvent *); |
45 | void slotClockChanged( bool ap ); | ||
41 | }; | 46 | }; |
42 | 47 | ||