summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweeklst.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 0555bc7..b0e78f1 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -195,243 +195,243 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
195 } 195 }
196 setText(QString(s) + " " + ev.description()); 196 setText(QString(s) + " " + ev.description());
197// connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 197// connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
198 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 198 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
199} 199}
200void DateBookWeekLstEvent::editMe() { 200void DateBookWeekLstEvent::editMe() {
201 emit editEvent(event.event()); 201 emit editEvent(event.event());
202} 202}
203void DateBookWeekLstEvent::duplicateMe() 203void DateBookWeekLstEvent::duplicateMe()
204{ 204{
205 emit duplicateEvent(event.event()); 205 emit duplicateEvent(event.event());
206} 206}
207void DateBookWeekLstEvent::deleteMe() 207void DateBookWeekLstEvent::deleteMe()
208{ 208{
209 emit removeEvent(event.event()); 209 emit removeEvent(event.event());
210 emit redraw(); 210 emit redraw();
211} 211}
212void DateBookWeekLstEvent::beamMe() 212void DateBookWeekLstEvent::beamMe()
213{ 213{
214 emit beamEvent( event.event() ); 214 emit beamEvent( event.event() );
215} 215}
216void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) 216void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
217{ 217{
218 popmenue = new QPopupMenu; 218 popmenue = new QPopupMenu;
219 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); 219 popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
220 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); 220 popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
221 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); 221 popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
222 if(Ir::supported()) 222 if(Ir::supported())
223 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); 223 popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
224 popmenue->popup( mapToGlobal( e->pos() )); 224 popmenue->popup( mapToGlobal( e->pos() ));
225} 225}
226 226
227DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 227DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
228 const QDate &d, bool onM, 228 const QDate &d, bool onM,
229 QWidget* parent, 229 QWidget* parent,
230 const char* name, WFlags fl) 230 const char* name, WFlags fl)
231 : QWidget( parent, name, fl ) 231 : QWidget( parent, name, fl )
232{ 232{
233 Config config("DateBook"); 233 Config config("DateBook");
234 config.setGroup("Main"); 234 config.setGroup("Main");
235 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 235 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
236 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; 236 odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
237 237
238 bStartOnMonday=onM; 238 bStartOnMonday=onM;
239 setPalette(white); 239 setPalette(white);
240 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 240 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
241 241
242 QVBoxLayout *layout = new QVBoxLayout( this ); 242 QVBoxLayout *layout = new QVBoxLayout( this );
243 243
244 qBubbleSort(ev); 244 qBubbleSort(ev);
245 QValueListIterator<EffectiveEvent> it; 245 QValueListIterator<EffectiveEvent> it;
246 it=ev.begin(); 246 it=ev.begin();
247 247
248 int dayOrder[7]; 248 int dayOrder[7];
249 if (bStartOnMonday) { 249 if (bStartOnMonday) {
250 for (int d=0; d<7; d++) dayOrder[d]=d+1; 250 for (int d=0; d<7; d++) dayOrder[d]=d+1;
251 } else { 251 } else {
252 for (int d=0; d<7; d++) dayOrder[d]=d; 252 for (int d=0; d<7; d++) dayOrder[d]=d;
253 dayOrder[0]=7; 253 dayOrder[0]=7;
254 } 254 }
255 255
256 // Calculate offset to first day of week. 256 // Calculate offset to first day of week.
257 int dayoffset=d.dayOfWeek(); 257 int dayoffset=d.dayOfWeek();
258 if(bStartOnMonday) dayoffset--; 258 if(bStartOnMonday) dayoffset--;
259 else if( dayoffset == 7 ) dayoffset = 0; 259 else if( dayoffset == 7 ) dayoffset = 0;
260 260
261 for (int i=0; i<7; i++) { 261 for (int i=0; i<7; i++) {
262 // Header 262 // Header
263 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 263 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
264 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 264 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
265 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 265 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
266 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 266 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
267 layout->addWidget(hdr); 267 layout->addWidget(hdr);
268 268
269 // Events 269 // Events
270 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 270 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
271 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. 271 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day.
272 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 272 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
273 layout->addWidget(l); 273 layout->addWidget(l);
274 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 274 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
275 connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 275 connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
276 connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 276 connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
277 connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 277 connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
278 connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); 278 connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
279 } 279 }
280 it++; 280 it++;
281 } 281 }
282 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 282 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
283 } 283 }
284} 284}
285DateBookWeekLstView::~DateBookWeekLstView(){} 285DateBookWeekLstView::~DateBookWeekLstView(){}
286void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 286void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
287 287
288DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 288DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
289 QValueList<EffectiveEvent> &ev2, 289 QValueList<EffectiveEvent> &ev2,
290 QDate &d, bool onM, 290 QDate &d, bool onM,
291 QWidget* parent, 291 QWidget* parent,
292 const char* name, WFlags fl) 292 const char* name, WFlags fl)
293 : QWidget( parent, name, fl ) 293 : QWidget( parent, name, fl )
294{ 294{
295 QHBoxLayout *layout = new QHBoxLayout( this ); 295 QHBoxLayout *layout = new QHBoxLayout( this );
296 296
297 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 297 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
298 layout->addWidget(w); 298 layout->addWidget(w);
299 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 299 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
300 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 300 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
301 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 301 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
302 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 302 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
303 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); 303 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
304 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 304 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
305 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 305 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
306 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 306 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
307 307
308 308
309 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 309 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
310 layout->addWidget(w); 310 layout->addWidget(w);
311 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 311 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
312 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 312 connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
313 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 313 connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
314 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 314 connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
315 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); 315 connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
316 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 316 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
317 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 317 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
318 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 318 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
319} 319}
320 320
321DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, 321DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
322 QWidget *parent, 322 QWidget *parent,
323 const char *name ) 323 const char *name )
324 : QWidget( parent, name ), 324 : QWidget( parent, name ),
325 db( newDB ), 325 db( newDB ),
326 startTime( 0 ), 326 startTime( 0 ),
327 ampm( ap ), 327 ampm( ap ),
328 bStartOnMonday(onM) 328 bStartOnMonday(onM)
329{ 329{
330 setFocusPolicy(StrongFocus); 330 setFocusPolicy(StrongFocus);
331 layout = new QVBoxLayout( this ); 331 layout = new QVBoxLayout( this );
332 layout->setMargin(0); 332 layout->setMargin(0);
333 333
334 header=new DateBookWeekLstHeader(onM, this); 334 header=new DateBookWeekLstHeader(onM, this);
335 layout->addWidget( header ); 335 layout->addWidget( header );
336 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); 336 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
337 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 337 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
338 338
339 scroll=new QScrollView(this); 339 scroll=new QScrollView(this);
340 scroll->setResizePolicy(QScrollView::AutoOneFit); 340 scroll->setResizePolicy(QScrollView::AutoOneFit);
341 layout->addWidget(scroll); 341 layout->addWidget(scroll);
342 342
343 view=NULL; 343 view=NULL;
344 Config config("DateBook"); 344 Config config("DateBook");
345 config.setGroup("Main"); 345 config.setGroup("Main");
346 dbl=config.readBoolEntry("weeklst_dbl", false); 346 dbl=config.readBoolEntry("weeklst_dbl", false);
347 header->dbl->setOn(dbl); 347 header->dbl->setOn(dbl);
348} 348}
349DateBookWeekLst::~DateBookWeekLst(){ 349DateBookWeekLst::~DateBookWeekLst(){
350 Config config("DateBook"); 350 Config config("DateBook");
351 config.setGroup("Main"); 351 config.setGroup("Main");
352 config.writeEntry("weeklst_dbl", dbl); 352 config.writeEntry("weeklst_dbl", dbl);
353} 353}
354 354
355void DateBookWeekLst::setDate(const QDate &d) { 355void DateBookWeekLst::setDate(const QDate &d) {
356 bdate=d; 356 bdate=d;
357 header->setDate(d); 357 header->setDate(d);
358} 358}
359 359
360void DateBookWeekLst::setDbl(bool on) { 360void DateBookWeekLst::setDbl(bool on) {
361 dbl=on; 361 dbl=on;
362 redraw(); 362 redraw();
363} 363}
364void DateBookWeekLst::redraw() {getEvents();} 364void DateBookWeekLst::redraw() {getEvents();}
365 365
366QDate DateBookWeekLst::date() { 366QDate DateBookWeekLst::date() {
367 return bdate; 367 return bdate;
368} 368}
369 369
370// return the date at the beginning of the week... 370// return the date at the beginning of the week...
371// copied from DateBookWeek 371// copied from DateBookWeek
372QDate DateBookWeekLst::weekDate() const 372QDate DateBookWeekLst::weekDate() const
373{ 373{
374 QDate d=bdate; 374 QDate d=bdate;
375 375
376 // Calculate offset to first day of week. 376 // Calculate offset to first day of week.
377 int dayoffset=d.dayOfWeek(); 377 int dayoffset=d.dayOfWeek();
378 if(bStartOnMonday) dayoffset--; 378 if(bStartOnMonday) dayoffset--;
379 else if( dayoffset == 7 ) 379 else if( dayoffset == 7 )
380 dayoffset = 0; 380 dayoffset = 0;
381 381
382 return d.addDays(-dayoffset); 382 return d.addDays(-dayoffset);
383} 383}
384 384
385void DateBookWeekLst::getEvents() { 385void DateBookWeekLst::getEvents() {
386 QDate start = weekDate(); //date(); 386 QDate start = weekDate(); //date();
387 QDate stop = start.addDays(7); 387 QDate stop = start.addDays(6);
388 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 388 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
389 389
390 if (view) delete view; 390 if (view) delete view;
391 if (dbl) { 391 if (dbl) {
392 QDate start2=start.addDays(8); 392 QDate start2=start.addDays(7);
393 stop=start2.addDays(7); 393 stop=start2.addDays(6);
394 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 394 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
395 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 395 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
396 } else { 396 } else {
397 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 397 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
398 } 398 }
399 399
400 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); 400 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
401 connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); 401 connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
402 connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); 402 connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
403 connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); 403 connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
404 connect (view, SIGNAL(redraw()), this, SLOT(redraw())); 404 connect (view, SIGNAL(redraw()), this, SLOT(redraw()));
405 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 405 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
406 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), 406 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
407 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); 407 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
408 408
409 scroll->addChild(view); 409 scroll->addChild(view);
410 view->show(); 410 view->show();
411 scroll->updateScrollBars(); 411 scroll->updateScrollBars();
412} 412}
413 413
414void DateBookWeekLst::dateChanged(QDate &newdate) { 414void DateBookWeekLst::dateChanged(QDate &newdate) {
415 bdate=newdate; 415 bdate=newdate;
416 getEvents(); 416 getEvents();
417} 417}
418 418
419void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 419void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
420{ 420{
421 switch(e->key()) { 421 switch(e->key()) {
422 case Key_Up: 422 case Key_Up:
423 scroll->scrollBy(0, -20); 423 scroll->scrollBy(0, -20);
424 break; 424 break;
425 case Key_Down: 425 case Key_Down:
426 scroll->scrollBy(0, 20); 426 scroll->scrollBy(0, 20);
427 break; 427 break;
428 case Key_Left: 428 case Key_Left:
429 header->prevWeek(); 429 header->prevWeek();
430 break; 430 break;
431 case Key_Right: 431 case Key_Right:
432 header->nextWeek(); 432 header->nextWeek();
433 break; 433 break;
434 default: 434 default:
435 e->ignore(); 435 e->ignore();
436 } 436 }
437} 437}