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 | |
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.
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 47 | ||||
-rw-r--r-- | core/pim/datebook/datebookweek.h | 6 | ||||
-rw-r--r-- | core/pim/datebook/datebookweekheaderimpl.cpp | 26 | ||||
-rw-r--r-- | core/pim/datebook/datebookweekheaderimpl.h | 4 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 76 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 11 |
6 files changed, 66 insertions, 104 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 | |||
@@ -367,13 +367,13 @@ DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, | |||
367 | 367 | ||
368 | tHide = new QTimer( this ); | 368 | tHide = new QTimer( this ); |
369 | 369 | ||
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))); |
377 | setDate(QDate::currentDate()); | 377 | setDate(QDate::currentDate()); |
378 | } | 378 | } |
379 | 379 | ||
@@ -396,52 +396,45 @@ void DateBookWeek::keyPressEvent(QKeyEvent *e) | |||
396 | e->ignore(); | 396 | e->ignore(); |
397 | } | 397 | } |
398 | } | 398 | } |
399 | 399 | ||
400 | void DateBookWeek::showDay( int day ) | 400 | void 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 | ||
409 | void DateBookWeek::setDate( int y, int m, int d ) | 414 | void DateBookWeek::setDate( int y, int m, int d ) |
410 | { | 415 | { |
411 | setDate(QDate(y, m, d)); | 416 | setDate(QDate(y, m, d)); |
412 | } | 417 | } |
413 | 418 | ||
414 | void DateBookWeek::setDate(QDate date) | 419 | void 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 | ||
422 | void DateBookWeek::dateChanged( int y, int w ) | 426 | void DateBookWeek::dateChanged( QDate &newdate ) |
423 | { | 427 | { |
424 | year = y; | 428 | bdate=newdate; |
425 | _week = w; | ||
426 | getEvents(); | 429 | getEvents(); |
427 | } | 430 | } |
428 | 431 | ||
429 | QDate DateBookWeek::date() const | 432 | QDate 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 | ||
444 | void DateBookWeek::getEvents() | 437 | void DateBookWeek::getEvents() |
445 | { | 438 | { |
446 | QDate startWeek = weekDate(); | 439 | QDate startWeek = weekDate(); |
447 | 440 | ||
@@ -575,13 +568,19 @@ void DateBookWeek::slotClockChanged( bool ap ) | |||
575 | ampm = ap; | 568 | ampm = ap; |
576 | } | 569 | } |
577 | 570 | ||
578 | // return the date at the beginning of the week... | 571 | // return the date at the beginning of the week... |
579 | QDate DateBookWeek::weekDate() const | 572 | QDate 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 |
585 | // week view since | 584 | // week view since |
586 | // we need to be able to figure out our total number of weeks on the fly... | 585 | // we need to be able to figure out our total number of weeks on the fly... |
587 | // this is probably the best place to put it.. | 586 | // this is probably the best place to put it.. |
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h index 8c5e06d..c273e30 100644 --- a/core/pim/datebook/datebookweek.h +++ b/core/pim/datebook/datebookweek.h | |||
@@ -121,13 +121,13 @@ signals: | |||
121 | 121 | ||
122 | protected slots: | 122 | protected slots: |
123 | void keyPressEvent(QKeyEvent *); | 123 | void keyPressEvent(QKeyEvent *); |
124 | 124 | ||
125 | private slots: | 125 | private slots: |
126 | void showDay( int day ); | 126 | void showDay( int day ); |
127 | void dateChanged( int y, int w ); | 127 | void dateChanged( QDate &newdate ); |
128 | void slotShowEvent( const EffectiveEvent & ); | 128 | void slotShowEvent( const EffectiveEvent & ); |
129 | void slotHideEvent(); | 129 | void slotHideEvent(); |
130 | void slotYearChanged( int ); | 130 | void slotYearChanged( int ); |
131 | 131 | ||
132 | private: | 132 | private: |
133 | void getEvents(); | 133 | void getEvents(); |
@@ -147,20 +147,20 @@ private: | |||
147 | */ | 147 | */ |
148 | void generateNormalTooltext( QString& text, | 148 | void generateNormalTooltext( QString& text, |
149 | const EffectiveEvent &ev); | 149 | const EffectiveEvent &ev); |
150 | int year; | 150 | int year; |
151 | int _week; | 151 | int _week; |
152 | int dow; | 152 | int dow; |
153 | QDate bdate; | ||
153 | DateBookWeekHeader *header; | 154 | DateBookWeekHeader *header; |
154 | DateBookWeekView *view; | 155 | DateBookWeekView *view; |
155 | DateBookDB *db; | 156 | DateBookDB *db; |
156 | QLabel *lblDesc; | 157 | QLabel *lblDesc; |
157 | QTimer *tHide; | 158 | QTimer *tHide; |
158 | int startTime; | 159 | int startTime; |
159 | bool ampm; | 160 | bool ampm; |
160 | bool bStartOnMonday; | 161 | bool bStartOnMonday; |
161 | }; | 162 | }; |
162 | 163 | ||
163 | 164 | ||
164 | bool calcWeek( const QDate &d, int &week, int &year, | 165 | bool calcWeek( const QDate &d, int &week, int &year, bool startOnMonday = false ); |
165 | bool startOnMonday = false ); | ||
166 | #endif | 166 | #endif |
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp index fd792e2..ff7626f 100644 --- a/core/pim/datebook/datebookweekheaderimpl.cpp +++ b/core/pim/datebook/datebookweekheaderimpl.cpp | |||
@@ -102,38 +102,14 @@ void DateBookWeekHeader::setDate(const QDate &d) { | |||
102 | QDate stop=start.addDays(6); | 102 | QDate stop=start.addDays(6); |
103 | labelDate->setText( QString::number(start.day()) + "." + | 103 | labelDate->setText( QString::number(start.day()) + "." + |
104 | start.monthName(start.month()) + "-" + | 104 | start.monthName(start.month()) + "-" + |
105 | QString::number(stop.day()) + "." + | 105 | QString::number(stop.day()) + "." + |
106 | start.monthName(stop.month()) +" ("+ | 106 | start.monthName(stop.month()) +" ("+ |
107 | tr("w")+":"+QString::number( week ) +")"); | 107 | tr("w")+":"+QString::number( week ) +")"); |
108 | emit dateChanged(year,week); | 108 | emit dateChanged(date); |
109 | } | 109 | } |
110 | 110 | ||
111 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) | 111 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) |
112 | { | 112 | { |
113 | bStartOnMonday = onMonday; | 113 | bStartOnMonday = onMonday; |
114 | setDate( date ); | 114 | setDate( date ); |
115 | } | 115 | } |
116 | |||
117 | // dateFromWeek | ||
118 | // compute the date from the week in the year | ||
119 | QDate dateFromWeek( int week, int year, bool startOnMonday ) | ||
120 | { | ||
121 | QDate d; | ||
122 | d.setYMD( year, 1, 1 ); | ||
123 | int dayOfWeek = d.dayOfWeek(); | ||
124 | if ( startOnMonday ) { | ||
125 | if ( dayOfWeek <= 4 ) { | ||
126 | d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 ); | ||
127 | } else { | ||
128 | d = d.addDays( (week) * 7 - dayOfWeek + 1 ); | ||
129 | } | ||
130 | } else { | ||
131 | if ( dayOfWeek <= 4 || dayOfWeek == 7) { | ||
132 | d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 ); | ||
133 | } else { | ||
134 | d = d.addDays( ( week ) * 7 - dayOfWeek % 7 ); | ||
135 | } | ||
136 | } | ||
137 | return d; | ||
138 | } | ||
139 | |||
diff --git a/core/pim/datebook/datebookweekheaderimpl.h b/core/pim/datebook/datebookweekheaderimpl.h index 1ab1d52..d8dce90 100644 --- a/core/pim/datebook/datebookweekheaderimpl.h +++ b/core/pim/datebook/datebookweekheaderimpl.h | |||
@@ -33,13 +33,13 @@ public: | |||
33 | ~DateBookWeekHeader(); | 33 | ~DateBookWeekHeader(); |
34 | 34 | ||
35 | void setDate(const QDate &d); | 35 | void setDate(const QDate &d); |
36 | void setStartOfWeek( bool onMonday ); | 36 | void setStartOfWeek( bool onMonday ); |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void dateChanged( int y, int w ); | 39 | void dateChanged( QDate &date ); |
40 | 40 | ||
41 | public slots: | 41 | public slots: |
42 | void pickDate(); | 42 | void pickDate(); |
43 | void nextMonth(); | 43 | void nextMonth(); |
44 | void prevMonth(); | 44 | void prevMonth(); |
45 | void nextWeek(); | 45 | void nextWeek(); |
@@ -51,9 +51,7 @@ protected slots: | |||
51 | 51 | ||
52 | private: | 52 | private: |
53 | QDate date; | 53 | QDate date; |
54 | bool bStartOnMonday; | 54 | bool bStartOnMonday; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | QDate dateFromWeek( int week, int year, bool startOnMonday ); | ||
58 | |||
59 | #endif // DATEBOOKDAYHEADER_H | 57 | #endif // DATEBOOKDAYHEADER_H |
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 | |||
@@ -69,13 +69,13 @@ void DateBookWeekLstHeader::setDate(const QDate &d) { | |||
69 | QDate stop=start.addDays(6); | 69 | QDate stop=start.addDays(6); |
70 | labelDate->setText( QString::number(start.day()) + "." + | 70 | labelDate->setText( QString::number(start.day()) + "." + |
71 | start.monthName(start.month()) + "-" + | 71 | start.monthName(start.month()) + "-" + |
72 | QString::number(stop.day()) + "." + | 72 | QString::number(stop.day()) + "." + |
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 | ||
78 | void DateBookWeekLstHeader::pickDate() { | 78 | void DateBookWeekLstHeader::pickDate() { |
79 | static QPopupMenu *m1 = 0; | 79 | static QPopupMenu *m1 = 0; |
80 | static DateBookMonth *picker = 0; | 80 | static DateBookMonth *picker = 0; |
81 | if ( !m1 ) { | 81 | if ( !m1 ) { |
@@ -106,21 +106,21 @@ void DateBookWeekLstHeader::nextMonth() | |||
106 | } | 106 | } |
107 | void DateBookWeekLstHeader::prevMonth() | 107 | void DateBookWeekLstHeader::prevMonth() |
108 | { | 108 | { |
109 | setDate(date.addDays(-28)); | 109 | setDate(date.addDays(-28)); |
110 | } | 110 | } |
111 | 111 | ||
112 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, | 112 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, |
113 | QWidget* parent, | 113 | QWidget* parent, |
114 | const char* name, | 114 | const char* name, |
115 | WFlags fl ) | 115 | WFlags fl ) |
116 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | 116 | : DateBookWeekLstDayHdrBase(parent, name, fl) { |
117 | 117 | ||
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 | ||
123 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); | 123 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); |
124 | add->setText("+"); | 124 | add->setText("+"); |
125 | 125 | ||
126 | if (d == QDate::currentDate()) { | 126 | if (d == QDate::currentDate()) { |
@@ -231,31 +231,34 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | |||
231 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 231 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
232 | } else { | 232 | } else { |
233 | for (int d=0; d<7; d++) dayOrder[d]=d; | 233 | for (int d=0; d<7; d++) dayOrder[d]=d; |
234 | dayOrder[0]=7; | 234 | dayOrder[0]=7; |
235 | } | 235 | } |
236 | 236 | ||
237 | for (int i=0; i<7; i++) { | 237 | // Calculate offset to first day of week. |
238 | int dayoffset=d.dayOfWeek(); | ||
239 | if(bStartOnMonday) dayoffset--; | ||
240 | |||
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 &)), |
242 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 246 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
243 | layout->addWidget(hdr); | 247 | layout->addWidget(hdr); |
244 | 248 | ||
245 | // Events | 249 | // Events |
246 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 250 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
247 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. | 251 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. |
248 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | 252 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); |
249 | layout->addWidget(l); | 253 | layout->addWidget(l); |
250 | connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 254 | connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
255 | } | ||
256 | it++; | ||
251 | } | 257 | } |
252 | it++; | 258 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
253 | } | ||
254 | |||
255 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | ||
256 | } | 259 | } |
257 | } | 260 | } |
258 | DateBookWeekLstView::~DateBookWeekLstView(){} | 261 | DateBookWeekLstView::~DateBookWeekLstView(){} |
259 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | 262 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} |
260 | 263 | ||
261 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 264 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
@@ -295,13 +298,13 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | |||
295 | setFocusPolicy(StrongFocus); | 298 | setFocusPolicy(StrongFocus); |
296 | layout = new QVBoxLayout( this ); | 299 | layout = new QVBoxLayout( this ); |
297 | layout->setMargin(0); | 300 | layout->setMargin(0); |
298 | 301 | ||
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 | ||
304 | scroll=new QScrollView(this); | 307 | scroll=new QScrollView(this); |
305 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 308 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
306 | layout->addWidget(scroll); | 309 | layout->addWidget(scroll); |
307 | 310 | ||
@@ -315,38 +318,24 @@ DateBookWeekLst::~DateBookWeekLst(){ | |||
315 | Config config("DateBook"); | 318 | Config config("DateBook"); |
316 | config.setGroup("Main"); | 319 | config.setGroup("Main"); |
317 | config.writeEntry("weeklst_dbl", dbl); | 320 | config.writeEntry("weeklst_dbl", dbl); |
318 | } | 321 | } |
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; |
329 | redraw(); | 330 | redraw(); |
330 | } | 331 | } |
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 | ||
349 | void DateBookWeekLst::getEvents() { | 338 | void DateBookWeekLst::getEvents() { |
350 | QDate start = date(); | 339 | QDate start = date(); |
351 | QDate stop = start.addDays(6); | 340 | QDate stop = start.addDays(6); |
352 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 341 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
@@ -368,15 +357,14 @@ void DateBookWeekLst::getEvents() { | |||
368 | 357 | ||
369 | scroll->addChild(view); | 358 | scroll->addChild(view); |
370 | view->show(); | 359 | view->show(); |
371 | scroll->updateScrollBars(); | 360 | scroll->updateScrollBars(); |
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 | } |
379 | 367 | ||
380 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 368 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
381 | { | 369 | { |
382 | switch(e->key()) { | 370 | switch(e->key()) { |
@@ -392,7 +380,7 @@ void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | |||
392 | case Key_Right: | 380 | case Key_Right: |
393 | header->nextWeek(); | 381 | header->nextWeek(); |
394 | break; | 382 | break; |
395 | default: | 383 | default: |
396 | e->ignore(); | 384 | e->ignore(); |
397 | } | 385 | } |
398 | } \ No newline at end of file | 386 | } |
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h index f858c4f..0bfbcda 100644 --- a/core/pim/datebook/datebookweeklst.h +++ b/core/pim/datebook/datebookweeklst.h | |||
@@ -29,13 +29,13 @@ public slots: | |||
29 | void prevWeek(); | 29 | void prevWeek(); |
30 | void nextMonth(); | 30 | void nextMonth(); |
31 | void prevMonth(); | 31 | void prevMonth(); |
32 | void pickDate(); | 32 | void pickDate(); |
33 | void setDate(int y, int m, int d); | 33 | void setDate(int y, int m, int d); |
34 | signals: | 34 | signals: |
35 | void dateChanged(int y, int w); | 35 | void dateChanged(QDate &newdate); |
36 | void setDbl(bool on); | 36 | void setDbl(bool on); |
37 | private: | 37 | private: |
38 | QDate date; | 38 | QDate date; |
39 | //bool onMonday; | 39 | //bool onMonday; |
40 | bool bStartOnMonday; | 40 | bool bStartOnMonday; |
41 | }; | 41 | }; |
@@ -116,17 +116,17 @@ public: | |||
116 | QWidget *parent = 0, | 116 | QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | ~DateBookWeekLst(); | 118 | ~DateBookWeekLst(); |
119 | void setDate( int y, int w ); | 119 | void setDate( int y, int w ); |
120 | void setDate(const QDate &d ); | 120 | void setDate(const QDate &d ); |
121 | int week() const { return _week; }; | 121 | int week() const { return _week; }; |
122 | QDate date() const; | 122 | QDate date(); |
123 | 123 | ||
124 | public slots: | 124 | public slots: |
125 | void redraw(); | 125 | void redraw(); |
126 | void dateChanged(int y, int w); | 126 | void dateChanged(QDate &date); |
127 | 127 | ||
128 | protected slots: | 128 | protected slots: |
129 | void keyPressEvent(QKeyEvent *); | 129 | void keyPressEvent(QKeyEvent *); |
130 | void setDbl(bool on); | 130 | void setDbl(bool on); |
131 | 131 | ||
132 | signals: | 132 | signals: |
@@ -138,17 +138,18 @@ signals: | |||
138 | private: | 138 | private: |
139 | DateBookDB *db; | 139 | DateBookDB *db; |
140 | int startTime; | 140 | int startTime; |
141 | bool ampm; | 141 | bool ampm; |
142 | bool bStartOnMonday; | 142 | bool bStartOnMonday; |
143 | bool dbl; | 143 | bool dbl; |
144 | int year, _week; | 144 | QDate bdate; |
145 | int year, _week,dow; | ||
145 | DateBookWeekLstHeader *header; | 146 | DateBookWeekLstHeader *header; |
146 | QWidget *view; | 147 | QWidget *view; |
147 | QVBoxLayout *layout; | 148 | QVBoxLayout *layout; |
148 | QScrollView *scroll; | 149 | QScrollView *scroll; |
149 | 150 | ||
150 | void getEvents(); | 151 | void getEvents(); |
151 | }; | 152 | }; |
152 | 153 | ||
153 | #endif | 154 | #endif |
154 | 155 | ||