summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweeklst.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweeklst.cpp297
1 files changed, 153 insertions, 144 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 3d6a029..3c8fc89 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -4,2 +4,4 @@
4 4
5#include "datebook.h"
6
5#include <qpe/calendar.h> 7#include <qpe/calendar.h>
@@ -145,20 +147,40 @@ void DateBookWeekLstDayHdr::newEvent() {
145DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 147DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
146 QWidget* parent, 148 int weeklistviewconfig,
147 const char* name, 149 QWidget* parent,
148 WFlags fl) : 150 const char* name,
149 OClickableLabel(parent,name,fl), 151 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
150 event(ev)
151{ 152{
152 char s[10]; 153 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
153 if ( ev.startDate() != ev.date() ) { // multiday event (not first day) 154 QString s,start,middle,end,day;
154 if ( ev.endDate() == ev.date() ) { // last day 155
155 strcpy(s, "__|__"); 156 qDebug("weeklistviewconfig=%d",weeklistviewconfig);
156 } else { 157 if(weeklistviewconfig==NONE) {// No times displayed.
157 strcpy(s, " |---"); 158 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
159 // middle.sprintf("<--->");
160 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
161 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
162 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
163 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
164 middle.sprintf(" |---");
165 end.sprintf("__|__");
166 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
167 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
168 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
169 middle.sprintf("<--->");
170 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
171 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
172 }
173
174 if(ev.event().type() == Event::Normal) {
175 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
176 s=day;
177 } else if(ev.startDate()==ev.date()) {// start event.
178 s=start;
179 } else if(ev.endDate()==ev.date()) { // end event.
180 s=end;
181 } else {// middle day.
182 s=middle;
158 } 183 }
159 } else { 184 } else {
160 if(ev.event().type() == Event::Normal ) 185 s="";
161 sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute());
162 else
163 sprintf(s," ");
164 } 186 }
@@ -169,3 +191,3 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
169void DateBookWeekLstEvent::editMe() { 191void DateBookWeekLstEvent::editMe() {
170 emit editEvent(event.event()); 192 emit editEvent(event.event());
171} 193}
@@ -179,19 +201,24 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
179{ 201{
180 onMonday=onM; 202 Config config("DateBook");
181 setPalette(white); 203 config.setGroup("Main");
182 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 204 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
205 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
183 206
184 QVBoxLayout *layout = new QVBoxLayout( this ); 207 onMonday=onM;
208 setPalette(white);
209 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
185 210
186 qBubbleSort(ev); 211 QVBoxLayout *layout = new QVBoxLayout( this );
187 QValueListIterator<EffectiveEvent> it;
188 it=ev.begin();
189 212
190 int dayOrder[7]; 213 qBubbleSort(ev);
191 if (onMonday) 214 QValueListIterator<EffectiveEvent> it;
192 for (int d=0; d<7; d++) dayOrder[d]=d+1; 215 it=ev.begin();
193 else { 216
194 for (int d=0; d<7; d++) dayOrder[d]=d; 217 int dayOrder[7];
195 dayOrder[0]=7; 218 if (onMonday) {
196 } 219 for (int d=0; d<7; d++) dayOrder[d]=d+1;
220 } else {
221 for (int d=0; d<7; d++) dayOrder[d]=d;
222 dayOrder[0]=7;
223 }
197 224
@@ -199,12 +226,7 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
199 // Header 226 // Header
200 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), 227 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this);
201 onMonday,this);
202 connect(hdr, SIGNAL(showDate(int,int,int)), 228 connect(hdr, SIGNAL(showDate(int,int,int)),
203 this, SIGNAL(showDate(int,int,int))); 229 this, SIGNAL(showDate(int,int,int)));
204 connect(hdr, SIGNAL(addEvent(const QDateTime &, 230 connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
205 const QDateTime &, 231 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
206 const QString &, const QString &)),
207 this, SIGNAL(addEvent(const QDateTime &,
208 const QDateTime &,
209 const QString &, const QString &)));
210 layout->addWidget(hdr); 232 layout->addWidget(hdr);
@@ -214,6 +236,5 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
214 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 236 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
215 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); 237 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
216 layout->addWidget(l); 238 layout->addWidget(l);
217 connect (l, SIGNAL(editEvent(const Event &)), 239 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
218 this, SIGNAL(editEvent(const Event &)));
219 } 240 }
@@ -235,26 +256,18 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
235{ 256{
236 QHBoxLayout *layout = new QHBoxLayout( this ); 257 QHBoxLayout *layout = new QHBoxLayout( this );
237 258
238 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 259 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
239 layout->addWidget(w); 260 layout->addWidget(w);
240 connect (w, SIGNAL(editEvent(const Event &)), 261 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
241 this, SIGNAL(editEvent(const Event &))); 262 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
242 connect (w, SIGNAL(showDate(int,int,int)), 263 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)),
243 this, SIGNAL(showDate(int,int,int))); 264 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
244 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 265
245 const QString &,const QString &)), 266
246 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, 267 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
247 const QString &, const QString &))); 268 layout->addWidget(w);
248 269 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
249 270 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
250 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 271 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
251 layout->addWidget(w); 272 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
252 connect (w, SIGNAL(editEvent(const Event &)),
253 this, SIGNAL(editEvent(const Event &)));
254 connect (w, SIGNAL(showDate(int,int,int)),
255 this, SIGNAL(showDate(int,int,int)));
256 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
257 const QString &, const QString &)),
258 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
259 const QString &, const QString &)));
260} 273}
@@ -276,23 +289,21 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
276 layout->addWidget( header ); 289 layout->addWidget( header );
277 connect(header, SIGNAL(dateChanged(int,int)), 290 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
278 this, SLOT(dateChanged(int,int))); 291 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
279 connect(header, SIGNAL(setDbl(bool)), 292
280 this, SLOT(setDbl(bool))); 293 scroll=new QScrollView(this);
281 294 //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
282 scroll=new QScrollView(this); 295 //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
283 //scroll->setVScrollBarMode(QScrollView::AlwaysOn); 296 scroll->setResizePolicy(QScrollView::AutoOneFit);
284 //scroll->setHScrollBarMode(QScrollView::AlwaysOff); 297 layout->addWidget(scroll);
285 scroll->setResizePolicy(QScrollView::AutoOneFit); 298
286 layout->addWidget(scroll); 299 view=NULL;
287 300 Config config("DateBook");
288 view=NULL; 301 config.setGroup("Main");
289 Config config("DateBook"); 302 dbl=config.readBoolEntry("weeklst_dbl", false);
290 config.setGroup("Main"); 303 header->dbl->setOn(dbl);
291 dbl=config.readBoolEntry("weeklst_dbl", false);
292 header->dbl->setOn(dbl);
293} 304}
294DateBookWeekLst::~DateBookWeekLst(){ 305DateBookWeekLst::~DateBookWeekLst(){
295 Config config("DateBook"); 306 Config config("DateBook");
296 config.setGroup("Main"); 307 config.setGroup("Main");
297 config.writeEntry("weeklst_dbl", dbl); 308 config.writeEntry("weeklst_dbl", dbl);
298} 309}
@@ -300,11 +311,11 @@ DateBookWeekLst::~DateBookWeekLst(){
300void DateBookWeekLst::setDate(const QDate &d) { 311void DateBookWeekLst::setDate(const QDate &d) {
301 int w,y; 312 int w,y;
302 calcWeek(d,w,y,onMonday); 313 calcWeek(d,w,y,onMonday);
303 year=y; 314 year=y;
304 _week=w; 315 _week=w;
305 header->setDate(date()); 316 header->setDate(date());
306} 317}
307void DateBookWeekLst::setDbl(bool on) { 318void DateBookWeekLst::setDbl(bool on) {
308 dbl=on; 319 dbl=on;
309 redraw(); 320 redraw();
310} 321}
@@ -313,12 +324,15 @@ void DateBookWeekLst::redraw() {getEvents();}
313QDate DateBookWeekLst::date() const { 324QDate DateBookWeekLst::date() const {
314 QDate d; 325 QDate d;
315 d.setYMD(year,1,1); 326 d.setYMD(year,1,1);
316 327
317 int dow= d.dayOfWeek(); 328 int dow= d.dayOfWeek();
318 if (!onMonday) 329 if (!onMonday)
319 if (dow==7) dow=1; 330 if (dow==7) {
320 else dow++; 331 dow=1;
332 } else {
333 dow++;
334 }
321 335
322 d=d.addDays( (_week-1)*7 - dow + 1 ); 336 d=d.addDays( (_week-1)*7 - dow + 1 );
323 return d; 337 return d;
324} 338}
@@ -326,29 +340,24 @@ QDate DateBookWeekLst::date() const {
326void DateBookWeekLst::getEvents() { 340void DateBookWeekLst::getEvents() {
327 QDate start = date(); 341 QDate start = date();
328 QDate stop = start.addDays(6); 342 QDate stop = start.addDays(6);
329 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 343 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
330 344
331 if (view) delete view; 345 if (view) delete view;
332 if (dbl) { 346 if (dbl) {
333 QDate start2=start.addDays(7); 347 QDate start2=start.addDays(7);
334 stop=start2.addDays(6); 348 stop=start2.addDays(6);
335 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 349 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
336 350 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll);
337 view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); 351 } else {
338 } else { 352 view=new DateBookWeekLstView(el,start,onMonday,scroll);
339 view=new DateBookWeekLstView(el,start,onMonday,scroll); 353 }
340 } 354
355 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
356 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
357 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
358 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
341 359
342 connect (view, SIGNAL(editEvent(const Event &)), 360 scroll->addChild(view);
343 this, SIGNAL(editEvent(const Event &))); 361 view->show();
344 connect (view, SIGNAL(showDate(int,int,int)), 362 scroll->updateScrollBars();
345 this, SIGNAL(showDate(int,int,int)));
346 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
347 const QString &, const QString &)),
348 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
349 const QString &, const QString &)));
350
351 scroll->addChild(view);
352 view->show();
353 scroll->updateScrollBars();
354} 363}
@@ -356,5 +365,5 @@ void DateBookWeekLst::getEvents() {
356void DateBookWeekLst::dateChanged(int y, int w) { 365void DateBookWeekLst::dateChanged(int y, int w) {
357 year=y; 366 year=y;
358 _week=w; 367 _week=w;
359 getEvents(); 368 getEvents();
360} 369}
@@ -363,18 +372,18 @@ void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
363{ 372{
364 switch(e->key()) { 373 switch(e->key()) {
365 case Key_Up: 374 case Key_Up:
366 scroll->scrollBy(0, -20); 375 scroll->scrollBy(0, -20);
367 break; 376 break;
368 case Key_Down: 377 case Key_Down:
369 scroll->scrollBy(0, 20); 378 scroll->scrollBy(0, 20);
370 break; 379 break;
371 case Key_Left: 380 case Key_Left:
372 header->prevWeek(); 381 header->prevWeek();
373 break; 382 break;
374 case Key_Right: 383 case Key_Right:
375 header->nextWeek(); 384 header->nextWeek();
376 break; 385 break;
377 default: 386 default:
378 e->ignore(); 387 e->ignore();
379 } 388 }
380} 389}