author | umopapisdn <umopapisdn> | 2003-05-13 22:58:18 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-05-13 22:58:18 (UTC) |
commit | 1e0e2f57472538bd880967ebe061c8f39a7e270b (patch) (unidiff) | |
tree | fcc070d53148385f93c0dc6ab5443d5100be0d26 /core/pim/datebook/datebookweeklst.cpp | |
parent | 45c0386de12b107e54e4d020d54eb05517a9efac (diff) | |
download | opie-1e0e2f57472538bd880967ebe061c8f39a7e270b.zip opie-1e0e2f57472538bd880967ebe061c8f39a7e270b.tar.gz opie-1e0e2f57472538bd880967ebe061c8f39a7e270b.tar.bz2 |
Bugfix: (Bug #0000902) Adding events in weekview shouldn't create them as events on the first day of the week but rather the last visited day.
Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 42 |
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 | |||
@@ -73,5 +73,5 @@ void DateBookWeekLstHeader::setDate(const QDate &d) { | |||
73 | start.monthName(stop.month()) +" ("+ | 73 | start.monthName(stop.month()) +" ("+ |
74 | tr("w")+":"+QString::number( week ) +")"); | 74 | tr("w")+":"+QString::number( week ) +")"); |
75 | emit dateChanged(year,week); | 75 | emit dateChanged(date); |
76 | } | 76 | } |
77 | 77 | ||
@@ -118,5 +118,5 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, | |||
118 | date=d; | 118 | date=d; |
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]; |
122 | 122 | ||
@@ -235,7 +235,11 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | |||
235 | } | 235 | } |
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))); |
241 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 245 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
@@ -252,5 +256,4 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | |||
252 | it++; | 256 | it++; |
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)); |
256 | } | 259 | } |
@@ -299,5 +302,5 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | |||
299 | header=new DateBookWeekLstHeader(onM, this); | 302 | header=new DateBookWeekLstHeader(onM, this); |
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))); |
303 | 306 | ||
@@ -319,10 +322,8 @@ DateBookWeekLst::~DateBookWeekLst(){ | |||
319 | 322 | ||
320 | void DateBookWeekLst::setDate(const QDate &d) { | 323 | void 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 | |||
327 | void DateBookWeekLst::setDbl(bool on) { | 328 | void DateBookWeekLst::setDbl(bool on) { |
328 | dbl=on; | 329 | dbl=on; |
@@ -331,18 +332,6 @@ void DateBookWeekLst::setDbl(bool on) { | |||
331 | void DateBookWeekLst::redraw() {getEvents();} | 332 | void DateBookWeekLst::redraw() {getEvents();} |
332 | 333 | ||
333 | QDate DateBookWeekLst::date() const { | 334 | QDate 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 | } |
348 | 337 | ||
@@ -372,7 +361,6 @@ void DateBookWeekLst::getEvents() { | |||
372 | } | 361 | } |
373 | 362 | ||
374 | void DateBookWeekLst::dateChanged(int y, int w) { | 363 | void DateBookWeekLst::dateChanged(QDate &newdate) { |
375 | year=y; | 364 | bdate=newdate; |
376 | _week=w; | ||
377 | getEvents(); | 365 | getEvents(); |
378 | } | 366 | } |