summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweek.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebookweek.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp47
1 files changed, 23 insertions, 24 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 3ae4610..12f57a0 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -370,7 +370,7 @@ DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
370 connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); 370 connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) );
371 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); 371 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
372 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); 372 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
373 connect( header, SIGNAL( dateChanged( int, int ) ), this, SLOT( dateChanged( int, int ) ) ); 373 connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) );
374 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); 374 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
375 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 375 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
376 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); 376 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
@@ -399,11 +399,16 @@ void DateBookWeek::keyPressEvent(QKeyEvent *e)
399 399
400void DateBookWeek::showDay( int day ) 400void DateBookWeek::showDay( int day )
401{ 401{
402 QDate d; 402 QDate d=bdate;
403 d = dateFromWeek( _week, year, bStartOnMonday ); 403
404 // Calculate offset to first day of week.
405 int dayoffset=d.dayOfWeek();
406 if(bStartOnMonday) dayoffset--;
407
404 day--; 408 day--;
405 d = d.addDays( day ); 409 d=d.addDays(day-dayoffset);
406 emit showDate( d.year(), d.month(), d.day() ); 410 emit showDate( d.year(), d.month(), d.day() );
411 qDebug("%4d-%02d-%02d / Day %d\n",d.year(),d.month(),d.day(),day);
407} 412}
408 413
409void DateBookWeek::setDate( int y, int m, int d ) 414void DateBookWeek::setDate( int y, int m, int d )
@@ -411,34 +416,22 @@ void DateBookWeek::setDate( int y, int m, int d )
411 setDate(QDate(y, m, d)); 416 setDate(QDate(y, m, d));
412} 417}
413 418
414void DateBookWeek::setDate(QDate date) 419void DateBookWeek::setDate(QDate newdate)
415{ 420{
416 dow = date.dayOfWeek(); 421 bdate=newdate;
417 int w, y; 422 dow = newdate.dayOfWeek();
418 calcWeek( date, w, y, bStartOnMonday ); 423 header->setDate( newdate );
419 header->setDate( date );
420} 424}
421 425
422void DateBookWeek::dateChanged( int y, int w ) 426void DateBookWeek::dateChanged( QDate &newdate )
423{ 427{
424 year = y; 428 bdate=newdate;
425 _week = w;
426 getEvents(); 429 getEvents();
427} 430}
428 431
429QDate DateBookWeek::date() const 432QDate DateBookWeek::date() const
430{ 433{
431 QDate d; 434 return bdate;
432 d = dateFromWeek( _week - 1, year, bStartOnMonday );
433 if ( bStartOnMonday )
434 d = d.addDays( 7 + dow - 1 );
435 else {
436 if ( dow == 7 )
437 d = d.addDays( dow );
438 else
439 d = d.addDays( 7 + dow );
440 }
441 return d;
442} 435}
443 436
444void DateBookWeek::getEvents() 437void DateBookWeek::getEvents()
@@ -578,7 +571,13 @@ void DateBookWeek::slotClockChanged( bool ap )
578// return the date at the beginning of the week... 571// return the date at the beginning of the week...
579QDate DateBookWeek::weekDate() const 572QDate DateBookWeek::weekDate() const
580{ 573{
581 return dateFromWeek( _week, year, bStartOnMonday ); 574 QDate d=bdate;
575
576 // Calculate offset to first day of week.
577 int dayoffset=d.dayOfWeek();
578 if(bStartOnMonday) dayoffset--;
579
580 return d.addDays(-dayoffset);
582} 581}
583 582
584// this used to only be needed by datebook.cpp, but now we need it inside 583// this used to only be needed by datebook.cpp, but now we need it inside