Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 7817042..aad1f3a 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -52,25 +52,30 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const ch | |||
52 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); | 52 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); |
53 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); | 53 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); |
54 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); | 54 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); |
55 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | 55 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); |
56 | bStartOnMonday=onM; | 56 | bStartOnMonday=onM; |
57 | } | 57 | } |
58 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 58 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
59 | 59 | ||
60 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 60 | void DateBookWeekLstHeader::setDate(const QDate &d) { |
61 | int year,week,dayofweek; | 61 | int year,week,dayofweek; |
62 | date=d; | 62 | date=d; |
63 | dayofweek=d.dayOfWeek(); | 63 | dayofweek=d.dayOfWeek(); |
64 | if(bStartOnMonday) dayofweek--; | 64 | if(bStartOnMonday) |
65 | dayofweek--; | ||
66 | else if( dayofweek == 7 ) | ||
67 | /* we already have the right day -7 would lead to the same week */ | ||
68 | dayofweek = 0; | ||
69 | |||
65 | date=date.addDays(-dayofweek); | 70 | date=date.addDays(-dayofweek); |
66 | 71 | ||
67 | calcWeek(date,week,year,bStartOnMonday); | 72 | calcWeek(date,week,year,bStartOnMonday); |
68 | QDate start=date; | 73 | QDate start=date; |
69 | QDate stop=start.addDays(6); | 74 | QDate stop=start.addDays(6); |
70 | labelDate->setText( QString::number(start.day()) + "." + | 75 | labelDate->setText( QString::number(start.day()) + "." + |
71 | start.monthName(start.month()) + "-" + | 76 | start.monthName(start.month()) + "-" + |
72 | QString::number(stop.day()) + "." + | 77 | QString::number(stop.day()) + "." + |
73 | start.monthName(stop.month()) +" ("+ | 78 | start.monthName(stop.month()) +" ("+ |
74 | tr("w")+":"+QString::number( week ) +")"); | 79 | tr("w")+":"+QString::number( week ) +")"); |
75 | emit dateChanged(date); | 80 | emit dateChanged(date); |
76 | } | 81 | } |
@@ -108,25 +113,25 @@ void DateBookWeekLstHeader::prevMonth() | |||
108 | { | 113 | { |
109 | setDate(date.addDays(-28)); | 114 | setDate(date.addDays(-28)); |
110 | } | 115 | } |
111 | 116 | ||
112 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, | 117 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, |
113 | QWidget* parent, | 118 | QWidget* parent, |
114 | const char* name, | 119 | const char* name, |
115 | WFlags fl ) | 120 | WFlags fl ) |
116 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | 121 | : DateBookWeekLstDayHdrBase(parent, name, fl) { |
117 | 122 | ||
118 | date=d; | 123 | date=d; |
119 | 124 | ||
120 | static const char *wdays={"MTWTFSSM"}; | 125 | static const QString wdays=tr("MTWTFSSM", "Week days"); |
121 | char day=wdays[d.dayOfWeek()-1]; | 126 | char day=wdays[d.dayOfWeek()-1]; |
122 | 127 | ||
123 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); | 128 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); |
124 | add->setText("+"); | 129 | add->setText("+"); |
125 | 130 | ||
126 | if (d == QDate::currentDate()) { | 131 | if (d == QDate::currentDate()) { |
127 | QPalette pal=label->palette(); | 132 | QPalette pal=label->palette(); |
128 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); | 133 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); |
129 | label->setPalette(pal); | 134 | label->setPalette(pal); |
130 | 135 | ||
131 | /* | 136 | /* |
132 | QFont f=label->font(); | 137 | QFont f=label->font(); |
@@ -228,24 +233,25 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | |||
228 | 233 | ||
229 | int dayOrder[7]; | 234 | int dayOrder[7]; |
230 | if (bStartOnMonday) { | 235 | if (bStartOnMonday) { |
231 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 236 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
232 | } else { | 237 | } else { |
233 | for (int d=0; d<7; d++) dayOrder[d]=d; | 238 | for (int d=0; d<7; d++) dayOrder[d]=d; |
234 | dayOrder[0]=7; | 239 | dayOrder[0]=7; |
235 | } | 240 | } |
236 | 241 | ||
237 | // Calculate offset to first day of week. | 242 | // Calculate offset to first day of week. |
238 | int dayoffset=d.dayOfWeek(); | 243 | int dayoffset=d.dayOfWeek(); |
239 | if(bStartOnMonday) dayoffset--; | 244 | if(bStartOnMonday) dayoffset--; |
245 | else if( dayoffset == 7 ) dayoffset = 0; | ||
240 | 246 | ||
241 | for (int i=0; i<7; i++) { | 247 | for (int i=0; i<7; i++) { |
242 | // Header | 248 | // Header |
243 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); | 249 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); |
244 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 250 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
245 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 251 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
246 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 252 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
247 | layout->addWidget(hdr); | 253 | layout->addWidget(hdr); |
248 | 254 | ||
249 | // Events | 255 | // Events |
250 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 256 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
251 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. | 257 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. |