summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 17f791d..b43c40e 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -341,489 +341,486 @@ void EventIndicator::drawContents(QPainter *p)
341 } 341 }
342 342
343 } 343 }
344 pa.end(); 344 pa.end();
345 345
346 } 346 }
347} 347}
348 348
349void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
350{ 350{
351 mXOffset = x; 351 mXOffset = x;
352} 352}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 354{
355 mPaintWidget = w; 355 mPaintWidget = w;
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 // FIX
438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
439#endif 438#endif
440 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
441 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
442 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
443 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
445 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
446 445
447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
448 agendaFrame); 447 agendaFrame);
449 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
450 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
451 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
452 451
453 // Create time labels 452 // Create time labels
454 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
455 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
456 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
457 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
458 457
459 // Create agenda 458 // Create agenda
460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
462 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
463 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
464 // Create event context menu for agenda 463 // Create event context menu for agenda
465 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
466 465
467#if 0 466#if 0
468 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
469 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
470 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
471 470
472#endif 471#endif
473 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
474 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
475 474
476 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
477 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
478 mAgenda->setPopup( mAllAgendaPopup ); 477 mAgenda->setPopup( mAllAgendaPopup );
479 mAllDayAgenda->setPopup( mAllAgendaPopup ); 478 mAllDayAgenda->setPopup( mAllAgendaPopup );
480 // make connections between dependent widgets 479 // make connections between dependent widgets
481 mTimeLabels->setAgenda(mAgenda); 480 mTimeLabels->setAgenda(mAgenda);
482 481
483 // Update widgets to reflect user preferences 482 // Update widgets to reflect user preferences
484 // updateConfig(); 483 // updateConfig();
485 484
486 // createDayLabels(); 485 // createDayLabels();
487 486
488 // these blank widgets make the All Day Event box line up with the agenda 487 // these blank widgets make the All Day Event box line up with the agenda
489 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
491 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
492 491
493 // Scrolling 492 // Scrolling
494 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
495 mTimeLabels, SLOT(positionChanged())); 494 mTimeLabels, SLOT(positionChanged()));
496 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
497 SLOT(setContentsPos(int))); 496 SLOT(setContentsPos(int)));
498 497
499 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
500 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
501 500
502 // Create/Show/Edit/Delete Event 501 // Create/Show/Edit/Delete Event
503 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 502 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
504 SLOT(newEvent(int,int))); 503 SLOT(newEvent(int,int)));
505 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
506 SLOT(newTodo(int,int))); 505 SLOT(newTodo(int,int)));
507 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
508 SLOT(newEvent(int,int,int,int))); 507 SLOT(newEvent(int,int,int,int)));
509 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
510 SLOT(newEventAllDay(int,int))); 509 SLOT(newEventAllDay(int,int)));
511 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
512 SLOT(newTodoAllDay(int,int))); 511 SLOT(newTodoAllDay(int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
514 SLOT(newEventAllDay(int,int))); 513 SLOT(newEventAllDay(int,int)));
515 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
516 SLOT(newTimeSpanSelected(int,int,int,int))); 515 SLOT(newTimeSpanSelected(int,int,int,int)));
517 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
518 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
519 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
521 520
522 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
523 SIGNAL(editIncidenceSignal(Incidence *))); 522 SIGNAL(editIncidenceSignal(Incidence *)));
524 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
525 SIGNAL(editIncidenceSignal(Incidence *))); 524 SIGNAL(editIncidenceSignal(Incidence *)));
526 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
527 SIGNAL(showIncidenceSignal(Incidence *))); 526 SIGNAL(showIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
529 SIGNAL(showIncidenceSignal(Incidence *))); 528 SIGNAL(showIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
531 SIGNAL(deleteIncidenceSignal(Incidence *))); 530 SIGNAL(deleteIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
533 SIGNAL(deleteIncidenceSignal(Incidence *))); 532 SIGNAL(deleteIncidenceSignal(Incidence *)));
534 533
535 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
536 SLOT(updateEventDates(KOAgendaItem *, int ))); 535 SLOT(updateEventDates(KOAgendaItem *, int )));
537 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
538 SLOT(updateEventDates(KOAgendaItem *, int))); 537 SLOT(updateEventDates(KOAgendaItem *, int)));
539 538
540 // event indicator update 539 // event indicator update
541 connect(mAgenda,SIGNAL(lowerYChanged(int)), 540 connect(mAgenda,SIGNAL(lowerYChanged(int)),
542 SLOT(updateEventIndicatorTop(int))); 541 SLOT(updateEventIndicatorTop(int)));
543 connect(mAgenda,SIGNAL(upperYChanged(int)), 542 connect(mAgenda,SIGNAL(upperYChanged(int)),
544 SLOT(updateEventIndicatorBottom(int))); 543 SLOT(updateEventIndicatorBottom(int)));
545 // drag signals 544 // drag signals
546 /* 545 /*
547 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 546 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
548 SLOT(startDrag(Event *))); 547 SLOT(startDrag(Event *)));
549 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
550 SLOT(startDrag(Event *))); 549 SLOT(startDrag(Event *)));
551 */ 550 */
552 // synchronize selections 551 // synchronize selections
553 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
554 mAllDayAgenda, SLOT( deselectItem() ) ); 553 mAllDayAgenda, SLOT( deselectItem() ) );
555 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
556 mAgenda, SLOT( deselectItem() ) ); 555 mAgenda, SLOT( deselectItem() ) );
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 SIGNAL( incidenceSelected( Incidence * ) ) ); 557 SIGNAL( incidenceSelected( Incidence * ) ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 SIGNAL( incidenceSelected( Incidence * ) ) ); 559 SIGNAL( incidenceSelected( Incidence * ) ) );
561 connect( mAgenda, SIGNAL( resizedSignal() ), 560 connect( mAgenda, SIGNAL( resizedSignal() ),
562 SLOT( updateConfig( ) ) ); 561 SLOT( updateConfig( ) ) );
563 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
564 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
565 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
566 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 565 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
567 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
569 568
569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
570 571
571} 572}
572 573
573void KOAgendaView::toggleAllDay() 574void KOAgendaView::toggleAllDay()
574{ 575{
575 if ( mSplitterAgenda->firstHandle() ) 576 if ( mSplitterAgenda->firstHandle() )
576 mSplitterAgenda->firstHandle()->toggle(); 577 mSplitterAgenda->firstHandle()->toggle();
577} 578}
578void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
579{ 580{
580 calendar()->addIncidence( inc ); 581 calendar()->addIncidence( inc );
581 582
582 if ( incOld ) { 583 if ( incOld ) {
583 if ( incOld->type() == "Todo" ) 584 if ( incOld->type() == "Todo" )
584 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
585 else 586 else
586 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
587 } 588 }
588 589
589} 590}
590 591
591KOAgendaView::~KOAgendaView() 592KOAgendaView::~KOAgendaView()
592{ 593{
593 delete mAllAgendaPopup; 594 delete mAllAgendaPopup;
594 //delete mAllDayAgendaPopup; 595 //delete mAllDayAgendaPopup;
595 delete KOAgendaItem::paintPix(); 596 delete KOAgendaItem::paintPix();
596 delete KOAgendaItem::paintPixSel(); 597 delete KOAgendaItem::paintPixSel();
597} 598}
598void KOAgendaView::resizeEvent( QResizeEvent* e ) 599void KOAgendaView::resizeEvent( QResizeEvent* e )
599{ 600{
600 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
601 bool uc = false; 602 bool uc = false;
602 int ow = e->oldSize().width(); 603 int ow = e->oldSize().width();
603 int oh = e->oldSize().height(); 604 int oh = e->oldSize().height();
604 int w = e->size().width(); 605 int w = e->size().width();
605 int h = e->size().height(); 606 int h = e->size().height();
606 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
607 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
608 uc = true; 609 uc = true;
609 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
610 } 611 }
611 mUpcomingWidth = e->size().width() ; 612 mUpcomingWidth = e->size().width() ;
612 if ( mBlockUpdating || uc ) { 613 if ( mBlockUpdating || uc ) {
613 mBlockUpdating = false; 614 mBlockUpdating = false;
614 //mAgenda->setMinimumSize(800 , 600 ); 615 //mAgenda->setMinimumSize(800 , 600 );
615 //qDebug("mAgenda->resize+++++++++++++++ "); 616 //qDebug("mAgenda->resize+++++++++++++++ ");
616 updateConfig(); 617 updateConfig();
617 //qDebug("KOAgendaView::Updating now possible "); 618 //qDebug("KOAgendaView::Updating now possible ");
618 } else 619 } else
619 createDayLabels(); 620 createDayLabels();
620 //qDebug("resizeEvent end "); 621 //qDebug("resizeEvent end ");
621 622
622} 623}
623void KOAgendaView::slotDaylabelClicked( int num ) 624void KOAgendaView::slotDaylabelClicked( int num )
624{ 625{
625 626
626 QDate firstDate = mSelectedDates.first(); 627 QDate firstDate = mSelectedDates.first();
627 if ( num == -1 ) 628 if ( num == -1 )
628 emit showDateView( 6, firstDate ); 629 emit showDateView( 6, firstDate );
629 else if (num >= 0 ) { 630 else if (num >= 0 ) {
630 if ( mSelectedDates.count() == 1) 631 if ( mSelectedDates.count() == 1)
631 emit showDateView( 9, firstDate.addDays( num ) ); 632 emit showDateView( 9, firstDate.addDays( num ) );
632 else 633 else
633 emit showDateView( 3, firstDate.addDays( num ) ); 634 emit showDateView( 3, firstDate.addDays( num ) );
634 } 635 }
635 else 636 else
636 showDateView( 10, firstDate.addDays(1) ); 637 showDateView( 10, firstDate.addDays(1) );
637} 638}
638 639
639KOAgendaButton* KOAgendaView::getNewDaylabel() 640KOAgendaButton* KOAgendaView::getNewDaylabel()
640{ 641{
641 642
642 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
643 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
644 mDayLabelsList.append( dayLabel ); 645 mDayLabelsList.append( dayLabel );
645 mLayoutDayLabels->addWidget(dayLabel); 646 mLayoutDayLabels->addWidget(dayLabel);
646 return dayLabel ; 647 return dayLabel ;
647} 648}
648 649
649void KOAgendaView::createDayLabels() 650void KOAgendaView::createDayLabels()
650{ 651{
651 652
652 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 653 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
653 // qDebug(" KOAgendaView::createDayLabels() blocked "); 654 // qDebug(" KOAgendaView::createDayLabels() blocked ");
654 return; 655 return;
655 656
656 } 657 }
657 int newHight; 658 int newHight;
658 if ( !mSelectedDates.count()) 659 if ( !mSelectedDates.count())
659 return; 660 return;
660 661
661 // ### Before deleting and recreating we could check if mSelectedDates changed... 662 // ### Before deleting and recreating we could check if mSelectedDates changed...
662 // It would remove some flickering and gain speed (since this is called by 663 // It would remove some flickering and gain speed (since this is called by
663 // each updateView() call) 664 // each updateView() call)
664 665
665 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
666 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
667 if ( maxWid < 20 ) 668 if ( maxWid < 20 )
668 maxWid = 20; 669 maxWid = 20;
669 670
670 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
671 QFontMetrics fm ( dlf ); 672 QFontMetrics fm ( dlf );
672 int selCount = mSelectedDates.count(); 673 int selCount = mSelectedDates.count();
673 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 674 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
674 QString dayTest = "Mon 20"; 675 QString dayTest = "Mon 20";
675 //QString dayTest = "Mon 20"; 676 //QString dayTest = "Mon 20";
676 int wid = fm.width( dayTest ); 677 int wid = fm.width( dayTest );
677 //maxWid -= ( selCount * 3 ); //working for QLabels 678 //maxWid -= ( selCount * 3 ); //working for QLabels
678 if ( QApplication::desktop()->width() <= 320 ) 679 if ( QApplication::desktop()->width() <= 320 )
679 maxWid -= ( selCount * 3 ); //working for QPushButton 680 maxWid -= ( selCount * 3 ); //working for QPushButton
680 else 681 else
681 maxWid -= ( selCount * 3 ); //working for QPushButton 682 maxWid -= ( selCount * 3 ); //working for QPushButton
682 if ( maxWid < 0 ) 683 if ( maxWid < 0 )
683 maxWid = 20; 684 maxWid = 20;
684 int needWid = wid * selCount; 685 int needWid = wid * selCount;
685 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
686 //if ( needWid > maxWid ) 687 //if ( needWid > maxWid )
687 // qDebug("DAYLABELS TOOOOOOO BIG "); 688 // qDebug("DAYLABELS TOOOOOOO BIG ");
688 while ( needWid > maxWid ) { 689 while ( needWid > maxWid ) {
689 dayTest = dayTest.left( dayTest.length() - 1 ); 690 dayTest = dayTest.left( dayTest.length() - 1 );
690 wid = fm.width( dayTest ); 691 wid = fm.width( dayTest );
691 needWid = wid * selCount; 692 needWid = wid * selCount;
692 } 693 }
693 int maxLen = dayTest.length(); 694 int maxLen = dayTest.length();
694 int fontPoint = dlf.pointSize(); 695 int fontPoint = dlf.pointSize();
695 if ( maxLen < 2 ) { 696 if ( maxLen < 2 ) {
696 int fontPoint = dlf.pointSize(); 697 int fontPoint = dlf.pointSize();
697 while ( fontPoint > 4 ) { 698 while ( fontPoint > 4 ) {
698 --fontPoint; 699 --fontPoint;
699 dlf.setPointSize( fontPoint ); 700 dlf.setPointSize( fontPoint );
700 QFontMetrics f( dlf ); 701 QFontMetrics f( dlf );
701 wid = f.width( "30" ); 702 wid = f.width( "30" );
702 needWid = wid * selCount; 703 needWid = wid * selCount;
703 if ( needWid < maxWid ) 704 if ( needWid < maxWid )
704 break; 705 break;
705 } 706 }
706 maxLen = 2; 707 maxLen = 2;
707 } 708 }
708 //qDebug("Max len %d ", dayTest.length() ); 709 //qDebug("Max len %d ", dayTest.length() );
709 710
710 QFontMetrics tempF( dlf ); 711 QFontMetrics tempF( dlf );
711 newHight = tempF.height(); 712 newHight = tempF.height();
712 mDayLabels->setFont( dlf ); 713 mDayLabels->setFont( dlf );
713 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
714 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 715 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
715 //mLayoutDayLabels->addSpacing( 2 ); 716 //mLayoutDayLabels->addSpacing( 2 );
716 // QFont lFont = dlf; 717 // QFont lFont = dlf;
717 bool appendLabels = false; 718 bool appendLabels = false;
718 KOAgendaButton *dayLabel; 719 KOAgendaButton *dayLabel;
719 dayLabel = mDayLabelsList.first(); 720 dayLabel = mDayLabelsList.first();
720 if ( !dayLabel ) { 721 if ( !dayLabel ) {
721 appendLabels = true; 722 appendLabels = true;
722 dayLabel = getNewDaylabel(); 723 dayLabel = getNewDaylabel();
723 } 724 }
724 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 725 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
725 dayLabel->setFont( dlf ); 726 dayLabel->setFont( dlf );
726 dayLabel->setNum( -1 ); 727 dayLabel->setNum( -1 );
727 //dayLabel->setAlignment(QLabel::AlignHCenter); 728 //dayLabel->setAlignment(QLabel::AlignHCenter);
728#if 0 729
729 if ( QApplication::desktop()->width() <= 320 ) 730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
731 else
732#endif
733 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
734 dayLabel->show(); 731 dayLabel->show();
735 DateList::ConstIterator dit; 732 DateList::ConstIterator dit;
736 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 733 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
737 int counter = -1; 734 int counter = -1;
738 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 735 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
739 ++counter; 736 ++counter;
740 QDate date = *dit; 737 QDate date = *dit;
741 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 738 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
742 if ( ! appendLabels ) { 739 if ( ! appendLabels ) {
743 dayLabel = mDayLabelsList.next(); 740 dayLabel = mDayLabelsList.next();
744 if ( !dayLabel ) 741 if ( !dayLabel )
745 appendLabels = true; 742 appendLabels = true;
746 } 743 }
747 if ( appendLabels ) { 744 if ( appendLabels ) {
748 dayLabel = getNewDaylabel(); 745 dayLabel = getNewDaylabel();
749 } 746 }
750 dayLabel->setMinimumWidth( 1 ); 747 dayLabel->setMinimumWidth( 1 );
751 dayLabel->setMaximumWidth( 10240 ); 748 dayLabel->setMaximumWidth( 10240 );
752 dayLabel->setFont( dlf ); 749 dayLabel->setFont( dlf );
753 dayLabel->show(); 750 dayLabel->show();
754 dayLabel->setAutoRepeat( false ); 751 dayLabel->setAutoRepeat( false );
755 dayLabel->setNum( counter ); 752 dayLabel->setNum( counter );
756 QString str; 753 QString str;
757 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 754 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
758 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 755 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
759 switch ( maxLen ) { 756 switch ( maxLen ) {
760 case 2: 757 case 2:
761 str = QString::number( date.day() ); 758 str = QString::number( date.day() );
762 break; 759 break;
763 760
764 case 3: 761 case 3:
765 str = dayName.left( 1 ) +QString::number( date.day()); 762 str = dayName.left( 1 ) +QString::number( date.day());
766 763
767 break; 764 break;
768 case 4: 765 case 4:
769 str = dayName.left( 1 ) + " " +QString::number( date.day()); 766 str = dayName.left( 1 ) + " " +QString::number( date.day());
770 767
771 break; 768 break;
772 case 5: 769 case 5:
773 str = dayName.left( 2 ) + " " +QString::number( date.day()); 770 str = dayName.left( 2 ) + " " +QString::number( date.day());
774 771
775 break; 772 break;
776 case 6: 773 case 6:
777 str = dayName.left( 3 ) + " " +QString::number( date.day()); 774 str = dayName.left( 3 ) + " " +QString::number( date.day());
778 break; 775 break;
779 776
780 default: 777 default:
781 break; 778 break;
782 } 779 }
783 if ( oneday ) { 780 if ( oneday ) {
784 QString addString; 781 QString addString;
785 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 782 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
786 addString = i18n("Today"); 783 addString = i18n("Today");
787 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
788 addString = i18n("Tomorrow"); 785 addString = i18n("Tomorrow");
789 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
790 addString = i18n("Yesterday"); 787 addString = i18n("Yesterday");
791 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
792 addString = i18n("Day before yesterday"); 789 addString = i18n("Day before yesterday");
793 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
794 addString = i18n("Day after tomorrow"); 791 addString = i18n("Day after tomorrow");
795 if ( !addString.isEmpty() ) { 792 if ( !addString.isEmpty() ) {
796 str = addString+", " + str; 793 str = addString+", " + str;
797 } else { 794 } else {
798 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 795 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
799 } 796 }
800 } 797 }
801 dayLabel->setText(str); 798 dayLabel->setText(str);
802 //dayLabel->setAlignment(QLabel::AlignHCenter); 799 //dayLabel->setAlignment(QLabel::AlignHCenter);
803 if (date == QDate::currentDate()) { 800 if (date == QDate::currentDate()) {
804 QFont bFont = dlf; 801 QFont bFont = dlf;
805 bFont.setBold( true ); 802 bFont.setBold( true );
806 dayLabel->setFont(bFont); 803 dayLabel->setFont(bFont);
807 } 804 }
808 //dayLayout->addWidget(dayLabel); 805 //dayLayout->addWidget(dayLabel);
809 806
810#ifndef KORG_NOPLUGINS 807#ifndef KORG_NOPLUGINS
811 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 808 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
812 CalendarDecoration *it; 809 CalendarDecoration *it;
813 for(it = cds.first(); it; it = cds.next()) { 810 for(it = cds.first(); it; it = cds.next()) {
814 QString text = it->shortText( date ); 811 QString text = it->shortText( date );
815 if ( !text.isEmpty() ) { 812 if ( !text.isEmpty() ) {
816 QLabel *label = new QLabel(text,mDayLabels); 813 QLabel *label = new QLabel(text,mDayLabels);
817 label->setAlignment(AlignCenter); 814 label->setAlignment(AlignCenter);
818 dayLayout->addWidget(label); 815 dayLayout->addWidget(label);
819 } 816 }
820 } 817 }
821 818
822 for(it = cds.first(); it; it = cds.next()) { 819 for(it = cds.first(); it; it = cds.next()) {
823 QWidget *wid = it->smallWidget(mDayLabels,date); 820 QWidget *wid = it->smallWidget(mDayLabels,date);
824 if ( wid ) { 821 if ( wid ) {
825 // wid->setHeight(20); 822 // wid->setHeight(20);
826 dayLayout->addWidget(wid); 823 dayLayout->addWidget(wid);
827 } 824 }
828 } 825 }
829#endif 826#endif
@@ -1086,202 +1083,193 @@ void KOAgendaView::fillAgenda(const QDate &)
1086 // qDebug("KOAgendaView::fillAgenda "); 1083 // qDebug("KOAgendaView::fillAgenda ");
1087 fillAgenda(); 1084 fillAgenda();
1088} 1085}
1089 1086
1090void KOAgendaView::fillAgenda() 1087void KOAgendaView::fillAgenda()
1091{ 1088{
1092 if ( globalFlagBlockStartup ) 1089 if ( globalFlagBlockStartup )
1093 return; 1090 return;
1094 if ( globalFlagBlockAgenda == 1 ) 1091 if ( globalFlagBlockAgenda == 1 )
1095 return; 1092 return;
1096 static bool onlyOne = false; 1093 static bool onlyOne = false;
1097 if ( onlyOne ) 1094 if ( onlyOne )
1098 return; 1095 return;
1099 onlyOne = true; 1096 onlyOne = true;
1100 //if ( globalFlagBlockAgenda == 2 ) 1097 //if ( globalFlagBlockAgenda == 2 )
1101 //globalFlagBlockAgenda = 0; 1098 //globalFlagBlockAgenda = 0;
1102 // globalFlagBlockPainting = false; 1099 // globalFlagBlockPainting = false;
1103 if ( globalFlagBlockAgenda == 0 ) 1100 if ( globalFlagBlockAgenda == 0 )
1104 globalFlagBlockAgenda = 1; 1101 globalFlagBlockAgenda = 1;
1105 // clearView(); 1102 // clearView();
1106 //qDebug("fillAgenda()++++ "); 1103 //qDebug("fillAgenda()++++ ");
1107 globalFlagBlockAgendaItemPaint = 1; 1104 globalFlagBlockAgendaItemPaint = 1;
1108 1105
1109 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1106 mAllDayAgenda->changeColumns(mSelectedDates.count());
1110 mAgenda->changeColumns(mSelectedDates.count()); 1107 mAgenda->changeColumns(mSelectedDates.count());
1111 qApp->processEvents(); 1108 qApp->processEvents();
1112 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1109 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1113 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1110 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1114 setHolidayMasks(); 1111 setHolidayMasks();
1115 1112
1116 //mAgenda->hideUnused(); 1113 //mAgenda->hideUnused();
1117 //mAllDayAgenda->hideUnused(); 1114 //mAllDayAgenda->hideUnused();
1118 1115
1119 // mAgenda->blockNextRepaint( false ); 1116 // mAgenda->blockNextRepaint( false );
1120 // mAgenda->viewport()->repaint(); 1117 // mAgenda->viewport()->repaint();
1121 // mAgenda->blockNextRepaint( true ); 1118 // mAgenda->blockNextRepaint( true );
1122 mMinY.resize(mSelectedDates.count()); 1119 mMinY.resize(mSelectedDates.count());
1123 mMaxY.resize(mSelectedDates.count()); 1120 mMaxY.resize(mSelectedDates.count());
1124 1121
1125 QPtrList<Event> dayEvents; 1122 QPtrList<Event> dayEvents;
1126 1123
1127 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1124 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1128 // Therefore, gtodoset all of them. 1125 // Therefore, gtodoset all of them.
1129 QPtrList<Todo> todos = calendar()->todos(); 1126 QPtrList<Todo> todos = calendar()->todos();
1130 1127
1131 mAgenda->setDateList(mSelectedDates); 1128 mAgenda->setDateList(mSelectedDates);
1132 1129
1133 QDate today = QDate::currentDate(); 1130 QDate today = QDate::currentDate();
1134 1131
1135 DateList::ConstIterator dit; 1132 DateList::ConstIterator dit;
1136 int curCol = 0; 1133 int curCol = 0;
1137 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1134 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1138 QDate currentDate = *dit; 1135 QDate currentDate = *dit;
1139 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1136 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1140 // << endl; 1137 // << endl;
1141 1138
1142 dayEvents = calendar()->events(currentDate,true); 1139 dayEvents = calendar()->events(currentDate,true);
1143 1140
1144 // Default values, which can never be reached 1141 // Default values, which can never be reached
1145 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1142 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1146 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1143 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1147 1144
1148 unsigned int numEvent; 1145 unsigned int numEvent;
1149 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1146 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1150 Event *event = dayEvents.at(numEvent); 1147 Event *event = dayEvents.at(numEvent);
1151 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1148 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1152 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1149 if ( event->uid().left(15) == QString("last-syncEvent-") )
1153 continue; 1150 continue;
1154 // kdDebug() << " Event: " << event->summary() << endl; 1151 // kdDebug() << " Event: " << event->summary() << endl;
1155 1152
1156 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1153 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1157 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1154 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1158 1155
1159 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1156 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1160 1157
1161 if (event->doesFloat()) { 1158 if (event->doesFloat()) {
1162 if (event->recurrence()->doesRecur()) { 1159 if (event->recurrence()->doesRecur()) {
1163 if (event->isMultiDay() ) { 1160 if (event->isMultiDay() ) {
1164 endX = endX - beginX;// endX is now number of days 1161 endX = endX - beginX;// endX is now number of days
1165 if ( event->recursOn( currentDate ) ) { 1162 if ( event->recursOn( currentDate ) ) {
1166 endX += curCol; 1163 endX += curCol;
1167 beginX = curCol; 1164 beginX = curCol;
1168 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1165 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1169 } else { 1166 } else {
1170 qDebug("days %d %s",endX , currentDate.toString().latin1()); 1167 qDebug("days %d %s",endX , currentDate.toString().latin1());
1171 QDate dateit = currentDate.addDays( -endX ); 1168 QDate dateit = currentDate.addDays( -endX );
1172 if ( event->recursOn( dateit ) ) { 1169 if ( event->recursOn( dateit ) ) {
1173 qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1170 qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1174 if ( curCol-endX < 0 ) { 1171 if ( curCol-endX < 0 ) {
1175 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1172 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1176 } 1173 }
1177 } 1174 }
1178 } 1175 }
1179 } else { 1176 } else {
1180 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1177 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1181 } 1178 }
1182#if 0 1179
1183 if (beginX <= 0 && curCol == 0) {
1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1185 } else if (beginX == curCol) {
1186 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1187 } else {
1188 qDebug("skipped %d %d %d ",beginX , endX, curCol);
1189 }
1190#endif
1191 //mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1192 } else { 1180 } else {
1193 if (beginX <= 0 && curCol == 0) { 1181 if (beginX <= 0 && curCol == 0) {
1194 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1182 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1195 } else if (beginX == curCol) { 1183 } else if (beginX == curCol) {
1196 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1197 } 1185 }
1198 } 1186 }
1199 } else if (event->isMultiDay()) { 1187 } else if (event->isMultiDay()) {
1200 if ( event->doesRecur () ) { 1188 if ( event->doesRecur () ) {
1201 QDate dateit = currentDate; 1189 QDate dateit = currentDate;
1202 int count = 0; 1190 int count = 0;
1203 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1191 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1204 while (! event->recursOn( dateit ) && count <= max ) { 1192 while (! event->recursOn( dateit ) && count <= max ) {
1205 ++count; 1193 ++count;
1206 dateit = dateit.addDays( -1 ); 1194 dateit = dateit.addDays( -1 );
1207 } 1195 }
1208 bool ok; 1196 bool ok;
1209 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1197 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1210 if ( ok ) 1198 if ( ok )
1211 { 1199 {
1212 int secs = event->dtStart().secsTo( event->dtEnd() ); 1200 int secs = event->dtStart().secsTo( event->dtEnd() );
1213 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1201 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1214 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1202 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1215 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1203 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1216 1204
1217 } 1205 }
1218 } 1206 }
1219 int startY = mAgenda->timeToY(event->dtStart().time()); 1207 int startY = mAgenda->timeToY(event->dtStart().time());
1220 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1208 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1221 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1209 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1222 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1210 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1223 //qDebug("insert!!! "); 1211 //qDebug("insert!!! ");
1224 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1212 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1225 } 1213 }
1226 if (beginX == curCol) { 1214 if (beginX == curCol) {
1227 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1215 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1228 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1216 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1229 } else if (endX == curCol) { 1217 } else if (endX == curCol) {
1230 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1218 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1231 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1219 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1232 } else { 1220 } else {
1233 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1221 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1234 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1222 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1235 } 1223 }
1236 } else { 1224 } else {
1237 int startY = mAgenda->timeToY(event->dtStart().time()); 1225 int startY = mAgenda->timeToY(event->dtStart().time());
1238 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1226 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1239 if (endY < startY) endY = startY; 1227 if (endY < startY) endY = startY;
1240 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1228 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1241 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1229 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1242 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1243 } 1231 }
1244 } 1232 }
1245 // ---------- [display Todos -------------- 1233 // ---------- [display Todos --------------
1246 unsigned int numTodo; 1234 unsigned int numTodo;
1247 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1235 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1248 Todo *todo = todos.at(numTodo); 1236 Todo *todo = todos.at(numTodo);
1249 1237
1250 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1238 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1251 1239
1252 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1240 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1253 // Already completed items can be displayed on their original due date 1241 // Already completed items can be displayed on their original due date
1254 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1242 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1255 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1243 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1256 bool fillIn = false; 1244 bool fillIn = false;
1257 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1245 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1258 fillIn = true; 1246 fillIn = true;
1259 if ( ! fillIn && !todo->hasCompletedDate() ) 1247 if ( ! fillIn && !todo->hasCompletedDate() )
1260 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1248 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1261 if ( fillIn ) { 1249 if ( fillIn ) {
1262 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1250 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1263 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1251 if ( KOPrefs::instance()->mShowTodoInAgenda )
1264 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1252 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1265 } 1253 }
1266 else { 1254 else {
1267 QDateTime dt; 1255 QDateTime dt;
1268 if ( todo->hasCompletedDate() ) 1256 if ( todo->hasCompletedDate() )
1269 dt = todo->completed(); 1257 dt = todo->completed();
1270 else 1258 else
1271 dt = todo->dtDue();; 1259 dt = todo->dtDue();;
1272 1260
1273 1261
1274 int endY = mAgenda->timeToY(dt.time()) - 1; 1262 int endY = mAgenda->timeToY(dt.time()) - 1;
1275 int hi = (18/KOPrefs::instance()->mHourSize); 1263 int hi = (18/KOPrefs::instance()->mHourSize);
1276 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1264 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1277 int startY = endY -hi; 1265 int startY = endY -hi;
1278 1266
1279 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1267 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1280 1268
1281 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1269 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1282 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1270 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1283 } 1271 }
1284 } 1272 }
1285 } 1273 }
1286 // ---------- display Todos] -------------- 1274 // ---------- display Todos] --------------
1287 1275