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.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 42a1753..af40143 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -51,49 +51,49 @@ void DateBookWeekLstHeader::setDate(const QDate &d) {
51 /* we already have the right day -7 would lead to the same week */ 51 /* we already have the right day -7 would lead to the same week */
52 dayofweek = 0; 52 dayofweek = 0;
53 53
54 date=date.addDays(-dayofweek); 54 date=date.addDays(-dayofweek);
55 55
56 calcWeek(date,week,year,bStartOnMonday); 56 calcWeek(date,week,year,bStartOnMonday);
57 QDate start=date; 57 QDate start=date;
58 QDate stop=start.addDays(6); 58 QDate stop=start.addDays(6);
59 labelDate->setText( QString::number(start.day()) + "." + 59 labelDate->setText( QString::number(start.day()) + "." +
60 Calendar::nameOfMonth( start.month() ) + "-" + 60 Calendar::nameOfMonth( start.month() ) + "-" +
61 QString::number(stop.day()) + "." + 61 QString::number(stop.day()) + "." +
62 Calendar::nameOfMonth( stop.month()) +" ("+ 62 Calendar::nameOfMonth( stop.month()) +" ("+
63 tr("w")+":"+QString::number( week ) +")"); 63 tr("w")+":"+QString::number( week ) +")");
64 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 64 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
65 emit dateChanged(date); 65 emit dateChanged(date);
66} 66}
67 67
68void DateBookWeekLstHeader::pickDate() { 68void DateBookWeekLstHeader::pickDate() {
69 static QPopupMenu *m1 = 0; 69 static QPopupMenu *m1 = 0;
70 static DateBookMonth *picker = 0; 70 static DateBookMonth *picker = 0;
71 if ( !m1 ) { 71 if ( !m1 ) {
72 m1 = new QPopupMenu( this ); 72 m1 = new QPopupMenu( this );
73 picker = new DateBookMonth( m1, 0, TRUE ); 73 picker = new DateBookMonth( m1, 0, TRUE );
74 m1->insertItem( picker ); 74 m1->insertItem( picker );
75 connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); 75 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
76 //connect( m1, SIGNAL( aboutToHide() ), 76 //connect( m1, SIGNAL( aboutToHide() ),
77 //this, SLOT( gotHide() ) ); 77 //this, SLOT( gotHide() ) );
78 } 78 }
79 picker->setDate( date.year(), date.month(), date.day() ); 79 picker->setDate( date.year(), date.month(), date.day() );
80 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 80 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
81 picker->setFocus(); 81 picker->setFocus();
82} 82}
83void DateBookWeekLstHeader::setDate(int y, int m, int d) { 83void DateBookWeekLstHeader::setDate(int y, int m, int d) {
84 setDate(QDate(y,m,d)); 84 setDate(QDate(y,m,d));
85} 85}
86 86
87void DateBookWeekLstHeader::nextWeek() { 87void DateBookWeekLstHeader::nextWeek() {
88 setDate(date.addDays(7)); 88 setDate(date.addDays(7));
89} 89}
90void DateBookWeekLstHeader::prevWeek() { 90void DateBookWeekLstHeader::prevWeek() {
91 setDate(date.addDays(-7)); 91 setDate(date.addDays(-7));
92} 92}
93void DateBookWeekLstHeader::nextMonth() 93void DateBookWeekLstHeader::nextMonth()
94{ 94{
95 setDate(date.addDays(28)); 95 setDate(date.addDays(28));
96} 96}
97void DateBookWeekLstHeader::prevMonth() 97void DateBookWeekLstHeader::prevMonth()
98{ 98{
99 setDate(date.addDays(-28)); 99 setDate(date.addDays(-28));
@@ -214,108 +214,108 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
214 214
215 QVBoxLayout *layout = new QVBoxLayout( this ); 215 QVBoxLayout *layout = new QVBoxLayout( this );
216 216
217 qBubbleSort(ev); 217 qBubbleSort(ev);
218 QValueListIterator<EffectiveEvent> it; 218 QValueListIterator<EffectiveEvent> it;
219 it=ev.begin(); 219 it=ev.begin();
220 220
221 int dayOrder[7]; 221 int dayOrder[7];
222 if (bStartOnMonday) { 222 if (bStartOnMonday) {
223 for (int d=0; d<7; d++) dayOrder[d]=d+1; 223 for (int d=0; d<7; d++) dayOrder[d]=d+1;
224 } else { 224 } else {
225 for (int d=0; d<7; d++) dayOrder[d]=d; 225 for (int d=0; d<7; d++) dayOrder[d]=d;
226 dayOrder[0]=7; 226 dayOrder[0]=7;
227 } 227 }
228 228
229 // Calculate offset to first day of week. 229 // Calculate offset to first day of week.
230 int dayoffset=d.dayOfWeek(); 230 int dayoffset=d.dayOfWeek();
231 if(bStartOnMonday) dayoffset--; 231 if(bStartOnMonday) dayoffset--;
232 else if( dayoffset == 7 ) dayoffset = 0; 232 else if( dayoffset == 7 ) dayoffset = 0;
233 233
234 for (int i=0; i<7; i++) { 234 for (int i=0; i<7; i++) {
235 // Header 235 // Header
236 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 236 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
237 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 237 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 &)), 238 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
239 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 239 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
240 layout->addWidget(hdr); 240 layout->addWidget(hdr);
241 241
242 // Events 242 // Events
243 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 243 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. 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 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 245 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
246 layout->addWidget(l); 246 layout->addWidget(l);
247 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 247 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
248 } 248 }
249 it++; 249 it++;
250 } 250 }
251 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 251 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
252 } 252 }
253} 253}
254DateBookWeekLstView::~DateBookWeekLstView(){} 254DateBookWeekLstView::~DateBookWeekLstView(){}
255void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 255void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
256 256
257DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 257DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
258 QValueList<EffectiveEvent> &ev2, 258 QValueList<EffectiveEvent> &ev2,
259 QDate &d, bool onM, 259 QDate &d, bool onM,
260 QWidget* parent, 260 QWidget* parent,
261 const char* name, WFlags fl) 261 const char* name, WFlags fl)
262 : QWidget( parent, name, fl ) 262 : QWidget( parent, name, fl )
263{ 263{
264 QHBoxLayout *layout = new QHBoxLayout( this ); 264 QHBoxLayout *layout = new QHBoxLayout( this );
265 265
266 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 266 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
267 layout->addWidget(w); 267 layout->addWidget(w);
268 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 268 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))); 269 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 &)), 270 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
271 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 271 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
272 272
273 273
274 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 274 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
275 layout->addWidget(w); 275 layout->addWidget(w);
276 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 276 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))); 277 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 &)), 278 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
279 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 279 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
280} 280}
281 281
282DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 282DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
283 QWidget *parent, 283 QWidget *parent,
284 const char *name ) 284 const char *name )
285 : QWidget( parent, name ), 285 : QWidget( parent, name ),
286 db( newDB ), 286 db( newDB ),
287 startTime( 0 ), 287 startTime( 0 ),
288 ampm( ap ), 288 ampm( ap ),
289 bStartOnMonday(onM) 289 bStartOnMonday(onM)
290{ 290{
291 setFocusPolicy(StrongFocus); 291 setFocusPolicy(StrongFocus);
292 layout = new QVBoxLayout( this ); 292 layout = new QVBoxLayout( this );
293 layout->setMargin(0); 293 layout->setMargin(0);
294 294
295 header=new DateBookWeekLstHeader(onM, this); 295 header=new DateBookWeekLstHeader(onM, this);
296 layout->addWidget( header ); 296 layout->addWidget( header );
297 connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &))); 297 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
298 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 298 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
299 299
300 scroll=new QScrollView(this); 300 scroll=new QScrollView(this);
301 scroll->setResizePolicy(QScrollView::AutoOneFit); 301 scroll->setResizePolicy(QScrollView::AutoOneFit);
302 layout->addWidget(scroll); 302 layout->addWidget(scroll);
303 303
304 view=NULL; 304 view=NULL;
305 Config config("DateBook"); 305 Config config("DateBook");
306 config.setGroup("Main"); 306 config.setGroup("Main");
307 dbl=config.readBoolEntry("weeklst_dbl", false); 307 dbl=config.readBoolEntry("weeklst_dbl", false);
308 header->dbl->setOn(dbl); 308 header->dbl->setOn(dbl);
309} 309}
310DateBookWeekLst::~DateBookWeekLst(){ 310DateBookWeekLst::~DateBookWeekLst(){
311 Config config("DateBook"); 311 Config config("DateBook");
312 config.setGroup("Main"); 312 config.setGroup("Main");
313 config.writeEntry("weeklst_dbl", dbl); 313 config.writeEntry("weeklst_dbl", dbl);
314} 314}
315 315
316void DateBookWeekLst::setDate(const QDate &d) { 316void DateBookWeekLst::setDate(const QDate &d) {
317 bdate=d; 317 bdate=d;
318 header->setDate(d); 318 header->setDate(d);
319} 319}
320 320
321void DateBookWeekLst::setDbl(bool on) { 321void DateBookWeekLst::setDbl(bool on) {
@@ -337,52 +337,52 @@ QDate DateBookWeekLst::weekDate() const
337 // Calculate offset to first day of week. 337 // Calculate offset to first day of week.
338 int dayoffset=d.dayOfWeek(); 338 int dayoffset=d.dayOfWeek();
339 if(bStartOnMonday) dayoffset--; 339 if(bStartOnMonday) dayoffset--;
340 else if( dayoffset == 7 ) 340 else if( dayoffset == 7 )
341 dayoffset = 0; 341 dayoffset = 0;
342 342
343 return d.addDays(-dayoffset); 343 return d.addDays(-dayoffset);
344} 344}
345 345
346void DateBookWeekLst::getEvents() { 346void DateBookWeekLst::getEvents() {
347 QDate start = weekDate(); //date(); 347 QDate start = weekDate(); //date();
348 QDate stop = start.addDays(6); 348 QDate stop = start.addDays(6);
349 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 349 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
350 350
351 if (view) delete view; 351 if (view) delete view;
352 if (dbl) { 352 if (dbl) {
353 QDate start2=start.addDays(7); 353 QDate start2=start.addDays(7);
354 stop=start2.addDays(6); 354 stop=start2.addDays(6);
355 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 355 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
356 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 356 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
357 } else { 357 } else {
358 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 358 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
359 } 359 }
360 360
361 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 361 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))); 362 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 &)), 363 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
364 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 364 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
365 365
366 scroll->addChild(view); 366 scroll->addChild(view);
367 view->show(); 367 view->show();
368 scroll->updateScrollBars(); 368 scroll->updateScrollBars();
369} 369}
370 370
371void DateBookWeekLst::dateChanged(QDate &newdate) { 371void DateBookWeekLst::dateChanged(QDate &newdate) {
372 bdate=newdate; 372 bdate=newdate;
373 getEvents(); 373 getEvents();
374} 374}
375 375
376void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 376void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
377{ 377{
378 switch(e->key()) { 378 switch(e->key()) {
379 case Key_Up: 379 case Key_Up:
380 scroll->scrollBy(0, -20); 380 scroll->scrollBy(0, -20);
381 break; 381 break;
382 case Key_Down: 382 case Key_Down:
383 scroll->scrollBy(0, 20); 383 scroll->scrollBy(0, 20);
384 break; 384 break;
385 case Key_Left: 385 case Key_Left:
386 header->prevWeek(); 386 header->prevWeek();
387 break; 387 break;
388 case Key_Right: 388 case Key_Right: