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
@@ -1,158 +1,167 @@
1#include "namespace_hack.h" 1#include "namespace_hack.h"
2#include "datebookweeklst.h" 2#include "datebookweeklst.h"
3#include "datebookweeklstheader.h" 3#include "datebookweeklstheader.h"
4#include "datebookweeklstview.h" 4#include "datebookweeklstview.h"
5#include "datebookweeklstdblview.h" 5#include "datebookweeklstdblview.h"
6 6
7#include "datebook.h" 7#include "datebook.h"
8 8
9#include <opie2/odebug.h> 9#include <opie2/odebug.h>
10 10
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>
15#include <qtoolbutton.h> 16#include <qtoolbutton.h>
16 17
17using namespace Opie::Ui; 18using namespace Opie::Ui;
18 19
19DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, 20DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
20 QWidget *parent, 21 QWidget *parent,
21 const char *name ) 22 const char *name )
22 : QWidget( parent, name ), 23 : QWidget( parent, name ),
23 db( newDB ), 24 db( newDB ),
24 startTime( 0 ), 25 startTime( 0 ),
25 ampm( ap ), 26 ampm( ap ),
26 bStartOnMonday(onM) 27 bStartOnMonday(onM)
27{ 28{
28 setFocusPolicy(StrongFocus); 29 setFocusPolicy(StrongFocus);
29 dateset = false; 30 dateset = false;
30 layout = new QVBoxLayout( this ); 31 layout = new QVBoxLayout( this );
31 layout->setMargin(0); 32 layout->setMargin(0);
32 33
33 header=new DateBookWeekLstHeader(onM, this); 34 header=new DateBookWeekLstHeader(onM, this);
34 layout->addWidget( header ); 35 layout->addWidget( header );
35 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); 36 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
36 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 37 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
37 38
38 scroll=new QScrollView(this); 39 scroll=new QScrollView(this);
39 scroll->setResizePolicy(QScrollView::AutoOneFit); 40 scroll->setResizePolicy(QScrollView::AutoOneFit);
40 layout->addWidget(scroll); 41 layout->addWidget(scroll);
41 42
42 m_CurrentView=NULL; 43 m_CurrentView=NULL;
43 Config config("DateBook"); 44 Config config("DateBook");
44 config.setGroup("Main"); 45 config.setGroup("Main");
45 dbl=config.readBoolEntry("weeklst_dbl", false); 46 dbl=config.readBoolEntry("weeklst_dbl", false);
46 header->dbl->setOn(dbl); 47 header->dbl->setOn(dbl);
47} 48}
48 49
49DateBookWeekLst::~DateBookWeekLst(){ 50DateBookWeekLst::~DateBookWeekLst(){
50 Config config("DateBook"); 51 Config config("DateBook");
51 config.setGroup("Main"); 52 config.setGroup("Main");
52 config.writeEntry("weeklst_dbl", dbl); 53 config.writeEntry("weeklst_dbl", dbl);
53} 54}
54 55
55void DateBookWeekLst::setDate(const QDate &d) { 56void DateBookWeekLst::setDate(const QDate &d) {
56 bdate=d; 57 bdate=d;
57 header->setDate(d); 58 header->setDate(d);
58} 59}
59 60
60void DateBookWeekLst::setDbl(bool on) { 61void DateBookWeekLst::setDbl(bool on) {
61 dbl=on; 62 dbl=on;
62 bool displayed = false; 63 bool displayed = false;
63 if (m_CurrentView) { 64 if (m_CurrentView) {
64 displayed = m_CurrentView->toggleDoubleView(on); 65 displayed = m_CurrentView->toggleDoubleView(on);
65 } 66 }
66 if (!displayed||dbl) { 67 if (!displayed||dbl) {
67 getEvents(); 68 getEvents();
68 } 69 }
69} 70}
70 71
71void DateBookWeekLst::redraw() {getEvents();} 72void DateBookWeekLst::redraw() {
73 getEvents();
74}
72 75
73QDate DateBookWeekLst::date() { 76QDate DateBookWeekLst::date() {
74 return bdate; 77 return bdate;
75} 78}
76 79
77// return the date at the beginning of the week... 80// return the date at the beginning of the week...
78// copied from DateBookWeek 81// copied from DateBookWeek
79QDate DateBookWeekLst::weekDate() const 82QDate DateBookWeekLst::weekDate() const
80{ 83{
81 QDate d=bdate; 84 QDate d=bdate;
82 85
83 // Calculate offset to first day of week. 86 // Calculate offset to first day of week.
84 int dayoffset=d.dayOfWeek(); 87 int dayoffset=d.dayOfWeek();
85 if(bStartOnMonday) dayoffset--; 88 if(bStartOnMonday) dayoffset--;
86 else if( dayoffset == 7 ) 89 else if( dayoffset == 7 )
87 dayoffset = 0; 90 dayoffset = 0;
88 91
89 return d.addDays(-dayoffset); 92 return d.addDays(-dayoffset);
90} 93}
91 94
92void DateBookWeekLst::getEvents() { 95void DateBookWeekLst::getEvents() {
93 if (!dateset) return; 96 if (!dateset) return;
94 QDate start = weekDate(); //date(); 97 QDate start = weekDate(); //date();
95 QDate stop = start.addDays(6); 98 QDate stop = start.addDays(6);
96 QDate start2; 99 QDate start2;
97 100
98 101
99 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 102 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
100 QValueList<EffectiveEvent> el2; 103 QValueList<EffectiveEvent> el2;
101 104
102 if (dbl) { 105 if (dbl) {
103 start2 = start.addDays(7); 106 start2 = start.addDays(7);
104 stop = start2.addDays(6); 107 stop = start2.addDays(6);
105 el2 = db->getEffectiveEvents(start2, stop); 108 el2 = db->getEffectiveEvents(start2, stop);
106 } 109 }
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));
114 connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 117 connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
115 connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 118 connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
116 connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 119 connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
117 connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 120 connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
118 connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw())); 121 connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw()));
119 connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 122 connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
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 {
124 if (dbl) { 128 if (dbl) {
125 m_CurrentView->setEvents(el,el2,start,bStartOnMonday); 129 m_CurrentView->setEvents(el,el2,start,bStartOnMonday);
126 } else { 130 } else {
127 m_CurrentView->setEvents(el,start,bStartOnMonday); 131 m_CurrentView->setEvents(el,start,bStartOnMonday);
128 } 132 }
129 } 133 }
130 scroll->updateScrollBars(); 134 scroll->updateScrollBars();
131} 135}
132 136
137void DateBookWeekLst::slotClockChanged( bool ap ) {
138 ampm = ap;
139 getEvents();
140}
141
133void DateBookWeekLst::dateChanged(QDate &newdate) { 142void DateBookWeekLst::dateChanged(QDate &newdate) {
134 dateset = true; 143 dateset = true;
135 bdate=newdate; 144 bdate=newdate;
136 odebug << "Date changed " << oendl; 145 odebug << "Date changed " << oendl;
137 getEvents(); 146 getEvents();
138} 147}
139 148
140void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 149void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
141{ 150{
142 switch(e->key()) { 151 switch(e->key()) {
143 case Key_Up: 152 case Key_Up:
144 scroll->scrollBy(0, -20); 153 scroll->scrollBy(0, -20);
145 break; 154 break;
146 case Key_Down: 155 case Key_Down:
147 scroll->scrollBy(0, 20); 156 scroll->scrollBy(0, 20);
148 break; 157 break;
149 case Key_Left: 158 case Key_Left:
150 header->prevWeek(); 159 header->prevWeek();
151 break; 160 break;
152 case Key_Right: 161 case Key_Right:
153 header->nextWeek(); 162 header->nextWeek();
154 break; 163 break;
155 default: 164 default:
156 e->ignore(); 165 e->ignore();
157 } 166 }
158} 167}
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
@@ -1,66 +1,67 @@
1#ifndef DATEBOOKWEEKLST 1#ifndef DATEBOOKWEEKLST
2#define DATEBOOKWEEKLST 2#define DATEBOOKWEEKLST
3 3
4#include <qpe/event.h> 4#include <qpe/event.h>
5 5
6#include <qwidget.h> 6#include <qwidget.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8 8
9class DateBookDB; 9class DateBookDB;
10class DateBookDBHoliday; 10class DateBookDBHoliday;
11class DateBookWeekLstHeader; 11class DateBookWeekLstHeader;
12class DateBookWeekLstEvent; 12class DateBookWeekLstEvent;
13class DateBookWeekLstDblView; 13class DateBookWeekLstDblView;
14class QVBoxLayout; 14class QVBoxLayout;
15class QScrollView; 15class QScrollView;
16 16
17class DateBookWeekLst : public QWidget 17class DateBookWeekLst : public QWidget
18{ 18{
19 Q_OBJECT 19 Q_OBJECT
20 20
21public: 21public:
22 DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB, 22 DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB,
23 QWidget *parent = 0, 23 QWidget *parent = 0,
24 const char *name = 0 ); 24 const char *name = 0 );
25 ~DateBookWeekLst(); 25 ~DateBookWeekLst();
26 void setDate( int y, int w ); 26 void setDate( int y, int w );
27 void setDate(const QDate &d ); 27 void setDate(const QDate &d );
28 int week() const { return _week; }; 28 int week() const { return _week; };
29 QDate date(); 29 QDate date();
30 QDate weekDate() const; 30 QDate weekDate() const;
31 31
32public slots: 32public slots:
33 void redraw(); 33 void redraw();
34 void dateChanged(QDate &date); 34 void dateChanged(QDate &date);
35 35
36protected slots: 36protected 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
40signals: 41signals:
41 void showDate(int y, int m, int d); 42 void showDate(int y, int m, int d);
42 void addEvent(const QDateTime &start, const QDateTime &stop, 43 void addEvent(const QDateTime &start, const QDateTime &stop,
43 const QString &str, const QString &location); 44 const QString &str, const QString &location);
44 void editEvent(const Event &e); 45 void editEvent(const Event &e);
45 void duplicateEvent(const Event &e); 46 void duplicateEvent(const Event &e);
46 void removeEvent(const Event &e); 47 void removeEvent(const Event &e);
47 void beamEvent(const Event &e); 48 void beamEvent(const Event &e);
48 49
49private: 50private:
50 DateBookDBHoliday *db; 51 DateBookDBHoliday *db;
51 int startTime; 52 int startTime;
52 bool ampm; 53 bool ampm;
53 bool bStartOnMonday; 54 bool bStartOnMonday;
54 bool dbl; 55 bool dbl;
55 QDate bdate; 56 QDate bdate;
56 int year, _week,dow; 57 int year, _week,dow;
57 DateBookWeekLstHeader *header; 58 DateBookWeekLstHeader *header;
58 QVBoxLayout *layout; 59 QVBoxLayout *layout;
59 QScrollView *scroll; 60 QScrollView *scroll;
60 DateBookWeekLstDblView*m_CurrentView; 61 DateBookWeekLstDblView*m_CurrentView;
61 bool dateset:1; 62 bool dateset:1;
62 63
63 void getEvents(); 64 void getEvents();
64}; 65};
65 66
66#endif 67#endif
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
@@ -1,131 +1,131 @@
1#include "datebookweeklstdblview.h" 1#include "datebookweeklstdblview.h"
2#include "datebookweeklstview.h" 2#include "datebookweeklstview.h"
3 3
4#include <qlayout.h> 4#include <qlayout.h>
5 5
6DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 6DateBookWeekLstDblView::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 );
14 14
15 leftView = 0; 15 leftView = 0;
16 rightView = 0; 16 rightView = 0;
17 setEvents(ev1,ev2,d,onM); 17 setEvents(ev1,ev2,d,onM);
18} 18}
19 19
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{
26 m_MainLayout = new QHBoxLayout( this ); 26 m_MainLayout = new QHBoxLayout( this );
27 27
28 leftView = 0; 28 leftView = 0;
29 rightView = 0; 29 rightView = 0;
30 setEvents(ev1,d,onM); 30 setEvents(ev1,d,onM);
31} 31}
32 32
33/* setting the variant with both views */ 33/* setting the variant with both views */
34void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM) 34void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM)
35{ 35{
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&)));
41 connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 41 connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
42 connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 42 connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
43 connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 43 connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
44 connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw())); 44 connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
45 connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 45 connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
46 connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 46 connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
47 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 47 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
48 48
49 } else { 49 } else {
50 leftView->hide(); 50 leftView->hide();
51 leftView->setEvents(ev1,d,onM); 51 leftView->setEvents(ev1,d,onM);
52 } 52 }
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&)));
58 connect (rightView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 58 connect (rightView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
59 connect (rightView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 59 connect (rightView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
60 connect (rightView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 60 connect (rightView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
61 connect (rightView, SIGNAL(redraw()), this, SIGNAL(redraw())); 61 connect (rightView, SIGNAL(redraw()), this, SIGNAL(redraw()));
62 connect (rightView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 62 connect (rightView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
63 connect (rightView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 63 connect (rightView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
64 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 64 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
65 } else { 65 } else {
66 rightView->hide(); 66 rightView->hide();
67 rightView->setEvents(ev2,d.addDays(7),onM); 67 rightView->setEvents(ev2,d.addDays(7),onM);
68 } 68 }
69 69
70 leftView->show(); 70 leftView->show();
71 rightView->show(); 71 rightView->show();
72 setUpdatesEnabled(true); 72 setUpdatesEnabled(true);
73} 73}
74 74
75void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM) 75void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM)
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&)));
81 connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 81 connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
82 connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 82 connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
83 connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 83 connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
84 connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw())); 84 connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
85 connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 85 connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
86 connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 86 connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
87 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 87 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
88 } else { 88 } else {
89 leftView->hide(); 89 leftView->hide();
90 leftView->setEvents(ev1,d,onM); 90 leftView->setEvents(ev1,d,onM);
91 } 91 }
92 leftView->show(); 92 leftView->show();
93 93
94 if (rightView) { 94 if (rightView) {
95 rightView->hide(); 95 rightView->hide();
96 } 96 }
97} 97}
98 98
99void DateBookWeekLstDblView::setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM) 99void DateBookWeekLstDblView::setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM)
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&)));
105 connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 105 connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
106 connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 106 connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
107 connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 107 connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
108 connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw())); 108 connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
109 connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 109 connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
110 connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 110 connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
111 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 111 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
112 } else { 112 } else {
113 rightView->hide(); 113 rightView->hide();
114 rightView->setEvents(ev1,d,onM); 114 rightView->setEvents(ev1,d,onM);
115 } 115 }
116 rightView->show(); 116 rightView->show();
117} 117}
118 118
119bool DateBookWeekLstDblView::toggleDoubleView(bool how) 119bool DateBookWeekLstDblView::toggleDoubleView(bool how)
120{ 120{
121 if (rightView) { 121 if (rightView) {
122 if (how) rightView->show(); 122 if (how) rightView->show();
123 else rightView->hide(); 123 else rightView->hide();
124 return true; 124 return true;
125 } 125 }
126 return false; 126 return false;
127} 127}
128 128
129DateBookWeekLstDblView::~DateBookWeekLstDblView() 129DateBookWeekLstDblView::~DateBookWeekLstDblView()
130{ 130{
131} 131}
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
@@ -1,48 +1,49 @@
1#ifndef _DATEBOOKWEEKLSTDBLVIEW_H 1#ifndef _DATEBOOKWEEKLSTDBLVIEW_H
2#define _DATEBOOKWEEKLSTDBLVIEW_H 2#define _DATEBOOKWEEKLSTDBLVIEW_H
3 3
4#include <qpe/event.h> 4#include <qpe/event.h>
5 5
6#include <qwidget.h> 6#include <qwidget.h>
7#include <qvaluelist.h> 7#include <qvaluelist.h>
8#include <qdatetime.h> 8#include <qdatetime.h>
9#include <qstring.h> 9#include <qstring.h>
10 10
11class DateBookWeekLstView; 11class DateBookWeekLstView;
12class QHBoxLayout; 12class QHBoxLayout;
13 13
14class DateBookWeekLstDblView: public QWidget { 14class DateBookWeekLstDblView: public QWidget {
15 Q_OBJECT 15 Q_OBJECT
16public: 16public:
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 );
26 virtual ~DateBookWeekLstDblView(); 26 virtual ~DateBookWeekLstDblView();
27 void setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM); 27 void setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM);
28 void setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM); 28 void setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM);
29 void setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM); 29 void setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM);
30 30
31 bool toggleDoubleView(bool how); 31 bool toggleDoubleView(bool how);
32 32
33signals: 33signals:
34 void editEvent(const Event &e); 34 void editEvent(const Event &e);
35 void duplicateEvent(const Event &e); 35 void duplicateEvent(const Event &e);
36 void removeEvent(const Event &e); 36 void removeEvent(const Event &e);
37 void beamEvent(const Event &e); 37 void beamEvent(const Event &e);
38 void redraw(); 38 void redraw();
39 void showDate(int y, int m, int d); 39 void showDate(int y, int m, int d);
40 void addEvent(const QDateTime &start, const QDateTime &stop, 40 void addEvent(const QDateTime &start, const QDateTime &stop,
41 const QString &str, const QString &location); 41 const QString &str, const QString &location);
42 42
43protected: 43protected:
44 QHBoxLayout*m_MainLayout; 44 QHBoxLayout*m_MainLayout;
45 DateBookWeekLstView *leftView,*rightView; 45 DateBookWeekLstView *leftView,*rightView;
46 bool ampm;
46}; 47};
47 48
48#endif 49#endif
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
@@ -1,34 +1,35 @@
1#ifndef _DATEBOOKWEEKLSTEVENT_H 1#ifndef _DATEBOOKWEEKLSTEVENT_H
2#define _DATEBOOKWEEKLSTEVENT_H 2#define _DATEBOOKWEEKLSTEVENT_H
3 3
4#include <opie2/oclickablelabel.h> 4#include <opie2/oclickablelabel.h>
5 5
6#include <qpe/event.h> 6#include <qpe/event.h>
7 7
8class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel 8class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
9{ 9{
10 Q_OBJECT 10 Q_OBJECT
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,
14 WFlags fl = 0); 14 WFlags fl = 0);
15signals: 15signals:
16 void editEvent(const Event &e); 16 void editEvent(const Event &e);
17 void duplicateEvent(const Event &e); 17 void duplicateEvent(const Event &e);
18 void removeEvent(const Event &e); 18 void removeEvent(const Event &e);
19 void beamEvent(const Event &e); 19 void beamEvent(const Event &e);
20 void redraw(); 20 void redraw();
21private slots: 21private slots:
22 void editMe(); 22 void editMe();
23 void duplicateMe(); 23 void duplicateMe();
24 void deleteMe(); 24 void deleteMe();
25 void beamMe(); 25 void beamMe();
26private: 26private:
27 const EffectiveEvent event; 27 const EffectiveEvent event;
28 QPopupMenu* popmenue; 28 QPopupMenu* popmenue;
29protected: 29protected:
30 void mousePressEvent( QMouseEvent *e ); 30 void mousePressEvent( QMouseEvent *e );
31 bool ampm;
31}; 32};
32 33
33 34
34#endif 35#endif
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
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{
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
25void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM) 26void 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
96void DateBookWeekLstView::slotClockChanged( bool ap ) {
97 ampm = ap;
98}
99
98DateBookWeekLstView::~DateBookWeekLstView() 100DateBookWeekLstView::~DateBookWeekLstView()
99{} 101{}
100 102
101void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) 103void DateBookWeekLstView::keyPressEvent(QKeyEvent *e)
102{ 104{
103 e->ignore(); 105 e->ignore();
104} 106}
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
@@ -1,43 +1,48 @@
1#ifndef _DATEBOOKWEEKLISTVIEW_H 1#ifndef _DATEBOOKWEEKLISTVIEW_H
2#define _DATEBOOKWEEKLISTVIEW_H 2#define _DATEBOOKWEEKLISTVIEW_H
3 3
4#include <qpe/event.h> 4#include <qpe/event.h>
5 5
6#include <qwidget.h> 6#include <qwidget.h>
7#include <qvaluelist.h> 7#include <qvaluelist.h>
8#include <qstring.h> 8#include <qstring.h>
9#include <qdatetime.h> 9#include <qdatetime.h>
10 10
11class QKeyEvent; 11class QKeyEvent;
12class QVBoxLayout; 12class QVBoxLayout;
13 13
14class DateBookWeekLstView: public QWidget 14class DateBookWeekLstView: public QWidget
15{ 15{
16 Q_OBJECT 16 Q_OBJECT
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 );
20 ~DateBookWeekLstView(); 22 ~DateBookWeekLstView();
21 23
22 void setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM); 24 void setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM);
23 25
24signals: 26signals:
25 void editEvent(const Event &e); 27 void editEvent(const Event &e);
26 void duplicateEvent(const Event &e); 28 void duplicateEvent(const Event &e);
27 void removeEvent(const Event &e); 29 void removeEvent(const Event &e);
28 void beamEvent(const Event &e); 30 void beamEvent(const Event &e);
29 void redraw(); 31 void redraw();
30 void showDate(int y, int m, int d); 32 void showDate(int y, int m, int d);
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
33protected: 36protected:
34 bool bStartOnMonday; 37 bool bStartOnMonday;
38 bool ampm;
35 QValueList<QObject*> childs; 39 QValueList<QObject*> childs;
36 40
37 QVBoxLayout*m_MainLayout; 41 QVBoxLayout*m_MainLayout;
38 42
39protected slots: 43protected slots:
40 void keyPressEvent(QKeyEvent *); 44 void keyPressEvent(QKeyEvent *);
45 void slotClockChanged( bool ap );
41}; 46};
42 47
43#endif 48#endif