summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweeklst.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebookweeklst.cpp42
1 files changed, 15 insertions, 27 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index a39ff40..7817042 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -74,3 +74,3 @@ void DateBookWeekLstHeader::setDate(const QDate &d) {
74 tr("w")+":"+QString::number( week ) +")"); 74 tr("w")+":"+QString::number( week ) +")");
75 emit dateChanged(year,week); 75 emit dateChanged(date);
76} 76}
@@ -119,3 +119,3 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
119 119
120 static const char *wdays={"MTWTFSS"}; 120 static const char *wdays={"MTWTFSSM"};
121 char day=wdays[d.dayOfWeek()-1]; 121 char day=wdays[d.dayOfWeek()-1];
@@ -236,5 +236,9 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
236 236
237 // Calculate offset to first day of week.
238 int dayoffset=d.dayOfWeek();
239 if(bStartOnMonday) dayoffset--;
240
237 for (int i=0; i<7; i++) { 241 for (int i=0; i<7; i++) {
238 // Header 242 // Header
239 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), bStartOnMonday,this); 243 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
240 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 244 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
@@ -253,3 +257,2 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
253 } 257 }
254
255 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 258 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
@@ -300,3 +303,3 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
300 layout->addWidget( header ); 303 layout->addWidget( header );
301 connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); 304 connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &)));
302 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 305 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
@@ -320,8 +323,6 @@ DateBookWeekLst::~DateBookWeekLst(){
320void DateBookWeekLst::setDate(const QDate &d) { 323void DateBookWeekLst::setDate(const QDate &d) {
321 int w,y; 324 bdate=d;
322 calcWeek(d,w,y,bStartOnMonday); 325 header->setDate(d);
323 year=y;
324 _week=w;
325 header->setDate(date());
326} 326}
327
327void DateBookWeekLst::setDbl(bool on) { 328void DateBookWeekLst::setDbl(bool on) {
@@ -332,16 +333,4 @@ void DateBookWeekLst::redraw() {getEvents();}
332 333
333QDate DateBookWeekLst::date() const { 334QDate DateBookWeekLst::date() {
334 QDate d; 335 return bdate;
335 d.setYMD(year,1,1);
336
337 int dow= d.dayOfWeek();
338 if (!bStartOnMonday)
339 if (dow==7) {
340 dow=1;
341 } else {
342 dow++;
343 }
344
345 d=d.addDays( (_week-1)*7 - dow + 1 );
346 return d;
347} 336}
@@ -373,5 +362,4 @@ void DateBookWeekLst::getEvents() {
373 362
374void DateBookWeekLst::dateChanged(int y, int w) { 363void DateBookWeekLst::dateChanged(QDate &newdate) {
375 year=y; 364 bdate=newdate;
376 _week=w;
377 getEvents(); 365 getEvents();