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/datebook/modules/weeklst/datebookweeklstview.cpp | |
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!
Diffstat (limited to 'core/pim/datebook/modules/weeklst/datebookweeklstview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/modules/weeklst/datebookweeklstview.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
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 | |||
@@ -1,104 +1,106 @@ | |||
1 | #include "datebookweeklstview.h" | 1 | #include "datebookweeklstview.h" |
2 | #include "datebooktypes.h" | 2 | #include "datebooktypes.h" |
3 | #include "datebookweeklstdayhdr.h" | 3 | #include "datebookweeklstdayhdr.h" |
4 | #include "datebookweeklstheader.h" | 4 | #include "datebookweeklstheader.h" |
5 | #include "datebookweeklstevent.h" | 5 | #include "datebookweeklstevent.h" |
6 | 6 | ||
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
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> |
12 | #include <qtl.h> | 13 | #include <qtl.h> |
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(); |
21 | m_MainLayout = new QVBoxLayout( this ); | 22 | m_MainLayout = new QVBoxLayout( this ); |
22 | setEvents(ev,d,onM); | 23 | setEvents(ev,d,onM); |
23 | } | 24 | } |
24 | 25 | ||
25 | void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM) | 26 | void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM) |
26 | { | 27 | { |
27 | QValueList<QObject*>::Iterator wIter; | 28 | QValueList<QObject*>::Iterator wIter; |
28 | for (wIter=childs.begin();wIter!=childs.end();++wIter) { | 29 | for (wIter=childs.begin();wIter!=childs.end();++wIter) { |
29 | QObject*w = (*wIter); | 30 | QObject*w = (*wIter); |
30 | delete w; | 31 | delete w; |
31 | } | 32 | } |
32 | childs.clear(); | 33 | childs.clear(); |
33 | 34 | ||
34 | setUpdatesEnabled(false); | 35 | setUpdatesEnabled(false); |
35 | // m_MainLayout->deleteAllItems(); | 36 | // m_MainLayout->deleteAllItems(); |
36 | Config config("DateBook"); | 37 | Config config("DateBook"); |
37 | config.setGroup("Main"); | 38 | config.setGroup("Main"); |
38 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | 39 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); |
39 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; | 40 | odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; |
40 | 41 | ||
41 | bStartOnMonday=onM; | 42 | bStartOnMonday=onM; |
42 | setPalette(white); | 43 | setPalette(white); |
43 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 44 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); |
44 | 45 | ||
45 | qBubbleSort(ev); | 46 | qBubbleSort(ev); |
46 | QValueListIterator<EffectiveEvent> it; | 47 | QValueListIterator<EffectiveEvent> it; |
47 | it=ev.begin(); | 48 | it=ev.begin(); |
48 | 49 | ||
49 | int dayOrder[7]; | 50 | int dayOrder[7]; |
50 | if (bStartOnMonday) { | 51 | if (bStartOnMonday) { |
51 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 52 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
52 | } else { | 53 | } else { |
53 | for (int d=0; d<7; d++) dayOrder[d]=d; | 54 | for (int d=0; d<7; d++) dayOrder[d]=d; |
54 | dayOrder[0]=7; | 55 | dayOrder[0]=7; |
55 | } | 56 | } |
56 | 57 | ||
57 | // Calculate offset to first day of week. | 58 | // Calculate offset to first day of week. |
58 | int dayoffset=d.dayOfWeek(); | 59 | int dayoffset=d.dayOfWeek(); |
59 | if(bStartOnMonday) dayoffset--; | 60 | if(bStartOnMonday) dayoffset--; |
60 | else if( dayoffset == 7 ) dayoffset = 0; | 61 | else if( dayoffset == 7 ) dayoffset = 0; |
61 | 62 | ||
62 | for (int i=0; i<7; i++) { | 63 | for (int i=0; i<7; i++) { |
63 | QWidget*w = new QWidget(this); | 64 | QWidget*w = new QWidget(this); |
64 | w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 65 | w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); |
65 | w->setPalette(white); | 66 | w->setPalette(white); |
66 | QVBoxLayout * tlayout = new QVBoxLayout(w); | 67 | QVBoxLayout * tlayout = new QVBoxLayout(w); |
67 | childs.append(w); | 68 | childs.append(w); |
68 | // Header | 69 | // Header |
69 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,w); | 70 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,w); |
70 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 71 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
71 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 72 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
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&))); |
81 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 83 | connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); |
82 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 84 | connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); |
83 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 85 | connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |
84 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); | 86 | connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); |
85 | } | 87 | } |
86 | it++; | 88 | it++; |
87 | } | 89 | } |
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 | {} |
100 | 102 | ||
101 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) | 103 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) |
102 | { | 104 | { |
103 | e->ignore(); | 105 | e->ignore(); |
104 | } | 106 | } |