author | zautrix <zautrix> | 2005-02-01 17:51:26 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-01 17:51:26 (UTC) |
commit | 81991bbbc7f815c82b37db654528ee3b224435dc (patch) (unidiff) | |
tree | 7e556083803d359c3a598d3ecf724d1127703480 /korganizer | |
parent | b699d9cf03b5b5bb92609bcd04eef2651fe0028b (diff) | |
download | kdepimpi-81991bbbc7f815c82b37db654528ee3b224435dc.zip kdepimpi-81991bbbc7f815c82b37db654528ee3b224435dc.tar.gz kdepimpi-81991bbbc7f815c82b37db654528ee3b224435dc.tar.bz2 |
fff
-rw-r--r-- | korganizer/koagendaview.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 8c27c43..d3db89a 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -530,255 +530,256 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
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 | 628 | ||
629 | QPushButton* KOAgendaView::getNewDaylabel() | 629 | QPushButton* KOAgendaView::getNewDaylabel() |
630 | { | 630 | { |
631 | 631 | ||
632 | QPushButton * dayLabel = new QPushButton(mDayLabels); | 632 | QPushButton * dayLabel = new QPushButton(mDayLabels); |
633 | dayLabel->setFlat( true ); | 633 | dayLabel->setFlat( true ); |
634 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 634 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
635 | dayLabel->setFocusPolicy(NoFocus); | 635 | dayLabel->setFocusPolicy(NoFocus); |
636 | dayLabel->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); | 636 | dayLabel->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); |
637 | mDayLabelsList.append( dayLabel ); | 637 | mDayLabelsList.append( dayLabel ); |
638 | mLayoutDayLabels->addWidget(dayLabel); | 638 | mLayoutDayLabels->addWidget(dayLabel); |
639 | //mLayoutDayLabels->setStretchFactor(dayLabel, 100); | 639 | //mLayoutDayLabels->setStretchFactor(dayLabel, 100); |
640 | return dayLabel ; | 640 | return dayLabel ; |
641 | } | 641 | } |
642 | 642 | ||
643 | void KOAgendaView::createDayLabels() | 643 | void KOAgendaView::createDayLabels() |
644 | { | 644 | { |
645 | 645 | ||
646 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 646 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
647 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 647 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
648 | return; | 648 | return; |
649 | 649 | ||
650 | } | 650 | } |
651 | int newHight; | 651 | int newHight; |
652 | 652 | ||
653 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 653 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
654 | // It would remove some flickering and gain speed (since this is called by | 654 | // It would remove some flickering and gain speed (since this is called by |
655 | // each updateView() call) | 655 | // each updateView() call) |
656 | 656 | ||
657 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 657 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
658 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 658 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
659 | if ( maxWid < 0 ) | 659 | if ( maxWid < 0 ) |
660 | maxWid = 20; | 660 | maxWid = 20; |
661 | 661 | ||
662 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 662 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
663 | QFontMetrics fm ( dlf ); | 663 | QFontMetrics fm ( dlf ); |
664 | int selCount = mSelectedDates.count(); | 664 | int selCount = mSelectedDates.count(); |
665 | QString dayTest = "Mon 20"; | 665 | QString dayTest = "Won 20"; |
666 | //QString dayTest = "Mon 20"; | ||
666 | int wid = fm.width( dayTest ); | 667 | int wid = fm.width( dayTest ); |
667 | //maxWid -= ( selCount * 3 ); //working for QLabels | 668 | //maxWid -= ( selCount * 3 ); //working for QLabels |
668 | maxWid -= ( selCount * 5 ); //working for QPushButton | 669 | maxWid -= ( selCount * 5 ); //working for QPushButton |
669 | if ( maxWid < 0 ) | 670 | if ( maxWid < 0 ) |
670 | maxWid = 20; | 671 | maxWid = 20; |
671 | int needWid = wid * selCount; | 672 | int needWid = wid * selCount; |
672 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 673 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
673 | //if ( needWid > maxWid ) | 674 | //if ( needWid > maxWid ) |
674 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 675 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
675 | while ( needWid > maxWid ) { | 676 | while ( needWid > maxWid ) { |
676 | dayTest = dayTest.left( dayTest.length() - 1 ); | 677 | dayTest = dayTest.left( dayTest.length() - 1 ); |
677 | wid = fm.width( dayTest ); | 678 | wid = fm.width( dayTest )+1; |
678 | needWid = wid * selCount; | 679 | needWid = wid * selCount; |
679 | } | 680 | } |
680 | int maxLen = dayTest.length(); | 681 | int maxLen = dayTest.length(); |
681 | int fontPoint = dlf.pointSize(); | 682 | int fontPoint = dlf.pointSize(); |
682 | if ( maxLen < 2 ) { | 683 | if ( maxLen < 2 ) { |
683 | int fontPoint = dlf.pointSize(); | 684 | int fontPoint = dlf.pointSize(); |
684 | while ( fontPoint > 4 ) { | 685 | while ( fontPoint > 4 ) { |
685 | --fontPoint; | 686 | --fontPoint; |
686 | dlf.setPointSize( fontPoint ); | 687 | dlf.setPointSize( fontPoint ); |
687 | QFontMetrics f( dlf ); | 688 | QFontMetrics f( dlf ); |
688 | wid = f.width( "20" )+2; | 689 | wid = f.width( "30" )+3; |
689 | needWid = wid * selCount; | 690 | needWid = wid * selCount; |
690 | if ( needWid < maxWid ) | 691 | if ( needWid < maxWid ) |
691 | break; | 692 | break; |
692 | } | 693 | } |
693 | maxLen = 2; | 694 | maxLen = 2; |
694 | } | 695 | } |
695 | //qDebug("Max len %d ", dayTest.length() ); | 696 | //qDebug("Max len %d ", dayTest.length() ); |
696 | 697 | ||
697 | QFontMetrics tempF( dlf ); | 698 | QFontMetrics tempF( dlf ); |
698 | newHight = tempF.height(); | 699 | newHight = tempF.height(); |
699 | mDayLabels->setFont( dlf ); | 700 | mDayLabels->setFont( dlf ); |
700 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 701 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
701 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 702 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
702 | //mLayoutDayLabels->addSpacing( 2 ); | 703 | //mLayoutDayLabels->addSpacing( 2 ); |
703 | // QFont lFont = dlf; | 704 | // QFont lFont = dlf; |
704 | bool appendLabels = false; | 705 | bool appendLabels = false; |
705 | QPushButton *dayLabel; | 706 | QPushButton *dayLabel; |
706 | dayLabel = mDayLabelsList.first(); | 707 | dayLabel = mDayLabelsList.first(); |
707 | if ( !dayLabel ) { | 708 | if ( !dayLabel ) { |
708 | appendLabels = true; | 709 | appendLabels = true; |
709 | dayLabel = getNewDaylabel(); | 710 | dayLabel = getNewDaylabel(); |
710 | } | 711 | } |
711 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 712 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
712 | dayLabel->setFont( dlf ); | 713 | dayLabel->setFont( dlf ); |
713 | dayLabel->setCaption("0"); | 714 | dayLabel->setCaption("0"); |
714 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 715 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
715 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 716 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
716 | dayLabel->show(); | 717 | dayLabel->show(); |
717 | DateList::ConstIterator dit; | 718 | DateList::ConstIterator dit; |
718 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 719 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
719 | int counter = 0; | 720 | int counter = 0; |
720 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 721 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
721 | ++counter; | 722 | ++counter; |
722 | QDate date = *dit; | 723 | QDate date = *dit; |
723 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 724 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
724 | if ( ! appendLabels ) { | 725 | if ( ! appendLabels ) { |
725 | dayLabel = mDayLabelsList.next(); | 726 | dayLabel = mDayLabelsList.next(); |
726 | if ( !dayLabel ) | 727 | if ( !dayLabel ) |
727 | appendLabels = true; | 728 | appendLabels = true; |
728 | } | 729 | } |
729 | if ( appendLabels ) { | 730 | if ( appendLabels ) { |
730 | dayLabel = getNewDaylabel(); | 731 | dayLabel = getNewDaylabel(); |
731 | } | 732 | } |
732 | dayLabel->setMinimumWidth( 1 ); | 733 | dayLabel->setMinimumWidth( 1 ); |
733 | dayLabel->setMaximumWidth( 2048 ); | 734 | dayLabel->setMaximumWidth( 2048 ); |
734 | dayLabel->setFont( dlf ); | 735 | dayLabel->setFont( dlf ); |
735 | dayLabel->show(); | 736 | dayLabel->show(); |
736 | dayLabel->setCaption(QString::number( counter )); | 737 | dayLabel->setCaption(QString::number( counter )); |
737 | QString str; | 738 | QString str; |
738 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 739 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
739 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 740 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
740 | switch ( maxLen ) { | 741 | switch ( maxLen ) { |
741 | case 2: | 742 | case 2: |
742 | str = QString::number( date.day() ); | 743 | str = QString::number( date.day() ); |
743 | break; | 744 | break; |
744 | 745 | ||
745 | case 3: | 746 | case 3: |
746 | str = dayName.left( 1 ) +QString::number( date.day()); | 747 | str = dayName.left( 1 ) +QString::number( date.day()); |
747 | 748 | ||
748 | break; | 749 | break; |
749 | case 4: | 750 | case 4: |
750 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 751 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
751 | 752 | ||
752 | break; | 753 | break; |
753 | case 5: | 754 | case 5: |
754 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 755 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
755 | 756 | ||
756 | break; | 757 | break; |
757 | case 6: | 758 | case 6: |
758 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 759 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
759 | break; | 760 | break; |
760 | 761 | ||
761 | default: | 762 | default: |
762 | break; | 763 | break; |
763 | } | 764 | } |
764 | if ( oneday ) { | 765 | if ( oneday ) { |
765 | QString addString; | 766 | QString addString; |
766 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 767 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
767 | addString = i18n("Today"); | 768 | addString = i18n("Today"); |
768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 769 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
769 | addString = i18n("Tomorrow"); | 770 | addString = i18n("Tomorrow"); |
770 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 771 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
771 | addString = i18n("Yesterday"); | 772 | addString = i18n("Yesterday"); |
772 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 773 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
773 | addString = i18n("Day before yesterday"); | 774 | addString = i18n("Day before yesterday"); |
774 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 775 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
775 | addString = i18n("Day after tomorrow"); | 776 | addString = i18n("Day after tomorrow"); |
776 | if ( !addString.isEmpty() ) { | 777 | if ( !addString.isEmpty() ) { |
777 | str = addString+", " + str; | 778 | str = addString+", " + str; |
778 | } | 779 | } |
779 | } | 780 | } |
780 | dayLabel->setText(str); | 781 | dayLabel->setText(str); |
781 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 782 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
782 | if (date == QDate::currentDate()) { | 783 | if (date == QDate::currentDate()) { |
783 | QFont bFont = dlf; | 784 | QFont bFont = dlf; |
784 | bFont.setBold( true ); | 785 | bFont.setBold( true ); |
@@ -904,194 +905,192 @@ void KOAgendaView::updateConfig() | |||
904 | 905 | ||
905 | // update config for children | 906 | // update config for children |
906 | mTimeLabels->updateConfig(); | 907 | mTimeLabels->updateConfig(); |
907 | mAgenda->storePosition(); | 908 | mAgenda->storePosition(); |
908 | mAgenda->updateConfig(); | 909 | mAgenda->updateConfig(); |
909 | mAllDayAgenda->updateConfig(); | 910 | mAllDayAgenda->updateConfig(); |
910 | // widget synchronization | 911 | // widget synchronization |
911 | //TODO: find a better way, maybe signal/slot | 912 | //TODO: find a better way, maybe signal/slot |
912 | mTimeLabels->positionChanged(); | 913 | mTimeLabels->positionChanged(); |
913 | 914 | ||
914 | // for some reason, this needs to be called explicitly | 915 | // for some reason, this needs to be called explicitly |
915 | mTimeLabels->repaint(); | 916 | mTimeLabels->repaint(); |
916 | 917 | ||
917 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 918 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
918 | 919 | ||
919 | // ToolTips displaying summary of events | 920 | // ToolTips displaying summary of events |
920 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 921 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
921 | ->mEnableToolTips); | 922 | ->mEnableToolTips); |
922 | 923 | ||
923 | //setHolidayMasks(); | 924 | //setHolidayMasks(); |
924 | 925 | ||
925 | //createDayLabels(); called by via updateView(); | 926 | //createDayLabels(); called by via updateView(); |
926 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 927 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
927 | updateView(); | 928 | updateView(); |
928 | mAgenda->restorePosition(); | 929 | mAgenda->restorePosition(); |
929 | } | 930 | } |
930 | 931 | ||
931 | 932 | ||
932 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 933 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
933 | { | 934 | { |
934 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 935 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
935 | //qDebug("KOAgendaView::updateEventDates "); | 936 | //qDebug("KOAgendaView::updateEventDates "); |
936 | QDateTime startDt,endDt; | 937 | QDateTime startDt,endDt; |
937 | QDate startDate; | 938 | QDate startDate; |
938 | int lenInSecs; | 939 | int lenInSecs; |
939 | // if ( type == KOAgenda::RESIZETOP ) | 940 | // if ( type == KOAgenda::RESIZETOP ) |
940 | // qDebug("RESIZETOP "); | 941 | // qDebug("RESIZETOP "); |
941 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 942 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
942 | // qDebug("RESIZEBOTTOM "); | 943 | // qDebug("RESIZEBOTTOM "); |
943 | // if ( type == KOAgenda::MOVE ) | 944 | // if ( type == KOAgenda::MOVE ) |
944 | // qDebug("MOVE "); | 945 | // qDebug("MOVE "); |
945 | if ( item->incidence()->type() == "Event" ) { | 946 | if ( item->incidence()->type() == "Event" ) { |
946 | startDt =item->incidence()->dtStart(); | 947 | startDt =item->incidence()->dtStart(); |
947 | endDt = item->incidence()->dtEnd(); | 948 | endDt = item->incidence()->dtEnd(); |
948 | lenInSecs = startDt.secsTo( endDt ); | 949 | lenInSecs = startDt.secsTo( endDt ); |
949 | } | 950 | } |
950 | 951 | ||
951 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 952 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
952 | 953 | ||
953 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 954 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
954 | startDate = mSelectedDates[item->mLastMoveXPos]; | 955 | startDate = mSelectedDates[item->mLastMoveXPos]; |
955 | } else { | 956 | } else { |
956 | if (item->cellX() < 0) { | 957 | if (item->cellX() < 0) { |
957 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 958 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
958 | } else { | 959 | } else { |
959 | startDate = mSelectedDates[item->cellX()]; | 960 | startDate = mSelectedDates[item->cellX()]; |
960 | } | 961 | } |
961 | } | 962 | } |
962 | startDt.setDate(startDate); | 963 | startDt.setDate(startDate); |
963 | 964 | ||
964 | if (item->incidence()->doesFloat()) { | 965 | if (item->incidence()->doesFloat()) { |
965 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 966 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
966 | } else { | 967 | } else { |
967 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 968 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
968 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 969 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
969 | if ( item->incidence()->type() == "Event" ) { | 970 | if ( item->incidence()->type() == "Event" ) { |
970 | if ( type == KOAgenda::MOVE ) { | 971 | if ( type == KOAgenda::MOVE ) { |
971 | endDt = startDt.addSecs(lenInSecs); | 972 | endDt = startDt.addSecs(lenInSecs); |
972 | 973 | ||
973 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 974 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
974 | if (item->lastMultiItem()) { | 975 | if (item->lastMultiItem()) { |
975 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 976 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
976 | endDt.setDate(startDate. | 977 | endDt.setDate(startDate. |
977 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 978 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
978 | } else { | 979 | } else { |
979 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 980 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
980 | endDt.setDate(startDate); | 981 | endDt.setDate(startDate); |
981 | } | 982 | } |
982 | } | 983 | } |
983 | } else { | 984 | } else { |
984 | // todo | 985 | // todo |
985 | qDebug("tooooodoooooo "); | 986 | qDebug("tooooodoooooo "); |
986 | if (item->lastMultiItem()) { | 987 | if (item->lastMultiItem()) { |
987 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 988 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
988 | endDt.setDate(startDate. | 989 | endDt.setDate(startDate. |
989 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 990 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
990 | } else { | 991 | } else { |
991 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 992 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
992 | if ( item->cellYBottom() > 0 ) | 993 | if ( item->cellYBottom() > 0 ) |
993 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 994 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
994 | else | 995 | else |
995 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 996 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
996 | endDt.setDate(startDate); | 997 | endDt.setDate(startDate); |
997 | } | 998 | } |
998 | } | 999 | } |
999 | } | 1000 | } |
1000 | |||
1001 | qDebug("to888"); | ||
1002 | if ( item->incidence()->type() == "Event" ) { | 1001 | if ( item->incidence()->type() == "Event" ) { |
1003 | item->incidence()->setDtStart(startDt); | 1002 | item->incidence()->setDtStart(startDt); |
1004 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1003 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1005 | } else if ( item->incidence()->type() == "Todo" ) { | 1004 | } else if ( item->incidence()->type() == "Todo" ) { |
1006 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 1005 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); |
1007 | } | 1006 | } |
1008 | //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() ); |
1009 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1008 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1010 | item->setItemDate(startDt.date()); | 1009 | item->setItemDate(startDt.date()); |
1011 | //item->updateItem(); | 1010 | //item->updateItem(); |
1012 | if ( item->incidence()->type() == "Todo" ) { | 1011 | if ( item->incidence()->type() == "Todo" ) { |
1013 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1012 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1014 | 1013 | ||
1015 | } | 1014 | } |
1016 | else | 1015 | else |
1017 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1016 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1018 | item->updateItem(); | 1017 | item->updateItem(); |
1019 | } | 1018 | } |
1020 | 1019 | ||
1021 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1020 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1022 | { | 1021 | { |
1023 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1022 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1024 | 1023 | ||
1025 | mSelectedDates.clear(); | 1024 | mSelectedDates.clear(); |
1026 | // qDebug("KOAgendaView::showDates "); | 1025 | // qDebug("KOAgendaView::showDates "); |
1027 | QDate d = start; | 1026 | QDate d = start; |
1028 | while (d <= end) { | 1027 | while (d <= end) { |
1029 | mSelectedDates.append(d); | 1028 | mSelectedDates.append(d); |
1030 | d = d.addDays( 1 ); | 1029 | d = d.addDays( 1 ); |
1031 | } | 1030 | } |
1032 | 1031 | ||
1033 | // and update the view | 1032 | // and update the view |
1034 | fillAgenda(); | 1033 | fillAgenda(); |
1035 | } | 1034 | } |
1036 | 1035 | ||
1037 | 1036 | ||
1038 | void KOAgendaView::showEvents(QPtrList<Event>) | 1037 | void KOAgendaView::showEvents(QPtrList<Event>) |
1039 | { | 1038 | { |
1040 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1039 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1041 | } | 1040 | } |
1042 | 1041 | ||
1043 | void KOAgendaView::changeEventDisplay(Event *, int) | 1042 | void KOAgendaView::changeEventDisplay(Event *, int) |
1044 | { | 1043 | { |
1045 | // qDebug("KOAgendaView::changeEventDisplay "); | 1044 | // qDebug("KOAgendaView::changeEventDisplay "); |
1046 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1045 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1047 | // 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 |
1048 | // are just playing dumb. | 1047 | // are just playing dumb. |
1049 | fillAgenda(); | 1048 | fillAgenda(); |
1050 | } | 1049 | } |
1051 | 1050 | ||
1052 | void KOAgendaView::fillAgenda(const QDate &) | 1051 | void KOAgendaView::fillAgenda(const QDate &) |
1053 | { | 1052 | { |
1054 | // qDebug("KOAgendaView::fillAgenda "); | 1053 | // qDebug("KOAgendaView::fillAgenda "); |
1055 | fillAgenda(); | 1054 | fillAgenda(); |
1056 | } | 1055 | } |
1057 | 1056 | ||
1058 | void KOAgendaView::fillAgenda() | 1057 | void KOAgendaView::fillAgenda() |
1059 | { | 1058 | { |
1060 | if ( globalFlagBlockStartup ) | 1059 | if ( globalFlagBlockStartup ) |
1061 | return; | 1060 | return; |
1062 | if ( globalFlagBlockAgenda == 1 ) | 1061 | if ( globalFlagBlockAgenda == 1 ) |
1063 | return; | 1062 | return; |
1064 | //if ( globalFlagBlockAgenda == 2 ) | 1063 | //if ( globalFlagBlockAgenda == 2 ) |
1065 | //globalFlagBlockAgenda = 0; | 1064 | //globalFlagBlockAgenda = 0; |
1066 | // globalFlagBlockPainting = false; | 1065 | // globalFlagBlockPainting = false; |
1067 | if ( globalFlagBlockAgenda == 0 ) | 1066 | if ( globalFlagBlockAgenda == 0 ) |
1068 | globalFlagBlockAgenda = 1; | 1067 | globalFlagBlockAgenda = 1; |
1069 | // clearView(); | 1068 | // clearView(); |
1070 | //qDebug("fillAgenda()++++ "); | 1069 | //qDebug("fillAgenda()++++ "); |
1071 | globalFlagBlockAgendaItemPaint = 1; | 1070 | globalFlagBlockAgendaItemPaint = 1; |
1072 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1071 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1073 | mAgenda->changeColumns(mSelectedDates.count()); | 1072 | mAgenda->changeColumns(mSelectedDates.count()); |
1074 | qApp->processEvents(); | 1073 | qApp->processEvents(); |
1075 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1074 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1076 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1075 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1077 | setHolidayMasks(); | 1076 | setHolidayMasks(); |
1078 | 1077 | ||
1079 | //mAgenda->hideUnused(); | 1078 | //mAgenda->hideUnused(); |
1080 | //mAllDayAgenda->hideUnused(); | 1079 | //mAllDayAgenda->hideUnused(); |
1081 | 1080 | ||
1082 | // mAgenda->blockNextRepaint( false ); | 1081 | // mAgenda->blockNextRepaint( false ); |
1083 | // mAgenda->viewport()->repaint(); | 1082 | // mAgenda->viewport()->repaint(); |
1084 | // mAgenda->blockNextRepaint( true ); | 1083 | // mAgenda->blockNextRepaint( true ); |
1085 | mMinY.resize(mSelectedDates.count()); | 1084 | mMinY.resize(mSelectedDates.count()); |
1086 | mMaxY.resize(mSelectedDates.count()); | 1085 | mMaxY.resize(mSelectedDates.count()); |
1087 | 1086 | ||
1088 | QPtrList<Event> dayEvents; | 1087 | QPtrList<Event> dayEvents; |
1089 | 1088 | ||
1090 | // 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. |
1091 | // Therefore, gtodoset all of them. | 1090 | // Therefore, gtodoset all of them. |
1092 | QPtrList<Todo> todos = calendar()->todos(); | 1091 | QPtrList<Todo> todos = calendar()->todos(); |
1093 | 1092 | ||
1094 | mAgenda->setDateList(mSelectedDates); | 1093 | mAgenda->setDateList(mSelectedDates); |
1095 | 1094 | ||
1096 | QDate today = QDate::currentDate(); | 1095 | QDate today = QDate::currentDate(); |
1097 | 1096 | ||