author | umopapisdn <umopapisdn> | 2003-04-12 03:56:46 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-04-12 03:56:46 (UTC) |
commit | 8c690a7bb709773217ba3d39d3ef769a2414cc72 (patch) (unidiff) | |
tree | a34bae70ee8dc46f40f60150e1703088fbc4da36 /core/pim/datebook/datebookweeklst.cpp | |
parent | 212aef7fd20182fe926644af2ab10a4b49549440 (diff) | |
download | opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.zip opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.gz opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.bz2 |
New feature:
Added a configurable option to make the weeklist view display either no times at all, only start times, or both start and end time.
Also moved the configuration of default view from the menu into the preference dialog.
Diffstat (limited to 'core/pim/datebook/datebookweeklst.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 297 |
1 files changed, 153 insertions, 144 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 3d6a029..3c8fc89 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | #include "datebookweekheaderimpl.h" | 3 | #include "datebookweekheaderimpl.h" |
4 | 4 | ||
5 | #include "datebook.h" | ||
6 | |||
5 | #include <qpe/calendar.h> | 7 | #include <qpe/calendar.h> |
6 | #include <qpe/datebookdb.h> | 8 | #include <qpe/datebookdb.h> |
7 | #include <qpe/event.h> | 9 | #include <qpe/event.h> |
@@ -143,31 +145,51 @@ void DateBookWeekLstDayHdr::newEvent() { | |||
143 | emit addEvent(start,stop,"",0); | 145 | emit addEvent(start,stop,"",0); |
144 | } | 146 | } |
145 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | 147 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, |
146 | QWidget* parent, | 148 | int weeklistviewconfig, |
147 | const char* name, | 149 | QWidget* parent, |
148 | WFlags fl) : | 150 | const char* name, |
149 | OClickableLabel(parent,name,fl), | 151 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) |
150 | event(ev) | ||
151 | { | 152 | { |
152 | char s[10]; | 153 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", |
153 | if ( ev.startDate() != ev.date() ) { // multiday event (not first day) | 154 | QString s,start,middle,end,day; |
154 | if ( ev.endDate() == ev.date() ) { // last day | 155 | |
155 | strcpy(s, "__|__"); | 156 | qDebug("weeklistviewconfig=%d",weeklistviewconfig); |
156 | } else { | 157 | if(weeklistviewconfig==NONE) {// No times displayed. |
157 | strcpy(s, " |---"); | 158 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); |
159 | // middle.sprintf("<--->"); | ||
160 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | ||
161 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | ||
162 | } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. | ||
163 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
164 | middle.sprintf(" |---"); | ||
165 | end.sprintf("__|__"); | ||
166 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
167 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. | ||
168 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | ||
169 | middle.sprintf("<--->"); | ||
170 | end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | ||
171 | day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | ||
172 | } | ||
173 | |||
174 | if(ev.event().type() == Event::Normal) { | ||
175 | if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. | ||
176 | s=day; | ||
177 | } else if(ev.startDate()==ev.date()) {// start event. | ||
178 | s=start; | ||
179 | } else if(ev.endDate()==ev.date()) { // end event. | ||
180 | s=end; | ||
181 | } else {// middle day. | ||
182 | s=middle; | ||
158 | } | 183 | } |
159 | } else { | 184 | } else { |
160 | if(ev.event().type() == Event::Normal ) | 185 | s=""; |
161 | sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
162 | else | ||
163 | sprintf(s," "); | ||
164 | } | 186 | } |
165 | setText(QString(s) + " " + ev.description()); | 187 | setText(QString(s) + " " + ev.description()); |
166 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 188 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
167 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 189 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
168 | } | 190 | } |
169 | void DateBookWeekLstEvent::editMe() { | 191 | void DateBookWeekLstEvent::editMe() { |
170 | emit editEvent(event.event()); | 192 | emit editEvent(event.event()); |
171 | } | 193 | } |
172 | 194 | ||
173 | 195 | ||
@@ -177,45 +199,44 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | |||
177 | const char* name, WFlags fl) | 199 | const char* name, WFlags fl) |
178 | : QWidget( parent, name, fl ) | 200 | : QWidget( parent, name, fl ) |
179 | { | 201 | { |
180 | onMonday=onM; | 202 | Config config("DateBook"); |
181 | setPalette(white); | 203 | config.setGroup("Main"); |
182 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 204 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); |
205 | qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); | ||
183 | 206 | ||
184 | QVBoxLayout *layout = new QVBoxLayout( this ); | 207 | onMonday=onM; |
208 | setPalette(white); | ||
209 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | ||
185 | 210 | ||
186 | qBubbleSort(ev); | 211 | QVBoxLayout *layout = new QVBoxLayout( this ); |
187 | QValueListIterator<EffectiveEvent> it; | ||
188 | it=ev.begin(); | ||
189 | 212 | ||
190 | int dayOrder[7]; | 213 | qBubbleSort(ev); |
191 | if (onMonday) | 214 | QValueListIterator<EffectiveEvent> it; |
192 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 215 | it=ev.begin(); |
193 | else { | 216 | |
194 | for (int d=0; d<7; d++) dayOrder[d]=d; | 217 | int dayOrder[7]; |
195 | dayOrder[0]=7; | 218 | if (onMonday) { |
196 | } | 219 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
220 | } else { | ||
221 | for (int d=0; d<7; d++) dayOrder[d]=d; | ||
222 | dayOrder[0]=7; | ||
223 | } | ||
197 | 224 | ||
198 | for (int i=0; i<7; i++) { | 225 | for (int i=0; i<7; i++) { |
199 | // Header | 226 | // Header |
200 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), | 227 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this); |
201 | onMonday,this); | ||
202 | connect(hdr, SIGNAL(showDate(int,int,int)), | 228 | connect(hdr, SIGNAL(showDate(int,int,int)), |
203 | this, SIGNAL(showDate(int,int,int))); | 229 | this, SIGNAL(showDate(int,int,int))); |
204 | connect(hdr, SIGNAL(addEvent(const QDateTime &, | 230 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
205 | const QDateTime &, | 231 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
206 | const QString &, const QString &)), | ||
207 | this, SIGNAL(addEvent(const QDateTime &, | ||
208 | const QDateTime &, | ||
209 | const QString &, const QString &))); | ||
210 | layout->addWidget(hdr); | 232 | layout->addWidget(hdr); |
211 | 233 | ||
212 | // Events | 234 | // Events |
213 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 235 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
214 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. | 236 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. |
215 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); | 237 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); |
216 | layout->addWidget(l); | 238 | layout->addWidget(l); |
217 | connect (l, SIGNAL(editEvent(const Event &)), | 239 | connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
218 | this, SIGNAL(editEvent(const Event &))); | ||
219 | } | 240 | } |
220 | it++; | 241 | it++; |
221 | } | 242 | } |
@@ -233,30 +254,22 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | |||
233 | const char* name, WFlags fl) | 254 | const char* name, WFlags fl) |
234 | : QWidget( parent, name, fl ) | 255 | : QWidget( parent, name, fl ) |
235 | { | 256 | { |
236 | QHBoxLayout *layout = new QHBoxLayout( this ); | 257 | QHBoxLayout *layout = new QHBoxLayout( this ); |
237 | 258 | ||
238 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | 259 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); |
239 | layout->addWidget(w); | 260 | layout->addWidget(w); |
240 | connect (w, SIGNAL(editEvent(const Event &)), | 261 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); |
241 | this, SIGNAL(editEvent(const Event &))); | 262 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
242 | connect (w, SIGNAL(showDate(int,int,int)), | 263 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), |
243 | this, SIGNAL(showDate(int,int,int))); | 264 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
244 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | 265 | |
245 | const QString &,const QString &)), | 266 | |
246 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | 267 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); |
247 | const QString &, const QString &))); | 268 | layout->addWidget(w); |
248 | 269 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | |
249 | 270 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | |
250 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 271 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), |
251 | layout->addWidget(w); | 272 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); |
252 | connect (w, SIGNAL(editEvent(const Event &)), | ||
253 | this, SIGNAL(editEvent(const Event &))); | ||
254 | connect (w, SIGNAL(showDate(int,int,int)), | ||
255 | this, SIGNAL(showDate(int,int,int))); | ||
256 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | ||
257 | const QString &, const QString &)), | ||
258 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | ||
259 | const QString &, const QString &))); | ||
260 | } | 273 | } |
261 | 274 | ||
262 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 275 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, |
@@ -274,108 +287,104 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | |||
274 | 287 | ||
275 | header=new DateBookWeekLstHeader(onM, this); | 288 | header=new DateBookWeekLstHeader(onM, this); |
276 | layout->addWidget( header ); | 289 | layout->addWidget( header ); |
277 | connect(header, SIGNAL(dateChanged(int,int)), | 290 | connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); |
278 | this, SLOT(dateChanged(int,int))); | 291 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); |
279 | connect(header, SIGNAL(setDbl(bool)), | 292 | |
280 | this, SLOT(setDbl(bool))); | 293 | scroll=new QScrollView(this); |
281 | 294 | //scroll->setVScrollBarMode(QScrollView::AlwaysOn); | |
282 | scroll=new QScrollView(this); | 295 | //scroll->setHScrollBarMode(QScrollView::AlwaysOff); |
283 | //scroll->setVScrollBarMode(QScrollView::AlwaysOn); | 296 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
284 | //scroll->setHScrollBarMode(QScrollView::AlwaysOff); | 297 | layout->addWidget(scroll); |
285 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 298 | |
286 | layout->addWidget(scroll); | 299 | view=NULL; |
287 | 300 | Config config("DateBook"); | |
288 | view=NULL; | 301 | config.setGroup("Main"); |
289 | Config config("DateBook"); | 302 | dbl=config.readBoolEntry("weeklst_dbl", false); |
290 | config.setGroup("Main"); | 303 | header->dbl->setOn(dbl); |
291 | dbl=config.readBoolEntry("weeklst_dbl", false); | ||
292 | header->dbl->setOn(dbl); | ||
293 | } | 304 | } |
294 | DateBookWeekLst::~DateBookWeekLst(){ | 305 | DateBookWeekLst::~DateBookWeekLst(){ |
295 | Config config("DateBook"); | 306 | Config config("DateBook"); |
296 | config.setGroup("Main"); | 307 | config.setGroup("Main"); |
297 | config.writeEntry("weeklst_dbl", dbl); | 308 | config.writeEntry("weeklst_dbl", dbl); |
298 | } | 309 | } |
299 | 310 | ||
300 | void DateBookWeekLst::setDate(const QDate &d) { | 311 | void DateBookWeekLst::setDate(const QDate &d) { |
301 | int w,y; | 312 | int w,y; |
302 | calcWeek(d,w,y,onMonday); | 313 | calcWeek(d,w,y,onMonday); |
303 | year=y; | 314 | year=y; |
304 | _week=w; | 315 | _week=w; |
305 | header->setDate(date()); | 316 | header->setDate(date()); |
306 | } | 317 | } |
307 | void DateBookWeekLst::setDbl(bool on) { | 318 | void DateBookWeekLst::setDbl(bool on) { |
308 | dbl=on; | 319 | dbl=on; |
309 | redraw(); | 320 | redraw(); |
310 | } | 321 | } |
311 | void DateBookWeekLst::redraw() {getEvents();} | 322 | void DateBookWeekLst::redraw() {getEvents();} |
312 | 323 | ||
313 | QDate DateBookWeekLst::date() const { | 324 | QDate DateBookWeekLst::date() const { |
314 | QDate d; | 325 | QDate d; |
315 | d.setYMD(year,1,1); | 326 | d.setYMD(year,1,1); |
316 | 327 | ||
317 | int dow= d.dayOfWeek(); | 328 | int dow= d.dayOfWeek(); |
318 | if (!onMonday) | 329 | if (!onMonday) |
319 | if (dow==7) dow=1; | 330 | if (dow==7) { |
320 | else dow++; | 331 | dow=1; |
332 | } else { | ||
333 | dow++; | ||
334 | } | ||
321 | 335 | ||
322 | d=d.addDays( (_week-1)*7 - dow + 1 ); | 336 | d=d.addDays( (_week-1)*7 - dow + 1 ); |
323 | return d; | 337 | return d; |
324 | } | 338 | } |
325 | 339 | ||
326 | void DateBookWeekLst::getEvents() { | 340 | void DateBookWeekLst::getEvents() { |
327 | QDate start = date(); | 341 | QDate start = date(); |
328 | QDate stop = start.addDays(6); | 342 | QDate stop = start.addDays(6); |
329 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 343 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
330 | 344 | ||
331 | if (view) delete view; | 345 | if (view) delete view; |
332 | if (dbl) { | 346 | if (dbl) { |
333 | QDate start2=start.addDays(7); | 347 | QDate start2=start.addDays(7); |
334 | stop=start2.addDays(6); | 348 | stop=start2.addDays(6); |
335 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 349 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); |
336 | 350 | view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); | |
337 | view=new DateBookWeekLstDblView(el,el2,start,onMonday,scroll); | 351 | } else { |
338 | } else { | 352 | view=new DateBookWeekLstView(el,start,onMonday,scroll); |
339 | view=new DateBookWeekLstView(el,start,onMonday,scroll); | 353 | } |
340 | } | 354 | |
355 | connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | ||
356 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | ||
357 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | ||
358 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | ||
341 | 359 | ||
342 | connect (view, SIGNAL(editEvent(const Event &)), | 360 | scroll->addChild(view); |
343 | this, SIGNAL(editEvent(const Event &))); | 361 | view->show(); |
344 | connect (view, SIGNAL(showDate(int,int,int)), | 362 | scroll->updateScrollBars(); |
345 | this, SIGNAL(showDate(int,int,int))); | ||
346 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | ||
347 | const QString &, const QString &)), | ||
348 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, | ||
349 | const QString &, const QString &))); | ||
350 | |||
351 | scroll->addChild(view); | ||
352 | view->show(); | ||
353 | scroll->updateScrollBars(); | ||
354 | } | 363 | } |
355 | 364 | ||
356 | void DateBookWeekLst::dateChanged(int y, int w) { | 365 | void DateBookWeekLst::dateChanged(int y, int w) { |
357 | year=y; | 366 | year=y; |
358 | _week=w; | 367 | _week=w; |
359 | getEvents(); | 368 | getEvents(); |
360 | } | 369 | } |
361 | 370 | ||
362 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 371 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
363 | { | 372 | { |
364 | switch(e->key()) { | 373 | switch(e->key()) { |
365 | case Key_Up: | 374 | case Key_Up: |
366 | scroll->scrollBy(0, -20); | 375 | scroll->scrollBy(0, -20); |
367 | break; | 376 | break; |
368 | case Key_Down: | 377 | case Key_Down: |
369 | scroll->scrollBy(0, 20); | 378 | scroll->scrollBy(0, 20); |
370 | break; | 379 | break; |
371 | case Key_Left: | 380 | case Key_Left: |
372 | header->prevWeek(); | 381 | header->prevWeek(); |
373 | break; | 382 | break; |
374 | case Key_Right: | 383 | case Key_Right: |
375 | header->nextWeek(); | 384 | header->nextWeek(); |
376 | break; | 385 | break; |
377 | default: | 386 | default: |
378 | e->ignore(); | 387 | e->ignore(); |
379 | } | 388 | } |
380 | } | 389 | } |
381 | 390 | ||