summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-02-02 01:54:29 (UTC)
committer zautrix <zautrix>2005-02-02 01:54:29 (UTC)
commit5bc675bc7e9d5d6fa2d2bc48675a7cfa985ab2c7 (patch) (unidiff)
tree5d8092ab72fbd191f6045ff0ff4f81f0ec0d088b /korganizer
parent9ecfd0660e36b6b8dd7401f0edb16dd3d6f03289 (diff)
downloadkdepimpi-5bc675bc7e9d5d6fa2d2bc48675a7cfa985ab2c7.zip
kdepimpi-5bc675bc7e9d5d6fa2d2bc48675a7cfa985ab2c7.tar.gz
kdepimpi-5bc675bc7e9d5d6fa2d2bc48675a7cfa985ab2c7.tar.bz2
abc
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp1
-rw-r--r--korganizer/komonthview.cpp10
-rw-r--r--korganizer/koviewmanager.cpp5
3 files changed, 8 insertions, 8 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index c8cef44..d4ff77a 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -599,769 +599,768 @@ void KOAgendaView::resizeEvent( QResizeEvent* e )
599 uc = true; 599 uc = true;
600 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 600 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
601 } 601 }
602 mUpcomingWidth = e->size().width() ; 602 mUpcomingWidth = e->size().width() ;
603 if ( mBlockUpdating || uc ) { 603 if ( mBlockUpdating || uc ) {
604 mBlockUpdating = false; 604 mBlockUpdating = false;
605 //mAgenda->setMinimumSize(800 , 600 ); 605 //mAgenda->setMinimumSize(800 , 600 );
606 //qDebug("mAgenda->resize+++++++++++++++ "); 606 //qDebug("mAgenda->resize+++++++++++++++ ");
607 updateConfig(); 607 updateConfig();
608 //qDebug("KOAgendaView::Updating now possible "); 608 //qDebug("KOAgendaView::Updating now possible ");
609 } else 609 } else
610 createDayLabels(); 610 createDayLabels();
611 //qDebug("resizeEvent end "); 611 //qDebug("resizeEvent end ");
612 612
613} 613}
614void KOAgendaView::slotDaylabelClicked( int num ) 614void KOAgendaView::slotDaylabelClicked( int num )
615{ 615{
616 616
617 QDate firstDate = mSelectedDates.first(); 617 QDate firstDate = mSelectedDates.first();
618 if ( num == -1 ) 618 if ( num == -1 )
619 emit showDateView( 6, firstDate ); 619 emit showDateView( 6, firstDate );
620 else if (num >= 0 ) { 620 else if (num >= 0 ) {
621 if ( mSelectedDates.count() == 1) 621 if ( mSelectedDates.count() == 1)
622 emit showDateView( 9, firstDate.addDays( num ) ); 622 emit showDateView( 9, firstDate.addDays( num ) );
623 else 623 else
624 emit showDateView( 3, firstDate.addDays( num ) ); 624 emit showDateView( 3, firstDate.addDays( num ) );
625 } 625 }
626 else 626 else
627 showDateView( 10, firstDate.addDays(1) ); 627 showDateView( 10, firstDate.addDays(1) );
628} 628}
629 629
630KOAgendaButton* KOAgendaView::getNewDaylabel() 630KOAgendaButton* KOAgendaView::getNewDaylabel()
631{ 631{
632 632
633 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 633 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
634 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 634 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
635 mDayLabelsList.append( dayLabel ); 635 mDayLabelsList.append( dayLabel );
636 mLayoutDayLabels->addWidget(dayLabel); 636 mLayoutDayLabels->addWidget(dayLabel);
637 return dayLabel ; 637 return dayLabel ;
638} 638}
639 639
640void KOAgendaView::createDayLabels() 640void KOAgendaView::createDayLabels()
641{ 641{
642 642
643 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 643 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
644 // qDebug(" KOAgendaView::createDayLabels() blocked "); 644 // qDebug(" KOAgendaView::createDayLabels() blocked ");
645 return; 645 return;
646 646
647 } 647 }
648 int newHight; 648 int newHight;
649 649
650 // ### Before deleting and recreating we could check if mSelectedDates changed... 650 // ### Before deleting and recreating we could check if mSelectedDates changed...
651 // It would remove some flickering and gain speed (since this is called by 651 // It would remove some flickering and gain speed (since this is called by
652 // each updateView() call) 652 // each updateView() call)
653 653
654 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 654 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
655 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 655 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
656 if ( maxWid < 0 ) 656 if ( maxWid < 0 )
657 maxWid = 20; 657 maxWid = 20;
658 658
659 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 659 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
660 QFontMetrics fm ( dlf ); 660 QFontMetrics fm ( dlf );
661 int selCount = mSelectedDates.count(); 661 int selCount = mSelectedDates.count();
662 QString dayTest = "Mon 20"; 662 QString dayTest = "Mon 20";
663 //QString dayTest = "Mon 20"; 663 //QString dayTest = "Mon 20";
664 int wid = fm.width( dayTest ); 664 int wid = fm.width( dayTest );
665 //maxWid -= ( selCount * 3 ); //working for QLabels 665 //maxWid -= ( selCount * 3 ); //working for QLabels
666 maxWid -= ( selCount * 3 ); //working for QPushButton 666 maxWid -= ( selCount * 3 ); //working for QPushButton
667 if ( maxWid < 0 ) 667 if ( maxWid < 0 )
668 maxWid = 20; 668 maxWid = 20;
669 int needWid = wid * selCount; 669 int needWid = wid * selCount;
670 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 670 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
671 //if ( needWid > maxWid ) 671 //if ( needWid > maxWid )
672 // qDebug("DAYLABELS TOOOOOOO BIG "); 672 // qDebug("DAYLABELS TOOOOOOO BIG ");
673 while ( needWid > maxWid ) { 673 while ( needWid > maxWid ) {
674 dayTest = dayTest.left( dayTest.length() - 1 ); 674 dayTest = dayTest.left( dayTest.length() - 1 );
675 wid = fm.width( dayTest ); 675 wid = fm.width( dayTest );
676 needWid = wid * selCount; 676 needWid = wid * selCount;
677 } 677 }
678 int maxLen = dayTest.length(); 678 int maxLen = dayTest.length();
679 int fontPoint = dlf.pointSize(); 679 int fontPoint = dlf.pointSize();
680 if ( maxLen < 2 ) { 680 if ( maxLen < 2 ) {
681 int fontPoint = dlf.pointSize(); 681 int fontPoint = dlf.pointSize();
682 while ( fontPoint > 4 ) { 682 while ( fontPoint > 4 ) {
683 --fontPoint; 683 --fontPoint;
684 dlf.setPointSize( fontPoint ); 684 dlf.setPointSize( fontPoint );
685 QFontMetrics f( dlf ); 685 QFontMetrics f( dlf );
686 wid = f.width( "30" ); 686 wid = f.width( "30" );
687 needWid = wid * selCount; 687 needWid = wid * selCount;
688 if ( needWid < maxWid ) 688 if ( needWid < maxWid )
689 break; 689 break;
690 } 690 }
691 maxLen = 2; 691 maxLen = 2;
692 } 692 }
693 //qDebug("Max len %d ", dayTest.length() ); 693 //qDebug("Max len %d ", dayTest.length() );
694 694
695 QFontMetrics tempF( dlf ); 695 QFontMetrics tempF( dlf );
696 newHight = tempF.height(); 696 newHight = tempF.height();
697 mDayLabels->setFont( dlf ); 697 mDayLabels->setFont( dlf );
698 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 698 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
699 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 699 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
700 //mLayoutDayLabels->addSpacing( 2 ); 700 //mLayoutDayLabels->addSpacing( 2 );
701 // QFont lFont = dlf; 701 // QFont lFont = dlf;
702 bool appendLabels = false; 702 bool appendLabels = false;
703 KOAgendaButton *dayLabel; 703 KOAgendaButton *dayLabel;
704 dayLabel = mDayLabelsList.first(); 704 dayLabel = mDayLabelsList.first();
705 if ( !dayLabel ) { 705 if ( !dayLabel ) {
706 appendLabels = true; 706 appendLabels = true;
707 dayLabel = getNewDaylabel(); 707 dayLabel = getNewDaylabel();
708 } 708 }
709 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 709 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
710 dayLabel->setFont( dlf ); 710 dayLabel->setFont( dlf );
711 dayLabel->setNum( -1 ); 711 dayLabel->setNum( -1 );
712 //dayLabel->setAlignment(QLabel::AlignHCenter); 712 //dayLabel->setAlignment(QLabel::AlignHCenter);
713 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 713 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
714 dayLabel->show(); 714 dayLabel->show();
715 DateList::ConstIterator dit; 715 DateList::ConstIterator dit;
716 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 716 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
717 int counter = -1; 717 int counter = -1;
718 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 718 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
719 ++counter; 719 ++counter;
720 QDate date = *dit; 720 QDate date = *dit;
721 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 721 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
722 if ( ! appendLabels ) { 722 if ( ! appendLabels ) {
723 dayLabel = mDayLabelsList.next(); 723 dayLabel = mDayLabelsList.next();
724 if ( !dayLabel ) 724 if ( !dayLabel )
725 appendLabels = true; 725 appendLabels = true;
726 } 726 }
727 if ( appendLabels ) { 727 if ( appendLabels ) {
728 dayLabel = getNewDaylabel(); 728 dayLabel = getNewDaylabel();
729 } 729 }
730 dayLabel->setMinimumWidth( 1 ); 730 dayLabel->setMinimumWidth( 1 );
731 dayLabel->setMaximumWidth( 1024 ); 731 dayLabel->setMaximumWidth( 1024 );
732 dayLabel->setFont( dlf ); 732 dayLabel->setFont( dlf );
733 dayLabel->show(); 733 dayLabel->show();
734 dayLabel->setNum( counter ); 734 dayLabel->setNum( counter );
735 QString str; 735 QString str;
736 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 736 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
737 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 737 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
738 switch ( maxLen ) { 738 switch ( maxLen ) {
739 case 2: 739 case 2:
740 str = QString::number( date.day() ); 740 str = QString::number( date.day() );
741 break; 741 break;
742 742
743 case 3: 743 case 3:
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 4: 747 case 4:
748 str = dayName.left( 1 ) + " " +QString::number( date.day()); 748 str = dayName.left( 1 ) + " " +QString::number( date.day());
749 749
750 break; 750 break;
751 case 5: 751 case 5:
752 str = dayName.left( 2 ) + " " +QString::number( date.day()); 752 str = dayName.left( 2 ) + " " +QString::number( date.day());
753 753
754 break; 754 break;
755 case 6: 755 case 6:
756 str = dayName.left( 3 ) + " " +QString::number( date.day()); 756 str = dayName.left( 3 ) + " " +QString::number( date.day());
757 break; 757 break;
758 758
759 default: 759 default:
760 break; 760 break;
761 } 761 }
762 if ( oneday ) { 762 if ( oneday ) {
763 QString addString; 763 QString addString;
764 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 764 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
765 addString = i18n("Today"); 765 addString = i18n("Today");
766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
767 addString = i18n("Tomorrow"); 767 addString = i18n("Tomorrow");
768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
769 addString = i18n("Yesterday"); 769 addString = i18n("Yesterday");
770 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 770 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
771 addString = i18n("Day before yesterday"); 771 addString = i18n("Day before yesterday");
772 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 772 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
773 addString = i18n("Day after tomorrow"); 773 addString = i18n("Day after tomorrow");
774 if ( !addString.isEmpty() ) { 774 if ( !addString.isEmpty() ) {
775 str = addString+", " + str; 775 str = addString+", " + str;
776 } 776 }
777 } 777 }
778 dayLabel->setText(str); 778 dayLabel->setText(str);
779 //dayLabel->setAlignment(QLabel::AlignHCenter); 779 //dayLabel->setAlignment(QLabel::AlignHCenter);
780 if (date == QDate::currentDate()) { 780 if (date == QDate::currentDate()) {
781 QFont bFont = dlf; 781 QFont bFont = dlf;
782 bFont.setBold( true ); 782 bFont.setBold( true );
783 dayLabel->setFont(bFont); 783 dayLabel->setFont(bFont);
784 } 784 }
785 //dayLayout->addWidget(dayLabel); 785 //dayLayout->addWidget(dayLabel);
786 786
787#ifndef KORG_NOPLUGINS 787#ifndef KORG_NOPLUGINS
788 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 788 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
789 CalendarDecoration *it; 789 CalendarDecoration *it;
790 for(it = cds.first(); it; it = cds.next()) { 790 for(it = cds.first(); it; it = cds.next()) {
791 QString text = it->shortText( date ); 791 QString text = it->shortText( date );
792 if ( !text.isEmpty() ) { 792 if ( !text.isEmpty() ) {
793 QLabel *label = new QLabel(text,mDayLabels); 793 QLabel *label = new QLabel(text,mDayLabels);
794 label->setAlignment(AlignCenter); 794 label->setAlignment(AlignCenter);
795 dayLayout->addWidget(label); 795 dayLayout->addWidget(label);
796 } 796 }
797 } 797 }
798 798
799 for(it = cds.first(); it; it = cds.next()) { 799 for(it = cds.first(); it; it = cds.next()) {
800 QWidget *wid = it->smallWidget(mDayLabels,date); 800 QWidget *wid = it->smallWidget(mDayLabels,date);
801 if ( wid ) { 801 if ( wid ) {
802 // wid->setHeight(20); 802 // wid->setHeight(20);
803 dayLayout->addWidget(wid); 803 dayLayout->addWidget(wid);
804 } 804 }
805 } 805 }
806#endif 806#endif
807 } 807 }
808 if ( ! appendLabels ) { 808 if ( ! appendLabels ) {
809 dayLabel = mDayLabelsList.next(); 809 dayLabel = mDayLabelsList.next();
810 if ( !dayLabel ) 810 if ( !dayLabel )
811 appendLabels = true; 811 appendLabels = true;
812 } 812 }
813 if ( appendLabels ) { 813 if ( appendLabels ) {
814 dayLabel = getNewDaylabel(); 814 dayLabel = getNewDaylabel();
815 } 815 }
816 //dayLabel->hide();//test only 816 //dayLabel->hide();//test only
817 817
818 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 818 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
819 if ( offset < 0 ) offset = 0; 819 if ( offset < 0 ) offset = 0;
820 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 820 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
821 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 821 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
822 dayLabel->setFont( dlf ); 822 dayLabel->setFont( dlf );
823 dayLabel->show(); 823 dayLabel->show();
824 dayLabel->setNum( -2 ); 824 dayLabel->setNum( -2 );
825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
828 if ( !appendLabels ) { 828 if ( !appendLabels ) {
829 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
830 while ( dayLabel ) { 830 while ( dayLabel ) {
831 //qDebug("!dayLabel %d",dayLabel ); 831 //qDebug("!dayLabel %d",dayLabel );
832 dayLabel->hide(); 832 dayLabel->hide();
833 dayLabel = mDayLabelsList.next(); 833 dayLabel = mDayLabelsList.next();
834 } 834 }
835 } 835 }
836 //mDayLabelsFrame->show(); 836 //mDayLabelsFrame->show();
837 //mDayLabels->show(); 837 //mDayLabels->show();
838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
840 mDayLabelsFrame->setFixedHeight( newHight ); 840 mDayLabelsFrame->setFixedHeight( newHight );
841} 841}
842 842
843int KOAgendaView::maxDatesHint() 843int KOAgendaView::maxDatesHint()
844{ 844{
845 // Not sure about the max number of events, so return 0 for now. 845 // Not sure about the max number of events, so return 0 for now.
846 return 0; 846 return 0;
847} 847}
848 848
849int KOAgendaView::currentDateCount() 849int KOAgendaView::currentDateCount()
850{ 850{
851 return mSelectedDates.count(); 851 return mSelectedDates.count();
852} 852}
853 853
854QPtrList<Incidence> KOAgendaView::selectedIncidences() 854QPtrList<Incidence> KOAgendaView::selectedIncidences()
855{ 855{
856 QPtrList<Incidence> selected; 856 QPtrList<Incidence> selected;
857 Incidence *incidence; 857 Incidence *incidence;
858 858
859 incidence = mAgenda->selectedIncidence(); 859 incidence = mAgenda->selectedIncidence();
860 if (incidence) selected.append(incidence); 860 if (incidence) selected.append(incidence);
861 861
862 incidence = mAllDayAgenda->selectedIncidence(); 862 incidence = mAllDayAgenda->selectedIncidence();
863 if (incidence) selected.append(incidence); 863 if (incidence) selected.append(incidence);
864 864
865 return selected; 865 return selected;
866} 866}
867 867
868DateList KOAgendaView::selectedDates() 868DateList KOAgendaView::selectedDates()
869{ 869{
870 DateList selected; 870 DateList selected;
871 QDate qd; 871 QDate qd;
872 872
873 qd = mAgenda->selectedIncidenceDate(); 873 qd = mAgenda->selectedIncidenceDate();
874 if (qd.isValid()) selected.append(qd); 874 if (qd.isValid()) selected.append(qd);
875 875
876 qd = mAllDayAgenda->selectedIncidenceDate(); 876 qd = mAllDayAgenda->selectedIncidenceDate();
877 if (qd.isValid()) selected.append(qd); 877 if (qd.isValid()) selected.append(qd);
878 878
879 return selected; 879 return selected;
880} 880}
881 881
882 882
883void KOAgendaView::updateView() 883void KOAgendaView::updateView()
884{ 884{
885 if ( mBlockUpdating ) 885 if ( mBlockUpdating )
886 return; 886 return;
887 // kdDebug() << "KOAgendaView::updateView()" << endl; 887 // kdDebug() << "KOAgendaView::updateView()" << endl;
888 fillAgenda(); 888 fillAgenda();
889 889
890} 890}
891 891
892 892
893/* 893/*
894 Update configuration settings for the agenda view. This method is not 894 Update configuration settings for the agenda view. This method is not
895 complete. 895 complete.
896*/ 896*/
897void KOAgendaView::updateConfig() 897void KOAgendaView::updateConfig()
898{ 898{
899 if ( mBlockUpdating ) 899 if ( mBlockUpdating )
900 return; 900 return;
901 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 901 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
902 902
903 // update config for children 903 // update config for children
904 mTimeLabels->updateConfig(); 904 mTimeLabels->updateConfig();
905 mAgenda->storePosition(); 905 mAgenda->storePosition();
906 mAgenda->updateConfig(); 906 mAgenda->updateConfig();
907 mAllDayAgenda->updateConfig(); 907 mAllDayAgenda->updateConfig();
908 // widget synchronization 908 // widget synchronization
909 //TODO: find a better way, maybe signal/slot 909 //TODO: find a better way, maybe signal/slot
910 mTimeLabels->positionChanged(); 910 mTimeLabels->positionChanged();
911 911
912 // for some reason, this needs to be called explicitly 912 // for some reason, this needs to be called explicitly
913 mTimeLabels->repaint(); 913 mTimeLabels->repaint();
914 914
915 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 915 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
916 916
917 // ToolTips displaying summary of events 917 // ToolTips displaying summary of events
918 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 918 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
919 ->mEnableToolTips); 919 ->mEnableToolTips);
920 920
921 //setHolidayMasks(); 921 //setHolidayMasks();
922 922
923 //createDayLabels(); called by via updateView(); 923 //createDayLabels(); called by via updateView();
924 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 924 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
925 updateView(); 925 updateView();
926 mAgenda->restorePosition(); 926 mAgenda->restorePosition();
927} 927}
928 928
929 929
930void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 930void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
931{ 931{
932 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 932 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
933 //qDebug("KOAgendaView::updateEventDates "); 933 //qDebug("KOAgendaView::updateEventDates ");
934 QDateTime startDt,endDt; 934 QDateTime startDt,endDt;
935 QDate startDate; 935 QDate startDate;
936 int lenInSecs; 936 int lenInSecs;
937 // if ( type == KOAgenda::RESIZETOP ) 937 // if ( type == KOAgenda::RESIZETOP )
938 // qDebug("RESIZETOP "); 938 // qDebug("RESIZETOP ");
939 // if ( type == KOAgenda::RESIZEBOTTOM ) 939 // if ( type == KOAgenda::RESIZEBOTTOM )
940 // qDebug("RESIZEBOTTOM "); 940 // qDebug("RESIZEBOTTOM ");
941 // if ( type == KOAgenda::MOVE ) 941 // if ( type == KOAgenda::MOVE )
942 // qDebug("MOVE "); 942 // qDebug("MOVE ");
943 if ( item->incidence()->type() == "Event" ) { 943 if ( item->incidence()->type() == "Event" ) {
944 startDt =item->incidence()->dtStart(); 944 startDt =item->incidence()->dtStart();
945 endDt = item->incidence()->dtEnd(); 945 endDt = item->incidence()->dtEnd();
946 lenInSecs = startDt.secsTo( endDt ); 946 lenInSecs = startDt.secsTo( endDt );
947 } 947 }
948 948
949 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 949 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
950 950
951 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 951 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
952 startDate = mSelectedDates[item->mLastMoveXPos]; 952 startDate = mSelectedDates[item->mLastMoveXPos];
953 } else { 953 } else {
954 if (item->cellX() < 0) { 954 if (item->cellX() < 0) {
955 startDate = (mSelectedDates.first()).addDays(item->cellX()); 955 startDate = (mSelectedDates.first()).addDays(item->cellX());
956 } else { 956 } else {
957 startDate = mSelectedDates[item->cellX()]; 957 startDate = mSelectedDates[item->cellX()];
958 } 958 }
959 } 959 }
960 startDt.setDate(startDate); 960 startDt.setDate(startDate);
961 961
962 if (item->incidence()->doesFloat()) { 962 if (item->incidence()->doesFloat()) {
963 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 963 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
964 } else { 964 } else {
965 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 965 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
966 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 966 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
967 if ( item->incidence()->type() == "Event" ) { 967 if ( item->incidence()->type() == "Event" ) {
968 if ( type == KOAgenda::MOVE ) { 968 if ( type == KOAgenda::MOVE ) {
969 endDt = startDt.addSecs(lenInSecs); 969 endDt = startDt.addSecs(lenInSecs);
970 970
971 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 971 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
972 if (item->lastMultiItem()) { 972 if (item->lastMultiItem()) {
973 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 973 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
974 endDt.setDate(startDate. 974 endDt.setDate(startDate.
975 addDays(item->lastMultiItem()->cellX() - item->cellX())); 975 addDays(item->lastMultiItem()->cellX() - item->cellX()));
976 } else { 976 } else {
977 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 977 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
978 endDt.setDate(startDate); 978 endDt.setDate(startDate);
979 } 979 }
980 } 980 }
981 } else { 981 } else {
982 // todo 982 // todo
983 qDebug("tooooodoooooo ");
984 if (item->lastMultiItem()) { 983 if (item->lastMultiItem()) {
985 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 984 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
986 endDt.setDate(startDate. 985 endDt.setDate(startDate.
987 addDays(item->lastMultiItem()->cellX() - item->cellX())); 986 addDays(item->lastMultiItem()->cellX() - item->cellX()));
988 } else { 987 } else {
989 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 988 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
990 if ( item->cellYBottom() > 0 ) 989 if ( item->cellYBottom() > 0 )
991 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 990 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
992 else 991 else
993 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 992 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
994 endDt.setDate(startDate); 993 endDt.setDate(startDate);
995 } 994 }
996 } 995 }
997 } 996 }
998 if ( item->incidence()->type() == "Event" ) { 997 if ( item->incidence()->type() == "Event" ) {
999 item->incidence()->setDtStart(startDt); 998 item->incidence()->setDtStart(startDt);
1000 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 999 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1001 } else if ( item->incidence()->type() == "Todo" ) { 1000 } else if ( item->incidence()->type() == "Todo" ) {
1002 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 1001 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
1003 } 1002 }
1004 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1003 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1005 item->incidence()->setRevision(item->incidence()->revision()+1); 1004 item->incidence()->setRevision(item->incidence()->revision()+1);
1006 item->setItemDate(startDt.date()); 1005 item->setItemDate(startDt.date());
1007 //item->updateItem(); 1006 //item->updateItem();
1008 if ( item->incidence()->type() == "Todo" ) { 1007 if ( item->incidence()->type() == "Todo" ) {
1009 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1008 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1010 1009
1011 } 1010 }
1012 else 1011 else
1013 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1012 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1014 item->updateItem(); 1013 item->updateItem();
1015} 1014}
1016 1015
1017void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1016void KOAgendaView::showDates( const QDate &start, const QDate &end )
1018{ 1017{
1019 // kdDebug() << "KOAgendaView::selectDates" << endl; 1018 // kdDebug() << "KOAgendaView::selectDates" << endl;
1020 1019
1021 mSelectedDates.clear(); 1020 mSelectedDates.clear();
1022 // qDebug("KOAgendaView::showDates "); 1021 // qDebug("KOAgendaView::showDates ");
1023 QDate d = start; 1022 QDate d = start;
1024 while (d <= end) { 1023 while (d <= end) {
1025 mSelectedDates.append(d); 1024 mSelectedDates.append(d);
1026 d = d.addDays( 1 ); 1025 d = d.addDays( 1 );
1027 } 1026 }
1028 1027
1029 // and update the view 1028 // and update the view
1030 fillAgenda(); 1029 fillAgenda();
1031} 1030}
1032 1031
1033 1032
1034void KOAgendaView::showEvents(QPtrList<Event>) 1033void KOAgendaView::showEvents(QPtrList<Event>)
1035{ 1034{
1036 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1035 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1037} 1036}
1038 1037
1039void KOAgendaView::changeEventDisplay(Event *, int) 1038void KOAgendaView::changeEventDisplay(Event *, int)
1040{ 1039{
1041 // qDebug("KOAgendaView::changeEventDisplay "); 1040 // qDebug("KOAgendaView::changeEventDisplay ");
1042 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1041 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1043 // this should be re-written to be MUCH smarter. Right now we 1042 // this should be re-written to be MUCH smarter. Right now we
1044 // are just playing dumb. 1043 // are just playing dumb.
1045 fillAgenda(); 1044 fillAgenda();
1046} 1045}
1047 1046
1048void KOAgendaView::fillAgenda(const QDate &) 1047void KOAgendaView::fillAgenda(const QDate &)
1049{ 1048{
1050 // qDebug("KOAgendaView::fillAgenda "); 1049 // qDebug("KOAgendaView::fillAgenda ");
1051 fillAgenda(); 1050 fillAgenda();
1052} 1051}
1053 1052
1054void KOAgendaView::fillAgenda() 1053void KOAgendaView::fillAgenda()
1055{ 1054{
1056 if ( globalFlagBlockStartup ) 1055 if ( globalFlagBlockStartup )
1057 return; 1056 return;
1058 if ( globalFlagBlockAgenda == 1 ) 1057 if ( globalFlagBlockAgenda == 1 )
1059 return; 1058 return;
1060 //if ( globalFlagBlockAgenda == 2 ) 1059 //if ( globalFlagBlockAgenda == 2 )
1061 //globalFlagBlockAgenda = 0; 1060 //globalFlagBlockAgenda = 0;
1062 // globalFlagBlockPainting = false; 1061 // globalFlagBlockPainting = false;
1063 if ( globalFlagBlockAgenda == 0 ) 1062 if ( globalFlagBlockAgenda == 0 )
1064 globalFlagBlockAgenda = 1; 1063 globalFlagBlockAgenda = 1;
1065 // clearView(); 1064 // clearView();
1066 //qDebug("fillAgenda()++++ "); 1065 //qDebug("fillAgenda()++++ ");
1067 globalFlagBlockAgendaItemPaint = 1; 1066 globalFlagBlockAgendaItemPaint = 1;
1068 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1067 mAllDayAgenda->changeColumns(mSelectedDates.count());
1069 mAgenda->changeColumns(mSelectedDates.count()); 1068 mAgenda->changeColumns(mSelectedDates.count());
1070 qApp->processEvents(); 1069 qApp->processEvents();
1071 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1070 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1072 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1071 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1073 setHolidayMasks(); 1072 setHolidayMasks();
1074 1073
1075 //mAgenda->hideUnused(); 1074 //mAgenda->hideUnused();
1076 //mAllDayAgenda->hideUnused(); 1075 //mAllDayAgenda->hideUnused();
1077 1076
1078 // mAgenda->blockNextRepaint( false ); 1077 // mAgenda->blockNextRepaint( false );
1079 // mAgenda->viewport()->repaint(); 1078 // mAgenda->viewport()->repaint();
1080 // mAgenda->blockNextRepaint( true ); 1079 // mAgenda->blockNextRepaint( true );
1081 mMinY.resize(mSelectedDates.count()); 1080 mMinY.resize(mSelectedDates.count());
1082 mMaxY.resize(mSelectedDates.count()); 1081 mMaxY.resize(mSelectedDates.count());
1083 1082
1084 QPtrList<Event> dayEvents; 1083 QPtrList<Event> dayEvents;
1085 1084
1086 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1085 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1087 // Therefore, gtodoset all of them. 1086 // Therefore, gtodoset all of them.
1088 QPtrList<Todo> todos = calendar()->todos(); 1087 QPtrList<Todo> todos = calendar()->todos();
1089 1088
1090 mAgenda->setDateList(mSelectedDates); 1089 mAgenda->setDateList(mSelectedDates);
1091 1090
1092 QDate today = QDate::currentDate(); 1091 QDate today = QDate::currentDate();
1093 1092
1094 DateList::ConstIterator dit; 1093 DateList::ConstIterator dit;
1095 int curCol = 0; 1094 int curCol = 0;
1096 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1095 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1097 QDate currentDate = *dit; 1096 QDate currentDate = *dit;
1098 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1097 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1099 // << endl; 1098 // << endl;
1100 1099
1101 dayEvents = calendar()->events(currentDate,true); 1100 dayEvents = calendar()->events(currentDate,true);
1102 1101
1103 // Default values, which can never be reached 1102 // Default values, which can never be reached
1104 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1103 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1105 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1104 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1106 1105
1107 unsigned int numEvent; 1106 unsigned int numEvent;
1108 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1107 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1109 Event *event = dayEvents.at(numEvent); 1108 Event *event = dayEvents.at(numEvent);
1110 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1109 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1111 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1110 if ( event->uid().left(15) == QString("last-syncEvent-") )
1112 continue; 1111 continue;
1113 // kdDebug() << " Event: " << event->summary() << endl; 1112 // kdDebug() << " Event: " << event->summary() << endl;
1114 1113
1115 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1114 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1116 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1115 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1117 1116
1118 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1117 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1119 1118
1120 if (event->doesFloat()) { 1119 if (event->doesFloat()) {
1121 if (event->recurrence()->doesRecur()) { 1120 if (event->recurrence()->doesRecur()) {
1122 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1121 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1123 } else { 1122 } else {
1124 if (beginX <= 0 && curCol == 0) { 1123 if (beginX <= 0 && curCol == 0) {
1125 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1124 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1126 } else if (beginX == curCol) { 1125 } else if (beginX == curCol) {
1127 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1126 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1128 } 1127 }
1129 } 1128 }
1130 } else if (event->isMultiDay()) { 1129 } else if (event->isMultiDay()) {
1131 if ( event->doesRecur () ) { 1130 if ( event->doesRecur () ) {
1132 QDate dateit = currentDate; 1131 QDate dateit = currentDate;
1133 int count = 0; 1132 int count = 0;
1134 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1133 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1135 while (! event->recursOn( dateit ) && count <= max ) { 1134 while (! event->recursOn( dateit ) && count <= max ) {
1136 ++count; 1135 ++count;
1137 dateit = dateit.addDays( -1 ); 1136 dateit = dateit.addDays( -1 );
1138 } 1137 }
1139 bool ok; 1138 bool ok;
1140 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1139 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1141 if ( ok ) 1140 if ( ok )
1142 { 1141 {
1143 int secs = event->dtStart().secsTo( event->dtEnd() ); 1142 int secs = event->dtStart().secsTo( event->dtEnd() );
1144 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1143 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1145 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1144 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1146 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1145 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1147 1146
1148 } 1147 }
1149 } 1148 }
1150 int startY = mAgenda->timeToY(event->dtStart().time()); 1149 int startY = mAgenda->timeToY(event->dtStart().time());
1151 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1150 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1152 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1151 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1153 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1152 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1154 //qDebug("insert!!! "); 1153 //qDebug("insert!!! ");
1155 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1154 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1156 } 1155 }
1157 if (beginX == curCol) { 1156 if (beginX == curCol) {
1158 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1157 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1159 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1158 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1160 } else if (endX == curCol) { 1159 } else if (endX == curCol) {
1161 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1160 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1162 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1161 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1163 } else { 1162 } else {
1164 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1163 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1165 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1164 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1166 } 1165 }
1167 } else { 1166 } else {
1168 int startY = mAgenda->timeToY(event->dtStart().time()); 1167 int startY = mAgenda->timeToY(event->dtStart().time());
1169 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1168 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1170 if (endY < startY) endY = startY; 1169 if (endY < startY) endY = startY;
1171 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1170 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1172 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1171 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1173 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1172 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1174 } 1173 }
1175 } 1174 }
1176 // ---------- [display Todos -------------- 1175 // ---------- [display Todos --------------
1177 unsigned int numTodo; 1176 unsigned int numTodo;
1178 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1177 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1179 Todo *todo = todos.at(numTodo); 1178 Todo *todo = todos.at(numTodo);
1180 1179
1181 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1180 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1182 1181
1183 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1182 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1184 // Already completed items can be displayed on their original due date 1183 // Already completed items can be displayed on their original due date
1185 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1184 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1186 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1185 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1187 bool fillIn = false; 1186 bool fillIn = false;
1188 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1187 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1189 fillIn = true; 1188 fillIn = true;
1190 if ( ! fillIn && !todo->hasCompletedDate() ) 1189 if ( ! fillIn && !todo->hasCompletedDate() )
1191 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1190 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1192 if ( fillIn ) { 1191 if ( fillIn ) {
1193 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1192 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1194 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1193 if ( KOPrefs::instance()->mShowTodoInAgenda )
1195 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1194 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1196 } 1195 }
1197 else { 1196 else {
1198 QDateTime dt; 1197 QDateTime dt;
1199 if ( todo->hasCompletedDate() ) 1198 if ( todo->hasCompletedDate() )
1200 dt = todo->completed(); 1199 dt = todo->completed();
1201 else 1200 else
1202 dt = todo->dtDue();; 1201 dt = todo->dtDue();;
1203 1202
1204 1203
1205 int endY = mAgenda->timeToY(dt.time()) - 1; 1204 int endY = mAgenda->timeToY(dt.time()) - 1;
1206 int hi = (18/KOPrefs::instance()->mHourSize); 1205 int hi = (18/KOPrefs::instance()->mHourSize);
1207 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1206 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1208 int startY = endY -hi; 1207 int startY = endY -hi;
1209 1208
1210 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1209 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1211 1210
1212 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1211 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1213 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1212 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1214 } 1213 }
1215 } 1214 }
1216 } 1215 }
1217 // ---------- display Todos] -------------- 1216 // ---------- display Todos] --------------
1218 1217
1219 ++curCol; 1218 ++curCol;
1220 } 1219 }
1221 mAgenda->hideUnused(); 1220 mAgenda->hideUnused();
1222 mAllDayAgenda->hideUnused(); 1221 mAllDayAgenda->hideUnused();
1223 mAgenda->checkScrollBoundaries(); 1222 mAgenda->checkScrollBoundaries();
1224 1223
1225 deleteSelectedDateTime(); 1224 deleteSelectedDateTime();
1226 1225
1227 createDayLabels(); 1226 createDayLabels();
1228 emit incidenceSelected( 0 ); 1227 emit incidenceSelected( 0 );
1229 1228
1230 if ( globalFlagBlockAgenda == 2 ) { 1229 if ( globalFlagBlockAgenda == 2 ) {
1231 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1230 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1232 setStartHour( KOPrefs::instance()->mDayBegins ); 1231 setStartHour( KOPrefs::instance()->mDayBegins );
1233 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1232 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1234 setStartHour( QTime::currentTime ().hour() ); 1233 setStartHour( QTime::currentTime ().hour() );
1235 // qApp->processEvents(); 1234 // qApp->processEvents();
1236 } 1235 }
1237 qApp->processEvents(); 1236 qApp->processEvents();
1238 //qDebug("qApp->processEvents(); END "); 1237 //qDebug("qApp->processEvents(); END ");
1239 globalFlagBlockAgenda = 0; 1238 globalFlagBlockAgenda = 0;
1240 1239
1241 // mAgenda->hideUnused(); 1240 // mAgenda->hideUnused();
1242 //mAllDayAgenda->hideUnused(); 1241 //mAllDayAgenda->hideUnused();
1243 mAllDayAgenda->drawContentsToPainter(); 1242 mAllDayAgenda->drawContentsToPainter();
1244 mAgenda->drawContentsToPainter(); 1243 mAgenda->drawContentsToPainter();
1245 repaintAgenda(); 1244 repaintAgenda();
1246 // mAgenda->finishUpdate(); 1245 // mAgenda->finishUpdate();
1247 //mAllDayAgenda->finishUpdate(); 1246 //mAllDayAgenda->finishUpdate();
1248 1247
1249 // repaintAgenda(); 1248 // repaintAgenda();
1250 //qApp->processEvents(); 1249 //qApp->processEvents();
1251 // globalFlagBlockAgenda = 0; 1250 // globalFlagBlockAgenda = 0;
1252} 1251}
1253void KOAgendaView::repaintAgenda() 1252void KOAgendaView::repaintAgenda()
1254{ 1253{
1255 // mAllDayAgenda->drawContentsToPainter(); 1254 // mAllDayAgenda->drawContentsToPainter();
1256// mAllDayAgenda->viewport()->repaint( false ); 1255// mAllDayAgenda->viewport()->repaint( false );
1257// mAgenda->drawContentsToPainter(); 1256// mAgenda->drawContentsToPainter();
1258// mAgenda->viewport()->repaint( false ); 1257// mAgenda->viewport()->repaint( false );
1259// qApp->processEvents(); 1258// qApp->processEvents();
1260 1259
1261 //qDebug("KOAgendaView::repaintAgenda() "); 1260 //qDebug("KOAgendaView::repaintAgenda() ");
1262 //qApp->processEvents(); 1261 //qApp->processEvents();
1263 mAgenda->viewport()->repaint( false ); 1262 mAgenda->viewport()->repaint( false );
1264 mAllDayAgenda->viewport()->repaint( false ); 1263 mAllDayAgenda->viewport()->repaint( false );
1265 mAgenda->finishUpdate(); 1264 mAgenda->finishUpdate();
1266 mAllDayAgenda->finishUpdate(); 1265 mAllDayAgenda->finishUpdate();
1267} 1266}
1268 1267
1269 1268
1270void KOAgendaView::clearView() 1269void KOAgendaView::clearView()
1271{ 1270{
1272 // kdDebug() << "ClearView" << endl; 1271 // kdDebug() << "ClearView" << endl;
1273 mAllDayAgenda->clear(); 1272 mAllDayAgenda->clear();
1274 mAgenda->clear(); 1273 mAgenda->clear();
1275} 1274}
1276 1275
1277void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1276void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1278 const QDate &td) 1277 const QDate &td)
1279{ 1278{
1280#ifndef KORG_NOPRINTER 1279#ifndef KORG_NOPRINTER
1281 if (fd == td) 1280 if (fd == td)
1282 calPrinter->preview(CalPrinter::Day, fd, td); 1281 calPrinter->preview(CalPrinter::Day, fd, td);
1283 else 1282 else
1284 calPrinter->preview(CalPrinter::Week, fd, td); 1283 calPrinter->preview(CalPrinter::Week, fd, td);
1285#endif 1284#endif
1286} 1285}
1287 1286
1288// void KOAgendaView::updateMovedTodo() 1287// void KOAgendaView::updateMovedTodo()
1289// { 1288// {
1290// // updateConfig(); 1289// // updateConfig();
1291// // emit updateTodoViews(); 1290// // emit updateTodoViews();
1292// } 1291// }
1293 1292
1294void KOAgendaView::newEvent(int gx, int gy) 1293void KOAgendaView::newEvent(int gx, int gy)
1295{ 1294{
1296 if (!mSelectedDates.count()) return; 1295 if (!mSelectedDates.count()) return;
1297 1296
1298 QDate day = mSelectedDates[gx]; 1297 QDate day = mSelectedDates[gx];
1299 1298
1300 QTime time = mAgenda->gyToTime(gy); 1299 QTime time = mAgenda->gyToTime(gy);
1301 QDateTime dt(day,time); 1300 QDateTime dt(day,time);
1302 // if ( dt < QDateTime::currentDateTime () ) 1301 // if ( dt < QDateTime::currentDateTime () )
1303 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1302 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1304 emit newEventSignal(dt); 1303 emit newEventSignal(dt);
1305} 1304}
1306 1305
1307void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1306void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1308{ 1307{
1309 if (!mSelectedDates.count()) return; 1308 if (!mSelectedDates.count()) return;
1310 1309
1311 QDate dayStart = mSelectedDates[gxStart]; 1310 QDate dayStart = mSelectedDates[gxStart];
1312 QDate dayEnd = mSelectedDates[gxEnd]; 1311 QDate dayEnd = mSelectedDates[gxEnd];
1313 1312
1314 QTime timeStart = mAgenda->gyToTime(gyStart); 1313 QTime timeStart = mAgenda->gyToTime(gyStart);
1315 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1314 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1316 1315
1317 QDateTime dtStart(dayStart,timeStart); 1316 QDateTime dtStart(dayStart,timeStart);
1318 QDateTime dtEnd(dayEnd,timeEnd); 1317 QDateTime dtEnd(dayEnd,timeEnd);
1319 1318
1320 emit newEventSignal(dtStart,dtEnd); 1319 emit newEventSignal(dtStart,dtEnd);
1321} 1320}
1322 1321
1323void KOAgendaView::newEventAllDay(int gx, int ) 1322void KOAgendaView::newEventAllDay(int gx, int )
1324{ 1323{
1325 if (!mSelectedDates.count()) return; 1324 if (!mSelectedDates.count()) return;
1326 1325
1327 QDate day = mSelectedDates[gx]; 1326 QDate day = mSelectedDates[gx];
1328 1327
1329 emit newEventSignal(day); 1328 emit newEventSignal(day);
1330} 1329}
1331void KOAgendaView::newTodoAllDay(int gx, int ) 1330void KOAgendaView::newTodoAllDay(int gx, int )
1332{ 1331{
1333 if (!mSelectedDates.count()) return; 1332 if (!mSelectedDates.count()) return;
1334 1333
1335 QDateTime day (mSelectedDates[gx] ); 1334 QDateTime day (mSelectedDates[gx] );
1336 emit newTodoSignal(day, true); 1335 emit newTodoSignal(day, true);
1337} 1336}
1338void KOAgendaView::newTodo(int gx, int gy ) 1337void KOAgendaView::newTodo(int gx, int gy )
1339{ 1338{
1340 if (!mSelectedDates.count()) return; 1339 if (!mSelectedDates.count()) return;
1341 QDate dayStart = mSelectedDates[gx]; 1340 QDate dayStart = mSelectedDates[gx];
1342 QTime timeStart = mAgenda->gyToTime(gy); 1341 QTime timeStart = mAgenda->gyToTime(gy);
1343 QDateTime dt (dayStart,timeStart); 1342 QDateTime dt (dayStart,timeStart);
1344 emit newTodoSignal( dt, false ); 1343 emit newTodoSignal( dt, false );
1345} 1344}
1346 1345
1347void KOAgendaView::updateEventIndicatorTop(int newY) 1346void KOAgendaView::updateEventIndicatorTop(int newY)
1348{ 1347{
1349 uint i; 1348 uint i;
1350 for(i=0;i<mMinY.size();++i) { 1349 for(i=0;i<mMinY.size();++i) {
1351 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1350 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1352 else mEventIndicatorTop->enableColumn(i,false); 1351 else mEventIndicatorTop->enableColumn(i,false);
1353 } 1352 }
1354 1353
1355 mEventIndicatorTop->update(); 1354 mEventIndicatorTop->update();
1356} 1355}
1357 1356
1358void KOAgendaView::updateEventIndicatorBottom(int newY) 1357void KOAgendaView::updateEventIndicatorBottom(int newY)
1359{ 1358{
1360 uint i; 1359 uint i;
1361 for(i=0;i<mMaxY.size();++i) { 1360 for(i=0;i<mMaxY.size();++i) {
1362 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1361 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1363 else mEventIndicatorBottom->enableColumn(i,false); 1362 else mEventIndicatorBottom->enableColumn(i,false);
1364 } 1363 }
1365 1364
1366 mEventIndicatorBottom->update(); 1365 mEventIndicatorBottom->update();
1367} 1366}
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 6294b98..0ef5ae4 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -778,630 +778,634 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
778 // the layout. 778 // the layout.
779 mDayLabels.resize( mDaysPerWeek ); 779 mDayLabels.resize( mDaysPerWeek );
780 QFont bfont = font(); 780 QFont bfont = font();
781 if ( QApplication::desktop()->width() < 650 ) { 781 if ( QApplication::desktop()->width() < 650 ) {
782 bfont.setPointSize( bfont.pointSize() - 2 ); 782 bfont.setPointSize( bfont.pointSize() - 2 );
783 } 783 }
784 bfont.setBold( true ); 784 bfont.setBold( true );
785 int i; 785 int i;
786 786
787 for( i = 0; i < mDaysPerWeek; i++ ) { 787 for( i = 0; i < mDaysPerWeek; i++ ) {
788 QLabel *label = new QLabel( this ); 788 QLabel *label = new QLabel( this );
789 label->setFont(bfont); 789 label->setFont(bfont);
790 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 790 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
791 label->setLineWidth(1); 791 label->setLineWidth(1);
792 label->setAlignment(AlignCenter); 792 label->setAlignment(AlignCenter);
793 mDayLabels.insert( i, label ); 793 mDayLabels.insert( i, label );
794 } 794 }
795 795
796 bfont.setBold( false ); 796 bfont.setBold( false );
797 mWeekLabels.resize( mNumWeeks+1 ); 797 mWeekLabels.resize( mNumWeeks+1 );
798 for( i = 0; i < mNumWeeks+1; i++ ) { 798 for( i = 0; i < mNumWeeks+1; i++ ) {
799 KOWeekButton *label = new KOWeekButton( this ); 799 KOWeekButton *label = new KOWeekButton( this );
800 label->setFont(bfont); 800 label->setFont(bfont);
801 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); 801 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
802 label->setFlat(true); 802 label->setFlat(true);
803 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); 803 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
804 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 804 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
805 //label->setLineWidth(1); 805 //label->setLineWidth(1);
806 //label->setAlignment(AlignCenter); 806 //label->setAlignment(AlignCenter);
807 mWeekLabels.insert( i, label ); 807 mWeekLabels.insert( i, label );
808 } 808 }
809 mWeekLabels[mNumWeeks]->setText( i18n("W")); 809 mWeekLabels[mNumWeeks]->setText( i18n("W"));
810 int row, col; 810 int row, col;
811 mCells.resize( mNumCells ); 811 mCells.resize( mNumCells );
812 for( row = 0; row < mNumWeeks; ++row ) { 812 for( row = 0; row < mNumWeeks; ++row ) {
813 for( col = 0; col < mDaysPerWeek; ++col ) { 813 for( col = 0; col < mDaysPerWeek; ++col ) {
814 MonthViewCell *cell = new MonthViewCell( this ); 814 MonthViewCell *cell = new MonthViewCell( this );
815 mCells.insert( row * mDaysPerWeek + col, cell ); 815 mCells.insert( row * mDaysPerWeek + col, cell );
816 816
817 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 817 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
818 SLOT( defaultAction( Incidence * ) ) ); 818 SLOT( defaultAction( Incidence * ) ) );
819 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 819 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
820 SIGNAL( newEventSignal( QDateTime ) ) ); 820 SIGNAL( newEventSignal( QDateTime ) ) );
821 connect( cell, SIGNAL( showDaySignal( QDate ) ), 821 connect( cell, SIGNAL( showDaySignal( QDate ) ),
822 SIGNAL( showDaySignal( QDate ) ) ); 822 SIGNAL( showDaySignal( QDate ) ) );
823 } 823 }
824 } 824 }
825 825
826 connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), 826 connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ),
827 SLOT( switchView() ) ); 827 SLOT( switchView() ) );
828 mContextMenu = eventPopup(); 828 mContextMenu = eventPopup();
829 // updateConfig(); //useless here 829 // updateConfig(); //useless here
830 830
831 emit incidenceSelected( 0 ); 831 emit incidenceSelected( 0 );
832} 832}
833 833
834KOMonthView::~KOMonthView() 834KOMonthView::~KOMonthView()
835{ 835{
836 delete mContextMenu; 836 delete mContextMenu;
837} 837}
838void KOMonthView::switchView() 838void KOMonthView::switchView()
839{ 839{
840 if ( selectedCell( ) ) 840 if ( selectedCell( ) )
841 selectedCell()->deselect(); 841 selectedCell()->deselect();
842 mShowWeekView = !mShowWeekView; 842 mShowWeekView = !mShowWeekView;
843 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 843 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
844 emit showNavigator( !mShowWeekView ); 844 emit showNavigator( !mShowWeekView );
845 computeLayout(); 845 computeLayout();
846 updateConfig(); 846 updateConfig();
847} 847}
848 848
849int KOMonthView::maxDatesHint() 849int KOMonthView::maxDatesHint()
850{ 850{
851 return mNumCells; 851 return mNumCells;
852} 852}
853 853
854int KOMonthView::currentDateCount() 854int KOMonthView::currentDateCount()
855{ 855{
856 return mNumCells; 856 return mNumCells;
857} 857}
858 858
859QPtrList<Incidence> KOMonthView::selectedIncidences() 859QPtrList<Incidence> KOMonthView::selectedIncidences()
860{ 860{
861 QPtrList<Incidence> selected; 861 QPtrList<Incidence> selected;
862 862
863 if ( mSelectedCell ) { 863 if ( mSelectedCell ) {
864 Incidence *incidence = mSelectedCell->selectedIncidence(); 864 Incidence *incidence = mSelectedCell->selectedIncidence();
865 if ( incidence ) selected.append( incidence ); 865 if ( incidence ) selected.append( incidence );
866 } 866 }
867 867
868 return selected; 868 return selected;
869} 869}
870 870
871DateList KOMonthView::selectedDates() 871DateList KOMonthView::selectedDates()
872{ 872{
873 DateList selected; 873 DateList selected;
874 874
875 if ( mSelectedCell ) { 875 if ( mSelectedCell ) {
876 QDate qd = mSelectedCell->selectedIncidenceDate(); 876 QDate qd = mSelectedCell->selectedIncidenceDate();
877 if ( qd.isValid() ) selected.append( qd ); 877 if ( qd.isValid() ) selected.append( qd );
878 } 878 }
879 879
880 return selected; 880 return selected;
881} 881}
882 882
883void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 883void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
884 const QDate &td) 884 const QDate &td)
885{ 885{
886#ifndef KORG_NOPRINTER 886#ifndef KORG_NOPRINTER
887 calPrinter->preview(CalPrinter::Month, fd, td); 887 calPrinter->preview(CalPrinter::Month, fd, td);
888#endif 888#endif
889} 889}
890 890
891void KOMonthView::updateConfig() 891void KOMonthView::updateConfig()
892{ 892{
893 893
894 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 894 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
895 895
896 if ( mShowWeekView ) 896 if ( mShowWeekView )
897 mWeekStartsMonday = true; 897 mWeekStartsMonday = true;
898 QFontMetrics fontmetric(mDayLabels[0]->font()); 898 QFontMetrics fontmetric(mDayLabels[0]->font());
899 mWidthLongDayLabel = 0; 899 mWidthLongDayLabel = 0;
900 900
901 for (int i = 0; i < 7; i++) { 901 for (int i = 0; i < 7; i++) {
902 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 902 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
903 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 903 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
904 } 904 }
905 bool temp = mShowSatSunComp ; 905 bool temp = mShowSatSunComp ;
906 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 906 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
907 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 907 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
908 computeLayout(); 908 computeLayout();
909 updateDayLabels(); 909 updateDayLabels();
910 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 910 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
911 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 911 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
912 //resizeEvent( 0 ); 912 //resizeEvent( 0 );
913 for (uint i = 0; i < mCells.count(); ++i) { 913 for (uint i = 0; i < mCells.count(); ++i) {
914 mCells[i]->updateConfig(); 914 mCells[i]->updateConfig();
915 } 915 }
916#ifdef DESKTOP_VERSION 916#ifdef DESKTOP_VERSION
917 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 917 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
918#endif 918#endif
919 updateView(); 919 updateView();
920} 920}
921 921
922void KOMonthView::updateDayLabels() 922void KOMonthView::updateDayLabels()
923{ 923{
924 924
925 for (int i = 0; i < 7; i++) { 925 for (int i = 0; i < 7; i++) {
926 if (mWeekStartsMonday) { 926 if (mWeekStartsMonday) {
927 bool show = mShortDayLabels; 927 bool show = mShortDayLabels;
928 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 928 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
929 show = true; 929 show = true;
930 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 930 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
931 } else { 931 } else {
932 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 932 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
933 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 933 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
934 934
935 } 935 }
936 } 936 }
937} 937}
938 938
939void KOMonthView::showDates(const QDate &start, const QDate &) 939void KOMonthView::showDates(const QDate &start, const QDate &)
940{ 940{
941 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 941 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
942 942
943 943
944 mStartDate = start; 944 mStartDate = start;
945 945
946 int startWeekDay = mWeekStartsMonday ? 1 : 7; 946 int startWeekDay = mWeekStartsMonday ? 1 : 7;
947 947
948 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 948 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
949 mStartDate = mStartDate.addDays( -1 ); 949 mStartDate = mStartDate.addDays( -1 );
950 } 950 }
951 951
952 bool primary = false; 952 bool primary = false;
953 uint i; 953 uint i;
954 for( i = 0; i < mCells.size(); ++i ) { 954 for( i = 0; i < mCells.size(); ++i ) {
955 QDate date = mStartDate.addDays( i ); 955 QDate date = mStartDate.addDays( i );
956 mCells[i]->setDate( date ); 956 mCells[i]->setDate( date );
957 957
958#ifndef KORG_NOPLUGINS 958#ifndef KORG_NOPLUGINS
959 // add holiday, if present 959 // add holiday, if present
960 QString hstring(KOCore::self()->holiday(date)); 960 QString hstring(KOCore::self()->holiday(date));
961 mCells[i]->setHoliday( hstring ); 961 mCells[i]->setHoliday( hstring );
962#endif 962#endif
963 963
964 } 964 }
965 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 965 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
966 for( i = 0; i < 6; ++i ) { 966 for( i = 0; i < 6; ++i ) {
967 int wno; 967 int wno;
968 // remember, according to ISO 8601, the first week of the year is the 968 // remember, according to ISO 8601, the first week of the year is the
969 // first week that contains a thursday. Thus we must subtract off 4, 969 // first week that contains a thursday. Thus we must subtract off 4,
970 // not just 1. 970 // not just 1.
971 int dayOfYear = date.dayOfYear(); 971 int dayOfYear = date.dayOfYear();
972 if (dayOfYear % 7 != 0) 972 if (dayOfYear % 7 != 0)
973 wno = dayOfYear / 7 + 1; 973 wno = dayOfYear / 7 + 1;
974 else 974 else
975 wno =dayOfYear / 7; 975 wno =dayOfYear / 7;
976 mWeekLabels[i]->setWeekNum( wno ); 976 mWeekLabels[i]->setWeekNum( wno );
977 date = date.addDays( 7 ); 977 date = date.addDays( 7 );
978 } 978 }
979 updateView(); 979 updateView();
980} 980}
981 981
982void KOMonthView::showEvents(QPtrList<Event>) 982void KOMonthView::showEvents(QPtrList<Event>)
983{ 983{
984 qDebug("KOMonthView::selectEvents is not implemented yet. "); 984 qDebug("KOMonthView::selectEvents is not implemented yet. ");
985} 985}
986 986
987void KOMonthView::changeEventDisplay(Event *, int) 987void KOMonthView::changeEventDisplay(Event *, int)
988{ 988{
989 // this should be re-written to be much more efficient, but this 989 // this should be re-written to be much more efficient, but this
990 // quick-and-dirty-hack gets the job done for right now. 990 // quick-and-dirty-hack gets the job done for right now.
991 updateView(); 991 updateView();
992} 992}
993 993
994void KOMonthView::updateView() 994void KOMonthView::updateView()
995{ 995{
996 996
997 if ( !updatePossible ) 997 if ( !updatePossible )
998 return; 998 return;
999 //QTime ti; 999 //QTime ti;
1000 //ti.start(); 1000 //ti.start();
1001#if 1 1001#if 1
1002 int i; 1002 int i;
1003 int timeSpan = mCells.size()-1; 1003 int timeSpan = mCells.size()-1;
1004 if ( KOPrefs::instance()->mMonthViewWeek ) 1004 if ( KOPrefs::instance()->mMonthViewWeek )
1005 timeSpan = 6; 1005 timeSpan = 6;
1006 for( i = 0; i < timeSpan + 1; ++i ) { 1006 for( i = 0; i < timeSpan + 1; ++i ) {
1007 mCells[i]->startUpdateCell(); 1007 mCells[i]->startUpdateCell();
1008 } 1008 }
1009 1009
1010 QPtrList<Event> events = calendar()->events(); 1010 QPtrList<Event> events = calendar()->events();
1011 Event *event; 1011 Event *event;
1012 QDateTime dt; 1012 QDateTime dt;
1013 bool ok; 1013 bool ok;
1014 QDate endDate = mStartDate.addDays( timeSpan ); 1014 QDate endDate = mStartDate.addDays( timeSpan );
1015 for( event = events.first(); event; event = events.next() ) { // for event 1015 for( event = events.first(); event; event = events.next() ) { // for event
1016 if ( event->doesRecur() ) { 1016 if ( event->doesRecur() ) {
1017 bool last; 1017 bool last;
1018 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1018 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1019 QDateTime incidenceEnd; 1019 QDateTime incidenceEnd;
1020 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1020 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1021 bool invalid = false; 1021 bool invalid = false;
1022 while( true ) { 1022 while( true ) {
1023 if ( incidenceStart.isValid() ) { 1023 if ( incidenceStart.isValid() ) {
1024 incidenceEnd = incidenceStart.addDays( eventlen ); 1024 incidenceEnd = incidenceStart.addDays( eventlen );
1025 int st = incidenceStart.date().daysTo( endDate ); 1025 int st = incidenceStart.date().daysTo( endDate );
1026 if ( st >= 0 ) { // start before timeend 1026 if ( st >= 0 ) { // start before timeend
1027 int end = mStartDate.daysTo( incidenceEnd.date() ); 1027 int end = mStartDate.daysTo( incidenceEnd.date() );
1028 if ( end >= 0 ) { // end after timestart --- got one! 1028 if ( end >= 0 ) { // end after timestart --- got one!
1029 //normalize 1029 //normalize
1030 st = timeSpan - st; 1030 st = timeSpan - st;
1031 if ( st < 0 ) st = 0; 1031 if ( st < 0 ) st = 0;
1032 if ( end > timeSpan ) end = timeSpan; 1032 if ( end > timeSpan ) end = timeSpan;
1033 int iii; 1033 int iii;
1034 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1034 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1035 for ( iii = st;iii<= end;++iii) 1035 for ( iii = st;iii<= end;++iii)
1036 mCells[iii]->insertEvent( event ); 1036 mCells[iii]->insertEvent( event );
1037 } 1037 }
1038 } 1038 }
1039 } else { 1039 } else {
1040 if ( invalid ) 1040 if ( invalid )
1041 break; 1041 break;
1042 invalid = true; 1042 invalid = true;
1043 //qDebug("invalid %s", event->summary().latin1()); 1043 //qDebug("invalid %s", event->summary().latin1());
1044 incidenceStart = QDateTime( mStartDate ); 1044 incidenceStart = QDateTime( mStartDate );
1045 } 1045 }
1046 if ( last ) 1046 if ( last )
1047 break; 1047 break;
1048 bool ok; 1048 bool ok;
1049 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1049 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1050 if ( ! ok ) 1050 if ( ! ok )
1051 break; 1051 break;
1052 if ( incidenceStart.date() > endDate ) 1052 if ( incidenceStart.date() > endDate )
1053 break; 1053 break;
1054 } 1054 }
1055 } else { // no recur 1055 } else { // no recur
1056 int st = event->dtStart().date().daysTo( endDate ); 1056 int st = event->dtStart().date().daysTo( endDate );
1057 if ( st >= 0 ) { // start before timeend 1057 if ( st >= 0 ) { // start before timeend
1058 int end = mStartDate.daysTo( event->dtEnd().date() ); 1058 int end = mStartDate.daysTo( event->dtEnd().date() );
1059 if ( end >= 0 ) { // end after timestart --- got one! 1059 if ( end >= 0 ) { // end after timestart --- got one!
1060 //normalize 1060 //normalize
1061 st = timeSpan - st; 1061 st = timeSpan - st;
1062 if ( st < 0 ) st = 0; 1062 if ( st < 0 ) st = 0;
1063 if ( end > timeSpan ) end = timeSpan; 1063 if ( end > timeSpan ) end = timeSpan;
1064 int iii; 1064 int iii;
1065 for ( iii = st;iii<= end;++iii) 1065 for ( iii = st;iii<= end;++iii)
1066 mCells[iii]->insertEvent( event ); 1066 mCells[iii]->insertEvent( event );
1067 } 1067 }
1068 } 1068 }
1069 } 1069 }
1070 } 1070 }
1071 // insert due todos 1071 // insert due todos
1072 QPtrList<Todo> todos = calendar()->todos( ); 1072 QPtrList<Todo> todos = calendar()->todos( );
1073 Todo *todo; 1073 Todo *todo;
1074 for(todo = todos.first(); todo; todo = todos.next()) { 1074 for(todo = todos.first(); todo; todo = todos.next()) {
1075 //insertTodo( todo ); 1075 //insertTodo( todo );
1076 if ( todo->hasDueDate() ) { 1076 if ( todo->hasDueDate() ) {
1077 int day = mStartDate.daysTo( todo->dtDue().date() ); 1077 int day = mStartDate.daysTo( todo->dtDue().date() );
1078 if ( day >= 0 && day < timeSpan + 1) { 1078 if ( day >= 0 && day < timeSpan + 1) {
1079 mCells[day]->insertTodo( todo ); 1079 mCells[day]->insertTodo( todo );
1080 } 1080 }
1081 } 1081 }
1082 } 1082 }
1083 1083
1084 for( i = 0; i < timeSpan+1; ++i ) { 1084 for( i = 0; i < timeSpan+1; ++i ) {
1085 mCells[i]->finishUpdateCell(); 1085 mCells[i]->finishUpdateCell();
1086 } 1086 }
1087 processSelectionChange(); 1087 processSelectionChange();
1088 mCells[0]->setFocus(); 1088 mCells[0]->setFocus();
1089 1089
1090 1090
1091#else 1091#else
1092 // old code 1092 // old code
1093 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1093 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1094 int i; 1094 int i;
1095 for( i = 0; i < mCells.count(); ++i ) { 1095 for( i = 0; i < mCells.count(); ++i ) {
1096 mCells[i]->updateCell(); 1096 mCells[i]->updateCell();
1097 } 1097 }
1098 1098
1099 //qDebug("KOMonthView::updateView() "); 1099 //qDebug("KOMonthView::updateView() ");
1100 processSelectionChange(); 1100 processSelectionChange();
1101 // qDebug("---------------------------------------------------------------------+ "); 1101 // qDebug("---------------------------------------------------------------------+ ");
1102 mCells[0]->setFocus(); 1102 mCells[0]->setFocus();
1103#endif 1103#endif
1104 1104
1105 //qDebug("update time %d ", ti.elapsed()); 1105 //qDebug("update time %d ", ti.elapsed());
1106} 1106}
1107 1107
1108void KOMonthView::resizeEvent(QResizeEvent * e) 1108void KOMonthView::resizeEvent(QResizeEvent * e)
1109{ 1109{
1110 computeLayout(); 1110 computeLayout();
1111 mCells[0]->setFocus(); 1111 mCells[0]->setFocus();
1112} 1112}
1113void KOMonthView::computeLayoutWeek() 1113void KOMonthView::computeLayoutWeek()
1114{ 1114{
1115 1115
1116 int daysToShow; 1116 int daysToShow;
1117 bool combinedSatSun = false; 1117 bool combinedSatSun = false;
1118 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1118 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1119 daysToShow = 6; 1119 daysToShow = 6;
1120 combinedSatSun = true; 1120 combinedSatSun = true;
1121 } 1121 }
1122 int tWid = topLevelWidget()->size().width(); 1122 int tWid = topLevelWidget()->size().width();
1123 int tHei = topLevelWidget()->size().height(); 1123 int tHei = topLevelWidget()->size().height();
1124 1124
1125 int wid = size().width();//e 1125 int wid = size().width();//e
1126 int hei = size().height()-1; 1126 int hei = size().height()-1;
1127 1127
1128 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1128 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1129 return; 1129 return;
1130 1130
1131 if ( wid < hei ) 1131 if ( wid < hei )
1132 daysToShow = 2; 1132 daysToShow = 2;
1133 else 1133 else
1134 daysToShow = 3; 1134 daysToShow = 3;
1135 mShowSatSunComp = true; 1135 mShowSatSunComp = true;
1136 combinedSatSun = true; 1136 combinedSatSun = true;
1137 1137
1138 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1138 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1139 QFontMetrics fm ( mWeekLabels[0]->font() ); 1139 QFontMetrics fm ( mWeekLabels[0]->font() );
1140 int weeklabelwid = fm.width( "888" ); 1140 int weeklabelwid = fm.width( "888" );
1141 wid -= weeklabelwid; 1141 wid -= weeklabelwid;
1142 1142
1143 int colWid = wid / daysToShow; 1143 int colWid = wid / daysToShow;
1144 int lastCol = wid - ( colWid*6 ); 1144 int lastCol = wid - ( colWid*6 );
1145 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1145 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1146 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1146 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1147 int colModulo = wid % daysToShow; 1147 int colModulo = wid % daysToShow;
1148 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1148 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1149 //qDebug("rowmod %d ", rowModulo); 1149 //qDebug("rowmod %d ", rowModulo);
1150 int i; 1150 int i;
1151 int x,y,w,h; 1151 int x,y,w,h;
1152 x= 0; 1152 x= 0;
1153 y= 0; 1153 y= 0;
1154 w = colWid; 1154 w = colWid;
1155 h = dayLabelHei ; 1155 h = dayLabelHei ;
1156 for ( i = 0; i < 7; i++) { 1156 for ( i = 0; i < 7; i++) {
1157 if ( i && !( i % daysToShow) && i < 6) { 1157 if ( i && !( i % daysToShow) && i < 6) {
1158 y += hei/(5-daysToShow); 1158 y += hei/(5-daysToShow);
1159 x = 0; 1159 x = 0;
1160 w = colWid; 1160 w = colWid;
1161 } 1161 }
1162 if ( i == daysToShow-colModulo ) 1162 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1163 ++w; 1163 ++w;
1164 }
1164 if ( i >= 5 ) { 1165 if ( i >= 5 ) {
1165 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+1,h); 1166 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1166 x -= w/2 ; 1167 x -= (w/2 );
1167 } 1168 }
1168 else 1169 else
1169 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1170 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1170 x += w; 1171 x += w;
1171 } 1172 }
1172 x= 0; 1173 x= 0;
1173 y= dayLabelHei; 1174 y= dayLabelHei;
1174 w = colWid; 1175 w = colWid;
1175 h = cellHei; 1176 h = cellHei;
1176 for ( i = 0; i < mCells.count(); ++i) { 1177 for ( i = 0; i < mCells.count(); ++i) {
1177 if ( i > 6 ) { 1178 if ( i > 6 ) {
1178 mCells[i]->hide(); 1179 mCells[i]->hide();
1179 continue; 1180 continue;
1180 } 1181 }
1181 1182
1182 w = colWid; 1183 w = colWid;
1183 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1184 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1184 ++w; 1185 ++w;
1185 } 1186 }
1186 if ( i == (daysToShow-1-rowModulo)*7) 1187 if ( i == (daysToShow-1-rowModulo)*7)
1187 ++h; 1188 ++h;
1188 1189
1189 if ( i >= 5 ) { 1190 if ( i >= 5 ) {
1190 if ( i ==5 ) { 1191 if ( i ==5 ) {
1191 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1192 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1192 x -= w ;y += h/2; 1193 x -= w ;y += h/2;
1193 } else { 1194 } else {
1195 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1196 ++w;
1197 }
1194 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1198 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1195 y -= h/2; 1199 y -= h/2;
1196 } 1200 }
1197 } else 1201 } else
1198 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1202 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1199 1203
1200 1204
1201 x += w; 1205 x += w;
1202 if ( x + w/2 > wid ) { 1206 if ( x + w/2 > wid ) {
1203 x = 0; 1207 x = 0;
1204 y += h+dayLabelHei ; 1208 y += h+dayLabelHei ;
1205 } 1209 }
1206 } 1210 }
1207 y= dayLabelHei; 1211 y= dayLabelHei;
1208 h = cellHei ; 1212 h = cellHei ;
1209 mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1213 mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1210 for ( i = 1; i < 6; i++) { 1214 for ( i = 1; i < 6; i++) {
1211 mWeekLabels[i]->hide(); 1215 mWeekLabels[i]->hide();
1212 } 1216 }
1213 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1217 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1214 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1218 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1215 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1219 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1216 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1220 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1217 updateDayLabels(); 1221 updateDayLabels();
1218 bool forceUpdate = !updatePossible; 1222 bool forceUpdate = !updatePossible;
1219 updatePossible = true; 1223 updatePossible = true;
1220 mWeekLabels[mNumWeeks]->setText( i18n("M")); 1224 mWeekLabels[mNumWeeks]->setText( i18n("M"));
1221 if ( forceUpdate ) 1225 if ( forceUpdate )
1222 updateView(); 1226 updateView();
1223} 1227}
1224void KOMonthView::computeLayout() 1228void KOMonthView::computeLayout()
1225{ 1229{
1226 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 1230 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
1227 // note this only changes the text if the requested size crosses the 1231 // note this only changes the text if the requested size crosses the
1228 // threshold between big enough to support the full name and not big 1232 // threshold between big enough to support the full name and not big
1229 // enough. 1233 // enough.
1230 if ( mShowWeekView ){ 1234 if ( mShowWeekView ){
1231 computeLayoutWeek(); 1235 computeLayoutWeek();
1232 return; 1236 return;
1233 } 1237 }
1234 int daysToShow = 7; 1238 int daysToShow = 7;
1235 bool combinedSatSun = false; 1239 bool combinedSatSun = false;
1236 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1240 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1237 daysToShow = 6; 1241 daysToShow = 6;
1238 combinedSatSun = true; 1242 combinedSatSun = true;
1239 } 1243 }
1240 int tWid = topLevelWidget()->size().width(); 1244 int tWid = topLevelWidget()->size().width();
1241 int tHei = topLevelWidget()->size().height(); 1245 int tHei = topLevelWidget()->size().height();
1242 1246
1243 int wid = size().width();//e 1247 int wid = size().width();//e
1244 int hei = size().height()-1; 1248 int hei = size().height()-1;
1245 1249
1246 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1250 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1247 return; 1251 return;
1248 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1252 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1249 QFontMetrics fm ( mWeekLabels[0]->font() ); 1253 QFontMetrics fm ( mWeekLabels[0]->font() );
1250 int weeklabelwid = fm.width( "888" ); 1254 int weeklabelwid = fm.width( "888" );
1251 wid -= weeklabelwid; 1255 wid -= weeklabelwid;
1252 1256
1253 int colWid = wid / daysToShow; 1257 int colWid = wid / daysToShow;
1254 int lastCol = wid - ( colWid*6 ); 1258 int lastCol = wid - ( colWid*6 );
1255 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1259 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1256 int cellHei = (hei - dayLabelHei) /6; 1260 int cellHei = (hei - dayLabelHei) /6;
1257 int colModulo = wid % daysToShow; 1261 int colModulo = wid % daysToShow;
1258 int rowModulo = (hei- dayLabelHei) % 6; 1262 int rowModulo = (hei- dayLabelHei) % 6;
1259 //qDebug("rowmod %d ", rowModulo); 1263 //qDebug("rowmod %d ", rowModulo);
1260 int i; 1264 int i;
1261 int x,y,w,h; 1265 int x,y,w,h;
1262 x= 0; 1266 x= 0;
1263 y= 0; 1267 y= 0;
1264 w = colWid; 1268 w = colWid;
1265 h = dayLabelHei ; 1269 h = dayLabelHei ;
1266 for ( i = 0; i < 7; i++) { 1270 for ( i = 0; i < 7; i++) {
1267 if ( i == daysToShow-colModulo ) 1271 if ( i == daysToShow-colModulo )
1268 ++w; 1272 ++w;
1269 if ( combinedSatSun ) { 1273 if ( combinedSatSun ) {
1270 if ( i >= daysToShow-1 ) { 1274 if ( i >= daysToShow-1 ) {
1271 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1275 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1272 x -= w/2 ; 1276 x -= w/2 ;
1273 } 1277 }
1274 else 1278 else
1275 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1279 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1276 } else 1280 } else
1277 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1281 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1278 x += w; 1282 x += w;
1279 } 1283 }
1280 x= 0; 1284 x= 0;
1281 y= dayLabelHei; 1285 y= dayLabelHei;
1282 w = colWid; 1286 w = colWid;
1283 h = cellHei ; 1287 h = cellHei ;
1284 for ( i = 0; i < mCells.count(); ++i) { 1288 for ( i = 0; i < mCells.count(); ++i) {
1285 mCells[i]->show(); 1289 mCells[i]->show();
1286 w = colWid; 1290 w = colWid;
1287 if ( ((i) % 7) >= 7-colModulo ) { 1291 if ( ((i) % 7) >= 7-colModulo ) {
1288 ++w; 1292 ++w;
1289 } 1293 }
1290 if ( i == (6-rowModulo)*7) 1294 if ( i == (6-rowModulo)*7)
1291 ++h; 1295 ++h;
1292 if ( combinedSatSun ) { 1296 if ( combinedSatSun ) {
1293 if ( (i)%7 >= daysToShow-1 ) { 1297 if ( (i)%7 >= daysToShow-1 ) {
1294 if ( (i)%7 == daysToShow-1 ) { 1298 if ( (i)%7 == daysToShow-1 ) {
1295 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1299 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1296 x -= w ;y += h/2; 1300 x -= w ;y += h/2;
1297 } else { 1301 } else {
1298 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1302 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1299 y -= h/2; 1303 y -= h/2;
1300 } 1304 }
1301 } else 1305 } else
1302 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1306 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1303 1307
1304 } 1308 }
1305 else 1309 else
1306 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1310 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1307 x += w; 1311 x += w;
1308 if ( x + w/2 > wid ) { 1312 if ( x + w/2 > wid ) {
1309 x = 0; 1313 x = 0;
1310 y += h; 1314 y += h;
1311 } 1315 }
1312 } 1316 }
1313 y= dayLabelHei; 1317 y= dayLabelHei;
1314 h = cellHei ; 1318 h = cellHei ;
1315 for ( i = 0; i < 6; i++) { 1319 for ( i = 0; i < 6; i++) {
1316 mWeekLabels[i]->show(); 1320 mWeekLabels[i]->show();
1317 if ( i == (6-rowModulo)) 1321 if ( i == (6-rowModulo))
1318 ++h; 1322 ++h;
1319 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1323 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1320 y += h; 1324 y += h;
1321 } 1325 }
1322 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1326 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1323 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1327 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1324 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1328 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1325 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1329 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1326 updateDayLabels(); 1330 updateDayLabels();
1327 bool forceUpdate = !updatePossible; 1331 bool forceUpdate = !updatePossible;
1328 updatePossible = true; 1332 updatePossible = true;
1329 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1333 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1330 if ( forceUpdate ) 1334 if ( forceUpdate )
1331 updateView(); 1335 updateView();
1332} 1336}
1333 1337
1334void KOMonthView::showContextMenu( Incidence *incidence ) 1338void KOMonthView::showContextMenu( Incidence *incidence )
1335{ 1339{
1336 mContextMenu->showIncidencePopup(incidence); 1340 mContextMenu->showIncidencePopup(incidence);
1337 /* 1341 /*
1338 if( incidence && incidence->type() == "Event" ) { 1342 if( incidence && incidence->type() == "Event" ) {
1339 Event *event = static_cast<Event *>(incidence); 1343 Event *event = static_cast<Event *>(incidence);
1340 mContextMenu->showEventPopup(event); 1344 mContextMenu->showEventPopup(event);
1341 } else { 1345 } else {
1342 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1346 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1343 } 1347 }
1344 */ 1348 */
1345} 1349}
1346MonthViewCell * KOMonthView::selectedCell( ) 1350MonthViewCell * KOMonthView::selectedCell( )
1347{ 1351{
1348 return mSelectedCell; 1352 return mSelectedCell;
1349} 1353}
1350void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1354void KOMonthView::setSelectedCell( MonthViewCell *cell )
1351{ 1355{
1352 // qDebug("KOMonthView::setSelectedCell "); 1356 // qDebug("KOMonthView::setSelectedCell ");
1353 if ( mSelectedCell && mSelectedCell != cell ) { 1357 if ( mSelectedCell && mSelectedCell != cell ) {
1354 MonthViewCell * mvc = mSelectedCell; 1358 MonthViewCell * mvc = mSelectedCell;
1355 mSelectedCell = cell; 1359 mSelectedCell = cell;
1356 mvc->deselect(); 1360 mvc->deselect();
1357 } else 1361 } else
1358 mSelectedCell = cell; 1362 mSelectedCell = cell;
1359 // if ( mSelectedCell ) 1363 // if ( mSelectedCell )
1360 // mSelectedCell->select(); 1364 // mSelectedCell->select();
1361 if ( !mSelectedCell ) 1365 if ( !mSelectedCell )
1362 emit incidenceSelected( 0 ); 1366 emit incidenceSelected( 0 );
1363 else 1367 else
1364 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1368 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1365} 1369}
1366 1370
1367void KOMonthView::processSelectionChange() 1371void KOMonthView::processSelectionChange()
1368{ 1372{
1369 QPtrList<Incidence> incidences = selectedIncidences(); 1373 QPtrList<Incidence> incidences = selectedIncidences();
1370 if (incidences.count() > 0) { 1374 if (incidences.count() > 0) {
1371 emit incidenceSelected( incidences.first() ); 1375 emit incidenceSelected( incidences.first() );
1372 } else { 1376 } else {
1373 emit incidenceSelected( 0 ); 1377 emit incidenceSelected( 0 );
1374 } 1378 }
1375} 1379}
1376 1380
1377void KOMonthView::clearSelection() 1381void KOMonthView::clearSelection()
1378{ 1382{
1379 if ( mSelectedCell ) { 1383 if ( mSelectedCell ) {
1380 mSelectedCell->deselect(); 1384 mSelectedCell->deselect();
1381 mSelectedCell = 0; 1385 mSelectedCell = 0;
1382 } 1386 }
1383} 1387}
1384void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1388void KOMonthView::keyPressEvent ( QKeyEvent * e )
1385{ 1389{
1386 //qDebug("KOMonthView::keyPressEvent "); 1390 //qDebug("KOMonthView::keyPressEvent ");
1387 switch(e->key()) { 1391 switch(e->key()) {
1388 case Key_Up: 1392 case Key_Up:
1389 { 1393 {
1390 emit prevMonth(); 1394 emit prevMonth();
1391 mCells[0]->setFocus(); 1395 mCells[0]->setFocus();
1392 } 1396 }
1393 e->accept(); 1397 e->accept();
1394 break; 1398 break;
1395 case Key_Down: 1399 case Key_Down:
1396 { 1400 {
1397 emit nextMonth(); 1401 emit nextMonth();
1398 mCells[0]->setFocus(); 1402 mCells[0]->setFocus();
1399 1403
1400 } 1404 }
1401 e->accept(); 1405 e->accept();
1402 break; 1406 break;
1403 default: 1407 default:
1404 e->ignore(); 1408 e->ignore();
1405 break; 1409 break;
1406 } 1410 }
1407} 1411}
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 6afd203..8aa0697 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,513 +1,510 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") showMonthView(); 91 else if (view == "Month") showMonthView();
92 else if (view == "List") showListView(); 92 else if (view == "List") showListView();
93 else if (view == "Journal") showJournalView(); 93 else if (view == "Journal") showJournalView();
94 else if (view == "TimeSpan") showTimeSpanView(); 94 else if (view == "TimeSpan") showTimeSpanView();
95 else if (view == "Todo") showTodoView(); 95 else if (view == "Todo") showTodoView();
96 else { 96 else {
97 showAgendaView(); 97 showAgendaView();
98 } 98 }
99} 99}
100 100
101void KOViewManager::showDateView( int view, QDate date) 101void KOViewManager::showDateView( int view, QDate date)
102{ 102{
103 static int lastMode = 0; 103 static int lastMode = 0;
104 static int lastCount = 0; 104 static int lastCount = 0;
105 static bool lastNDMode = false; 105 static bool lastNDMode = false;
106 static QDate lastDate; 106 static QDate lastDate;
107 //qDebug("date %d %s", view, date.toString().latin1()); 107 //qDebug("date %d %s", view, date.toString().latin1());
108 108
109 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 109 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
110 bool savemFlagShowNextxDays = mFlagShowNextxDays; 110 bool savemFlagShowNextxDays = mFlagShowNextxDays;
111 mFlagShowNextxDays = false; 111 mFlagShowNextxDays = false;
112 if ( view == 3 ) { 112 if ( view == 3 ) {
113 //mCurrentAgendaView = 1 ; 113 //mCurrentAgendaView = 1 ;
114 lastDate = mMainView->dateNavigator()->selectedDates().first(); 114 lastDate = mMainView->dateNavigator()->selectedDates().first();
115 lastCount = mMainView->dateNavigator()->selectedDates().count(); 115 lastCount = mMainView->dateNavigator()->selectedDates().count();
116 lastNDMode = savemFlagShowNextxDays; 116 lastNDMode = savemFlagShowNextxDays;
117 mMainView->showDay( date ); 117 mMainView->showDay( date );
118 } else if (view == 4 ) { 118 } else if (view == 4 ) {
119 mCurrentAgendaView = 7 ; 119 mCurrentAgendaView = 7 ;
120 mMainView->dateNavigator()->selectDates( date, 7 ); 120 mMainView->dateNavigator()->selectDates( date, 7 );
121 } else if (view == 5 ) { 121 } else if (view == 5 ) {
122 mCurrentAgendaView = 14 ; 122 mCurrentAgendaView = 14 ;
123 mMainView->dateNavigator()->selectDates( date, 14); 123 mMainView->dateNavigator()->selectDates( date, 14);
124 } else if (view == 6 ) { 124 } else if (view == 6 ) {
125 mMainView->dateNavigator()->blockSignals( true ); 125 mMainView->dateNavigator()->selectDates( date, 7 );
126 showMonthView(); 126 showMonthView();
127 mMainView->dateNavigator()->selectMonthByDate( date );
128 mMainView->dateNavigator()->blockSignals( false );
129 mMainView->dateNavigator()->selectDate( date );
130 } else if (view == 7 ) { 127 } else if (view == 7 ) {
131 mMainView->dateNavigator()->selectDate( date ); 128 mMainView->dateNavigator()->selectDate( date );
132 showJournalView(); 129 showJournalView();
133 } else if (view == 8 ) { 130 } else if (view == 8 ) {
134 globalFlagBlockAgenda = 1; 131 globalFlagBlockAgenda = 1;
135 if ( mCurrentAgendaView != 3 ) 132 if ( mCurrentAgendaView != 3 )
136 mCurrentAgendaView = -1; 133 mCurrentAgendaView = -1;
137 showAgendaView(KOPrefs::instance()->mFullViewMonth); 134 showAgendaView(KOPrefs::instance()->mFullViewMonth);
138 globalFlagBlockAgenda = 2; 135 globalFlagBlockAgenda = 2;
139 mMainView->dateNavigator()->selectDates( date , 136 mMainView->dateNavigator()->selectDates( date ,
140 KOPrefs::instance()->mNextXDays ); 137 KOPrefs::instance()->mNextXDays );
141 mFlagShowNextxDays = true; 138 mFlagShowNextxDays = true;
142 mCurrentAgendaView = 3 ; 139 mCurrentAgendaView = 3 ;
143 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 140 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
144 if ( lastMode ) { 141 if ( lastMode ) {
145 mCurrentAgendaView = lastCount ; 142 mCurrentAgendaView = lastCount ;
146 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 143 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
147 mFlagShowNextxDays = lastNDMode; 144 mFlagShowNextxDays = lastNDMode;
148 if ( mFlagShowNextxDays ) { 145 if ( mFlagShowNextxDays ) {
149 mCurrentAgendaView = 3 ; 146 mCurrentAgendaView = 3 ;
150 } 147 }
151 } else 148 } else
152 showWeekView(); 149 showWeekView();
153 } else if (view == 10) { 150 } else if (view == 10) {
154 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 151 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
155 } 152 }
156 lastMode = view; 153 lastMode = view;
157} 154}
158 155
159 156
160 157
161void KOViewManager::writeSettings(KConfig *config) 158void KOViewManager::writeSettings(KConfig *config)
162{ 159{
163 config->setGroup("General"); 160 config->setGroup("General");
164 161
165 QString view; 162 QString view;
166 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 163 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
167 else if (mCurrentView == mMonthView) view = "Month"; 164 else if (mCurrentView == mMonthView) view = "Month";
168 else if (mCurrentView == mListView) view = "List"; 165 else if (mCurrentView == mListView) view = "List";
169 else if (mCurrentView == mJournalView) view = "Journal"; 166 else if (mCurrentView == mJournalView) view = "Journal";
170 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 167 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
171 else if (mCurrentView == mTodoView) view = "Todo"; 168 else if (mCurrentView == mTodoView) view = "Todo";
172 else view = "Agenda"; 169 else view = "Agenda";
173 170
174 config->writeEntry("Current View",view); 171 config->writeEntry("Current View",view);
175 172
176 if (mAgendaView) { 173 if (mAgendaView) {
177 mAgendaView->writeSettings(config); 174 mAgendaView->writeSettings(config);
178 } 175 }
179 if (mTimeSpanView) { 176 if (mTimeSpanView) {
180 mTimeSpanView->writeSettings(config); 177 mTimeSpanView->writeSettings(config);
181 } 178 }
182 if (mListView) { 179 if (mListView) {
183 mListView->writeSettings(config); 180 mListView->writeSettings(config);
184 } 181 }
185 if (mTodoView) { 182 if (mTodoView) {
186 mTodoView->saveLayout(config,"Todo View"); 183 mTodoView->saveLayout(config,"Todo View");
187 } 184 }
188} 185}
189 186
190void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 187void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
191{ 188{
192 189
193 //mFlagShowNextxDays = false; 190 //mFlagShowNextxDays = false;
194 //if(view == mCurrentView) return; 191 //if(view == mCurrentView) return;
195 if ( view == 0 ) { 192 if ( view == 0 ) {
196 view = mCurrentView; 193 view = mCurrentView;
197 if ( view == 0 ) 194 if ( view == 0 )
198 return; 195 return;
199 } 196 }
200 bool full = fullScreen; 197 bool full = fullScreen;
201 if(view == mCurrentView && view != mWhatsNextView ) { 198 if(view == mCurrentView && view != mWhatsNextView ) {
202 if ( mCurrentAgendaView < 0 ) 199 if ( mCurrentAgendaView < 0 )
203 return; 200 return;
204 full = mMainView->leftFrame()->isVisible(); 201 full = mMainView->leftFrame()->isVisible();
205 } else { 202 } else {
206 mCurrentView = view; 203 mCurrentView = view;
207 // bool full = fullScreen; 204 // bool full = fullScreen;
208 bool isFull = !mMainView->leftFrame()->isVisible(); 205 bool isFull = !mMainView->leftFrame()->isVisible();
209 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 206 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
210 full = true; 207 full = true;
211 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 208 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
212 full = false; 209 full = false;
213 } 210 }
214 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 211 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
215 //raiseCurrentView( full ); 212 //raiseCurrentView( full );
216 mMainView->processIncidenceSelection( 0 ); 213 mMainView->processIncidenceSelection( 0 );
217 //mMainView->updateView(); 214 //mMainView->updateView();
218 raiseCurrentView( full, true ); 215 raiseCurrentView( full, true );
219 mMainView->adaptNavigationUnits(); 216 mMainView->adaptNavigationUnits();
220} 217}
221 218
222void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 219void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
223{ 220{
224 mCurrentAgendaView = 0; 221 mCurrentAgendaView = 0;
225 int wid = mMainView->width() ; 222 int wid = mMainView->width() ;
226 int hei = mMainView->height(); 223 int hei = mMainView->height();
227 if ( mCurrentView == mMonthView ) { 224 if ( mCurrentView == mMonthView ) {
228 if ( !KOPrefs::instance()->mMonthViewWeek ) { 225 if ( !KOPrefs::instance()->mMonthViewWeek ) {
229 mMainView->navigatorBar()->show(); 226 mMainView->navigatorBar()->show();
230 hei -= mMainView->navigatorBar()->sizeHint().height(); 227 hei -= mMainView->navigatorBar()->sizeHint().height();
231 } 228 }
232 //mMainView->navigatorBar()->hide(); 229 //mMainView->navigatorBar()->hide();
233 } else { 230 } else {
234 mMainView->navigatorBar()->hide(); 231 mMainView->navigatorBar()->hide();
235 } 232 }
236 if ( fullScreen ) { 233 if ( fullScreen ) {
237 mMainView->leftFrame()->hide(); 234 mMainView->leftFrame()->hide();
238 } else { 235 } else {
239 mMainView->leftFrame()->show(); 236 mMainView->leftFrame()->show();
240 if ( KOPrefs::instance()->mVerticalScreen ) 237 if ( KOPrefs::instance()->mVerticalScreen )
241 hei -= mMainView->leftFrame()->height(); 238 hei -= mMainView->leftFrame()->height();
242 else 239 else
243 wid -= mMainView->leftFrame()->width(); 240 wid -= mMainView->leftFrame()->width();
244 } 241 }
245 emit signalFullScreen( !fullScreen ); 242 emit signalFullScreen( !fullScreen );
246 if ( callUpdateView ) 243 if ( callUpdateView )
247 mMainView->updateView(); 244 mMainView->updateView();
248 245
249 if ( globalFlagBlockAgenda == 5 ) { 246 if ( globalFlagBlockAgenda == 5 ) {
250 globalFlagBlockAgenda = 4; 247 globalFlagBlockAgenda = 4;
251 globalFlagBlockAgendaItemPaint = 1; 248 globalFlagBlockAgendaItemPaint = 1;
252 } 249 }
253 mMainView->viewStack()->raiseWidget(mCurrentView); 250 mMainView->viewStack()->raiseWidget(mCurrentView);
254 if ( globalFlagBlockAgenda == 4 ) { 251 if ( globalFlagBlockAgenda == 4 ) {
255 if ( mCurrentView == mAgendaView ) { 252 if ( mCurrentView == mAgendaView ) {
256 //globalFlagBlockAgenda =1 ; 253 //globalFlagBlockAgenda =1 ;
257 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 254 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
258 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 255 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
259 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 256 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
260 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 257 mAgendaView->setStartHour( QTime::currentTime ().hour() );
261 qApp->processEvents(); 258 qApp->processEvents();
262 //qDebug("qApp->processEvents() "); 259 //qDebug("qApp->processEvents() ");
263 globalFlagBlockAgenda = 0; 260 globalFlagBlockAgenda = 0;
264 mAgendaView->repaintAgenda(); 261 mAgendaView->repaintAgenda();
265 262
266 } 263 }
267 globalFlagBlockAgenda = 0; 264 globalFlagBlockAgenda = 0;
268 } 265 }
269 emit signalAgendaView( mCurrentView == mAgendaView ); 266 emit signalAgendaView( mCurrentView == mAgendaView );
270 //qDebug("raiseCurrentView ende "); 267 //qDebug("raiseCurrentView ende ");
271 268
272} 269}
273 270
274void KOViewManager::updateView() 271void KOViewManager::updateView()
275{ 272{
276 // qDebug("KOViewManager::updateView() "); 273 // qDebug("KOViewManager::updateView() ");
277 // if we are updating mTodoView, we get endless recursion 274 // if we are updating mTodoView, we get endless recursion
278 if ( mTodoView == mCurrentView ) 275 if ( mTodoView == mCurrentView )
279 return; 276 return;
280 if ( mCurrentView ) mCurrentView->updateView(); 277 if ( mCurrentView ) mCurrentView->updateView();
281 278
282} 279}
283 280
284void KOViewManager::updateView(const QDate &start, const QDate &end) 281void KOViewManager::updateView(const QDate &start, const QDate &end)
285{ 282{
286 // kdDebug() << "KOViewManager::updateView()" << endl; 283 // kdDebug() << "KOViewManager::updateView()" << endl;
287 284
288 if (mCurrentView) mCurrentView->showDates(start, end); 285 if (mCurrentView) mCurrentView->showDates(start, end);
289 286
290 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 287 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
291} 288}
292 289
293 290
294void KOViewManager::updateWNview() 291void KOViewManager::updateWNview()
295{ 292{
296 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 293 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
297 mWhatsNextView->updateView(); 294 mWhatsNextView->updateView();
298 295
299} 296}
300void KOViewManager::showWhatsNextView() 297void KOViewManager::showWhatsNextView()
301{ 298{
302 if (!mWhatsNextView) { 299 if (!mWhatsNextView) {
303 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 300 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
304 "KOViewManager::WhatsNextView"); 301 "KOViewManager::WhatsNextView");
305 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 302 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
306 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 303 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
307 addView(mWhatsNextView); 304 addView(mWhatsNextView);
308 connect(this, SIGNAL( printWNV() ), 305 connect(this, SIGNAL( printWNV() ),
309 mWhatsNextView, SLOT( printMe() ) ); 306 mWhatsNextView, SLOT( printMe() ) );
310 } 307 }
311 globalFlagBlockAgenda = 1; 308 globalFlagBlockAgenda = 1;
312 showView(mWhatsNextView, true ); 309 showView(mWhatsNextView, true );
313 //mWhatsNextView->updateView(); 310 //mWhatsNextView->updateView();
314 311
315} 312}
316 313
317void KOViewManager::showListView() 314void KOViewManager::showListView()
318{ 315{
319 if (!mListView) { 316 if (!mListView) {
320 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 317 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
321 addView(mListView); 318 addView(mListView);
322 319
323 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 320 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
324 mMainView, SLOT(showIncidence(Incidence *))); 321 mMainView, SLOT(showIncidence(Incidence *)));
325 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 322 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
326 mMainView, SLOT(editIncidence(Incidence *))); 323 mMainView, SLOT(editIncidence(Incidence *)));
327 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 324 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
328 mMainView, SLOT(deleteIncidence(Incidence *))); 325 mMainView, SLOT(deleteIncidence(Incidence *)));
329 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 326 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
330 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 327 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
331 connect( mListView, SIGNAL( signalNewEvent() ), 328 connect( mListView, SIGNAL( signalNewEvent() ),
332 mMainView, SLOT( newEvent() ) ); 329 mMainView, SLOT( newEvent() ) );
333 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 330 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
334 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 331 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
335 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 332 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
336 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 333 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
337 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 334 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
338 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 335 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
339 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 336 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
340 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 337 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
341 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 338 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
342 } 339 }
343 // bool temp = mFlagShowNextxDays; 340 // bool temp = mFlagShowNextxDays;
344 //globalFlagBlockPainting = true; 341 //globalFlagBlockPainting = true;
345 globalFlagBlockAgenda = 1; 342 globalFlagBlockAgenda = 1;
346 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 343 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
347 mMainView->setBlockShowDates( true ); 344 mMainView->setBlockShowDates( true );
348 mMainView->dateNavigator()->selectMonth(); 345 mMainView->dateNavigator()->selectMonth();
349 mMainView->setBlockShowDates( false ); 346 mMainView->setBlockShowDates( false );
350 } 347 }
351 showView(mListView, KOPrefs::instance()->mFullViewTodo); 348 showView(mListView, KOPrefs::instance()->mFullViewTodo);
352 //mFlagShowNextxDays = temp; 349 //mFlagShowNextxDays = temp;
353} 350}
354 351
355void KOViewManager::showAgendaView( bool fullScreen ) 352void KOViewManager::showAgendaView( bool fullScreen )
356{ 353{
357 354
358 mMainView->dialogManager()->hideSearchDialog(); 355 mMainView->dialogManager()->hideSearchDialog();
359 // qDebug("KOViewManager::showAgendaView "); 356 // qDebug("KOViewManager::showAgendaView ");
360 bool full; 357 bool full;
361 full = fullScreen; 358 full = fullScreen;
362 if (!mAgendaView) { 359 if (!mAgendaView) {
363 full = false; 360 full = false;
364 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 361 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
365 addView(mAgendaView); 362 addView(mAgendaView);
366#ifndef DESKTOP_VERSION 363#ifndef DESKTOP_VERSION
367 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 364 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
368#endif 365#endif
369 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 366 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
370 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 367 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
371 368
372 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 369 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
373 370
374 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 371 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
375 372
376 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 373 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
377 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 374 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
378 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 375 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
379 mMainView, SLOT(newEvent(QDateTime))); 376 mMainView, SLOT(newEvent(QDateTime)));
380 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 377 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
381 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 378 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
382 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 379 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
383 mMainView, SLOT(newEvent(QDate))); 380 mMainView, SLOT(newEvent(QDate)));
384 381
385 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 382 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
386 mMainView, SLOT(editIncidence(Incidence *))); 383 mMainView, SLOT(editIncidence(Incidence *)));
387 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 384 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
388 mMainView, SLOT(showIncidence(Incidence *))); 385 mMainView, SLOT(showIncidence(Incidence *)));
389 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 386 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
390 mMainView, SLOT(deleteIncidence(Incidence *))); 387 mMainView, SLOT(deleteIncidence(Incidence *)));
391 388
392 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 389 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
393 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 390 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
394 391
395 connect(mAgendaView, SIGNAL( toggleExpand() ), 392 connect(mAgendaView, SIGNAL( toggleExpand() ),
396 mMainView, SLOT( toggleExpand() ) ); 393 mMainView, SLOT( toggleExpand() ) );
397 394
398 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 395 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
399 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 396 mAgendaView, SLOT( setExpandedButton( bool ) ) );
400 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 397 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
401 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 398 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
402 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 399 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
403 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 400 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
404 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 401 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
405 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 402 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
406 SLOT( updateTodo( Todo *, int ) ) ); 403 SLOT( updateTodo( Todo *, int ) ) );
407 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 404 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
408 mMainView, SIGNAL( todoModified( Todo *, int ))); 405 mMainView, SIGNAL( todoModified( Todo *, int )));
409 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 406 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
410 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 407 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
411 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 408 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
412 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 409 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
413 mAgendaView->readSettings(); 410 mAgendaView->readSettings();
414 mAgendaView->updateConfig(); 411 mAgendaView->updateConfig();
415 } 412 }
416 413
417 showView( mAgendaView, full); 414 showView( mAgendaView, full);
418 415
419} 416}
420 417
421void KOViewManager::showDayView() 418void KOViewManager::showDayView()
422{ 419{
423 mFlagShowNextxDays = false; 420 mFlagShowNextxDays = false;
424 globalFlagBlockLabel = 1; 421 globalFlagBlockLabel = 1;
425 globalFlagBlockAgenda = 1; 422 globalFlagBlockAgenda = 1;
426 if ( mCurrentAgendaView != 1 ) 423 if ( mCurrentAgendaView != 1 )
427 mCurrentAgendaView = -1; 424 mCurrentAgendaView = -1;
428 showAgendaView(); 425 showAgendaView();
429 qApp->processEvents(); 426 qApp->processEvents();
430 globalFlagBlockAgenda = 2; 427 globalFlagBlockAgenda = 2;
431 globalFlagBlockLabel = 0; 428 globalFlagBlockLabel = 0;
432 mMainView->dateNavigator()->selectDates( 1 ); 429 mMainView->dateNavigator()->selectDates( 1 );
433 mCurrentAgendaView = 1 ; 430 mCurrentAgendaView = 1 ;
434 431
435} 432}
436 433
437void KOViewManager::showWorkWeekView() 434void KOViewManager::showWorkWeekView()
438{ 435{
439 mFlagShowNextxDays = false; 436 mFlagShowNextxDays = false;
440 globalFlagBlockAgenda = 1; 437 globalFlagBlockAgenda = 1;
441 globalFlagBlockLabel = 1; 438 globalFlagBlockLabel = 1;
442 if ( mCurrentAgendaView != 5 ) 439 if ( mCurrentAgendaView != 5 )
443 mCurrentAgendaView = -1; 440 mCurrentAgendaView = -1;
444 showAgendaView(); 441 showAgendaView();
445 qApp->processEvents(); 442 qApp->processEvents();
446 globalFlagBlockAgenda = 2; 443 globalFlagBlockAgenda = 2;
447 globalFlagBlockLabel = 0; 444 globalFlagBlockLabel = 0;
448 mMainView->dateNavigator()->selectWorkWeek(); 445 mMainView->dateNavigator()->selectWorkWeek();
449 mCurrentAgendaView = 5 ; 446 mCurrentAgendaView = 5 ;
450 447
451} 448}
452 449
453void KOViewManager::showWeekView() 450void KOViewManager::showWeekView()
454{ 451{
455 /* 452 /*
456 globalFlagBlockAgenda = 2; 453 globalFlagBlockAgenda = 2;
457 qDebug("4globalFlagBlockAgenda = 2; "); 454 qDebug("4globalFlagBlockAgenda = 2; ");
458 //globalFlagBlockPainting = true; 455 //globalFlagBlockPainting = true;
459 mMainView->dateNavigator()->selectWeek(); 456 mMainView->dateNavigator()->selectWeek();
460 showAgendaView(); 457 showAgendaView();
461 */ 458 */
462 459
463 460
464 mFlagShowNextxDays = false; 461 mFlagShowNextxDays = false;
465 globalFlagBlockAgenda = 1; 462 globalFlagBlockAgenda = 1;
466 globalFlagBlockLabel = 1; 463 globalFlagBlockLabel = 1;
467 if ( mCurrentAgendaView != 7 ) 464 if ( mCurrentAgendaView != 7 )
468 mCurrentAgendaView = -1; 465 mCurrentAgendaView = -1;
469 showAgendaView(); 466 showAgendaView();
470 qApp->processEvents(); 467 qApp->processEvents();
471 globalFlagBlockAgenda = 2; 468 globalFlagBlockAgenda = 2;
472 globalFlagBlockLabel = 0; 469 globalFlagBlockLabel = 0;
473 mMainView->dateNavigator()->selectWeek(); 470 mMainView->dateNavigator()->selectWeek();
474 mCurrentAgendaView = 7 ; 471 mCurrentAgendaView = 7 ;
475} 472}
476 473
477void KOViewManager::showNextXView() 474void KOViewManager::showNextXView()
478{ 475{
479 476
480 globalFlagBlockAgenda = 1; 477 globalFlagBlockAgenda = 1;
481 if ( mCurrentAgendaView != 3 ) 478 if ( mCurrentAgendaView != 3 )
482 mCurrentAgendaView = -1; 479 mCurrentAgendaView = -1;
483 showAgendaView(KOPrefs::instance()->mFullViewMonth); 480 showAgendaView(KOPrefs::instance()->mFullViewMonth);
484 globalFlagBlockAgenda = 2; 481 globalFlagBlockAgenda = 2;
485 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 482 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
486 KOPrefs::instance()->mNextXDays ); 483 KOPrefs::instance()->mNextXDays );
487 mFlagShowNextxDays = true; 484 mFlagShowNextxDays = true;
488 mCurrentAgendaView = 3 ; 485 mCurrentAgendaView = 3 ;
489} 486}
490bool KOViewManager::showsNextDays() 487bool KOViewManager::showsNextDays()
491{ 488{
492 return mFlagShowNextxDays; 489 return mFlagShowNextxDays;
493} 490}
494void KOViewManager::showMonthView() 491void KOViewManager::showMonthView()
495{ 492{
496 if (!mMonthView) { 493 if (!mMonthView) {
497 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 494 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
498 495
499 addView(mMonthView); 496 addView(mMonthView);
500 // mMonthView->show(); 497 // mMonthView->show();
501 // SIGNALS/SLOTS FOR MONTH VIEW 498 // SIGNALS/SLOTS FOR MONTH VIEW
502 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 499 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
503 mMainView, SLOT(newEvent(QDateTime))); 500 mMainView, SLOT(newEvent(QDateTime)));
504 501
505 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 502 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
506 mMainView, SLOT(showIncidence(Incidence *))); 503 mMainView, SLOT(showIncidence(Incidence *)));
507 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 504 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
508 mMainView, SLOT(editIncidence(Incidence *))); 505 mMainView, SLOT(editIncidence(Incidence *)));
509 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 506 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
510 mMainView, SLOT(deleteIncidence(Incidence *))); 507 mMainView, SLOT(deleteIncidence(Incidence *)));
511 508
512 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 509 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
513 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 510 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );