summaryrefslogtreecommitdiff
authorzecke <zecke>2004-03-14 18:58:59 (UTC)
committer zecke <zecke>2004-03-14 18:58:59 (UTC)
commitd91c046d1faaf9fb039bda5cc186c96d4ff2c227 (patch) (unidiff)
treec196f20c933d46cc913c9460f02ce3274bd21fc9
parentddfee0836adbd62be48888fbe05e7a79481e81c9 (diff)
downloadopie-d91c046d1faaf9fb039bda5cc186c96d4ff2c227.zip
opie-d91c046d1faaf9fb039bda5cc186c96d4ff2c227.tar.gz
opie-d91c046d1faaf9fb039bda5cc186c96d4ff2c227.tar.bz2
Opie DP changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/config.in2
-rw-r--r--core/pim/datebook/datebook.pro2
-rw-r--r--core/pim/datebook/datebookweeklst.cpp1
-rw-r--r--core/pim/datebook/datebookweeklst.h4
-rw-r--r--core/pim/datebook/dateentryimpl.cpp2
-rw-r--r--core/pim/datebook/main.cpp3
6 files changed, 8 insertions, 6 deletions
diff --git a/core/pim/datebook/config.in b/core/pim/datebook/config.in
index aa3e8fc..dd9c798 100644
--- a/core/pim/datebook/config.in
+++ b/core/pim/datebook/config.in
@@ -1,4 +1,4 @@
1 config DATEBOOK 1 config DATEBOOK
2 boolean "opie-datebook (a datebook/appointment manager)" 2 boolean "opie-datebook (a datebook/appointment manager)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIEUI2
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro
index f3b5a59..2b2efaa 100644
--- a/core/pim/datebook/datebook.pro
+++ b/core/pim/datebook/datebook.pro
@@ -1,40 +1,40 @@
1 CONFIG += qt warn_on release quick-app 1 CONFIG += qt warn_on release quick-app
2 HEADERS= datebookday.h \ 2 HEADERS= datebookday.h \
3 datebook.h \ 3 datebook.h \
4 dateentryimpl.h \ 4 dateentryimpl.h \
5 datebookdayheaderimpl.h \ 5 datebookdayheaderimpl.h \
6 datebooksettings.h \ 6 datebooksettings.h \
7 datebookweek.h \ 7 datebookweek.h \
8 datebookweeklst.h \ 8 datebookweeklst.h \
9 datebookweekheaderimpl.h \ 9 datebookweekheaderimpl.h \
10 repeatentry.h \ 10 repeatentry.h \
11 noteentryimpl.h \ 11 noteentryimpl.h \
12 onoteedit.h \ 12 onoteedit.h \
13 datebookdayallday.h 13 datebookdayallday.h
14 SOURCES= main.cpp \ 14 SOURCES= main.cpp \
15 datebookday.cpp \ 15 datebookday.cpp \
16 datebook.cpp \ 16 datebook.cpp \
17 dateentryimpl.cpp \ 17 dateentryimpl.cpp \
18 datebookdayheaderimpl.cpp \ 18 datebookdayheaderimpl.cpp \
19 datebooksettings.cpp \ 19 datebooksettings.cpp \
20 datebookweek.cpp \ 20 datebookweek.cpp \
21 datebookweeklst.cpp \ 21 datebookweeklst.cpp \
22 datebookweekheaderimpl.cpp \ 22 datebookweekheaderimpl.cpp \
23 repeatentry.cpp \ 23 repeatentry.cpp \
24 noteentryimpl.cpp \ 24 noteentryimpl.cpp \
25 onoteedit.cpp \ 25 onoteedit.cpp \
26 datebookdayallday.cpp 26 datebookdayallday.cpp
27 INTERFACES= dateentry.ui \ 27 INTERFACES= dateentry.ui \
28 datebookdayheader.ui \ 28 datebookdayheader.ui \
29 datebookweekheader.ui \ 29 datebookweekheader.ui \
30 datebookweeklstheader.ui \ 30 datebookweeklstheader.ui \
31 datebookweeklstdayhdr.ui \ 31 datebookweeklstdayhdr.ui \
32 repeatentrybase.ui \ 32 repeatentrybase.ui \
33 datebooksettingsbase.ui \ 33 datebooksettingsbase.ui \
34 noteentry.ui 34 noteentry.ui
35INCLUDEPATH += $(OPIEDIR)/include 35INCLUDEPATH += $(OPIEDIR)/include
36 DEPENDPATH+= $(OPIEDIR)/include 36 DEPENDPATH+= $(OPIEDIR)/include
37LIBS += -lqpe -lopie 37LIBS += -lqpe -lopieui2
38 TARGET = datebook 38 TARGET = datebook
39 39
40include ( $(OPIEDIR)/include.pro ) 40include ( $(OPIEDIR)/include.pro )
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index af40143..30c925d 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,394 +1,395 @@
1#include "datebookweeklst.h" 1#include "datebookweeklst.h"
2 2
3 3
4#include "datebook.h" 4#include "datebook.h"
5 5
6#include <qpe/datebookmonth.h> 6#include <qpe/datebookmonth.h>
7#include <qpe/config.h> 7#include <qpe/config.h>
8#include <qpe/resource.h> 8#include <qpe/resource.h>
9 9
10#include <qlayout.h> 10#include <qlayout.h>
11#include <qtoolbutton.h> 11#include <qtoolbutton.h>
12#include <qtl.h> 12#include <qtl.h>
13 13
14bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); 14bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
15 15
16using namespace Opie::Ui;
16DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) 17DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
17 : DateBookWeekLstHeaderBase(parent, name, fl) 18 : DateBookWeekLstHeaderBase(parent, name, fl)
18{ 19{
19 setBackgroundMode( PaletteButton ); 20 setBackgroundMode( PaletteButton );
20 labelDate->setBackgroundMode( PaletteButton ); 21 labelDate->setBackgroundMode( PaletteButton );
21 forwardweek->setBackgroundMode( PaletteButton ); 22 forwardweek->setBackgroundMode( PaletteButton );
22 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 23 forwardweek->setPixmap( Resource::loadPixmap("forward") );
23 forwardmonth->setBackgroundMode( PaletteButton ); 24 forwardmonth->setBackgroundMode( PaletteButton );
24 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 25 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
25 backweek->setBackgroundMode( PaletteButton ); 26 backweek->setBackgroundMode( PaletteButton );
26 backweek->setPixmap( Resource::loadPixmap("back") ); 27 backweek->setPixmap( Resource::loadPixmap("back") );
27 backmonth->setBackgroundMode( PaletteButton ); 28 backmonth->setBackgroundMode( PaletteButton );
28 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 29 backmonth->setPixmap( Resource::loadPixmap("fastback") );
29 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 30 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
30 DateBookWeekLstHeaderBaseLayout->setMargin(0); 31 DateBookWeekLstHeaderBaseLayout->setMargin(0);
31 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 32 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
32 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 33 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
33 34
34 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); 35 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
35 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); 36 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
36 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); 37 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
37 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); 38 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
38 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); 39 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
39 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 40 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
40 bStartOnMonday=onM; 41 bStartOnMonday=onM;
41} 42}
42DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 43DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
43 44
44void DateBookWeekLstHeader::setDate(const QDate &d) { 45void DateBookWeekLstHeader::setDate(const QDate &d) {
45 int year,week,dayofweek; 46 int year,week,dayofweek;
46 date=d; 47 date=d;
47 dayofweek=d.dayOfWeek(); 48 dayofweek=d.dayOfWeek();
48 if(bStartOnMonday) 49 if(bStartOnMonday)
49 dayofweek--; 50 dayofweek--;
50 else if( dayofweek == 7 ) 51 else if( dayofweek == 7 )
51 /* we already have the right day -7 would lead to the same week */ 52 /* we already have the right day -7 would lead to the same week */
52 dayofweek = 0; 53 dayofweek = 0;
53 54
54 date=date.addDays(-dayofweek); 55 date=date.addDays(-dayofweek);
55 56
56 calcWeek(date,week,year,bStartOnMonday); 57 calcWeek(date,week,year,bStartOnMonday);
57 QDate start=date; 58 QDate start=date;
58 QDate stop=start.addDays(6); 59 QDate stop=start.addDays(6);
59 labelDate->setText( QString::number(start.day()) + "." + 60 labelDate->setText( QString::number(start.day()) + "." +
60 Calendar::nameOfMonth( start.month() ) + "-" + 61 Calendar::nameOfMonth( start.month() ) + "-" +
61 QString::number(stop.day()) + "." + 62 QString::number(stop.day()) + "." +
62 Calendar::nameOfMonth( stop.month()) +" ("+ 63 Calendar::nameOfMonth( stop.month()) +" ("+
63 tr("w")+":"+QString::number( week ) +")"); 64 tr("w")+":"+QString::number( week ) +")");
64 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 65 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
65 emit dateChanged(date); 66 emit dateChanged(date);
66} 67}
67 68
68void DateBookWeekLstHeader::pickDate() { 69void DateBookWeekLstHeader::pickDate() {
69 static QPopupMenu *m1 = 0; 70 static QPopupMenu *m1 = 0;
70 static DateBookMonth *picker = 0; 71 static DateBookMonth *picker = 0;
71 if ( !m1 ) { 72 if ( !m1 ) {
72 m1 = new QPopupMenu( this ); 73 m1 = new QPopupMenu( this );
73 picker = new DateBookMonth( m1, 0, TRUE ); 74 picker = new DateBookMonth( m1, 0, TRUE );
74 m1->insertItem( picker ); 75 m1->insertItem( picker );
75 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); 76 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
76 //connect( m1, SIGNAL( aboutToHide() ), 77 //connect( m1, SIGNAL( aboutToHide() ),
77 //this, SLOT( gotHide() ) ); 78 //this, SLOT( gotHide() ) );
78 } 79 }
79 picker->setDate( date.year(), date.month(), date.day() ); 80 picker->setDate( date.year(), date.month(), date.day() );
80 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 81 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
81 picker->setFocus(); 82 picker->setFocus();
82} 83}
83void DateBookWeekLstHeader::setDate(int y, int m, int d) { 84void DateBookWeekLstHeader::setDate(int y, int m, int d) {
84 setDate(QDate(y,m,d)); 85 setDate(QDate(y,m,d));
85} 86}
86 87
87void DateBookWeekLstHeader::nextWeek() { 88void DateBookWeekLstHeader::nextWeek() {
88 setDate(date.addDays(7)); 89 setDate(date.addDays(7));
89} 90}
90void DateBookWeekLstHeader::prevWeek() { 91void DateBookWeekLstHeader::prevWeek() {
91 setDate(date.addDays(-7)); 92 setDate(date.addDays(-7));
92} 93}
93void DateBookWeekLstHeader::nextMonth() 94void DateBookWeekLstHeader::nextMonth()
94{ 95{
95 setDate(date.addDays(28)); 96 setDate(date.addDays(28));
96} 97}
97void DateBookWeekLstHeader::prevMonth() 98void DateBookWeekLstHeader::prevMonth()
98{ 99{
99 setDate(date.addDays(-28)); 100 setDate(date.addDays(-28));
100} 101}
101 102
102DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, 103DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
103 QWidget* parent, 104 QWidget* parent,
104 const char* name, 105 const char* name,
105 WFlags fl ) 106 WFlags fl )
106 : DateBookWeekLstDayHdrBase(parent, name, fl) { 107 : DateBookWeekLstDayHdrBase(parent, name, fl) {
107 108
108 date=d; 109 date=d;
109 110
110 static const QString wdays=tr("MTWTFSSM", "Week days"); 111 static const QString wdays=tr("MTWTFSSM", "Week days");
111 char day=wdays[d.dayOfWeek()-1]; 112 char day=wdays[d.dayOfWeek()-1];
112 113
113 //dont use dayOfWeek() to save space ! 114 //dont use dayOfWeek() to save space !
114 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); 115 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
115 116
116 add->setText("+"); 117 add->setText("+");
117 118
118 if (d == QDate::currentDate()) { 119 if (d == QDate::currentDate()) {
119 QPalette pal=label->palette(); 120 QPalette pal=label->palette();
120 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 121 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
121 label->setPalette(pal); 122 label->setPalette(pal);
122 123
123 /* 124 /*
124 QFont f=label->font(); 125 QFont f=label->font();
125 f.setItalic(true); 126 f.setItalic(true);
126 label->setFont(f); 127 label->setFont(f);
127 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 128 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
128 */ 129 */
129 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 130 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
130 QPalette pal=label->palette(); 131 QPalette pal=label->palette();
131 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 132 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
132 label->setPalette(pal); 133 label->setPalette(pal);
133 } 134 }
134 135
135 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 136 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
136 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 137 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
137} 138}
138 139
139void DateBookWeekLstDayHdr::showDay() { 140void DateBookWeekLstDayHdr::showDay() {
140 emit showDate(date.year(), date.month(), date.day()); 141 emit showDate(date.year(), date.month(), date.day());
141} 142}
142 143
143void DateBookWeekLstDayHdr::newEvent() { 144void DateBookWeekLstDayHdr::newEvent() {
144 QDateTime start, stop; 145 QDateTime start, stop;
145 start=stop=date; 146 start=stop=date;
146 start.setTime(QTime(10,0)); 147 start.setTime(QTime(10,0));
147 stop.setTime(QTime(12,0)); 148 stop.setTime(QTime(12,0));
148 149
149 emit addEvent(start,stop,"",0); 150 emit addEvent(start,stop,"",0);
150} 151}
151DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 152DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
152 int weeklistviewconfig, 153 int weeklistviewconfig,
153 QWidget* parent, 154 QWidget* parent,
154 const char* name, 155 const char* name,
155 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) 156 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
156{ 157{
157 // old values... lastday = "__|__", middle=" |---", Firstday="00:00", 158 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
158 QString s,start,middle,end,day; 159 QString s,start,middle,end,day;
159 160
160 qDebug("weeklistviewconfig=%d",weeklistviewconfig); 161 qDebug("weeklistviewconfig=%d",weeklistviewconfig);
161 if(weeklistviewconfig==NONE) {// No times displayed. 162 if(weeklistviewconfig==NONE) {// No times displayed.
162 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 163 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
163 // middle.sprintf("<--->"); 164 // middle.sprintf("<--->");
164 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 165 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
165 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 166 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
166 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. 167 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
167 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 168 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
168 middle.sprintf(" |---"); 169 middle.sprintf(" |---");
169 end.sprintf("__|__"); 170 end.sprintf("__|__");
170 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 171 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
171 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 172 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
172 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 173 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
173 middle.sprintf("<--->"); 174 middle.sprintf("<--->");
174 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 175 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
175 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 176 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
176 } 177 }
177 178
178 if(ev.event().type() == Event::Normal) { 179 if(ev.event().type() == Event::Normal) {
179 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. 180 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
180 s=day; 181 s=day;
181 } else if(ev.startDate()==ev.date()) {// start event. 182 } else if(ev.startDate()==ev.date()) {// start event.
182 s=start; 183 s=start;
183 } else if(ev.endDate()==ev.date()) { // end event. 184 } else if(ev.endDate()==ev.date()) { // end event.
184 s=end; 185 s=end;
185 } else {// middle day. 186 } else {// middle day.
186 s=middle; 187 s=middle;
187 } 188 }
188 } else { 189 } else {
189 s=""; 190 s="";
190 } 191 }
191 setText(QString(s) + " " + ev.description()); 192 setText(QString(s) + " " + ev.description());
192 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 193 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
193 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 194 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
194} 195}
195void DateBookWeekLstEvent::editMe() { 196void DateBookWeekLstEvent::editMe() {
196 emit editEvent(event.event()); 197 emit editEvent(event.event());
197} 198}
198 199
199 200
200DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 201DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
201 const QDate &d, bool onM, 202 const QDate &d, bool onM,
202 QWidget* parent, 203 QWidget* parent,
203 const char* name, WFlags fl) 204 const char* name, WFlags fl)
204 : QWidget( parent, name, fl ) 205 : QWidget( parent, name, fl )
205{ 206{
206 Config config("DateBook"); 207 Config config("DateBook");
207 config.setGroup("Main"); 208 config.setGroup("Main");
208 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 209 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
209 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); 210 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
210 211
211 bStartOnMonday=onM; 212 bStartOnMonday=onM;
212 setPalette(white); 213 setPalette(white);
213 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 214 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
214 215
215 QVBoxLayout *layout = new QVBoxLayout( this ); 216 QVBoxLayout *layout = new QVBoxLayout( this );
216 217
217 qBubbleSort(ev); 218 qBubbleSort(ev);
218 QValueListIterator<EffectiveEvent> it; 219 QValueListIterator<EffectiveEvent> it;
219 it=ev.begin(); 220 it=ev.begin();
220 221
221 int dayOrder[7]; 222 int dayOrder[7];
222 if (bStartOnMonday) { 223 if (bStartOnMonday) {
223 for (int d=0; d<7; d++) dayOrder[d]=d+1; 224 for (int d=0; d<7; d++) dayOrder[d]=d+1;
224 } else { 225 } else {
225 for (int d=0; d<7; d++) dayOrder[d]=d; 226 for (int d=0; d<7; d++) dayOrder[d]=d;
226 dayOrder[0]=7; 227 dayOrder[0]=7;
227 } 228 }
228 229
229 // Calculate offset to first day of week. 230 // Calculate offset to first day of week.
230 int dayoffset=d.dayOfWeek(); 231 int dayoffset=d.dayOfWeek();
231 if(bStartOnMonday) dayoffset--; 232 if(bStartOnMonday) dayoffset--;
232 else if( dayoffset == 7 ) dayoffset = 0; 233 else if( dayoffset == 7 ) dayoffset = 0;
233 234
234 for (int i=0; i<7; i++) { 235 for (int i=0; i<7; i++) {
235 // Header 236 // Header
236 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 237 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
237 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 238 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
238 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 239 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
239 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 240 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
240 layout->addWidget(hdr); 241 layout->addWidget(hdr);
241 242
242 // Events 243 // Events
243 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 244 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
244 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 245 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
245 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 246 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
246 layout->addWidget(l); 247 layout->addWidget(l);
247 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 248 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
248 } 249 }
249 it++; 250 it++;
250 } 251 }
251 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 252 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
252 } 253 }
253} 254}
254DateBookWeekLstView::~DateBookWeekLstView(){} 255DateBookWeekLstView::~DateBookWeekLstView(){}
255void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 256void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
256 257
257DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 258DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
258 QValueList<EffectiveEvent> &ev2, 259 QValueList<EffectiveEvent> &ev2,
259 QDate &d, bool onM, 260 QDate &d, bool onM,
260 QWidget* parent, 261 QWidget* parent,
261 const char* name, WFlags fl) 262 const char* name, WFlags fl)
262 : QWidget( parent, name, fl ) 263 : QWidget( parent, name, fl )
263{ 264{
264 QHBoxLayout *layout = new QHBoxLayout( this ); 265 QHBoxLayout *layout = new QHBoxLayout( this );
265 266
266 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 267 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
267 layout->addWidget(w); 268 layout->addWidget(w);
268 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 269 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
269 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 270 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
270 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 271 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
271 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 272 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
272 273
273 274
274 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 275 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
275 layout->addWidget(w); 276 layout->addWidget(w);
276 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 277 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
277 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 278 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
278 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 279 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
279 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 280 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
280} 281}
281 282
282DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 283DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
283 QWidget *parent, 284 QWidget *parent,
284 const char *name ) 285 const char *name )
285 : QWidget( parent, name ), 286 : QWidget( parent, name ),
286 db( newDB ), 287 db( newDB ),
287 startTime( 0 ), 288 startTime( 0 ),
288 ampm( ap ), 289 ampm( ap ),
289 bStartOnMonday(onM) 290 bStartOnMonday(onM)
290{ 291{
291 setFocusPolicy(StrongFocus); 292 setFocusPolicy(StrongFocus);
292 layout = new QVBoxLayout( this ); 293 layout = new QVBoxLayout( this );
293 layout->setMargin(0); 294 layout->setMargin(0);
294 295
295 header=new DateBookWeekLstHeader(onM, this); 296 header=new DateBookWeekLstHeader(onM, this);
296 layout->addWidget( header ); 297 layout->addWidget( header );
297 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); 298 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
298 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 299 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
299 300
300 scroll=new QScrollView(this); 301 scroll=new QScrollView(this);
301 scroll->setResizePolicy(QScrollView::AutoOneFit); 302 scroll->setResizePolicy(QScrollView::AutoOneFit);
302 layout->addWidget(scroll); 303 layout->addWidget(scroll);
303 304
304 view=NULL; 305 view=NULL;
305 Config config("DateBook"); 306 Config config("DateBook");
306 config.setGroup("Main"); 307 config.setGroup("Main");
307 dbl=config.readBoolEntry("weeklst_dbl", false); 308 dbl=config.readBoolEntry("weeklst_dbl", false);
308 header->dbl->setOn(dbl); 309 header->dbl->setOn(dbl);
309} 310}
310DateBookWeekLst::~DateBookWeekLst(){ 311DateBookWeekLst::~DateBookWeekLst(){
311 Config config("DateBook"); 312 Config config("DateBook");
312 config.setGroup("Main"); 313 config.setGroup("Main");
313 config.writeEntry("weeklst_dbl", dbl); 314 config.writeEntry("weeklst_dbl", dbl);
314} 315}
315 316
316void DateBookWeekLst::setDate(const QDate &d) { 317void DateBookWeekLst::setDate(const QDate &d) {
317 bdate=d; 318 bdate=d;
318 header->setDate(d); 319 header->setDate(d);
319} 320}
320 321
321void DateBookWeekLst::setDbl(bool on) { 322void DateBookWeekLst::setDbl(bool on) {
322 dbl=on; 323 dbl=on;
323 redraw(); 324 redraw();
324} 325}
325void DateBookWeekLst::redraw() {getEvents();} 326void DateBookWeekLst::redraw() {getEvents();}
326 327
327QDate DateBookWeekLst::date() { 328QDate DateBookWeekLst::date() {
328 return bdate; 329 return bdate;
329} 330}
330 331
331// return the date at the beginning of the week... 332// return the date at the beginning of the week...
332// copied from DateBookWeek 333// copied from DateBookWeek
333QDate DateBookWeekLst::weekDate() const 334QDate DateBookWeekLst::weekDate() const
334{ 335{
335 QDate d=bdate; 336 QDate d=bdate;
336 337
337 // Calculate offset to first day of week. 338 // Calculate offset to first day of week.
338 int dayoffset=d.dayOfWeek(); 339 int dayoffset=d.dayOfWeek();
339 if(bStartOnMonday) dayoffset--; 340 if(bStartOnMonday) dayoffset--;
340 else if( dayoffset == 7 ) 341 else if( dayoffset == 7 )
341 dayoffset = 0; 342 dayoffset = 0;
342 343
343 return d.addDays(-dayoffset); 344 return d.addDays(-dayoffset);
344} 345}
345 346
346void DateBookWeekLst::getEvents() { 347void DateBookWeekLst::getEvents() {
347 QDate start = weekDate(); //date(); 348 QDate start = weekDate(); //date();
348 QDate stop = start.addDays(6); 349 QDate stop = start.addDays(6);
349 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 350 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
350 351
351 if (view) delete view; 352 if (view) delete view;
352 if (dbl) { 353 if (dbl) {
353 QDate start2=start.addDays(7); 354 QDate start2=start.addDays(7);
354 stop=start2.addDays(6); 355 stop=start2.addDays(6);
355 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 356 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
356 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 357 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
357 } else { 358 } else {
358 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 359 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
359 } 360 }
360 361
361 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 362 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
362 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 363 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
363 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 364 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
364 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 365 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
365 366
366 scroll->addChild(view); 367 scroll->addChild(view);
367 view->show(); 368 view->show();
368 scroll->updateScrollBars(); 369 scroll->updateScrollBars();
369} 370}
370 371
371void DateBookWeekLst::dateChanged(QDate &newdate) { 372void DateBookWeekLst::dateChanged(QDate &newdate) {
372 bdate=newdate; 373 bdate=newdate;
373 getEvents(); 374 getEvents();
374} 375}
375 376
376void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 377void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
377{ 378{
378 switch(e->key()) { 379 switch(e->key()) {
379 case Key_Up: 380 case Key_Up:
380 scroll->scrollBy(0, -20); 381 scroll->scrollBy(0, -20);
381 break; 382 break;
382 case Key_Down: 383 case Key_Down:
383 scroll->scrollBy(0, 20); 384 scroll->scrollBy(0, 20);
384 break; 385 break;
385 case Key_Left: 386 case Key_Left:
386 header->prevWeek(); 387 header->prevWeek();
387 break; 388 break;
388 case Key_Right: 389 case Key_Right:
389 header->nextWeek(); 390 header->nextWeek();
390 break; 391 break;
391 default: 392 default:
392 e->ignore(); 393 e->ignore();
393 } 394 }
394} 395}
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index f683ce7..32fa23f 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -1,156 +1,156 @@
1#ifndef DATEBOOKWEEKLST 1#ifndef DATEBOOKWEEKLST
2#define DATEBOOKWEEKLST 2#define DATEBOOKWEEKLST
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qdatetime.h> 5#include <qdatetime.h>
6#include <qpe/event.h> 6#include <qpe/event.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qscrollview.h> 8#include <qscrollview.h>
9 9
10#include "datebookweeklstheader.h" 10#include "datebookweeklstheader.h"
11#include "datebookweeklstdayhdr.h" 11#include "datebookweeklstdayhdr.h"
12 12
13#include <opie/oclickablelabel.h> 13#include <opie2/oclickablelabel.h>
14 14
15class QDateTime; 15class QDateTime;
16class DateBookDB; 16class DateBookDB;
17 17
18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase 18class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21public: 21public:
22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, 22 DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
23 WFlags fl = 0 ); 23 WFlags fl = 0 );
24 ~DateBookWeekLstHeader(); 24 ~DateBookWeekLstHeader();
25 void setDate(const QDate &d); 25 void setDate(const QDate &d);
26 26
27public slots: 27public slots:
28 void nextWeek(); 28 void nextWeek();
29 void prevWeek(); 29 void prevWeek();
30 void nextMonth(); 30 void nextMonth();
31 void prevMonth(); 31 void prevMonth();
32 void pickDate(); 32 void pickDate();
33 void setDate(int y, int m, int d); 33 void setDate(int y, int m, int d);
34signals: 34signals:
35 void dateChanged(QDate &newdate); 35 void dateChanged(QDate &newdate);
36 void setDbl(bool on); 36 void setDbl(bool on);
37private: 37private:
38 QDate date; 38 QDate date;
39 //bool onMonday; 39 //bool onMonday;
40 bool bStartOnMonday; 40 bool bStartOnMonday;
41}; 41};
42 42
43class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase 43class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46public: 46public:
47 DateBookWeekLstDayHdr(const QDate &d, bool onM, 47 DateBookWeekLstDayHdr(const QDate &d, bool onM,
48 QWidget* parent = 0, const char* name = 0, 48 QWidget* parent = 0, const char* name = 0,
49 WFlags fl = 0 ); 49 WFlags fl = 0 );
50public slots: 50public slots:
51 void showDay(); 51 void showDay();
52 void newEvent(); 52 void newEvent();
53signals: 53signals:
54 void showDate(int y, int m, int d); 54 void showDate(int y, int m, int d);
55 void addEvent(const QDateTime &start, const QDateTime &stop, 55 void addEvent(const QDateTime &start, const QDateTime &stop,
56 const QString &str, const QString &location); 56 const QString &str, const QString &location);
57private: 57private:
58 QDate date; 58 QDate date;
59}; 59};
60 60
61class DateBookWeekLstEvent: public OClickableLabel 61class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1, 65 DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
66 QWidget* parent = 0, const char* name = 0, 66 QWidget* parent = 0, const char* name = 0,
67 WFlags fl = 0); 67 WFlags fl = 0);
68signals: 68signals:
69 void editEvent(const Event &e); 69 void editEvent(const Event &e);
70private slots: 70private slots:
71 void editMe(); 71 void editMe();
72private: 72private:
73 const EffectiveEvent event; 73 const EffectiveEvent event;
74}; 74};
75 75
76class DateBookWeekLstView: public QWidget 76class DateBookWeekLstView: public QWidget
77{ 77{
78 Q_OBJECT 78 Q_OBJECT
79public: 79public:
80 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, 80 DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
81 QWidget* parent = 0, const char* name = 0, 81 QWidget* parent = 0, const char* name = 0,
82 WFlags fl = 0 ); 82 WFlags fl = 0 );
83 ~DateBookWeekLstView(); 83 ~DateBookWeekLstView();
84signals: 84signals:
85 void editEvent(const Event &e); 85 void editEvent(const Event &e);
86 void showDate(int y, int m, int d); 86 void showDate(int y, int m, int d);
87 void addEvent(const QDateTime &start, const QDateTime &stop, 87 void addEvent(const QDateTime &start, const QDateTime &stop,
88 const QString &str, const QString &location); 88 const QString &str, const QString &location);
89private: 89private:
90 bool bStartOnMonday; 90 bool bStartOnMonday;
91protected slots: 91protected slots:
92 void keyPressEvent(QKeyEvent *); 92 void keyPressEvent(QKeyEvent *);
93}; 93};
94 94
95class DateBookWeekLstDblView: public QWidget { 95class DateBookWeekLstDblView: public QWidget {
96 Q_OBJECT 96 Q_OBJECT
97public: 97public:
98 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 98 DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
99 QValueList<EffectiveEvent> &ev2, 99 QValueList<EffectiveEvent> &ev2,
100 QDate &d, bool onM, 100 QDate &d, bool onM,
101 QWidget* parent = 0, const char* name = 0, 101 QWidget* parent = 0, const char* name = 0,
102 WFlags fl = 0 ); 102 WFlags fl = 0 );
103signals: 103signals:
104 void editEvent(const Event &e); 104 void editEvent(const Event &e);
105 void showDate(int y, int m, int d); 105 void showDate(int y, int m, int d);
106 void addEvent(const QDateTime &start, const QDateTime &stop, 106 void addEvent(const QDateTime &start, const QDateTime &stop,
107 const QString &str, const QString &location); 107 const QString &str, const QString &location);
108}; 108};
109 109
110class DateBookWeekLst : public QWidget 110class DateBookWeekLst : public QWidget
111{ 111{
112 Q_OBJECT 112 Q_OBJECT
113 113
114public: 114public:
115 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, 115 DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
116 QWidget *parent = 0, 116 QWidget *parent = 0,
117 const char *name = 0 ); 117 const char *name = 0 );
118 ~DateBookWeekLst(); 118 ~DateBookWeekLst();
119 void setDate( int y, int w ); 119 void setDate( int y, int w );
120 void setDate(const QDate &d ); 120 void setDate(const QDate &d );
121 int week() const { return _week; }; 121 int week() const { return _week; };
122 QDate date(); 122 QDate date();
123 QDate weekDate() const; 123 QDate weekDate() const;
124 124
125public slots: 125public slots:
126 void redraw(); 126 void redraw();
127 void dateChanged(QDate &date); 127 void dateChanged(QDate &date);
128 128
129protected slots: 129protected slots:
130 void keyPressEvent(QKeyEvent *); 130 void keyPressEvent(QKeyEvent *);
131 void setDbl(bool on); 131 void setDbl(bool on);
132 132
133signals: 133signals:
134 void showDate(int y, int m, int d); 134 void showDate(int y, int m, int d);
135 void addEvent(const QDateTime &start, const QDateTime &stop, 135 void addEvent(const QDateTime &start, const QDateTime &stop,
136 const QString &str, const QString &location); 136 const QString &str, const QString &location);
137 void editEvent(const Event &e); 137 void editEvent(const Event &e);
138 138
139private: 139private:
140 DateBookDB *db; 140 DateBookDB *db;
141 int startTime; 141 int startTime;
142 bool ampm; 142 bool ampm;
143 bool bStartOnMonday; 143 bool bStartOnMonday;
144 bool dbl; 144 bool dbl;
145 QDate bdate; 145 QDate bdate;
146 int year, _week,dow; 146 int year, _week,dow;
147 DateBookWeekLstHeader *header; 147 DateBookWeekLstHeader *header;
148 QWidget *view; 148 QWidget *view;
149 QVBoxLayout *layout; 149 QVBoxLayout *layout;
150 QScrollView *scroll; 150 QScrollView *scroll;
151 151
152 void getEvents(); 152 void getEvents();
153}; 153};
154 154
155#endif 155#endif
156 156
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 57bcd89..dbff18f 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -1,544 +1,544 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "dateentryimpl.h" 21#include "dateentryimpl.h"
22#include "repeatentry.h" 22#include "repeatentry.h"
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/categoryselect.h> 25#include <qpe/categoryselect.h>
26#include <qpe/datebookmonth.h> 26#include <qpe/datebookmonth.h>
27#include <qpe/tzselect.h> 27#include <qpe/tzselect.h>
28 28
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qspinbox.h> 30#include <qspinbox.h>
31 31
32#include <opie/otimepicker.h> 32#include <opie2/otimepicker.h>
33#include "onoteedit.h" 33#include "onoteedit.h"
34 34
35#include <stdlib.h> 35#include <stdlib.h>
36#include <stdio.h> 36#include <stdio.h>
37 37
38/* 38/*
39 * Constructs a DateEntry which is a child of 'parent', with the 39 * Constructs a DateEntry which is a child of 'parent', with the
40 * name 'name' and widget flags set to 'f' 40 * name 'name' and widget flags set to 'f'
41 * 41 *
42 * The dialog will by default be modeless, unless you set 'modal' to 42 * The dialog will by default be modeless, unless you set 'modal' to
43 * TRUE to construct a modal dialog. 43 * TRUE to construct a modal dialog.
44 */ 44 */
45 45
46DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, 46DateEntry::DateEntry( bool startOnMonday, const QDateTime &start,
47 const QDateTime &end, bool whichClock, QWidget* parent, 47 const QDateTime &end, bool whichClock, QWidget* parent,
48 const char* name ) 48 const char* name )
49 : DateEntryBase( parent, name ), 49 : DateEntryBase( parent, name ),
50 ampm( whichClock ), 50 ampm( whichClock ),
51 startWeekOnMonday( startOnMonday ), 51 startWeekOnMonday( startOnMonday ),
52 m_showStart(true) 52 m_showStart(true)
53{ 53{
54 init(); 54 init();
55 setDates(start,end); 55 setDates(start,end);
56 setFocusProxy(comboDescription); 56 setFocusProxy(comboDescription);
57} 57}
58 58
59bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) 59bool DateEntry::eventFilter(QObject *obj, QEvent *ev )
60{ 60{
61 if( ev->type() == QEvent::FocusIn ){ 61 if( ev->type() == QEvent::FocusIn ){
62 if( obj == comboStart ){ 62 if( obj == comboStart ){
63 timePickerStart->setHour(startTime.hour()); 63 timePickerStart->setHour(startTime.hour());
64 timePickerStart->setMinute(startTime.minute()); 64 timePickerStart->setMinute(startTime.minute());
65 TimePickerLabel->setText( tr("Start Time" ) ); 65 TimePickerLabel->setText( tr("Start Time" ) );
66 m_showStart= true; 66 m_showStart= true;
67 }else if( obj == comboEnd ){ 67 }else if( obj == comboEnd ){
68 timePickerStart->setHour(endTime.hour()); 68 timePickerStart->setHour(endTime.hour());
69 timePickerStart->setMinute(endTime.minute()); 69 timePickerStart->setMinute(endTime.minute());
70 TimePickerLabel->setText( tr("End Time") ); 70 TimePickerLabel->setText( tr("End Time") );
71 m_showStart = false; 71 m_showStart = false;
72 } 72 }
73 } else if( ev->type() == QEvent::FocusOut ){ 73 } else if( ev->type() == QEvent::FocusOut ){
74// if( obj == comboEnd ){ 74// if( obj == comboEnd ){
75// QString s; 75// QString s;
76// s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); 76// s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute());
77// comboEnd->setText(s); 77// comboEnd->setText(s);
78// } 78// }
79// else if( obj == comboStart ){ 79// else if( obj == comboStart ){
80// QString s; 80// QString s;
81// s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); 81// s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute());
82// comboStart->setText(s); 82// comboStart->setText(s);
83// } 83// }
84 } 84 }
85 85
86 return false; 86 return false;
87} 87}
88 88
89static void addOrPick( QComboBox* combo, const QString& t ) 89static void addOrPick( QComboBox* combo, const QString& t )
90{ 90{
91 // Pick an item if one excists 91 // Pick an item if one excists
92 for (int i=0; i<combo->count(); i++) { 92 for (int i=0; i<combo->count(); i++) {
93 if ( combo->text(i) == t ) { 93 if ( combo->text(i) == t ) {
94 combo->setCurrentItem(i); 94 combo->setCurrentItem(i);
95 return; 95 return;
96 } 96 }
97 } 97 }
98 98
99 // Else add one 99 // Else add one
100 combo->insertItem(t); 100 combo->insertItem(t);
101 combo->setCurrentItem(combo->count()-1); 101 combo->setCurrentItem(combo->count()-1);
102} 102}
103 103
104DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 104DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
105 QWidget* parent, const char* name ) 105 QWidget* parent, const char* name )
106 : DateEntryBase( parent, name ), 106 : DateEntryBase( parent, name ),
107 ampm( whichClock ), 107 ampm( whichClock ),
108 startWeekOnMonday( startOnMonday ), 108 startWeekOnMonday( startOnMonday ),
109 m_showStart(true) 109 m_showStart(true)
110 110
111{ 111{
112 init(); 112 init();
113 setDates(event.start(),event.end()); 113 setDates(event.start(),event.end());
114 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); 114 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") );
115 if(!event.description().isEmpty()) 115 if(!event.description().isEmpty())
116 addOrPick( comboDescription, event.description() ); 116 addOrPick( comboDescription, event.description() );
117 if(!event.location().isEmpty()) 117 if(!event.location().isEmpty())
118 addOrPick( comboLocation, event.location() ); 118 addOrPick( comboLocation, event.location() );
119 checkAlarm->setChecked( event.hasAlarm() ); 119 checkAlarm->setChecked( event.hasAlarm() );
120 checkAllDay->setChecked( event.type() == Event::AllDay ); 120 checkAllDay->setChecked( event.type() == Event::AllDay );
121 if(!event.notes().isEmpty()) noteStr=event.notes(); 121 if(!event.notes().isEmpty()) noteStr=event.notes();
122 else noteStr=""; 122 else noteStr="";
123 spinAlarm->setValue(event.alarmTime()); 123 spinAlarm->setValue(event.alarmTime());
124 if ( event.alarmSound() != Event::Silent ) 124 if ( event.alarmSound() != Event::Silent )
125 comboSound->setCurrentItem( 1 ); 125 comboSound->setCurrentItem( 1 );
126 if ( event.hasRepeat() ) { 126 if ( event.hasRepeat() ) {
127 rp = event.repeatPattern(); 127 rp = event.repeatPattern();
128 cmdRepeat->setText( tr("Repeat...") ); 128 cmdRepeat->setText( tr("Repeat...") );
129 } 129 }
130 setRepeatLabel(); 130 setRepeatLabel();
131} 131}
132 132
133void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) 133void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
134{ 134{
135 startDate = s.date(); 135 startDate = s.date();
136 endDate = e.date(); 136 endDate = e.date();
137 startTime = s.time(); 137 startTime = s.time();
138 endTime = e.time(); 138 endTime = e.time();
139 139
140 startDateChanged( s.date().year(), s.date().month(), s.date().day() ); 140 startDateChanged( s.date().year(), s.date().month(), s.date().day() );
141 endDateChanged( e.date().year(), e.date().month(), e.date().day() ); 141 endDateChanged( e.date().year(), e.date().month(), e.date().day() );
142 142
143 updateTimeEdit(true,true); 143 updateTimeEdit(true,true);
144} 144}
145 145
146void DateEntry::updateTimeEdit(bool s, bool e) { 146void DateEntry::updateTimeEdit(bool s, bool e) {
147 147
148 // Comboboxes 148 // Comboboxes
149 QString strStart, strEnd; 149 QString strStart, strEnd;
150 int shour, ehour; 150 int shour, ehour;
151 if ( ampm ) { 151 if ( ampm ) {
152 shour = startTime.hour(); 152 shour = startTime.hour();
153 ehour = endTime.hour(); 153 ehour = endTime.hour();
154 if ( shour >= 12 ) { 154 if ( shour >= 12 ) {
155 if ( shour > 12 ) 155 if ( shour > 12 )
156 shour -= 12; 156 shour -= 12;
157 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 157 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
158 } else { 158 } else {
159 if ( shour == 0 ) 159 if ( shour == 0 )
160 shour = 12; 160 shour = 12;
161 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 161 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
162 } 162 }
163 if ( ehour == 24 && endTime.minute() == 0 ) { 163 if ( ehour == 24 && endTime.minute() == 0 ) {
164 strEnd = "11:59 PM"; // or "midnight" 164 strEnd = "11:59 PM"; // or "midnight"
165 } else if ( ehour >= 12 ) { 165 } else if ( ehour >= 12 ) {
166 if ( ehour > 12 ) 166 if ( ehour > 12 )
167 ehour -= 12; 167 ehour -= 12;
168 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 168 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
169 } else { 169 } else {
170 if ( ehour == 0 ) 170 if ( ehour == 0 )
171 ehour = 12; 171 ehour = 12;
172 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 172 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
173 } 173 }
174 } else { 174 } else {
175 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 175 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
176 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 176 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
177 } 177 }
178 178
179 if (s) comboStart->setText(strStart); 179 if (s) comboStart->setText(strStart);
180 if (e) comboEnd->setText(strEnd); 180 if (e) comboEnd->setText(strEnd);
181} 181}
182 182
183void DateEntry::init() 183void DateEntry::init()
184{ 184{
185 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 185 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
186 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 186 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
187 187
188 initCombos(); 188 initCombos();
189 QPopupMenu *m1 = new QPopupMenu( this ); 189 QPopupMenu *m1 = new QPopupMenu( this );
190 startPicker = new DateBookMonth( m1, 0, TRUE ); 190 startPicker = new DateBookMonth( m1, 0, TRUE );
191 m1->insertItem( startPicker ); 191 m1->insertItem( startPicker );
192 buttonStart->setPopup( m1 ); 192 buttonStart->setPopup( m1 );
193 connect( startPicker, SIGNAL( dateClicked(int,int,int) ), 193 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
194 this, SLOT( startDateChanged(int,int,int) ) ); 194 this, SLOT( startDateChanged(int,int,int) ) );
195 195
196 //Let start button change both start and end dates 196 //Let start button change both start and end dates
197 connect( startPicker, SIGNAL( dateClicked(int,int,int) ), 197 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
198 this, SLOT( endDateChanged(int,int,int) ) ); 198 this, SLOT( endDateChanged(int,int,int) ) );
199 connect( qApp, SIGNAL( clockChanged(bool) ), 199 connect( qApp, SIGNAL( clockChanged(bool) ),
200 this, SLOT( slotChangeClock(bool) ) ); 200 this, SLOT( slotChangeClock(bool) ) );
201 connect( qApp, SIGNAL(weekChanged(bool)), 201 connect( qApp, SIGNAL(weekChanged(bool)),
202 this, SLOT(slotChangeStartOfWeek(bool)) ); 202 this, SLOT(slotChangeStartOfWeek(bool)) );
203 203
204 connect( editNote, SIGNAL(clicked()), 204 connect( editNote, SIGNAL(clicked()),
205 this, SLOT(slotEditNote()) ); 205 this, SLOT(slotEditNote()) );
206 206
207 QPopupMenu *m2 = new QPopupMenu( this ); 207 QPopupMenu *m2 = new QPopupMenu( this );
208 endPicker = new DateBookMonth( m2, 0, TRUE ); 208 endPicker = new DateBookMonth( m2, 0, TRUE );
209 m2->insertItem( endPicker ); 209 m2->insertItem( endPicker );
210 buttonEnd->setPopup( m2 ); 210 buttonEnd->setPopup( m2 );
211 connect( endPicker, SIGNAL( dateClicked(int,int,int) ), 211 connect( endPicker, SIGNAL( dateClicked(int,int,int) ),
212 this, SLOT( endDateChanged(int,int,int) ) ); 212 this, SLOT( endDateChanged(int,int,int) ) );
213 213
214 connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ), 214 connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ),
215 this, SLOT( startTimePicked(const QTime&) )); 215 this, SLOT( startTimePicked(const QTime&) ));
216 // install eventFilters 216 // install eventFilters
217 comboEnd->installEventFilter( this ); 217 comboEnd->installEventFilter( this );
218 comboStart->installEventFilter( this ); 218 comboStart->installEventFilter( this );
219} 219}
220 220
221/* 221/*
222 * Destroys the object and frees any allocated resources 222 * Destroys the object and frees any allocated resources
223 */ 223 */
224DateEntry::~DateEntry() 224DateEntry::~DateEntry()
225{ 225{
226 // no need to delete child widgets, Qt does it all for us 226 // no need to delete child widgets, Qt does it all for us
227 //cout << "Del: " << comboStart->currentText() << endl; 227 //cout << "Del: " << comboStart->currentText() << endl;
228} 228}
229 229
230/* 230/*
231 * public slot 231 * public slot
232 */ 232 */
233 233
234void DateEntry::slotEditNote() { 234void DateEntry::slotEditNote() {
235 QString s; 235 QString s;
236 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; 236 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>";
237// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); 237// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month());
238 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, 238 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr,
239 this,0,TRUE); 239 this,0,TRUE);
240 240
241 if ( QPEApplication::execDialog( &noteDlg ) ) { 241 if ( QPEApplication::execDialog( &noteDlg ) ) {
242 noteStr=noteDlg.note->text(); 242 noteStr=noteDlg.note->text();
243 } 243 }
244 244
245} 245}
246 246
247void DateEntry::endDateChanged( int y, int m, int d ) 247void DateEntry::endDateChanged( int y, int m, int d )
248{ 248{
249 endDate.setYMD( y, m, d ); 249 endDate.setYMD( y, m, d );
250 if ( endDate < startDate ) { 250 if ( endDate < startDate ) {
251 endDate = startDate; 251 endDate = startDate;
252 } 252 }
253 253
254 buttonEnd->setText( TimeString::shortDate( endDate ) ); 254 buttonEnd->setText( TimeString::shortDate( endDate ) );
255 255
256 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 256 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
257} 257}
258 258
259static QTime parseTime( const QString& s, bool ampm ) 259static QTime parseTime( const QString& s, bool ampm )
260{ 260{
261 QTime tmpTime; 261 QTime tmpTime;
262 QStringList l = QStringList::split( ':', s ); 262 QStringList l = QStringList::split( ':', s );
263 int hour = l[0].toInt(); 263 int hour = l[0].toInt();
264 if ( ampm ) { 264 if ( ampm ) {
265 int i=0; 265 int i=0;
266 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') 266 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9')
267 i++; 267 i++;
268 QString digits = l[1].left(i); 268 QString digits = l[1].left(i);
269 if ( l[1].contains( "PM", FALSE ) ) { 269 if ( l[1].contains( "PM", FALSE ) ) {
270 if ( hour != 12 ) 270 if ( hour != 12 )
271 hour += 12; 271 hour += 12;
272 } else { 272 } else {
273 if ( hour == 12 ) 273 if ( hour == 12 )
274 hour = 0; 274 hour = 0;
275 } 275 }
276 l[1] = digits; 276 l[1] = digits;
277 } 277 }
278 int minute = l[1].toInt(); 278 int minute = l[1].toInt();
279 if ( minute > 59 ) 279 if ( minute > 59 )
280 minute = 59; 280 minute = 59;
281 else if ( minute < 0 ) 281 else if ( minute < 0 )
282 minute = 0; 282 minute = 0;
283 if ( hour > 23 ) { 283 if ( hour > 23 ) {
284 hour = 23; 284 hour = 23;
285 minute = 59; 285 minute = 59;
286 } else if ( hour < 0 ) 286 } else if ( hour < 0 )
287 hour = 0; 287 hour = 0;
288 tmpTime.setHMS( hour, minute, 0 ); 288 tmpTime.setHMS( hour, minute, 0 );
289 return tmpTime; 289 return tmpTime;
290} 290}
291 291
292/* 292/*
293 * public slot 293 * public slot
294 */ 294 */
295void DateEntry::endTimeChanged( const QString &s ) 295void DateEntry::endTimeChanged( const QString &s )
296{ 296{
297 endTimeChanged( parseTime(s,ampm) ); 297 endTimeChanged( parseTime(s,ampm) );
298} 298}
299 299
300void DateEntry::endTimeChanged( const QTime &t ) { 300void DateEntry::endTimeChanged( const QTime &t ) {
301 if ( endDate > startDate || t >= startTime ) { 301 if ( endDate > startDate || t >= startTime ) {
302 endTime = t; 302 endTime = t;
303 } else { 303 } else {
304 endTime = startTime; 304 endTime = startTime;
305 //comboEnd->setCurrentItem( comboStart->currentItem() ); 305 //comboEnd->setCurrentItem( comboStart->currentItem() );
306 } 306 }
307 timePickerStart->setHour(endTime.hour()); 307 timePickerStart->setHour(endTime.hour());
308 timePickerStart->setMinute(endTime.minute()); 308 timePickerStart->setMinute(endTime.minute());
309} 309}
310 310
311/* 311/*
312 * public slot 312 * public slot
313 */ 313 */
314void DateEntry::startDateChanged( int y, int m, int d ) 314void DateEntry::startDateChanged( int y, int m, int d )
315{ 315{
316 QDate prev = startDate; 316 QDate prev = startDate;
317 startDate.setYMD( y, m, d ); 317 startDate.setYMD( y, m, d );
318 if ( rp.type == Event::Weekly && 318 if ( rp.type == Event::Weekly &&
319 startDate.dayOfWeek() != prev.dayOfWeek() ) { 319 startDate.dayOfWeek() != prev.dayOfWeek() ) {
320 // if we change the start of a weekly repeating event 320 // if we change the start of a weekly repeating event
321 // set the repeating day appropriately 321 // set the repeating day appropriately
322 char mask = 1 << (prev.dayOfWeek()-1); 322 char mask = 1 << (prev.dayOfWeek()-1);
323 rp.days &= (~mask); 323 rp.days &= (~mask);
324 rp.days |= 1 << (startDate.dayOfWeek()-1); 324 rp.days |= 1 << (startDate.dayOfWeek()-1);
325 } 325 }
326 326
327 buttonStart->setText( TimeString::shortDate( startDate ) ); 327 buttonStart->setText( TimeString::shortDate( startDate ) );
328 328
329 // our pickers must be reset... 329 // our pickers must be reset...
330 startPicker->setDate( y, m, d ); 330 startPicker->setDate( y, m, d );
331 endPicker->setDate( y, m, d ); 331 endPicker->setDate( y, m, d );
332} 332}
333 333
334/* 334/*
335 * public slot 335 * public slot
336 */ 336 */
337void DateEntry::startTimeEdited( const QString &s ) 337void DateEntry::startTimeEdited( const QString &s )
338{ 338{
339 startTimeChanged(parseTime(s,ampm)); 339 startTimeChanged(parseTime(s,ampm));
340 updateTimeEdit(false,true); 340 updateTimeEdit(false,true);
341 timePickerStart->setHour(startTime.hour()); 341 timePickerStart->setHour(startTime.hour());
342 timePickerStart->setMinute(startTime.minute()); 342 timePickerStart->setMinute(startTime.minute());
343} 343}
344 344
345void DateEntry::startTimeChanged( const QTime &t ) 345void DateEntry::startTimeChanged( const QTime &t )
346{ 346{
347 int duration=startTime.secsTo(endTime); 347 int duration=startTime.secsTo(endTime);
348 startTime = t; 348 startTime = t;
349 endTime=t.addSecs(duration); 349 endTime=t.addSecs(duration);
350} 350}
351void DateEntry::startTimePicked( const QTime &t ) { 351void DateEntry::startTimePicked( const QTime &t ) {
352 if(m_showStart ){ 352 if(m_showStart ){
353 startTimeChanged(t); 353 startTimeChanged(t);
354 updateTimeEdit(true,true); 354 updateTimeEdit(true,true);
355 }else{ 355 }else{
356 endTimeChanged(t); 356 endTimeChanged(t);
357 updateTimeEdit(false, true ); 357 updateTimeEdit(false, true );
358 } 358 }
359} 359}
360 360
361/* 361/*
362 * public slot 362 * public slot
363 */ 363 */
364void DateEntry::typeChanged( const QString &s ) 364void DateEntry::typeChanged( const QString &s )
365{ 365{
366 bool b = s != "All Day"; 366 bool b = s != "All Day";
367 buttonStart->setEnabled( b ); 367 buttonStart->setEnabled( b );
368 comboStart->setEnabled( b ); 368 comboStart->setEnabled( b );
369 comboEnd->setEnabled( b ); 369 comboEnd->setEnabled( b );
370} 370}
371 371
372void DateEntry::slotRepeat() 372void DateEntry::slotRepeat()
373{ 373{
374 // Work around for compiler Bug.. 374 // Work around for compiler Bug..
375 RepeatEntry *e; 375 RepeatEntry *e;
376 376
377 // it is better in my opinion to just grab this from the mother, 377 // it is better in my opinion to just grab this from the mother,
378 // since, this dialog doesn't need to keep track of it... 378 // since, this dialog doesn't need to keep track of it...
379 if ( rp.type != Event::NoRepeat ) 379 if ( rp.type != Event::NoRepeat )
380 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); 380 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this);
381 else 381 else
382 e = new RepeatEntry( startWeekOnMonday, startDate, this ); 382 e = new RepeatEntry( startWeekOnMonday, startDate, this );
383 383
384 if ( QPEApplication::execDialog( e ) ) { 384 if ( QPEApplication::execDialog( e ) ) {
385 rp = e->repeatPattern(); 385 rp = e->repeatPattern();
386 setRepeatLabel(); 386 setRepeatLabel();
387 } 387 }
388 // deleting sounds like a nice idea... 388 // deleting sounds like a nice idea...
389 delete e; 389 delete e;
390} 390}
391 391
392void DateEntry::slotChangeStartOfWeek( bool onMonday ) 392void DateEntry::slotChangeStartOfWeek( bool onMonday )
393{ 393{
394 startWeekOnMonday = onMonday; 394 startWeekOnMonday = onMonday;
395} 395}
396 396
397Event DateEntry::event() 397Event DateEntry::event()
398{ 398{
399 Event ev; 399 Event ev;
400 Event::SoundTypeChoice st; 400 Event::SoundTypeChoice st;
401 ev.setDescription( comboDescription->currentText() ); 401 ev.setDescription( comboDescription->currentText() );
402 ev.setLocation( comboLocation->currentText() ); 402 ev.setLocation( comboLocation->currentText() );
403 ev.setCategories( comboCategory->currentCategories() ); 403 ev.setCategories( comboCategory->currentCategories() );
404 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); 404 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal );
405 if ( startDate > endDate ) { 405 if ( startDate > endDate ) {
406 QDate tmp = endDate; 406 QDate tmp = endDate;
407 endDate = startDate; 407 endDate = startDate;
408 startDate = tmp; 408 startDate = tmp;
409 } 409 }
410 410
411 // This is now done in the changed slots 411 // This is now done in the changed slots
412 // startTime = parseTime( comboStart->text(), ampm ); 412 // startTime = parseTime( comboStart->text(), ampm );
413 //endTime = parseTime( comboEnd->text(), ampm ); 413 //endTime = parseTime( comboEnd->text(), ampm );
414 414
415 if ( startTime > endTime && endDate == startDate ) { 415 if ( startTime > endTime && endDate == startDate ) {
416 QTime tmp = endTime; 416 QTime tmp = endTime;
417 endTime = startTime; 417 endTime = startTime;
418 startTime = tmp; 418 startTime = tmp;
419 } 419 }
420 // don't set the time if theres no need too 420 // don't set the time if theres no need too
421 if ( ev.type() == Event::AllDay ) { 421 if ( ev.type() == Event::AllDay ) {
422 startTime.setHMS( 0, 0, 0 ); 422 startTime.setHMS( 0, 0, 0 );
423 endTime.setHMS( 23, 59, 59 ); 423 endTime.setHMS( 23, 59, 59 );
424 } 424 }
425 425
426 // adjust start and end times based on timezone 426 // adjust start and end times based on timezone
427 QDateTime start( startDate, startTime ); 427 QDateTime start( startDate, startTime );
428 QDateTime end( endDate, endTime ); 428 QDateTime end( endDate, endTime );
429 time_t start_utc, end_utc; 429 time_t start_utc, end_utc;
430 430
431// qDebug( "tz: %s", timezone->currentZone().latin1() ); 431// qDebug( "tz: %s", timezone->currentZone().latin1() );
432 432
433 // get real timezone 433 // get real timezone
434 QString realTZ; 434 QString realTZ;
435 realTZ = QString::fromLocal8Bit( getenv("TZ") ); 435 realTZ = QString::fromLocal8Bit( getenv("TZ") );
436 436
437 // set timezone 437 // set timezone
438 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) 438 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 )
439 qWarning( "There was a problem setting the timezone." ); 439 qWarning( "There was a problem setting the timezone." );
440 440
441 // convert to UTC based on selected TZ (calling tzset internally) 441 // convert to UTC based on selected TZ (calling tzset internally)
442 start_utc = TimeConversion::toUTC( start ); 442 start_utc = TimeConversion::toUTC( start );
443 end_utc = TimeConversion::toUTC( end ); 443 end_utc = TimeConversion::toUTC( end );
444 444
445 // done playing around... put it all back 445 // done playing around... put it all back
446 unsetenv( "TZ" ); 446 unsetenv( "TZ" );
447 if ( !realTZ.isNull() ) 447 if ( !realTZ.isNull() )
448 if ( setenv( "TZ", realTZ, true ) != 0 ) 448 if ( setenv( "TZ", realTZ, true ) != 0 )
449 qWarning( "There was a problem setting the timezone." ); 449 qWarning( "There was a problem setting the timezone." );
450 450
451 // convert UTC to local time (calling tzset internally) 451 // convert UTC to local time (calling tzset internally)
452 ev.setStart( TimeConversion::fromUTC( start_utc ) ); 452 ev.setStart( TimeConversion::fromUTC( start_utc ) );
453 ev.setEnd( TimeConversion::fromUTC( end_utc ) ); 453 ev.setEnd( TimeConversion::fromUTC( end_utc ) );
454 454
455 // we only have one type of sound at the moment... LOUD!!! 455 // we only have one type of sound at the moment... LOUD!!!
456 if ( comboSound->currentItem() != 0 ) 456 if ( comboSound->currentItem() != 0 )
457 st = Event::Loud; 457 st = Event::Loud;
458 else 458 else
459 st = Event::Silent; 459 st = Event::Silent;
460 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); 460 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st );
461 if ( rp.type != Event::NoRepeat ) 461 if ( rp.type != Event::NoRepeat )
462 ev.setRepeat( TRUE, rp ); 462 ev.setRepeat( TRUE, rp );
463 ev.setNotes( noteStr ); 463 ev.setNotes( noteStr );
464 464
465 //cout << "Start: " << comboStart->currentText() << endl; 465 //cout << "Start: " << comboStart->currentText() << endl;
466 466
467 return ev; 467 return ev;
468} 468}
469 469
470void DateEntry::setRepeatLabel() 470void DateEntry::setRepeatLabel()
471{ 471{
472 472
473 switch( rp.type ) { 473 switch( rp.type ) {
474 case Event::Daily: 474 case Event::Daily:
475 cmdRepeat->setText( tr("Daily...") ); 475 cmdRepeat->setText( tr("Daily...") );
476 break; 476 break;
477 case Event::Weekly: 477 case Event::Weekly:
478 cmdRepeat->setText( tr("Weekly...") ); 478 cmdRepeat->setText( tr("Weekly...") );
479 break; 479 break;
480 case Event::MonthlyDay: 480 case Event::MonthlyDay:
481 case Event::MonthlyDate: 481 case Event::MonthlyDate:
482 cmdRepeat->setText( tr("Monthly...") ); 482 cmdRepeat->setText( tr("Monthly...") );
483 break; 483 break;
484 case Event::Yearly: 484 case Event::Yearly:
485 cmdRepeat->setText( tr("Yearly...") ); 485 cmdRepeat->setText( tr("Yearly...") );
486 break; 486 break;
487 default: 487 default:
488 cmdRepeat->setText( tr("No Repeat...") ); 488 cmdRepeat->setText( tr("No Repeat...") );
489 } 489 }
490} 490}
491 491
492void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) 492void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound )
493{ 493{
494 checkAlarm->setChecked( alarmPreset ); 494 checkAlarm->setChecked( alarmPreset );
495 spinAlarm->setValue( presetTime ); 495 spinAlarm->setValue( presetTime );
496 if ( sound != Event::Silent ) 496 if ( sound != Event::Silent )
497 comboSound->setCurrentItem( 1 ); 497 comboSound->setCurrentItem( 1 );
498 else 498 else
499 comboSound->setCurrentItem( 0 ); 499 comboSound->setCurrentItem( 0 );
500} 500}
501 501
502void DateEntry::initCombos() 502void DateEntry::initCombos()
503{ 503{
504 /* 504 /*
505 comboStart->clear(); 505 comboStart->clear();
506 comboEnd->clear(); 506 comboEnd->clear();
507 if ( ampm ) { 507 if ( ampm ) {
508 for ( int i = 0; i < 24; i++ ) { 508 for ( int i = 0; i < 24; i++ ) {
509 if ( i == 0 ) { 509 if ( i == 0 ) {
510 comboStart->insertItem( "12:00 AM" ); 510 comboStart->insertItem( "12:00 AM" );
511 comboStart->insertItem( "12:30 AM" ); 511 comboStart->insertItem( "12:30 AM" );
512 comboEnd->insertItem( "12:00 AM" ); 512 comboEnd->insertItem( "12:00 AM" );
513 comboEnd->insertItem( "12:30 AM" ); 513 comboEnd->insertItem( "12:30 AM" );
514 } else if ( i == 12 ) { 514 } else if ( i == 12 ) {
515 comboStart->insertItem( "12:00 PM" ); 515 comboStart->insertItem( "12:00 PM" );
516 comboStart->insertItem( "12:30 PM" ); 516 comboStart->insertItem( "12:30 PM" );
517 comboEnd->insertItem( "12:00 PM" ); 517 comboEnd->insertItem( "12:00 PM" );
518 comboEnd->insertItem( "12:30 PM" ); 518 comboEnd->insertItem( "12:30 PM" );
519 } else if ( i > 12 ) { 519 } else if ( i > 12 ) {
520 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); 520 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" );
521 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); 521 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" );
522 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); 522 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" );
523 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); 523 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" );
524 } else { 524 } else {
525 comboStart->insertItem( QString::number( i) + ":00 AM" ); 525 comboStart->insertItem( QString::number( i) + ":00 AM" );
526 comboStart->insertItem( QString::number( i ) + ":30 AM" ); 526 comboStart->insertItem( QString::number( i ) + ":30 AM" );
527 comboEnd->insertItem( QString::number( i ) + ":00 AM" ); 527 comboEnd->insertItem( QString::number( i ) + ":00 AM" );
528 comboEnd->insertItem( QString::number( i ) + ":30 AM" ); 528 comboEnd->insertItem( QString::number( i ) + ":30 AM" );
529 } 529 }
530 } 530 }
531 } else { 531 } else {
532 for ( int i = 0; i < 24; i++ ) { 532 for ( int i = 0; i < 24; i++ ) {
533 if ( i < 10 ) { 533 if ( i < 10 ) {
534 comboStart->insertItem( QString("0") 534 comboStart->insertItem( QString("0")
535 + QString::number(i) + ":00" ); 535 + QString::number(i) + ":00" );
536 comboStart->insertItem( QString("0") 536 comboStart->insertItem( QString("0")
537 + QString::number(i) + ":30" ); 537 + QString::number(i) + ":30" );
538 comboEnd->insertItem( QString("0") 538 comboEnd->insertItem( QString("0")
539 + QString::number(i) + ":00" ); 539 + QString::number(i) + ":00" );
540 comboEnd->insertItem( QString("0") 540 comboEnd->insertItem( QString("0")
541 + QString::number(i) + ":30" ); 541 + QString::number(i) + ":30" );
542 } else { 542 } else {
543 comboStart->insertItem( QString::number(i) + ":00" ); 543 comboStart->insertItem( QString::number(i) + ":00" );
544 comboStart->insertItem( QString::number(i) + ":30" ); 544 comboStart->insertItem( QString::number(i) + ":30" );
diff --git a/core/pim/datebook/main.cpp b/core/pim/datebook/main.cpp
index 421e457..3cb60af 100644
--- a/core/pim/datebook/main.cpp
+++ b/core/pim/datebook/main.cpp
@@ -1,24 +1,25 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "datebook.h" 21#include "datebook.h"
22#include <opie/oapplicationfactory.h> 22#include <opie2/oapplicationfactory.h>
23 23
24using namespace Opie::Core;
24OPIE_EXPORT_APP( OApplicationFactory<DateBook> ) 25OPIE_EXPORT_APP( OApplicationFactory<DateBook> )