-rw-r--r-- | korganizer/koagendaview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index d43712f..aa36553 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -439,768 +439,769 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
439 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 439 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
440 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 440 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
441 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 441 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
442 | agendaFrame); | 442 | agendaFrame); |
443 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 443 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
444 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 444 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
445 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 445 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
446 | 446 | ||
447 | // Create time labels | 447 | // Create time labels |
448 | mTimeLabels = new TimeLabels(24,agendaFrame); | 448 | mTimeLabels = new TimeLabels(24,agendaFrame); |
449 | agendaLayout->addWidget(mTimeLabels,1,0); | 449 | agendaLayout->addWidget(mTimeLabels,1,0); |
450 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 450 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
451 | this,SLOT(updateConfig())); | 451 | this,SLOT(updateConfig())); |
452 | 452 | ||
453 | // Create agenda | 453 | // Create agenda |
454 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 454 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
455 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); | 455 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); |
456 | agendaLayout->setColStretch(1,1); | 456 | agendaLayout->setColStretch(1,1); |
457 | mAgenda->setFocusPolicy(NoFocus); | 457 | mAgenda->setFocusPolicy(NoFocus); |
458 | // Create event context menu for agenda | 458 | // Create event context menu for agenda |
459 | mAgendaPopup = eventPopup(); | 459 | mAgendaPopup = eventPopup(); |
460 | 460 | ||
461 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 461 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
462 | i18n("Toggle Alarm"),mAgenda, | 462 | i18n("Toggle Alarm"),mAgenda, |
463 | SLOT(popupAlarm()),true); | 463 | SLOT(popupAlarm()),true); |
464 | 464 | ||
465 | 465 | ||
466 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 466 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
467 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 467 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
468 | 468 | ||
469 | // make connections between dependent widgets | 469 | // make connections between dependent widgets |
470 | mTimeLabels->setAgenda(mAgenda); | 470 | mTimeLabels->setAgenda(mAgenda); |
471 | 471 | ||
472 | // Update widgets to reflect user preferences | 472 | // Update widgets to reflect user preferences |
473 | // updateConfig(); | 473 | // updateConfig(); |
474 | 474 | ||
475 | // createDayLabels(); | 475 | // createDayLabels(); |
476 | 476 | ||
477 | // these blank widgets make the All Day Event box line up with the agenda | 477 | // these blank widgets make the All Day Event box line up with the agenda |
478 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 478 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
479 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 479 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
480 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 480 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
481 | 481 | ||
482 | // Scrolling | 482 | // Scrolling |
483 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 483 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
484 | mTimeLabels, SLOT(positionChanged())); | 484 | mTimeLabels, SLOT(positionChanged())); |
485 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 485 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
486 | SLOT(setContentsPos(int))); | 486 | SLOT(setContentsPos(int))); |
487 | 487 | ||
488 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 488 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
489 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 489 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
490 | 490 | ||
491 | // Create/Show/Edit/Delete Event | 491 | // Create/Show/Edit/Delete Event |
492 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 492 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
493 | SLOT(newEvent(int,int))); | 493 | SLOT(newEvent(int,int))); |
494 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 494 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
495 | SLOT(newTodo(int,int))); | 495 | SLOT(newTodo(int,int))); |
496 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 496 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
497 | SLOT(newEvent(int,int,int,int))); | 497 | SLOT(newEvent(int,int,int,int))); |
498 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 498 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
499 | SLOT(newEventAllDay(int,int))); | 499 | SLOT(newEventAllDay(int,int))); |
500 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 500 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
501 | SLOT(newTodoAllDay(int,int))); | 501 | SLOT(newTodoAllDay(int,int))); |
502 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 502 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
503 | SLOT(newEventAllDay(int,int))); | 503 | SLOT(newEventAllDay(int,int))); |
504 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 504 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
505 | SLOT(newTimeSpanSelected(int,int,int,int))); | 505 | SLOT(newTimeSpanSelected(int,int,int,int))); |
506 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 506 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
507 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 507 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
508 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 508 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
509 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 509 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
510 | 510 | ||
511 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 511 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
512 | SIGNAL(editIncidenceSignal(Incidence *))); | 512 | SIGNAL(editIncidenceSignal(Incidence *))); |
513 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 513 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
514 | SIGNAL(editIncidenceSignal(Incidence *))); | 514 | SIGNAL(editIncidenceSignal(Incidence *))); |
515 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 515 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
516 | SIGNAL(showIncidenceSignal(Incidence *))); | 516 | SIGNAL(showIncidenceSignal(Incidence *))); |
517 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 517 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
518 | SIGNAL(showIncidenceSignal(Incidence *))); | 518 | SIGNAL(showIncidenceSignal(Incidence *))); |
519 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 519 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
520 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 520 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
521 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 521 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
522 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 522 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
523 | 523 | ||
524 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 524 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
525 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 525 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
526 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 526 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
527 | SLOT(updateEventDates(KOAgendaItem *, int))); | 527 | SLOT(updateEventDates(KOAgendaItem *, int))); |
528 | 528 | ||
529 | // event indicator update | 529 | // event indicator update |
530 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 530 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
531 | SLOT(updateEventIndicatorTop(int))); | 531 | SLOT(updateEventIndicatorTop(int))); |
532 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 532 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
533 | SLOT(updateEventIndicatorBottom(int))); | 533 | SLOT(updateEventIndicatorBottom(int))); |
534 | // drag signals | 534 | // drag signals |
535 | /* | 535 | /* |
536 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 536 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
537 | SLOT(startDrag(Event *))); | 537 | SLOT(startDrag(Event *))); |
538 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 538 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
539 | SLOT(startDrag(Event *))); | 539 | SLOT(startDrag(Event *))); |
540 | */ | 540 | */ |
541 | // synchronize selections | 541 | // synchronize selections |
542 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 542 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
543 | mAllDayAgenda, SLOT( deselectItem() ) ); | 543 | mAllDayAgenda, SLOT( deselectItem() ) ); |
544 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 544 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
545 | mAgenda, SLOT( deselectItem() ) ); | 545 | mAgenda, SLOT( deselectItem() ) ); |
546 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 546 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
547 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 547 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
548 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 548 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
549 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 549 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
550 | connect( mAgenda, SIGNAL( resizedSignal() ), | 550 | connect( mAgenda, SIGNAL( resizedSignal() ), |
551 | SLOT( updateConfig( ) ) ); | 551 | SLOT( updateConfig( ) ) ); |
552 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 552 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
553 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 553 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
554 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 554 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
555 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 555 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
556 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 556 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
557 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 557 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
558 | 558 | ||
559 | 559 | ||
560 | } | 560 | } |
561 | 561 | ||
562 | void KOAgendaView::toggleAllDay() | 562 | void KOAgendaView::toggleAllDay() |
563 | { | 563 | { |
564 | if ( mSplitterAgenda->firstHandle() ) | 564 | if ( mSplitterAgenda->firstHandle() ) |
565 | mSplitterAgenda->firstHandle()->toggle(); | 565 | mSplitterAgenda->firstHandle()->toggle(); |
566 | } | 566 | } |
567 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 567 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
568 | { | 568 | { |
569 | calendar()->addIncidence( inc ); | 569 | calendar()->addIncidence( inc ); |
570 | 570 | ||
571 | if ( incOld ) { | 571 | if ( incOld ) { |
572 | if ( incOld->type() == "Todo" ) | 572 | if ( incOld->type() == "Todo" ) |
573 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 573 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
574 | else | 574 | else |
575 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 575 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
576 | } | 576 | } |
577 | 577 | ||
578 | } | 578 | } |
579 | 579 | ||
580 | KOAgendaView::~KOAgendaView() | 580 | KOAgendaView::~KOAgendaView() |
581 | { | 581 | { |
582 | delete mAgendaPopup; | 582 | delete mAgendaPopup; |
583 | delete mAllDayAgendaPopup; | 583 | delete mAllDayAgendaPopup; |
584 | delete KOAgendaItem::paintPix(); | 584 | delete KOAgendaItem::paintPix(); |
585 | delete KOAgendaItem::paintPixSel(); | 585 | delete KOAgendaItem::paintPixSel(); |
586 | } | 586 | } |
587 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 587 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
588 | { | 588 | { |
589 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 589 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
590 | bool uc = false; | 590 | bool uc = false; |
591 | int ow = e->oldSize().width(); | 591 | int ow = e->oldSize().width(); |
592 | int oh = e->oldSize().height(); | 592 | int oh = e->oldSize().height(); |
593 | int w = e->size().width(); | 593 | int w = e->size().width(); |
594 | int h = e->size().height(); | 594 | int h = e->size().height(); |
595 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 595 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
596 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 596 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
597 | uc = true; | 597 | uc = true; |
598 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 598 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
599 | } | 599 | } |
600 | mUpcomingWidth = e->size().width() ; | 600 | mUpcomingWidth = e->size().width() ; |
601 | if ( mBlockUpdating || uc ) { | 601 | if ( mBlockUpdating || uc ) { |
602 | mBlockUpdating = false; | 602 | mBlockUpdating = false; |
603 | //mAgenda->setMinimumSize(800 , 600 ); | 603 | //mAgenda->setMinimumSize(800 , 600 ); |
604 | //qDebug("mAgenda->resize+++++++++++++++ "); | 604 | //qDebug("mAgenda->resize+++++++++++++++ "); |
605 | updateConfig(); | 605 | updateConfig(); |
606 | //qDebug("KOAgendaView::Updating now possible "); | 606 | //qDebug("KOAgendaView::Updating now possible "); |
607 | } else | 607 | } else |
608 | createDayLabels(); | 608 | createDayLabels(); |
609 | //qDebug("resizeEvent end "); | 609 | //qDebug("resizeEvent end "); |
610 | 610 | ||
611 | } | 611 | } |
612 | void KOAgendaView::slotDaylabelClicked() | 612 | void KOAgendaView::slotDaylabelClicked() |
613 | { | 613 | { |
614 | QString cap = ((QPushButton*) sender() )->caption(); | 614 | QString cap = ((QPushButton*) sender() )->caption(); |
615 | 615 | ||
616 | QDate firstDate = mSelectedDates.first(); | 616 | QDate firstDate = mSelectedDates.first(); |
617 | if ( cap == "0" ) | 617 | if ( cap == "0" ) |
618 | emit showDateView( 6, firstDate ); | 618 | emit showDateView( 6, firstDate ); |
619 | else if ( cap != "last" ) { | 619 | else if ( cap != "last" ) { |
620 | if ( mSelectedDates.count() == 1) | 620 | if ( mSelectedDates.count() == 1) |
621 | emit showDateView( 9, firstDate.addDays( cap.toInt()-1 ) ); | 621 | emit showDateView( 9, firstDate.addDays( cap.toInt()-1 ) ); |
622 | else | 622 | else |
623 | emit showDateView( 3, firstDate.addDays( cap.toInt()-1 ) ); | 623 | emit showDateView( 3, firstDate.addDays( cap.toInt()-1 ) ); |
624 | } | 624 | } |
625 | else | 625 | else |
626 | showDateView( 10, firstDate.addDays(1 ) ); | 626 | showDateView( 10, firstDate.addDays(1 ) ); |
627 | } | 627 | } |
628 | void KOAgendaView::createDayLabels() | 628 | void KOAgendaView::createDayLabels() |
629 | { | 629 | { |
630 | 630 | ||
631 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 631 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
632 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 632 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
633 | return; | 633 | return; |
634 | 634 | ||
635 | } | 635 | } |
636 | int newHight; | 636 | int newHight; |
637 | 637 | ||
638 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 638 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
639 | // It would remove some flickering and gain speed (since this is called by | 639 | // It would remove some flickering and gain speed (since this is called by |
640 | // each updateView() call) | 640 | // each updateView() call) |
641 | 641 | ||
642 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 642 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
643 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 643 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
644 | if ( maxWid < 0 ) | 644 | if ( maxWid < 0 ) |
645 | maxWid = 20; | 645 | maxWid = 20; |
646 | 646 | ||
647 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 647 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
648 | QFontMetrics fm ( dlf ); | 648 | QFontMetrics fm ( dlf ); |
649 | int selCount = mSelectedDates.count(); | 649 | int selCount = mSelectedDates.count(); |
650 | QString dayTest = "Mon 20"; | 650 | QString dayTest = "Mon 20"; |
651 | int wid = fm.width( dayTest ); | 651 | int wid = fm.width( dayTest ); |
652 | maxWid -= ( selCount * 3 ); | 652 | maxWid -= ( selCount * 3 ); |
653 | if ( maxWid < 0 ) | 653 | if ( maxWid < 0 ) |
654 | maxWid = 20; | 654 | maxWid = 20; |
655 | int needWid = wid * selCount; | 655 | int needWid = wid * selCount; |
656 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 656 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
657 | //if ( needWid > maxWid ) | 657 | //if ( needWid > maxWid ) |
658 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 658 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
659 | while ( needWid > maxWid ) { | 659 | while ( needWid > maxWid ) { |
660 | dayTest = dayTest.left( dayTest.length() - 1 ); | 660 | dayTest = dayTest.left( dayTest.length() - 1 ); |
661 | wid = fm.width( dayTest ); | 661 | wid = fm.width( dayTest ); |
662 | needWid = wid * selCount; | 662 | needWid = wid * selCount; |
663 | } | 663 | } |
664 | int maxLen = dayTest.length(); | 664 | int maxLen = dayTest.length(); |
665 | int fontPoint = dlf.pointSize(); | 665 | int fontPoint = dlf.pointSize(); |
666 | if ( maxLen < 2 ) { | 666 | if ( maxLen < 2 ) { |
667 | int fontPoint = dlf.pointSize(); | 667 | int fontPoint = dlf.pointSize(); |
668 | while ( fontPoint > 4 ) { | 668 | while ( fontPoint > 4 ) { |
669 | --fontPoint; | 669 | --fontPoint; |
670 | dlf.setPointSize( fontPoint ); | 670 | dlf.setPointSize( fontPoint ); |
671 | QFontMetrics f( dlf ); | 671 | QFontMetrics f( dlf ); |
672 | wid = f.width( "20" ); | 672 | wid = f.width( "20" ); |
673 | needWid = wid * selCount; | 673 | needWid = wid * selCount; |
674 | if ( needWid < maxWid ) | 674 | if ( needWid < maxWid ) |
675 | break; | 675 | break; |
676 | } | 676 | } |
677 | maxLen = 2; | 677 | maxLen = 2; |
678 | } | 678 | } |
679 | //qDebug("Max len %d ", dayTest.length() ); | 679 | //qDebug("Max len %d ", dayTest.length() ); |
680 | 680 | ||
681 | QFontMetrics tempF( dlf ); | 681 | QFontMetrics tempF( dlf ); |
682 | newHight = tempF.height(); | 682 | newHight = tempF.height(); |
683 | mDayLabels->setFont( dlf ); | 683 | mDayLabels->setFont( dlf ); |
684 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 684 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
685 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 685 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
686 | //mLayoutDayLabels->addSpacing( 2 ); | 686 | //mLayoutDayLabels->addSpacing( 2 ); |
687 | // QFont lFont = dlf; | 687 | // QFont lFont = dlf; |
688 | bool appendLabels = false; | 688 | bool appendLabels = false; |
689 | QPushButton *dayLabel; | 689 | QPushButton *dayLabel; |
690 | dayLabel = mDayLabelsList.first(); | 690 | dayLabel = mDayLabelsList.first(); |
691 | if ( !dayLabel ) { | 691 | if ( !dayLabel ) { |
692 | appendLabels = true; | 692 | appendLabels = true; |
693 | dayLabel = new QPushButton(mDayLabels); | 693 | dayLabel = new QPushButton(mDayLabels); |
694 | dayLabel->setFlat( true ); | 694 | dayLabel->setFlat( true ); |
695 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 695 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
696 | dayLabel->setFocusPolicy(NoFocus); | 696 | dayLabel->setFocusPolicy(NoFocus); |
697 | mDayLabelsList.append( dayLabel ); | 697 | mDayLabelsList.append( dayLabel ); |
698 | mLayoutDayLabels->addWidget(dayLabel); | 698 | mLayoutDayLabels->addWidget(dayLabel); |
699 | } | 699 | } |
700 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 700 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
701 | dayLabel->setFont( dlf ); | 701 | dayLabel->setFont( dlf ); |
702 | dayLabel->setCaption("0"); | 702 | dayLabel->setCaption("0"); |
703 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 703 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
704 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 704 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
705 | dayLabel->show(); | 705 | dayLabel->show(); |
706 | DateList::ConstIterator dit; | 706 | DateList::ConstIterator dit; |
707 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 707 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
708 | int counter = 0; | 708 | int counter = 0; |
709 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 709 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
710 | ++counter; | 710 | ++counter; |
711 | QDate date = *dit; | 711 | QDate date = *dit; |
712 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 712 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
713 | if ( ! appendLabels ) { | 713 | if ( ! appendLabels ) { |
714 | dayLabel = mDayLabelsList.next(); | 714 | dayLabel = mDayLabelsList.next(); |
715 | if ( !dayLabel ) | 715 | if ( !dayLabel ) |
716 | appendLabels = true; | 716 | appendLabels = true; |
717 | } | 717 | } |
718 | if ( appendLabels ) { | 718 | if ( appendLabels ) { |
719 | dayLabel = new QPushButton(mDayLabels); | 719 | dayLabel = new QPushButton(mDayLabels); |
720 | dayLabel->setFlat( true ); | 720 | dayLabel->setFlat( true ); |
721 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 721 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
722 | dayLabel->setFocusPolicy(NoFocus); | 722 | dayLabel->setFocusPolicy(NoFocus); |
723 | mDayLabelsList.append( dayLabel ); | 723 | mDayLabelsList.append( dayLabel ); |
724 | mLayoutDayLabels->addWidget(dayLabel); | 724 | mLayoutDayLabels->addWidget(dayLabel); |
725 | } | 725 | } |
726 | dayLabel->setMinimumWidth( 1 ); | 726 | dayLabel->setMinimumWidth( 1 ); |
727 | dayLabel->setMaximumWidth( 2048 ); | 727 | dayLabel->setMaximumWidth( 2048 ); |
728 | dayLabel->setFont( dlf ); | 728 | dayLabel->setFont( dlf ); |
729 | dayLabel->show(); | 729 | dayLabel->show(); |
730 | dayLabel->setCaption(QString::number( counter )); | 730 | dayLabel->setCaption(QString::number( counter )); |
731 | QString str; | 731 | QString str; |
732 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 732 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
733 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 733 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
734 | switch ( maxLen ) { | 734 | switch ( maxLen ) { |
735 | case 2: | 735 | case 2: |
736 | str = QString::number( date.day() ); | 736 | str = QString::number( date.day() ); |
737 | break; | 737 | break; |
738 | 738 | ||
739 | case 3: | 739 | case 3: |
740 | str = dayName.left( 1 ) +QString::number( date.day()); | 740 | str = dayName.left( 1 ) +QString::number( date.day()); |
741 | 741 | ||
742 | break; | 742 | break; |
743 | case 4: | 743 | case 4: |
744 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 744 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
745 | 745 | ||
746 | break; | 746 | break; |
747 | case 5: | 747 | case 5: |
748 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 748 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
749 | 749 | ||
750 | break; | 750 | break; |
751 | case 6: | 751 | case 6: |
752 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 752 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
753 | break; | 753 | break; |
754 | 754 | ||
755 | default: | 755 | default: |
756 | break; | 756 | break; |
757 | } | 757 | } |
758 | if ( oneday ) { | 758 | if ( oneday ) { |
759 | QString addString; | 759 | QString addString; |
760 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 760 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
761 | addString = i18n("Today"); | 761 | addString = i18n("Today"); |
762 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 762 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
763 | addString = i18n("Tomorrow"); | 763 | addString = i18n("Tomorrow"); |
764 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 764 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
765 | addString = i18n("Yesterday"); | 765 | addString = i18n("Yesterday"); |
766 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 766 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
767 | addString = i18n("Day before yesterday"); | 767 | addString = i18n("Day before yesterday"); |
768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
769 | addString = i18n("Day after tomorrow"); | 769 | addString = i18n("Day after tomorrow"); |
770 | if ( !addString.isEmpty() ) { | 770 | if ( !addString.isEmpty() ) { |
771 | str = addString+", " + str; | 771 | str = addString+", " + str; |
772 | } | 772 | } |
773 | } | 773 | } |
774 | dayLabel->setText(str); | 774 | dayLabel->setText(str); |
775 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 775 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
776 | if (date == QDate::currentDate()) { | 776 | if (date == QDate::currentDate()) { |
777 | QFont bFont = dlf; | 777 | QFont bFont = dlf; |
778 | bFont.setBold( true ); | 778 | bFont.setBold( true ); |
779 | dayLabel->setFont(bFont); | 779 | dayLabel->setFont(bFont); |
780 | } | 780 | } |
781 | //dayLayout->addWidget(dayLabel); | 781 | //dayLayout->addWidget(dayLabel); |
782 | 782 | ||
783 | #ifndef KORG_NOPLUGINS | 783 | #ifndef KORG_NOPLUGINS |
784 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 784 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
785 | CalendarDecoration *it; | 785 | CalendarDecoration *it; |
786 | for(it = cds.first(); it; it = cds.next()) { | 786 | for(it = cds.first(); it; it = cds.next()) { |
787 | QString text = it->shortText( date ); | 787 | QString text = it->shortText( date ); |
788 | if ( !text.isEmpty() ) { | 788 | if ( !text.isEmpty() ) { |
789 | QLabel *label = new QLabel(text,mDayLabels); | 789 | QLabel *label = new QLabel(text,mDayLabels); |
790 | label->setAlignment(AlignCenter); | 790 | label->setAlignment(AlignCenter); |
791 | dayLayout->addWidget(label); | 791 | dayLayout->addWidget(label); |
792 | } | 792 | } |
793 | } | 793 | } |
794 | 794 | ||
795 | for(it = cds.first(); it; it = cds.next()) { | 795 | for(it = cds.first(); it; it = cds.next()) { |
796 | QWidget *wid = it->smallWidget(mDayLabels,date); | 796 | QWidget *wid = it->smallWidget(mDayLabels,date); |
797 | if ( wid ) { | 797 | if ( wid ) { |
798 | // wid->setHeight(20); | 798 | // wid->setHeight(20); |
799 | dayLayout->addWidget(wid); | 799 | dayLayout->addWidget(wid); |
800 | } | 800 | } |
801 | } | 801 | } |
802 | #endif | 802 | #endif |
803 | } | 803 | } |
804 | if ( ! appendLabels ) { | 804 | if ( ! appendLabels ) { |
805 | dayLabel = mDayLabelsList.next(); | 805 | dayLabel = mDayLabelsList.next(); |
806 | if ( !dayLabel ) | 806 | if ( !dayLabel ) |
807 | appendLabels = true; | 807 | appendLabels = true; |
808 | } | 808 | } |
809 | if ( appendLabels ) { | 809 | if ( appendLabels ) { |
810 | dayLabel = new QPushButton(mDayLabels); | 810 | dayLabel = new QPushButton(mDayLabels); |
811 | dayLabel->setFlat( true ); | 811 | dayLabel->setFlat( true ); |
812 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 812 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
813 | dayLabel->setFocusPolicy(NoFocus); | 813 | dayLabel->setFocusPolicy(NoFocus); |
814 | mDayLabelsList.append( dayLabel ); | 814 | mDayLabelsList.append( dayLabel ); |
815 | mLayoutDayLabels->addWidget(dayLabel); | 815 | mLayoutDayLabels->addWidget(dayLabel); |
816 | } | 816 | } |
817 | //dayLabel->hide();//test only | 817 | //dayLabel->hide();//test only |
818 | 818 | ||
819 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 819 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
820 | if ( offset < 0 ) offset = 0; | 820 | if ( offset < 0 ) offset = 0; |
821 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 821 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
822 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 822 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
823 | dayLabel->setFont( dlf ); | ||
823 | dayLabel->show(); | 824 | dayLabel->show(); |
824 | dayLabel->setCaption("last"); | 825 | dayLabel->setCaption("last"); |
825 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 826 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
826 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 827 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
827 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 828 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
828 | if ( !appendLabels ) { | 829 | if ( !appendLabels ) { |
829 | dayLabel = mDayLabelsList.next(); | 830 | dayLabel = mDayLabelsList.next(); |
830 | while ( dayLabel ) { | 831 | while ( dayLabel ) { |
831 | //qDebug("!dayLabel %d",dayLabel ); | 832 | //qDebug("!dayLabel %d",dayLabel ); |
832 | dayLabel->hide(); | 833 | dayLabel->hide(); |
833 | dayLabel = mDayLabelsList.next(); | 834 | dayLabel = mDayLabelsList.next(); |
834 | } | 835 | } |
835 | } | 836 | } |
836 | //mDayLabelsFrame->show(); | 837 | //mDayLabelsFrame->show(); |
837 | //mDayLabels->show(); | 838 | //mDayLabels->show(); |
838 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 839 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
839 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 840 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
840 | mDayLabelsFrame->setFixedHeight( newHight ); | 841 | mDayLabelsFrame->setFixedHeight( newHight ); |
841 | } | 842 | } |
842 | 843 | ||
843 | int KOAgendaView::maxDatesHint() | 844 | int KOAgendaView::maxDatesHint() |
844 | { | 845 | { |
845 | // Not sure about the max number of events, so return 0 for now. | 846 | // Not sure about the max number of events, so return 0 for now. |
846 | return 0; | 847 | return 0; |
847 | } | 848 | } |
848 | 849 | ||
849 | int KOAgendaView::currentDateCount() | 850 | int KOAgendaView::currentDateCount() |
850 | { | 851 | { |
851 | return mSelectedDates.count(); | 852 | return mSelectedDates.count(); |
852 | } | 853 | } |
853 | 854 | ||
854 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 855 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
855 | { | 856 | { |
856 | QPtrList<Incidence> selected; | 857 | QPtrList<Incidence> selected; |
857 | Incidence *incidence; | 858 | Incidence *incidence; |
858 | 859 | ||
859 | incidence = mAgenda->selectedIncidence(); | 860 | incidence = mAgenda->selectedIncidence(); |
860 | if (incidence) selected.append(incidence); | 861 | if (incidence) selected.append(incidence); |
861 | 862 | ||
862 | incidence = mAllDayAgenda->selectedIncidence(); | 863 | incidence = mAllDayAgenda->selectedIncidence(); |
863 | if (incidence) selected.append(incidence); | 864 | if (incidence) selected.append(incidence); |
864 | 865 | ||
865 | return selected; | 866 | return selected; |
866 | } | 867 | } |
867 | 868 | ||
868 | DateList KOAgendaView::selectedDates() | 869 | DateList KOAgendaView::selectedDates() |
869 | { | 870 | { |
870 | DateList selected; | 871 | DateList selected; |
871 | QDate qd; | 872 | QDate qd; |
872 | 873 | ||
873 | qd = mAgenda->selectedIncidenceDate(); | 874 | qd = mAgenda->selectedIncidenceDate(); |
874 | if (qd.isValid()) selected.append(qd); | 875 | if (qd.isValid()) selected.append(qd); |
875 | 876 | ||
876 | qd = mAllDayAgenda->selectedIncidenceDate(); | 877 | qd = mAllDayAgenda->selectedIncidenceDate(); |
877 | if (qd.isValid()) selected.append(qd); | 878 | if (qd.isValid()) selected.append(qd); |
878 | 879 | ||
879 | return selected; | 880 | return selected; |
880 | } | 881 | } |
881 | 882 | ||
882 | 883 | ||
883 | void KOAgendaView::updateView() | 884 | void KOAgendaView::updateView() |
884 | { | 885 | { |
885 | if ( mBlockUpdating ) | 886 | if ( mBlockUpdating ) |
886 | return; | 887 | return; |
887 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 888 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
888 | fillAgenda(); | 889 | fillAgenda(); |
889 | 890 | ||
890 | } | 891 | } |
891 | 892 | ||
892 | 893 | ||
893 | /* | 894 | /* |
894 | Update configuration settings for the agenda view. This method is not | 895 | Update configuration settings for the agenda view. This method is not |
895 | complete. | 896 | complete. |
896 | */ | 897 | */ |
897 | void KOAgendaView::updateConfig() | 898 | void KOAgendaView::updateConfig() |
898 | { | 899 | { |
899 | if ( mBlockUpdating ) | 900 | if ( mBlockUpdating ) |
900 | return; | 901 | return; |
901 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; | 902 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; |
902 | 903 | ||
903 | // update config for children | 904 | // update config for children |
904 | mTimeLabels->updateConfig(); | 905 | mTimeLabels->updateConfig(); |
905 | mAgenda->storePosition(); | 906 | mAgenda->storePosition(); |
906 | mAgenda->updateConfig(); | 907 | mAgenda->updateConfig(); |
907 | mAllDayAgenda->updateConfig(); | 908 | mAllDayAgenda->updateConfig(); |
908 | // widget synchronization | 909 | // widget synchronization |
909 | //TODO: find a better way, maybe signal/slot | 910 | //TODO: find a better way, maybe signal/slot |
910 | mTimeLabels->positionChanged(); | 911 | mTimeLabels->positionChanged(); |
911 | 912 | ||
912 | // for some reason, this needs to be called explicitly | 913 | // for some reason, this needs to be called explicitly |
913 | mTimeLabels->repaint(); | 914 | mTimeLabels->repaint(); |
914 | 915 | ||
915 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 916 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
916 | 917 | ||
917 | // ToolTips displaying summary of events | 918 | // ToolTips displaying summary of events |
918 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 919 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
919 | ->mEnableToolTips); | 920 | ->mEnableToolTips); |
920 | 921 | ||
921 | //setHolidayMasks(); | 922 | //setHolidayMasks(); |
922 | 923 | ||
923 | //createDayLabels(); called by via updateView(); | 924 | //createDayLabels(); called by via updateView(); |
924 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 925 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
925 | updateView(); | 926 | updateView(); |
926 | mAgenda->restorePosition(); | 927 | mAgenda->restorePosition(); |
927 | } | 928 | } |
928 | 929 | ||
929 | 930 | ||
930 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 931 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
931 | { | 932 | { |
932 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 933 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
933 | //qDebug("KOAgendaView::updateEventDates "); | 934 | //qDebug("KOAgendaView::updateEventDates "); |
934 | QDateTime startDt,endDt; | 935 | QDateTime startDt,endDt; |
935 | QDate startDate; | 936 | QDate startDate; |
936 | int lenInSecs; | 937 | int lenInSecs; |
937 | // if ( type == KOAgenda::RESIZETOP ) | 938 | // if ( type == KOAgenda::RESIZETOP ) |
938 | // qDebug("RESIZETOP "); | 939 | // qDebug("RESIZETOP "); |
939 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 940 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
940 | // qDebug("RESIZEBOTTOM "); | 941 | // qDebug("RESIZEBOTTOM "); |
941 | // if ( type == KOAgenda::MOVE ) | 942 | // if ( type == KOAgenda::MOVE ) |
942 | // qDebug("MOVE "); | 943 | // qDebug("MOVE "); |
943 | if ( item->incidence()->type() == "Event" ) { | 944 | if ( item->incidence()->type() == "Event" ) { |
944 | startDt =item->incidence()->dtStart(); | 945 | startDt =item->incidence()->dtStart(); |
945 | endDt = item->incidence()->dtEnd(); | 946 | endDt = item->incidence()->dtEnd(); |
946 | lenInSecs = startDt.secsTo( endDt ); | 947 | lenInSecs = startDt.secsTo( endDt ); |
947 | } | 948 | } |
948 | 949 | ||
949 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 950 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
950 | 951 | ||
951 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 952 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
952 | startDate = mSelectedDates[item->mLastMoveXPos]; | 953 | startDate = mSelectedDates[item->mLastMoveXPos]; |
953 | } else { | 954 | } else { |
954 | if (item->cellX() < 0) { | 955 | if (item->cellX() < 0) { |
955 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 956 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
956 | } else { | 957 | } else { |
957 | startDate = mSelectedDates[item->cellX()]; | 958 | startDate = mSelectedDates[item->cellX()]; |
958 | } | 959 | } |
959 | } | 960 | } |
960 | startDt.setDate(startDate); | 961 | startDt.setDate(startDate); |
961 | 962 | ||
962 | if (item->incidence()->doesFloat()) { | 963 | if (item->incidence()->doesFloat()) { |
963 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 964 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
964 | } else { | 965 | } else { |
965 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 966 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
966 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 967 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
967 | if ( item->incidence()->type() == "Event" ) { | 968 | if ( item->incidence()->type() == "Event" ) { |
968 | if ( type == KOAgenda::MOVE ) { | 969 | if ( type == KOAgenda::MOVE ) { |
969 | endDt = startDt.addSecs(lenInSecs); | 970 | endDt = startDt.addSecs(lenInSecs); |
970 | 971 | ||
971 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 972 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
972 | if (item->lastMultiItem()) { | 973 | if (item->lastMultiItem()) { |
973 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
974 | endDt.setDate(startDate. | 975 | endDt.setDate(startDate. |
975 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
976 | } else { | 977 | } else { |
977 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 978 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
978 | endDt.setDate(startDate); | 979 | endDt.setDate(startDate); |
979 | } | 980 | } |
980 | } | 981 | } |
981 | } else { | 982 | } else { |
982 | // todo | 983 | // todo |
983 | qDebug("tooooodoooooo "); | 984 | qDebug("tooooodoooooo "); |
984 | if (item->lastMultiItem()) { | 985 | if (item->lastMultiItem()) { |
985 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 986 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
986 | endDt.setDate(startDate. | 987 | endDt.setDate(startDate. |
987 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 988 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
988 | } else { | 989 | } else { |
989 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 990 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
990 | if ( item->cellYBottom() > 0 ) | 991 | if ( item->cellYBottom() > 0 ) |
991 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 992 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
992 | else | 993 | else |
993 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 994 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
994 | endDt.setDate(startDate); | 995 | endDt.setDate(startDate); |
995 | } | 996 | } |
996 | } | 997 | } |
997 | } | 998 | } |
998 | 999 | ||
999 | qDebug("to888"); | 1000 | qDebug("to888"); |
1000 | if ( item->incidence()->type() == "Event" ) { | 1001 | if ( item->incidence()->type() == "Event" ) { |
1001 | item->incidence()->setDtStart(startDt); | 1002 | item->incidence()->setDtStart(startDt); |
1002 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1003 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1003 | } else if ( item->incidence()->type() == "Todo" ) { | 1004 | } else if ( item->incidence()->type() == "Todo" ) { |
1004 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 1005 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); |
1005 | } | 1006 | } |
1006 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1007 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1007 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1008 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1008 | item->setItemDate(startDt.date()); | 1009 | item->setItemDate(startDt.date()); |
1009 | //item->updateItem(); | 1010 | //item->updateItem(); |
1010 | if ( item->incidence()->type() == "Todo" ) { | 1011 | if ( item->incidence()->type() == "Todo" ) { |
1011 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1012 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1012 | 1013 | ||
1013 | } | 1014 | } |
1014 | else | 1015 | else |
1015 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1016 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1016 | item->updateItem(); | 1017 | item->updateItem(); |
1017 | } | 1018 | } |
1018 | 1019 | ||
1019 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1020 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1020 | { | 1021 | { |
1021 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1022 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1022 | 1023 | ||
1023 | mSelectedDates.clear(); | 1024 | mSelectedDates.clear(); |
1024 | // qDebug("KOAgendaView::showDates "); | 1025 | // qDebug("KOAgendaView::showDates "); |
1025 | QDate d = start; | 1026 | QDate d = start; |
1026 | while (d <= end) { | 1027 | while (d <= end) { |
1027 | mSelectedDates.append(d); | 1028 | mSelectedDates.append(d); |
1028 | d = d.addDays( 1 ); | 1029 | d = d.addDays( 1 ); |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | // and update the view | 1032 | // and update the view |
1032 | fillAgenda(); | 1033 | fillAgenda(); |
1033 | } | 1034 | } |
1034 | 1035 | ||
1035 | 1036 | ||
1036 | void KOAgendaView::showEvents(QPtrList<Event>) | 1037 | void KOAgendaView::showEvents(QPtrList<Event>) |
1037 | { | 1038 | { |
1038 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1039 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1039 | } | 1040 | } |
1040 | 1041 | ||
1041 | void KOAgendaView::changeEventDisplay(Event *, int) | 1042 | void KOAgendaView::changeEventDisplay(Event *, int) |
1042 | { | 1043 | { |
1043 | // qDebug("KOAgendaView::changeEventDisplay "); | 1044 | // qDebug("KOAgendaView::changeEventDisplay "); |
1044 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1045 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1045 | // this should be re-written to be MUCH smarter. Right now we | 1046 | // this should be re-written to be MUCH smarter. Right now we |
1046 | // are just playing dumb. | 1047 | // are just playing dumb. |
1047 | fillAgenda(); | 1048 | fillAgenda(); |
1048 | } | 1049 | } |
1049 | 1050 | ||
1050 | void KOAgendaView::fillAgenda(const QDate &) | 1051 | void KOAgendaView::fillAgenda(const QDate &) |
1051 | { | 1052 | { |
1052 | // qDebug("KOAgendaView::fillAgenda "); | 1053 | // qDebug("KOAgendaView::fillAgenda "); |
1053 | fillAgenda(); | 1054 | fillAgenda(); |
1054 | } | 1055 | } |
1055 | 1056 | ||
1056 | void KOAgendaView::fillAgenda() | 1057 | void KOAgendaView::fillAgenda() |
1057 | { | 1058 | { |
1058 | if ( globalFlagBlockStartup ) | 1059 | if ( globalFlagBlockStartup ) |
1059 | return; | 1060 | return; |
1060 | if ( globalFlagBlockAgenda == 1 ) | 1061 | if ( globalFlagBlockAgenda == 1 ) |
1061 | return; | 1062 | return; |
1062 | //if ( globalFlagBlockAgenda == 2 ) | 1063 | //if ( globalFlagBlockAgenda == 2 ) |
1063 | //globalFlagBlockAgenda = 0; | 1064 | //globalFlagBlockAgenda = 0; |
1064 | // globalFlagBlockPainting = false; | 1065 | // globalFlagBlockPainting = false; |
1065 | if ( globalFlagBlockAgenda == 0 ) | 1066 | if ( globalFlagBlockAgenda == 0 ) |
1066 | globalFlagBlockAgenda = 1; | 1067 | globalFlagBlockAgenda = 1; |
1067 | // clearView(); | 1068 | // clearView(); |
1068 | //qDebug("fillAgenda()++++ "); | 1069 | //qDebug("fillAgenda()++++ "); |
1069 | globalFlagBlockAgendaItemPaint = 1; | 1070 | globalFlagBlockAgendaItemPaint = 1; |
1070 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1071 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1071 | mAgenda->changeColumns(mSelectedDates.count()); | 1072 | mAgenda->changeColumns(mSelectedDates.count()); |
1072 | qApp->processEvents(); | 1073 | qApp->processEvents(); |
1073 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1074 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1074 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1075 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1075 | setHolidayMasks(); | 1076 | setHolidayMasks(); |
1076 | 1077 | ||
1077 | //mAgenda->hideUnused(); | 1078 | //mAgenda->hideUnused(); |
1078 | //mAllDayAgenda->hideUnused(); | 1079 | //mAllDayAgenda->hideUnused(); |
1079 | 1080 | ||
1080 | // mAgenda->blockNextRepaint( false ); | 1081 | // mAgenda->blockNextRepaint( false ); |
1081 | // mAgenda->viewport()->repaint(); | 1082 | // mAgenda->viewport()->repaint(); |
1082 | // mAgenda->blockNextRepaint( true ); | 1083 | // mAgenda->blockNextRepaint( true ); |
1083 | mMinY.resize(mSelectedDates.count()); | 1084 | mMinY.resize(mSelectedDates.count()); |
1084 | mMaxY.resize(mSelectedDates.count()); | 1085 | mMaxY.resize(mSelectedDates.count()); |
1085 | 1086 | ||
1086 | QPtrList<Event> dayEvents; | 1087 | QPtrList<Event> dayEvents; |
1087 | 1088 | ||
1088 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1089 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1089 | // Therefore, gtodoset all of them. | 1090 | // Therefore, gtodoset all of them. |
1090 | QPtrList<Todo> todos = calendar()->todos(); | 1091 | QPtrList<Todo> todos = calendar()->todos(); |
1091 | 1092 | ||
1092 | mAgenda->setDateList(mSelectedDates); | 1093 | mAgenda->setDateList(mSelectedDates); |
1093 | 1094 | ||
1094 | QDate today = QDate::currentDate(); | 1095 | QDate today = QDate::currentDate(); |
1095 | 1096 | ||
1096 | DateList::ConstIterator dit; | 1097 | DateList::ConstIterator dit; |
1097 | int curCol = 0; | 1098 | int curCol = 0; |
1098 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1099 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1099 | QDate currentDate = *dit; | 1100 | QDate currentDate = *dit; |
1100 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1101 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1101 | // << endl; | 1102 | // << endl; |
1102 | 1103 | ||
1103 | dayEvents = calendar()->events(currentDate,true); | 1104 | dayEvents = calendar()->events(currentDate,true); |
1104 | 1105 | ||
1105 | // Default values, which can never be reached | 1106 | // Default values, which can never be reached |
1106 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1107 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1107 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1108 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1108 | 1109 | ||
1109 | unsigned int numEvent; | 1110 | unsigned int numEvent; |
1110 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1111 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1111 | Event *event = dayEvents.at(numEvent); | 1112 | Event *event = dayEvents.at(numEvent); |
1112 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1113 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1113 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1114 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1114 | continue; | 1115 | continue; |
1115 | // kdDebug() << " Event: " << event->summary() << endl; | 1116 | // kdDebug() << " Event: " << event->summary() << endl; |
1116 | 1117 | ||
1117 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1118 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1118 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1119 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1119 | 1120 | ||
1120 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1121 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1121 | 1122 | ||
1122 | if (event->doesFloat()) { | 1123 | if (event->doesFloat()) { |
1123 | if (event->recurrence()->doesRecur()) { | 1124 | if (event->recurrence()->doesRecur()) { |
1124 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1125 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1125 | } else { | 1126 | } else { |
1126 | if (beginX <= 0 && curCol == 0) { | 1127 | if (beginX <= 0 && curCol == 0) { |
1127 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1128 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1128 | } else if (beginX == curCol) { | 1129 | } else if (beginX == curCol) { |
1129 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1130 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1130 | } | 1131 | } |
1131 | } | 1132 | } |
1132 | } else if (event->isMultiDay()) { | 1133 | } else if (event->isMultiDay()) { |
1133 | if ( event->doesRecur () ) { | 1134 | if ( event->doesRecur () ) { |
1134 | QDate dateit = currentDate; | 1135 | QDate dateit = currentDate; |
1135 | int count = 0; | 1136 | int count = 0; |
1136 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1137 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1137 | while (! event->recursOn( dateit ) && count <= max ) { | 1138 | while (! event->recursOn( dateit ) && count <= max ) { |
1138 | ++count; | 1139 | ++count; |
1139 | dateit = dateit.addDays( -1 ); | 1140 | dateit = dateit.addDays( -1 ); |
1140 | } | 1141 | } |
1141 | bool ok; | 1142 | bool ok; |
1142 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1143 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1143 | if ( ok ) | 1144 | if ( ok ) |
1144 | { | 1145 | { |
1145 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1146 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1146 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1147 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1147 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1148 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1148 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1149 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1149 | 1150 | ||
1150 | } | 1151 | } |
1151 | } | 1152 | } |
1152 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1153 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1153 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1154 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1154 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1155 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1155 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1156 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1156 | //qDebug("insert!!! "); | 1157 | //qDebug("insert!!! "); |
1157 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1158 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1158 | } | 1159 | } |
1159 | if (beginX == curCol) { | 1160 | if (beginX == curCol) { |
1160 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1161 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1161 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1162 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1162 | } else if (endX == curCol) { | 1163 | } else if (endX == curCol) { |
1163 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1164 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1164 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1165 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1165 | } else { | 1166 | } else { |
1166 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1167 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1167 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1168 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1168 | } | 1169 | } |
1169 | } else { | 1170 | } else { |
1170 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1171 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1171 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1172 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1172 | if (endY < startY) endY = startY; | 1173 | if (endY < startY) endY = startY; |
1173 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1174 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1174 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1175 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1175 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1176 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1176 | } | 1177 | } |
1177 | } | 1178 | } |
1178 | // ---------- [display Todos -------------- | 1179 | // ---------- [display Todos -------------- |
1179 | unsigned int numTodo; | 1180 | unsigned int numTodo; |
1180 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1181 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1181 | Todo *todo = todos.at(numTodo); | 1182 | Todo *todo = todos.at(numTodo); |
1182 | 1183 | ||
1183 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1184 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1184 | 1185 | ||
1185 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1186 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1186 | // Already completed items can be displayed on their original due date | 1187 | // Already completed items can be displayed on their original due date |
1187 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1188 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1188 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1189 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1189 | bool fillIn = false; | 1190 | bool fillIn = false; |
1190 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1191 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1191 | fillIn = true; | 1192 | fillIn = true; |
1192 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1193 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1193 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1194 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1194 | if ( fillIn ) { | 1195 | if ( fillIn ) { |
1195 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1196 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1196 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1197 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1197 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1198 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1198 | } | 1199 | } |
1199 | else { | 1200 | else { |
1200 | QDateTime dt; | 1201 | QDateTime dt; |
1201 | if ( todo->hasCompletedDate() ) | 1202 | if ( todo->hasCompletedDate() ) |
1202 | dt = todo->completed(); | 1203 | dt = todo->completed(); |
1203 | else | 1204 | else |
1204 | dt = todo->dtDue();; | 1205 | dt = todo->dtDue();; |
1205 | 1206 | ||
1206 | 1207 | ||
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 549ef2a..dd83d48 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -109,520 +109,521 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const | |||
109 | mSelEnd = mSelStart = NOSELECTION; | 109 | mSelEnd = mSelStart = NOSELECTION; |
110 | 110 | ||
111 | setAcceptDrops(true); | 111 | setAcceptDrops(true); |
112 | //setFont( QFont("Arial", 10) ); | 112 | //setFont( QFont("Arial", 10) ); |
113 | 113 | ||
114 | mUpdateTimer = new QTimer( this ); | 114 | mUpdateTimer = new QTimer( this ); |
115 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 115 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
116 | mRepaintTimer = new QTimer( this ); | 116 | mRepaintTimer = new QTimer( this ); |
117 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 117 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
118 | mDayChanged = false; | 118 | mDayChanged = false; |
119 | updateView(); | 119 | updateView(); |
120 | } | 120 | } |
121 | 121 | ||
122 | QColor KODayMatrix::getShadedColor(QColor color) | 122 | QColor KODayMatrix::getShadedColor(QColor color) |
123 | { | 123 | { |
124 | QColor shaded; | 124 | QColor shaded; |
125 | int h=0; | 125 | int h=0; |
126 | int s=0; | 126 | int s=0; |
127 | int v=0; | 127 | int v=0; |
128 | color.hsv(&h,&s,&v); | 128 | color.hsv(&h,&s,&v); |
129 | s = s/4; | 129 | s = s/4; |
130 | v = 192+v/4; | 130 | v = 192+v/4; |
131 | shaded.setHsv(h,s,v); | 131 | shaded.setHsv(h,s,v); |
132 | 132 | ||
133 | return shaded; | 133 | return shaded; |
134 | } | 134 | } |
135 | 135 | ||
136 | KODayMatrix::~KODayMatrix() | 136 | KODayMatrix::~KODayMatrix() |
137 | { | 137 | { |
138 | delete [] days; | 138 | delete [] days; |
139 | delete [] daylbls; | 139 | delete [] daylbls; |
140 | delete [] events; | 140 | delete [] events; |
141 | delete mToolTip; | 141 | delete mToolTip; |
142 | } | 142 | } |
143 | 143 | ||
144 | /* | 144 | /* |
145 | void KODayMatrix::setStartDate(QDate start) | 145 | void KODayMatrix::setStartDate(QDate start) |
146 | { | 146 | { |
147 | updateView(start); | 147 | updateView(start); |
148 | } | 148 | } |
149 | */ | 149 | */ |
150 | 150 | ||
151 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 151 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
152 | { | 152 | { |
153 | 153 | ||
154 | if (mSelStart == NOSELECTION) { | 154 | if (mSelStart == NOSELECTION) { |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | 157 | ||
158 | //cope with selection being out of matrix limits at top (< 0) | 158 | //cope with selection being out of matrix limits at top (< 0) |
159 | int i0 = mSelStart; | 159 | int i0 = mSelStart; |
160 | if (i0 < 0) { | 160 | if (i0 < 0) { |
161 | for (int i = i0; i < 0; i++) { | 161 | for (int i = i0; i < 0; i++) { |
162 | selDays.append(days[0].addDays(i)); | 162 | selDays.append(days[0].addDays(i)); |
163 | } | 163 | } |
164 | i0 = 0; | 164 | i0 = 0; |
165 | } | 165 | } |
166 | 166 | ||
167 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 167 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
168 | if (mSelEnd > NUMDAYS-1) { | 168 | if (mSelEnd > NUMDAYS-1) { |
169 | for (int i = i0; i <= NUMDAYS-1; i++) { | 169 | for (int i = i0; i <= NUMDAYS-1; i++) { |
170 | selDays.append(days[i]); | 170 | selDays.append(days[i]); |
171 | } | 171 | } |
172 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 172 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
173 | selDays.append(days[0].addDays(i)); | 173 | selDays.append(days[0].addDays(i)); |
174 | } | 174 | } |
175 | 175 | ||
176 | // apply normal routine to selection being entirely within matrix limits | 176 | // apply normal routine to selection being entirely within matrix limits |
177 | } else { | 177 | } else { |
178 | for (int i = i0; i <= mSelEnd; i++) { | 178 | for (int i = i0; i <= mSelEnd; i++) { |
179 | selDays.append(days[i]); | 179 | selDays.append(days[i]); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
185 | { | 185 | { |
186 | mSelStart = startdate.daysTo(start); | 186 | mSelStart = startdate.daysTo(start); |
187 | mSelEnd = startdate.daysTo(end); | 187 | mSelEnd = startdate.daysTo(end); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | void KODayMatrix::recalculateToday() | 191 | void KODayMatrix::recalculateToday() |
192 | { | 192 | { |
193 | today = -1; | 193 | today = -1; |
194 | for (int i=0; i<NUMDAYS; i++) { | 194 | for (int i=0; i<NUMDAYS; i++) { |
195 | events[i] = 0; | 195 | events[i] = 0; |
196 | days[i] = startdate.addDays(i); | 196 | days[i] = startdate.addDays(i); |
197 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 197 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
198 | 198 | ||
199 | // if today is in the currently displayed month, hilight today | 199 | // if today is in the currently displayed month, hilight today |
200 | if (days[i].year() == QDate::currentDate().year() && | 200 | if (days[i].year() == QDate::currentDate().year() && |
201 | days[i].month() == QDate::currentDate().month() && | 201 | days[i].month() == QDate::currentDate().month() && |
202 | days[i].day() == QDate::currentDate().day()) { | 202 | days[i].day() == QDate::currentDate().day()) { |
203 | today = i; | 203 | today = i; |
204 | } | 204 | } |
205 | } | 205 | } |
206 | // qDebug(QString("Today is visible at %1.").arg(today)); | 206 | // qDebug(QString("Today is visible at %1.").arg(today)); |
207 | } | 207 | } |
208 | 208 | ||
209 | void KODayMatrix::updateView() | 209 | void KODayMatrix::updateView() |
210 | { | 210 | { |
211 | updateView(startdate); | 211 | updateView(startdate); |
212 | } | 212 | } |
213 | void KODayMatrix::repaintViewTimed() | 213 | void KODayMatrix::repaintViewTimed() |
214 | { | 214 | { |
215 | mRepaintTimer->stop(); | 215 | mRepaintTimer->stop(); |
216 | repaint(false); | 216 | repaint(false); |
217 | } | 217 | } |
218 | void KODayMatrix::updateViewTimed() | 218 | void KODayMatrix::updateViewTimed() |
219 | { | 219 | { |
220 | 220 | ||
221 | mUpdateTimer->stop(); | 221 | mUpdateTimer->stop(); |
222 | for(int i = 0; i < NUMDAYS; i++) { | 222 | for(int i = 0; i < NUMDAYS; i++) { |
223 | // if events are set for the day then remember to draw it bold | 223 | // if events are set for the day then remember to draw it bold |
224 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 224 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
225 | Event *event; | 225 | Event *event; |
226 | int numEvents = eventlist.count(); | 226 | int numEvents = eventlist.count(); |
227 | QString holiStr = ""; | 227 | QString holiStr = ""; |
228 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 228 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
229 | ushort recurType = event->recurrence()->doesRecur(); | 229 | ushort recurType = event->recurrence()->doesRecur(); |
230 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 230 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
231 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 231 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
232 | numEvents--; | 232 | numEvents--; |
233 | } | 233 | } |
234 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 234 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
235 | if ( !holiStr.isEmpty() ) | 235 | if ( !holiStr.isEmpty() ) |
236 | holiStr += "\n"; | 236 | holiStr += "\n"; |
237 | holiStr += event->summary(); | 237 | holiStr += event->summary(); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | events[i] = numEvents; | 240 | events[i] = numEvents; |
241 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 241 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
242 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 242 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
243 | !holiStr.isEmpty()) { | 243 | !holiStr.isEmpty()) { |
244 | mHolidays[i] = holiStr; | 244 | mHolidays[i] = holiStr; |
245 | } else { | 245 | } else { |
246 | mHolidays[i] = QString::null; | 246 | mHolidays[i] = QString::null; |
247 | } | 247 | } |
248 | } | 248 | } |
249 | if ( ! mPendingUpdateBeforeRepaint ) | 249 | if ( ! mPendingUpdateBeforeRepaint ) |
250 | repaint(false); | 250 | repaint(false); |
251 | } | 251 | } |
252 | void KODayMatrix::updateView(QDate actdate) | 252 | void KODayMatrix::updateView(QDate actdate) |
253 | { | 253 | { |
254 | 254 | ||
255 | if ( ! actdate.isValid() ) { | 255 | if ( ! actdate.isValid() ) { |
256 | //qDebug("date not valid "); | 256 | //qDebug("date not valid "); |
257 | return; | 257 | return; |
258 | } | 258 | } |
259 | mDayChanged = false; | 259 | mDayChanged = false; |
260 | //flag to indicate if the starting day of the matrix has changed by this call | 260 | //flag to indicate if the starting day of the matrix has changed by this call |
261 | //mDayChanged = false; | 261 | //mDayChanged = false; |
262 | // if a new startdate is to be set then apply Cornelius's calculation | 262 | // if a new startdate is to be set then apply Cornelius's calculation |
263 | // of the first day to be shown | 263 | // of the first day to be shown |
264 | if (actdate != startdate) { | 264 | if (actdate != startdate) { |
265 | // reset index of selection according to shift of starting date from startdate to actdate | 265 | // reset index of selection according to shift of starting date from startdate to actdate |
266 | if (mSelStart != NOSELECTION) { | 266 | if (mSelStart != NOSELECTION) { |
267 | int tmp = actdate.daysTo(startdate); | 267 | int tmp = actdate.daysTo(startdate); |
268 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 268 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
269 | // shift selection if new one would be visible at least partly ! | 269 | // shift selection if new one would be visible at least partly ! |
270 | 270 | ||
271 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 271 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
272 | // nested if is required for next X display pushed from a different month - correction required | 272 | // nested if is required for next X display pushed from a different month - correction required |
273 | // otherwise, for month forward and backward, it must be avoided | 273 | // otherwise, for month forward and backward, it must be avoided |
274 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 274 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
275 | mSelStart = mSelStart + tmp; | 275 | mSelStart = mSelStart + tmp; |
276 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 276 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
277 | mSelEnd = mSelEnd + tmp; | 277 | mSelEnd = mSelEnd + tmp; |
278 | } | 278 | } |
279 | } | 279 | } |
280 | startdate = actdate; | 280 | startdate = actdate; |
281 | mDayChanged = true; | 281 | mDayChanged = true; |
282 | recalculateToday(); | 282 | recalculateToday(); |
283 | } | 283 | } |
284 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 284 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
285 | if ( !isVisible() ) { | 285 | if ( !isVisible() ) { |
286 | mPendingUpdateBeforeRepaint = true; | 286 | mPendingUpdateBeforeRepaint = true; |
287 | } else { | 287 | } else { |
288 | #ifdef DESKTOP_VERSION | 288 | #ifdef DESKTOP_VERSION |
289 | //mRepaintTimer->start( 250 ); | 289 | //mRepaintTimer->start( 250 ); |
290 | mUpdateTimer->start( 250 ); | 290 | mUpdateTimer->start( 250 ); |
291 | #else | 291 | #else |
292 | mRepaintTimer->start( 350 ); | 292 | mRepaintTimer->start( 350 ); |
293 | mUpdateTimer->start( 2000 ); | 293 | mUpdateTimer->start( 2000 ); |
294 | #endif | 294 | #endif |
295 | } | 295 | } |
296 | } | 296 | } |
297 | 297 | ||
298 | const QDate& KODayMatrix::getDate(int offset) | 298 | const QDate& KODayMatrix::getDate(int offset) |
299 | { | 299 | { |
300 | if (offset < 0 || offset > NUMDAYS-1) { | 300 | if (offset < 0 || offset > NUMDAYS-1) { |
301 | qDebug("Wrong offset2 "); | 301 | qDebug("Wrong offset2 "); |
302 | return days[0]; | 302 | return days[0]; |
303 | } | 303 | } |
304 | return days[offset]; | 304 | return days[offset]; |
305 | } | 305 | } |
306 | 306 | ||
307 | QString KODayMatrix::getHolidayLabel(int offset) | 307 | QString KODayMatrix::getHolidayLabel(int offset) |
308 | { | 308 | { |
309 | if (offset < 0 || offset > NUMDAYS-1) { | 309 | if (offset < 0 || offset > NUMDAYS-1) { |
310 | qDebug("Wrong offset1 "); | 310 | qDebug("Wrong offset1 "); |
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
313 | return mHolidays[offset]; | 313 | return mHolidays[offset]; |
314 | } | 314 | } |
315 | 315 | ||
316 | int KODayMatrix::getDayIndexFrom(int x, int y) | 316 | int KODayMatrix::getDayIndexFrom(int x, int y) |
317 | { | 317 | { |
318 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 318 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
319 | 6 - x/daysize.width() : x/daysize.width()); | 319 | 6 - x/daysize.width() : x/daysize.width()); |
320 | } | 320 | } |
321 | 321 | ||
322 | // ---------------------------------------------------------------------------- | 322 | // ---------------------------------------------------------------------------- |
323 | // M O U S E E V E N T H A N D L I N G | 323 | // M O U S E E V E N T H A N D L I N G |
324 | // ---------------------------------------------------------------------------- | 324 | // ---------------------------------------------------------------------------- |
325 | 325 | ||
326 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 326 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
327 | { | 327 | { |
328 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 328 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
329 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 329 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
330 | mSelInit = mSelStart; | 330 | mSelInit = mSelStart; |
331 | } | 331 | } |
332 | 332 | ||
333 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 333 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
334 | { | 334 | { |
335 | 335 | ||
336 | int tmp = getDayIndexFrom(e->x(), e->y()); | 336 | int tmp = getDayIndexFrom(e->x(), e->y()); |
337 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 337 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
338 | 338 | ||
339 | if (mSelInit > tmp) { | 339 | if (mSelInit > tmp) { |
340 | mSelEnd = mSelInit; | 340 | mSelEnd = mSelInit; |
341 | if (tmp != mSelStart) { | 341 | if (tmp != mSelStart) { |
342 | mSelStart = tmp; | 342 | mSelStart = tmp; |
343 | repaint(); | 343 | repaint(); |
344 | } | 344 | } |
345 | } else { | 345 | } else { |
346 | mSelStart = mSelInit; | 346 | mSelStart = mSelInit; |
347 | 347 | ||
348 | //repaint only if selection has changed | 348 | //repaint only if selection has changed |
349 | if (tmp != mSelEnd) { | 349 | if (tmp != mSelEnd) { |
350 | mSelEnd = tmp; | 350 | mSelEnd = tmp; |
351 | repaint(); | 351 | repaint(); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
355 | DateList daylist; | 355 | DateList daylist; |
356 | if ( mSelStart < 0 ) | 356 | if ( mSelStart < 0 ) |
357 | mSelStart = 0; | 357 | mSelStart = 0; |
358 | for (int i = mSelStart; i <= mSelEnd; i++) { | 358 | for (int i = mSelStart; i <= mSelEnd; i++) { |
359 | daylist.append(days[i]); | 359 | daylist.append(days[i]); |
360 | } | 360 | } |
361 | emit selected((const DateList)daylist); | 361 | emit selected((const DateList)daylist); |
362 | 362 | ||
363 | } | 363 | } |
364 | 364 | ||
365 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 365 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
366 | { | 366 | { |
367 | int tmp = getDayIndexFrom(e->x(), e->y()); | 367 | int tmp = getDayIndexFrom(e->x(), e->y()); |
368 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 368 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
369 | 369 | ||
370 | if (mSelInit > tmp) { | 370 | if (mSelInit > tmp) { |
371 | mSelEnd = mSelInit; | 371 | mSelEnd = mSelInit; |
372 | if (tmp != mSelStart) { | 372 | if (tmp != mSelStart) { |
373 | mSelStart = tmp; | 373 | mSelStart = tmp; |
374 | repaint(); | 374 | repaint(); |
375 | } | 375 | } |
376 | } else { | 376 | } else { |
377 | mSelStart = mSelInit; | 377 | mSelStart = mSelInit; |
378 | 378 | ||
379 | //repaint only if selection has changed | 379 | //repaint only if selection has changed |
380 | if (tmp != mSelEnd) { | 380 | if (tmp != mSelEnd) { |
381 | mSelEnd = tmp; | 381 | mSelEnd = tmp; |
382 | repaint(); | 382 | repaint(); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | // ---------------------------------------------------------------------------- | 387 | // ---------------------------------------------------------------------------- |
388 | // D R A G ' N D R O P H A N D L I N G | 388 | // D R A G ' N D R O P H A N D L I N G |
389 | // ---------------------------------------------------------------------------- | 389 | // ---------------------------------------------------------------------------- |
390 | 390 | ||
391 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 391 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
392 | { | 392 | { |
393 | #ifndef KORG_NODND | 393 | #ifndef KORG_NODND |
394 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 394 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
395 | e->ignore(); | 395 | e->ignore(); |
396 | return; | 396 | return; |
397 | } | 397 | } |
398 | 398 | ||
399 | // some visual feedback | 399 | // some visual feedback |
400 | // oldPalette = palette(); | 400 | // oldPalette = palette(); |
401 | // setPalette(my_HilitePalette); | 401 | // setPalette(my_HilitePalette); |
402 | // update(); | 402 | // update(); |
403 | #endif | 403 | #endif |
404 | } | 404 | } |
405 | 405 | ||
406 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 406 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
407 | { | 407 | { |
408 | #ifndef KORG_NODND | 408 | #ifndef KORG_NODND |
409 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 409 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
410 | e->ignore(); | 410 | e->ignore(); |
411 | return; | 411 | return; |
412 | } | 412 | } |
413 | 413 | ||
414 | e->accept(); | 414 | e->accept(); |
415 | #endif | 415 | #endif |
416 | } | 416 | } |
417 | 417 | ||
418 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 418 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
419 | { | 419 | { |
420 | #ifndef KORG_NODND | 420 | #ifndef KORG_NODND |
421 | // setPalette(oldPalette); | 421 | // setPalette(oldPalette); |
422 | // update(); | 422 | // update(); |
423 | #endif | 423 | #endif |
424 | } | 424 | } |
425 | 425 | ||
426 | void KODayMatrix::dropEvent(QDropEvent *e) | 426 | void KODayMatrix::dropEvent(QDropEvent *e) |
427 | { | 427 | { |
428 | #ifndef KORG_NODND | 428 | #ifndef KORG_NODND |
429 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 429 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
430 | 430 | ||
431 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 431 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
432 | e->ignore(); | 432 | e->ignore(); |
433 | return; | 433 | return; |
434 | } | 434 | } |
435 | 435 | ||
436 | DndFactory factory( mCalendar ); | 436 | DndFactory factory( mCalendar ); |
437 | Event *event = factory.createDrop(e); | 437 | Event *event = factory.createDrop(e); |
438 | 438 | ||
439 | if (event) { | 439 | if (event) { |
440 | e->acceptAction(); | 440 | e->acceptAction(); |
441 | 441 | ||
442 | Event *existingEvent = mCalendar->event(event->uid()); | 442 | Event *existingEvent = mCalendar->event(event->uid()); |
443 | 443 | ||
444 | if(existingEvent) { | 444 | if(existingEvent) { |
445 | // uniquify event | 445 | // uniquify event |
446 | event->recreate(); | 446 | event->recreate(); |
447 | /* | 447 | /* |
448 | KMessageBox::sorry(this, | 448 | KMessageBox::sorry(this, |
449 | i18n("Event already exists in this calendar."), | 449 | i18n("Event already exists in this calendar."), |
450 | i18n("Drop Event")); | 450 | i18n("Drop Event")); |
451 | delete event; | 451 | delete event; |
452 | return; | 452 | return; |
453 | */ | 453 | */ |
454 | } | 454 | } |
455 | // kdDebug() << "Drop new Event" << endl; | 455 | // kdDebug() << "Drop new Event" << endl; |
456 | // Adjust date | 456 | // Adjust date |
457 | QDateTime start = event->dtStart(); | 457 | QDateTime start = event->dtStart(); |
458 | QDateTime end = event->dtEnd(); | 458 | QDateTime end = event->dtEnd(); |
459 | int duration = start.daysTo(end); | 459 | int duration = start.daysTo(end); |
460 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 460 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
461 | 461 | ||
462 | start.setDate(days[idx]); | 462 | start.setDate(days[idx]); |
463 | end.setDate(days[idx].addDays(duration)); | 463 | end.setDate(days[idx].addDays(duration)); |
464 | 464 | ||
465 | event->setDtStart(start); | 465 | event->setDtStart(start); |
466 | event->setDtEnd(end); | 466 | event->setDtEnd(end); |
467 | mCalendar->addEvent(event); | 467 | mCalendar->addEvent(event); |
468 | 468 | ||
469 | emit eventDropped(event); | 469 | emit eventDropped(event); |
470 | } else { | 470 | } else { |
471 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 471 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
472 | e->ignore(); | 472 | e->ignore(); |
473 | } | 473 | } |
474 | #endif | 474 | #endif |
475 | } | 475 | } |
476 | 476 | ||
477 | // ---------------------------------------------------------------------------- | 477 | // ---------------------------------------------------------------------------- |
478 | // P A I N T E V E N T H A N D L I N G | 478 | // P A I N T E V E N T H A N D L I N G |
479 | // ---------------------------------------------------------------------------- | 479 | // ---------------------------------------------------------------------------- |
480 | 480 | ||
481 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 481 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
482 | { | 482 | { |
483 | if ( width() <= 0 || height() <= 0 ) | 483 | if ( width() <= 0 || height() <= 0 ) |
484 | return; | 484 | return; |
485 | if ( mPendingUpdateBeforeRepaint ) { | 485 | if ( mPendingUpdateBeforeRepaint ) { |
486 | updateViewTimed(); | 486 | updateViewTimed(); |
487 | mPendingUpdateBeforeRepaint = false; | 487 | mPendingUpdateBeforeRepaint = false; |
488 | } | 488 | } |
489 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 489 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
490 | myPix.resize(size() ); | 490 | myPix.resize(size() ); |
491 | } | 491 | } |
492 | QPainter p(&myPix); | 492 | QPainter p(&myPix); |
493 | p.setFont(font()); | ||
493 | 494 | ||
494 | QRect sz = frameRect(); | 495 | QRect sz = frameRect(); |
495 | int dheight = daysize.height(); | 496 | int dheight = daysize.height(); |
496 | int dwidth = daysize.width(); | 497 | int dwidth = daysize.width(); |
497 | int row,col; | 498 | int row,col; |
498 | int selw, selh; | 499 | int selw, selh; |
499 | bool isRTL = KOGlobals::self()->reverseLayout(); | 500 | bool isRTL = KOGlobals::self()->reverseLayout(); |
500 | 501 | ||
501 | // draw background and topleft frame | 502 | // draw background and topleft frame |
502 | p.fillRect(pevent->rect(), mDefaultBackColor); | 503 | p.fillRect(pevent->rect(), mDefaultBackColor); |
503 | p.setPen(mDefaultTextColor); | 504 | p.setPen(mDefaultTextColor); |
504 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 505 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
505 | 506 | ||
506 | // draw selected days with highlighted background color | 507 | // draw selected days with highlighted background color |
507 | if (mSelStart != NOSELECTION) { | 508 | if (mSelStart != NOSELECTION) { |
508 | 509 | ||
509 | row = mSelStart/7; | 510 | row = mSelStart/7; |
510 | col = mSelStart -row*7; | 511 | col = mSelStart -row*7; |
511 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 512 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
512 | 513 | ||
513 | if (row == mSelEnd/7) { | 514 | if (row == mSelEnd/7) { |
514 | // Single row selection | 515 | // Single row selection |
515 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, | 516 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, |
516 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); | 517 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); |
517 | } else { | 518 | } else { |
518 | // draw first row to the right | 519 | // draw first row to the right |
519 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 520 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
520 | dheight, selcol); | 521 | dheight, selcol); |
521 | // draw full block till last line | 522 | // draw full block till last line |
522 | selh = mSelEnd/7-row; | 523 | selh = mSelEnd/7-row; |
523 | if (selh > 1) { | 524 | if (selh > 1) { |
524 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 525 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
525 | } | 526 | } |
526 | // draw last block from left to mSelEnd | 527 | // draw last block from left to mSelEnd |
527 | selw = mSelEnd-7*(mSelEnd/7)+1; | 528 | selw = mSelEnd-7*(mSelEnd/7)+1; |
528 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 529 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
529 | selw*dwidth, dheight, selcol); | 530 | selw*dwidth, dheight, selcol); |
530 | } | 531 | } |
531 | } | 532 | } |
532 | 533 | ||
533 | // iterate over all days in the matrix and draw the day label in appropriate colors | 534 | // iterate over all days in the matrix and draw the day label in appropriate colors |
534 | QColor actcol = mDefaultTextColorShaded; | 535 | QColor actcol = mDefaultTextColorShaded; |
535 | p.setPen(actcol); | 536 | p.setPen(actcol); |
536 | QPen tmppen; | 537 | QPen tmppen; |
537 | for(int i = 0; i < NUMDAYS; i++) { | 538 | for(int i = 0; i < NUMDAYS; i++) { |
538 | row = i/7; | 539 | row = i/7; |
539 | col = isRTL ? 6-(i-row*7) : i-row*7; | 540 | col = isRTL ? 6-(i-row*7) : i-row*7; |
540 | 541 | ||
541 | // if it is the first day of a month switch color from normal to shaded and vice versa | 542 | // if it is the first day of a month switch color from normal to shaded and vice versa |
542 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 543 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
543 | if (actcol == mDefaultTextColorShaded) { | 544 | if (actcol == mDefaultTextColorShaded) { |
544 | actcol = mDefaultTextColor; | 545 | actcol = mDefaultTextColor; |
545 | } else { | 546 | } else { |
546 | actcol = mDefaultTextColorShaded; | 547 | actcol = mDefaultTextColorShaded; |
547 | } | 548 | } |
548 | p.setPen(actcol); | 549 | p.setPen(actcol); |
549 | } | 550 | } |
550 | 551 | ||
551 | //Reset pen color after selected days block | 552 | //Reset pen color after selected days block |
552 | if (i == mSelEnd+1) { | 553 | if (i == mSelEnd+1) { |
553 | p.setPen(actcol); | 554 | p.setPen(actcol); |
554 | } | 555 | } |
555 | 556 | ||
556 | // if today then draw rectangle around day | 557 | // if today then draw rectangle around day |
557 | if (today == i) { | 558 | if (today == i) { |
558 | tmppen = p.pen(); | 559 | tmppen = p.pen(); |
559 | QPen mTodayPen(p.pen()); | 560 | QPen mTodayPen(p.pen()); |
560 | 561 | ||
561 | mTodayPen.setWidth(mTodayMarginWidth); | 562 | mTodayPen.setWidth(mTodayMarginWidth); |
562 | //draw red rectangle for holidays | 563 | //draw red rectangle for holidays |
563 | if (!mHolidays[i].isNull()) { | 564 | if (!mHolidays[i].isNull()) { |
564 | if (actcol == mDefaultTextColor) { | 565 | if (actcol == mDefaultTextColor) { |
565 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 566 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
566 | } else { | 567 | } else { |
567 | mTodayPen.setColor(mHolidayColorShaded); | 568 | mTodayPen.setColor(mHolidayColorShaded); |
568 | } | 569 | } |
569 | } | 570 | } |
570 | //draw gray rectangle for today if in selection | 571 | //draw gray rectangle for today if in selection |
571 | if (i >= mSelStart && i <= mSelEnd) { | 572 | if (i >= mSelStart && i <= mSelEnd) { |
572 | QColor grey("grey"); | 573 | QColor grey("grey"); |
573 | mTodayPen.setColor(grey); | 574 | mTodayPen.setColor(grey); |
574 | } | 575 | } |
575 | p.setPen(mTodayPen); | 576 | p.setPen(mTodayPen); |
576 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 577 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
577 | p.setPen(tmppen); | 578 | p.setPen(tmppen); |
578 | } | 579 | } |
579 | 580 | ||
580 | // if any events are on that day then draw it using a bold font | 581 | // if any events are on that day then draw it using a bold font |
581 | if (events[i] > 0) { | 582 | if (events[i] > 0) { |
582 | QFont myFont = font(); | 583 | QFont myFont = font(); |
583 | myFont.setBold(true); | 584 | myFont.setBold(true); |
584 | p.setFont(myFont); | 585 | p.setFont(myFont); |
585 | } | 586 | } |
586 | 587 | ||
587 | // if it is a holiday then use the default holiday color | 588 | // if it is a holiday then use the default holiday color |
588 | if (!mHolidays[i].isNull()) { | 589 | if (!mHolidays[i].isNull()) { |
589 | if (actcol == mDefaultTextColor) { | 590 | if (actcol == mDefaultTextColor) { |
590 | p.setPen(KOPrefs::instance()->mHolidayColor); | 591 | p.setPen(KOPrefs::instance()->mHolidayColor); |
591 | } else { | 592 | } else { |
592 | p.setPen(mHolidayColorShaded); | 593 | p.setPen(mHolidayColorShaded); |
593 | } | 594 | } |
594 | } | 595 | } |
595 | 596 | ||
596 | // draw selected days with special color | 597 | // draw selected days with special color |
597 | // DO NOT specially highlight holidays in selection ! | 598 | // DO NOT specially highlight holidays in selection ! |
598 | if (i >= mSelStart && i <= mSelEnd) { | 599 | if (i >= mSelStart && i <= mSelEnd) { |
599 | p.setPen(mSelectedDaysColor); | 600 | p.setPen(mSelectedDaysColor); |
600 | } | 601 | } |
601 | 602 | ||
602 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 603 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, |
603 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 604 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
604 | 605 | ||
605 | // reset color to actual color | 606 | // reset color to actual color |
606 | if (!mHolidays[i].isNull()) { | 607 | if (!mHolidays[i].isNull()) { |
607 | p.setPen(actcol); | 608 | p.setPen(actcol); |
608 | } | 609 | } |
609 | // reset bold font to plain font | 610 | // reset bold font to plain font |
610 | if (events[i] > 0) { | 611 | if (events[i] > 0) { |
611 | QFont myFont = font(); | 612 | QFont myFont = font(); |
612 | myFont.setBold(false); | 613 | myFont.setBold(false); |
613 | p.setFont(myFont); | 614 | p.setFont(myFont); |
614 | } | 615 | } |
615 | } | 616 | } |
616 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 617 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
617 | } | 618 | } |
618 | 619 | ||
619 | // ---------------------------------------------------------------------------- | 620 | // ---------------------------------------------------------------------------- |
620 | // R E SI Z E E V E N T H A N D L I N G | 621 | // R E SI Z E E V E N T H A N D L I N G |
621 | // ---------------------------------------------------------------------------- | 622 | // ---------------------------------------------------------------------------- |
622 | 623 | ||
623 | void KODayMatrix::resizeEvent(QResizeEvent *) | 624 | void KODayMatrix::resizeEvent(QResizeEvent *) |
624 | { | 625 | { |
625 | QRect sz = frameRect(); | 626 | QRect sz = frameRect(); |
626 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 627 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
627 | daysize.setWidth(sz.width() / 7); | 628 | daysize.setWidth(sz.width() / 7); |
628 | } | 629 | } |