summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp47
-rw-r--r--core/pim/datebook/datebookweek.h6
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp26
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.h4
-rw-r--r--core/pim/datebook/datebookweeklst.cpp76
-rw-r--r--core/pim/datebook/datebookweeklst.h11
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
@@ -372,3 +372,3 @@ DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
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() ) );
@@ -401,7 +401,12 @@ 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}
@@ -413,14 +418,12 @@ void DateBookWeek::setDate( int y, int m, int d )
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();
@@ -430,13 +433,3 @@ 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}
@@ -580,3 +573,9 @@ 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}
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
@@ -126,3 +126,3 @@ 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 & );
@@ -152,2 +152,3 @@ private:
152 int dow; 152 int dow;
153 QDate bdate;
153 DateBookWeekHeader *header; 154 DateBookWeekHeader *header;
@@ -163,4 +164,3 @@ private:
163 164
164bool calcWeek( const QDate &d, int &week, int &year, 165bool 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
@@ -107,3 +107,3 @@ void DateBookWeekHeader::setDate(const QDate &d) {
107 tr("w")+":"+QString::number( week ) +")"); 107 tr("w")+":"+QString::number( week ) +")");
108 emit dateChanged(year,week); 108 emit dateChanged(date);
109} 109}
@@ -115,25 +115 @@ void DateBookWeekHeader::setStartOfWeek( bool onMonday )
115} }
116
117// dateFromWeek
118// compute the date from the week in the year
119QDate 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
@@ -38,3 +38,3 @@ public:
38signals: 38signals:
39 void dateChanged( int y, int w ); 39 void dateChanged( QDate &date );
40 40
@@ -56,4 +56,2 @@ private:
56 56
57QDate 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
@@ -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}
@@ -111,3 +111,3 @@ void DateBookWeekLstHeader::prevMonth()
111 111
112DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, 112DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
113 QWidget* parent, 113 QWidget* parent,
@@ -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,21 +236,24 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
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 }
@@ -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();
@@ -397,2 +385,2 @@ void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
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
@@ -34,3 +34,3 @@ public slots:
34signals: 34signals:
35 void dateChanged(int y, int w); 35 void dateChanged(QDate &newdate);
36 void setDbl(bool on); 36 void setDbl(bool on);
@@ -121,3 +121,3 @@ public:
121 int week() const { return _week; }; 121 int week() const { return _week; };
122 QDate date() const; 122 QDate date();
123 123
@@ -125,3 +125,3 @@ public slots:
125 void redraw(); 125 void redraw();
126 void dateChanged(int y, int w); 126 void dateChanged(QDate &date);
127 127
@@ -143,3 +143,4 @@ private:
143 bool dbl; 143 bool dbl;
144 int year, _week; 144 QDate bdate;
145 int year, _week,dow;
145 DateBookWeekLstHeader *header; 146 DateBookWeekLstHeader *header;
@@ -148,3 +149,3 @@ private:
148 QScrollView *scroll; 149 QScrollView *scroll;
149 150
150 void getEvents(); 151 void getEvents();