summaryrefslogtreecommitdiff
authorerik <erik>2007-04-23 20:46:34 (UTC)
committer erik <erik>2007-04-23 20:46:34 (UTC)
commit34975323367e4a903886cd317b34192f1271a1f2 (patch) (unidiff)
tree8898d9010cdb89b371e0bccdbf717f87359d8513
parentd38e40fe9ee475230425fa83e924c49e5946b87c (diff)
downloadopie-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 (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklst.cpp15
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklst.h1
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp16
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstdblview.h5
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp183
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstevent.h3
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstview.cpp18
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstview.h7
8 files changed, 140 insertions, 108 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
@@ -12,2 +12,3 @@
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include <qpe/qpeapplication.h>
13 14
@@ -70,3 +71,5 @@ void DateBookWeekLst::setDbl(bool on) {
70 71
71void DateBookWeekLst::redraw() {getEvents();} 72void DateBookWeekLst::redraw() {
73 getEvents();
74}
72 75
@@ -108,5 +111,5 @@ void DateBookWeekLst::getEvents() {
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 }
@@ -121,2 +124,3 @@ void DateBookWeekLst::getEvents() {
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);
@@ -132,2 +136,7 @@ void DateBookWeekLst::getEvents() {
132 136
137void DateBookWeekLst::slotClockChanged( bool ap ) {
138 ampm = ap;
139 getEvents();
140}
141
133void DateBookWeekLst::dateChanged(QDate &newdate) { 142void DateBookWeekLst::dateChanged(QDate &newdate) {
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
@@ -37,2 +37,3 @@ protected slots:
37 void keyPressEvent(QKeyEvent *); 37 void keyPressEvent(QKeyEvent *);
38 void slotClockChanged(bool);
38 void setDbl(bool on); 39 void setDbl(bool on);
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
@@ -7,6 +7,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{
@@ -20,6 +20,6 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
20DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 20DateBookWeekLstDblView::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{
@@ -37,3 +37,3 @@ void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueLis
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);
@@ -54,3 +54,3 @@ void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueLis
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);
@@ -77,3 +77,3 @@ void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QDate &d,
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);
@@ -101,3 +101,3 @@ void DateBookWeekLstDblView::setRightEvents(QValueList<EffectiveEvent> &ev1,QDat
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);
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
@@ -18,3 +18,3 @@ public:
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,
@@ -22,3 +22,3 @@ public:
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,
@@ -45,2 +45,3 @@ protected:
45 DateBookWeekLstView *leftView,*rightView; 45 DateBookWeekLstView *leftView,*rightView;
46 bool ampm;
46}; 47};
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
@@ -1,85 +1,98 @@
1#include "datebookweeklstevent.h" 1#include "datebookweeklstevent.h"
2#include "datebooktypes.h" 2#include "datebooktypes.h"
3 3
4#include <opie2/odebug.h> 4#include <opie2/odebug.h>
5 5
6#include <qpe/ir.h> 6#include <qpe/ir.h>
7 7
8#include <qstring.h> 8#include <qstring.h>
9#include <qpopupmenu.h> 9#include <qpopupmenu.h>
10 10
11DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 11DateBookWeekLstEvent::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",
18 QString s,start,middle,end,day; 18 QString s,start,middle,end,day;
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 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 27 shour -= 12;
28 middle.sprintf(" |---"); 28 }
29 end.sprintf("__|__"); 29 start.sprintf( "%.2d:%.2d PM", shour, smin );
30 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 30 day.sprintf("%.2d:%.2d PM",shour,smin);
31 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 31 } else {
32 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 32 if ( shour == 0 ) {
33 middle.sprintf("<--->"); 33 shour = 12;
34 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 34 }
35 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 35 start.sprintf( "%.2d:%.2d AM", shour, smin );
36 } 36 day.sprintf("%.2d:%.2d AM",shour,smin);
37 37 }
38 if(ev.event().type() == Event::Normal) { 38 } else {
39 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. 39 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
40 s=day; 40 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
41 } else if(ev.startDate()==ev.date()) { // start event. 41 }
42 s=start; 42 middle.sprintf(" |---");
43 } else if(ev.endDate()==ev.date()) { // end event. 43 end.sprintf("__|__");
44 s=end; 44 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
45 } else { // middle day. 45 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
46 s=middle; 46 middle.sprintf("<--->");
47 } 47 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
48 } else { 48 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
49 s=""; 49 }
50 } 50
51 setText(QString(s) + " " + ev.description()); 51 if(ev.event().type() == Event::Normal) {
52// connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 52 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event.
53 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 53 s=day;
54} 54 } else if(ev.startDate()==ev.date()) { // start event.
55void DateBookWeekLstEvent::editMe() { 55 s=start;
56 emit editEvent(event.event()); 56 } else if(ev.endDate()==ev.date()) { // end event.
57} 57 s=end;
58void DateBookWeekLstEvent::duplicateMe() 58 } else { // middle day.
59{ 59 s=middle;
60 emit duplicateEvent(event.event()); 60 }
61} 61 } else {
62void DateBookWeekLstEvent::deleteMe() 62 s="";
63{ 63 }
64 emit removeEvent(event.event()); 64 setText(QString(s) + " " + ev.description());
65 emit redraw(); 65// connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
66} 66 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
67void DateBookWeekLstEvent::beamMe() 67}
68{ 68void DateBookWeekLstEvent::editMe() {
69 emit beamEvent( event.event() ); 69 emit editEvent(event.event());
70} 70}
71void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) 71void DateBookWeekLstEvent::duplicateMe()
72{ 72{
73 if (!event.event().isValidUid()) { 73 emit duplicateEvent(event.event());
74 // this is just such a holiday event. 74}
75 return; 75void DateBookWeekLstEvent::deleteMe()
76 } 76{
77 popmenue = new QPopupMenu; 77 emit removeEvent(event.event());
78 78 emit redraw();
79 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); 79}
80 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); 80void DateBookWeekLstEvent::beamMe()
81 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); 81{
82 if(Ir::supported()) 82 emit beamEvent( event.event() );
83 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); 83}
84 popmenue->popup( mapToGlobal( e->pos() )); 84void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
85} 85{
86 if (!event.event().isValidUid()) {
87 // this is just such a holiday event.
88 return;
89 }
90 popmenue = new QPopupMenu;
91
92 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
93 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
94 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
95 if(Ir::supported())
96 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
97 popmenue->popup( mapToGlobal( e->pos() ));
98}
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
@@ -11,3 +11,3 @@ class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
11public: 11public:
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,
@@ -30,2 +30,3 @@ protected:
30 void mousePressEvent( QMouseEvent *e ); 30 void mousePressEvent( QMouseEvent *e );
31 bool ampm;
31}; 32};
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
@@ -9,2 +9,3 @@
9#include <qpe/config.h> 9#include <qpe/config.h>
10#include <qpe/qpeapplication.h>
10 11
@@ -14,6 +15,6 @@
14DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 15DateBookWeekLstView::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{
@@ -67,3 +68,3 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate
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);
@@ -73,2 +74,3 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate
73 tlayout->addWidget(hdr); 74 tlayout->addWidget(hdr);
75 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
74 76
@@ -77,3 +79,3 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate
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);
@@ -89,6 +91,2 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate
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 }
@@ -97,2 +95,6 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate
97 95
96void DateBookWeekLstView::slotClockChanged( bool ap ) {
97 ampm = ap;
98}
99
98DateBookWeekLstView::~DateBookWeekLstView() 100DateBookWeekLstView::~DateBookWeekLstView()
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
@@ -17,3 +17,5 @@ class DateBookWeekLstView: public QWidget
17public: 17public:
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 );
@@ -32,4 +34,6 @@ signals:
32 const QString &str, const QString &location); 34 const QString &str, const QString &location);
35
33protected: 36protected:
34 bool bStartOnMonday; 37 bool bStartOnMonday;
38 bool ampm;
35 QValueList<QObject*> childs; 39 QValueList<QObject*> childs;
@@ -40,2 +44,3 @@ protected slots:
40 void keyPressEvent(QKeyEvent *); 44 void keyPressEvent(QKeyEvent *);
45 void slotClockChanged( bool ap );
41}; 46};