summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp16
-rw-r--r--korganizer/koeventviewer.cpp5
-rw-r--r--korganizer/koeventviewerdialog.cpp1
3 files changed, 17 insertions, 5 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index e0a1a21..1864e22 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -640,894 +640,900 @@ void KOAgendaView::createDayLabels()
640 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 640 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
641 //if ( needWid > maxWid ) 641 //if ( needWid > maxWid )
642 // qDebug("DAYLABELS TOOOOOOO BIG "); 642 // qDebug("DAYLABELS TOOOOOOO BIG ");
643 while ( needWid > maxWid ) { 643 while ( needWid > maxWid ) {
644 dayTest = dayTest.left( dayTest.length() - 1 ); 644 dayTest = dayTest.left( dayTest.length() - 1 );
645 wid = fm.width( dayTest ); 645 wid = fm.width( dayTest );
646 needWid = wid * selCount; 646 needWid = wid * selCount;
647 } 647 }
648 int maxLen = dayTest.length(); 648 int maxLen = dayTest.length();
649 int fontPoint = dlf.pointSize(); 649 int fontPoint = dlf.pointSize();
650 if ( maxLen < 2 ) { 650 if ( maxLen < 2 ) {
651 int fontPoint = dlf.pointSize(); 651 int fontPoint = dlf.pointSize();
652 while ( fontPoint > 4 ) { 652 while ( fontPoint > 4 ) {
653 --fontPoint; 653 --fontPoint;
654 dlf.setPointSize( fontPoint ); 654 dlf.setPointSize( fontPoint );
655 QFontMetrics f( dlf ); 655 QFontMetrics f( dlf );
656 wid = f.width( "20" ); 656 wid = f.width( "20" );
657 needWid = wid * selCount; 657 needWid = wid * selCount;
658 if ( needWid < maxWid ) 658 if ( needWid < maxWid )
659 break; 659 break;
660 } 660 }
661 maxLen = 2; 661 maxLen = 2;
662 } 662 }
663 //qDebug("Max len %d ", dayTest.length() ); 663 //qDebug("Max len %d ", dayTest.length() );
664 664
665 QFontMetrics tempF( dlf ); 665 QFontMetrics tempF( dlf );
666 newHight = tempF.height(); 666 newHight = tempF.height();
667 mDayLabels->setFont( dlf ); 667 mDayLabels->setFont( dlf );
668 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 668 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
669 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 669 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
670 //mLayoutDayLabels->addSpacing( 2 ); 670 //mLayoutDayLabels->addSpacing( 2 );
671 // QFont lFont = dlf; 671 // QFont lFont = dlf;
672 bool appendLabels = false; 672 bool appendLabels = false;
673 QLabel *dayLabel; 673 QLabel *dayLabel;
674 dayLabel = mDayLabelsList.first(); 674 dayLabel = mDayLabelsList.first();
675 if ( !dayLabel ) { 675 if ( !dayLabel ) {
676 appendLabels = true; 676 appendLabels = true;
677 dayLabel = new QLabel(mDayLabels); 677 dayLabel = new QLabel(mDayLabels);
678 mDayLabelsList.append( dayLabel ); 678 mDayLabelsList.append( dayLabel );
679 mLayoutDayLabels->addWidget(dayLabel); 679 mLayoutDayLabels->addWidget(dayLabel);
680 } 680 }
681 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 681 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
682 dayLabel->setFont( dlf ); 682 dayLabel->setFont( dlf );
683 dayLabel->setAlignment(QLabel::AlignHCenter); 683 dayLabel->setAlignment(QLabel::AlignHCenter);
684 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 684 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
685 dayLabel->show(); 685 dayLabel->show();
686 DateList::ConstIterator dit; 686 DateList::ConstIterator dit;
687 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 687 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
688 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 688 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
689 QDate date = *dit; 689 QDate date = *dit;
690 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 690 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
691 if ( ! appendLabels ) { 691 if ( ! appendLabels ) {
692 dayLabel = mDayLabelsList.next(); 692 dayLabel = mDayLabelsList.next();
693 if ( !dayLabel ) 693 if ( !dayLabel )
694 appendLabels = true; 694 appendLabels = true;
695 } 695 }
696 if ( appendLabels ) { 696 if ( appendLabels ) {
697 dayLabel = new QLabel(mDayLabels); 697 dayLabel = new QLabel(mDayLabels);
698 mDayLabelsList.append( dayLabel ); 698 mDayLabelsList.append( dayLabel );
699 mLayoutDayLabels->addWidget(dayLabel); 699 mLayoutDayLabels->addWidget(dayLabel);
700 } 700 }
701 dayLabel->setMinimumWidth( 1 ); 701 dayLabel->setMinimumWidth( 1 );
702 dayLabel->setMaximumWidth( 2048 ); 702 dayLabel->setMaximumWidth( 2048 );
703 dayLabel->setFont( dlf ); 703 dayLabel->setFont( dlf );
704 dayLabel->show(); 704 dayLabel->show();
705 QString str; 705 QString str;
706 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 706 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
707 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 707 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
708 switch ( maxLen ) { 708 switch ( maxLen ) {
709 case 2: 709 case 2:
710 str = QString::number( date.day() ); 710 str = QString::number( date.day() );
711 break; 711 break;
712 712
713 case 3: 713 case 3:
714 str = dayName.left( 1 ) +QString::number( date.day()); 714 str = dayName.left( 1 ) +QString::number( date.day());
715 715
716 break; 716 break;
717 case 4: 717 case 4:
718 str = dayName.left( 1 ) + " " +QString::number( date.day()); 718 str = dayName.left( 1 ) + " " +QString::number( date.day());
719 719
720 break; 720 break;
721 case 5: 721 case 5:
722 str = dayName.left( 2 ) + " " +QString::number( date.day()); 722 str = dayName.left( 2 ) + " " +QString::number( date.day());
723 723
724 break; 724 break;
725 case 6: 725 case 6:
726 str = dayName.left( 3 ) + " " +QString::number( date.day()); 726 str = dayName.left( 3 ) + " " +QString::number( date.day());
727 break; 727 break;
728 728
729 default: 729 default:
730 break; 730 break;
731 } 731 }
732 if ( oneday ) { 732 if ( oneday ) {
733 QString addString; 733 QString addString;
734 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 734 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
735 addString = i18n("Today"); 735 addString = i18n("Today");
736 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 736 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
737 addString = i18n("Tomorrow"); 737 addString = i18n("Tomorrow");
738 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 738 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
739 addString = i18n("Yesterday"); 739 addString = i18n("Yesterday");
740 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 740 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
741 addString = i18n("Day before yesterday"); 741 addString = i18n("Day before yesterday");
742 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 742 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
743 addString = i18n("Day after tomorrow"); 743 addString = i18n("Day after tomorrow");
744 if ( !addString.isEmpty() ) { 744 if ( !addString.isEmpty() ) {
745 str = addString+", " + str; 745 str = addString+", " + str;
746 } 746 }
747 } 747 }
748 dayLabel->setText(str); 748 dayLabel->setText(str);
749 dayLabel->setAlignment(QLabel::AlignHCenter); 749 dayLabel->setAlignment(QLabel::AlignHCenter);
750 if (date == QDate::currentDate()) { 750 if (date == QDate::currentDate()) {
751 QFont bFont = dlf; 751 QFont bFont = dlf;
752 bFont.setBold( true ); 752 bFont.setBold( true );
753 dayLabel->setFont(bFont); 753 dayLabel->setFont(bFont);
754 } 754 }
755 //dayLayout->addWidget(dayLabel); 755 //dayLayout->addWidget(dayLabel);
756 756
757#ifndef KORG_NOPLUGINS 757#ifndef KORG_NOPLUGINS
758 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 758 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
759 CalendarDecoration *it; 759 CalendarDecoration *it;
760 for(it = cds.first(); it; it = cds.next()) { 760 for(it = cds.first(); it; it = cds.next()) {
761 QString text = it->shortText( date ); 761 QString text = it->shortText( date );
762 if ( !text.isEmpty() ) { 762 if ( !text.isEmpty() ) {
763 QLabel *label = new QLabel(text,mDayLabels); 763 QLabel *label = new QLabel(text,mDayLabels);
764 label->setAlignment(AlignCenter); 764 label->setAlignment(AlignCenter);
765 dayLayout->addWidget(label); 765 dayLayout->addWidget(label);
766 } 766 }
767 } 767 }
768 768
769 for(it = cds.first(); it; it = cds.next()) { 769 for(it = cds.first(); it; it = cds.next()) {
770 QWidget *wid = it->smallWidget(mDayLabels,date); 770 QWidget *wid = it->smallWidget(mDayLabels,date);
771 if ( wid ) { 771 if ( wid ) {
772 // wid->setHeight(20); 772 // wid->setHeight(20);
773 dayLayout->addWidget(wid); 773 dayLayout->addWidget(wid);
774 } 774 }
775 } 775 }
776#endif 776#endif
777 } 777 }
778 if ( ! appendLabels ) { 778 if ( ! appendLabels ) {
779 dayLabel = mDayLabelsList.next(); 779 dayLabel = mDayLabelsList.next();
780 if ( !dayLabel ) 780 if ( !dayLabel )
781 appendLabels = true; 781 appendLabels = true;
782 } 782 }
783 if ( appendLabels ) { 783 if ( appendLabels ) {
784 dayLabel = new QLabel(mDayLabels); 784 dayLabel = new QLabel(mDayLabels);
785 mDayLabelsList.append( dayLabel ); 785 mDayLabelsList.append( dayLabel );
786 mLayoutDayLabels->addWidget(dayLabel); 786 mLayoutDayLabels->addWidget(dayLabel);
787 } 787 }
788 //dayLabel->hide();//test only 788 //dayLabel->hide();//test only
789 789
790 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 790 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
791 if ( offset < 0 ) offset = 0; 791 if ( offset < 0 ) offset = 0;
792 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 792 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
793 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); 793 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) );
794 dayLabel->show(); 794 dayLabel->show();
795 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 795 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
796 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 796 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
797 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 797 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
798 if ( !appendLabels ) { 798 if ( !appendLabels ) {
799 dayLabel = mDayLabelsList.next(); 799 dayLabel = mDayLabelsList.next();
800 while ( dayLabel ) { 800 while ( dayLabel ) {
801 //qDebug("!dayLabel %d",dayLabel ); 801 //qDebug("!dayLabel %d",dayLabel );
802 dayLabel->hide(); 802 dayLabel->hide();
803 dayLabel = mDayLabelsList.next(); 803 dayLabel = mDayLabelsList.next();
804 } 804 }
805 } 805 }
806 //mDayLabelsFrame->show(); 806 //mDayLabelsFrame->show();
807 //mDayLabels->show(); 807 //mDayLabels->show();
808 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 808 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
809 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 809 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
810 mDayLabelsFrame->setFixedHeight( newHight ); 810 mDayLabelsFrame->setFixedHeight( newHight );
811} 811}
812 812
813int KOAgendaView::maxDatesHint() 813int KOAgendaView::maxDatesHint()
814{ 814{
815 // Not sure about the max number of events, so return 0 for now. 815 // Not sure about the max number of events, so return 0 for now.
816 return 0; 816 return 0;
817} 817}
818 818
819int KOAgendaView::currentDateCount() 819int KOAgendaView::currentDateCount()
820{ 820{
821 return mSelectedDates.count(); 821 return mSelectedDates.count();
822} 822}
823 823
824QPtrList<Incidence> KOAgendaView::selectedIncidences() 824QPtrList<Incidence> KOAgendaView::selectedIncidences()
825{ 825{
826 QPtrList<Incidence> selected; 826 QPtrList<Incidence> selected;
827 Incidence *incidence; 827 Incidence *incidence;
828 828
829 incidence = mAgenda->selectedIncidence(); 829 incidence = mAgenda->selectedIncidence();
830 if (incidence) selected.append(incidence); 830 if (incidence) selected.append(incidence);
831 831
832 incidence = mAllDayAgenda->selectedIncidence(); 832 incidence = mAllDayAgenda->selectedIncidence();
833 if (incidence) selected.append(incidence); 833 if (incidence) selected.append(incidence);
834 834
835 return selected; 835 return selected;
836} 836}
837 837
838DateList KOAgendaView::selectedDates() 838DateList KOAgendaView::selectedDates()
839{ 839{
840 DateList selected; 840 DateList selected;
841 QDate qd; 841 QDate qd;
842 842
843 qd = mAgenda->selectedIncidenceDate(); 843 qd = mAgenda->selectedIncidenceDate();
844 if (qd.isValid()) selected.append(qd); 844 if (qd.isValid()) selected.append(qd);
845 845
846 qd = mAllDayAgenda->selectedIncidenceDate(); 846 qd = mAllDayAgenda->selectedIncidenceDate();
847 if (qd.isValid()) selected.append(qd); 847 if (qd.isValid()) selected.append(qd);
848 848
849 return selected; 849 return selected;
850} 850}
851 851
852 852
853void KOAgendaView::updateView() 853void KOAgendaView::updateView()
854{ 854{
855 if ( mBlockUpdating ) 855 if ( mBlockUpdating )
856 return; 856 return;
857 // kdDebug() << "KOAgendaView::updateView()" << endl; 857 // kdDebug() << "KOAgendaView::updateView()" << endl;
858 fillAgenda(); 858 fillAgenda();
859 859
860} 860}
861 861
862 862
863/* 863/*
864 Update configuration settings for the agenda view. This method is not 864 Update configuration settings for the agenda view. This method is not
865 complete. 865 complete.
866*/ 866*/
867void KOAgendaView::updateConfig() 867void KOAgendaView::updateConfig()
868{ 868{
869 if ( mBlockUpdating ) 869 if ( mBlockUpdating )
870 return; 870 return;
871 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 871 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
872 872
873 // update config for children 873 // update config for children
874 mTimeLabels->updateConfig(); 874 mTimeLabels->updateConfig();
875 mAgenda->storePosition(); 875 mAgenda->storePosition();
876 mAgenda->updateConfig(); 876 mAgenda->updateConfig();
877 mAllDayAgenda->updateConfig(); 877 mAllDayAgenda->updateConfig();
878 // widget synchronization 878 // widget synchronization
879 //TODO: find a better way, maybe signal/slot 879 //TODO: find a better way, maybe signal/slot
880 mTimeLabels->positionChanged(); 880 mTimeLabels->positionChanged();
881 881
882 // for some reason, this needs to be called explicitly 882 // for some reason, this needs to be called explicitly
883 mTimeLabels->repaint(); 883 mTimeLabels->repaint();
884 884
885 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 885 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
886 886
887 // ToolTips displaying summary of events 887 // ToolTips displaying summary of events
888 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 888 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
889 ->mEnableToolTips); 889 ->mEnableToolTips);
890 890
891 //setHolidayMasks(); 891 //setHolidayMasks();
892 892
893 //createDayLabels(); called by via updateView(); 893 //createDayLabels(); called by via updateView();
894 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 894 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
895 updateView(); 895 updateView();
896 mAgenda->restorePosition(); 896 mAgenda->restorePosition();
897} 897}
898 898
899 899
900void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 900void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
901{ 901{
902 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 902 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
903 //qDebug("KOAgendaView::updateEventDates "); 903 //qDebug("KOAgendaView::updateEventDates ");
904 QDateTime startDt,endDt; 904 QDateTime startDt,endDt;
905 QDate startDate; 905 QDate startDate;
906 int lenInSecs; 906 int lenInSecs;
907 // if ( type == KOAgenda::RESIZETOP ) 907 // if ( type == KOAgenda::RESIZETOP )
908 // qDebug("RESIZETOP "); 908 // qDebug("RESIZETOP ");
909 // if ( type == KOAgenda::RESIZEBOTTOM ) 909 // if ( type == KOAgenda::RESIZEBOTTOM )
910 // qDebug("RESIZEBOTTOM "); 910 // qDebug("RESIZEBOTTOM ");
911 // if ( type == KOAgenda::MOVE ) 911 // if ( type == KOAgenda::MOVE )
912 // qDebug("MOVE "); 912 // qDebug("MOVE ");
913 if ( item->incidence()->type() == "Event" ) { 913 if ( item->incidence()->type() == "Event" ) {
914 startDt =item->incidence()->dtStart(); 914 startDt =item->incidence()->dtStart();
915 endDt = item->incidence()->dtEnd(); 915 endDt = item->incidence()->dtEnd();
916 lenInSecs = startDt.secsTo( endDt ); 916 lenInSecs = startDt.secsTo( endDt );
917 } 917 }
918 918
919 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 919 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
920 920
921 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 921 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
922 startDate = mSelectedDates[item->mLastMoveXPos]; 922 startDate = mSelectedDates[item->mLastMoveXPos];
923 } else { 923 } else {
924 if (item->cellX() < 0) { 924 if (item->cellX() < 0) {
925 startDate = (mSelectedDates.first()).addDays(item->cellX()); 925 startDate = (mSelectedDates.first()).addDays(item->cellX());
926 } else { 926 } else {
927 startDate = mSelectedDates[item->cellX()]; 927 startDate = mSelectedDates[item->cellX()];
928 } 928 }
929 } 929 }
930 startDt.setDate(startDate); 930 startDt.setDate(startDate);
931 931
932 if (item->incidence()->doesFloat()) { 932 if (item->incidence()->doesFloat()) {
933 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 933 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
934 } else { 934 } else {
935 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 935 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
936 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 936 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
937 if ( item->incidence()->type() == "Event" ) { 937 if ( item->incidence()->type() == "Event" ) {
938 if ( type == KOAgenda::MOVE ) { 938 if ( type == KOAgenda::MOVE ) {
939 endDt = startDt.addSecs(lenInSecs); 939 endDt = startDt.addSecs(lenInSecs);
940 940
941 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 941 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
942 if (item->lastMultiItem()) { 942 if (item->lastMultiItem()) {
943 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 943 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
944 endDt.setDate(startDate. 944 endDt.setDate(startDate.
945 addDays(item->lastMultiItem()->cellX() - item->cellX())); 945 addDays(item->lastMultiItem()->cellX() - item->cellX()));
946 } else { 946 } else {
947 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 947 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
948 endDt.setDate(startDate); 948 endDt.setDate(startDate);
949 } 949 }
950 } 950 }
951 } else { 951 } else {
952 // todo 952 // todo
953 if (item->lastMultiItem()) { 953 if (item->lastMultiItem()) {
954 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 954 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
955 endDt.setDate(startDate. 955 endDt.setDate(startDate.
956 addDays(item->lastMultiItem()->cellX() - item->cellX())); 956 addDays(item->lastMultiItem()->cellX() - item->cellX()));
957 } else { 957 } else {
958 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 958 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
959 if ( item->cellYBottom() > 0 ) 959 if ( item->cellYBottom() > 0 )
960 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 960 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
961 else 961 else
962 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 962 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
963 endDt.setDate(startDate); 963 endDt.setDate(startDate);
964 } 964 }
965 } 965 }
966 } 966 }
967 967
968 968
969 if ( item->incidence()->type() == "Event" ) { 969 if ( item->incidence()->type() == "Event" ) {
970 item->incidence()->setDtStart(startDt); 970 item->incidence()->setDtStart(startDt);
971 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 971 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
972 } else if ( item->incidence()->type() == "Todo" ) { 972 } else if ( item->incidence()->type() == "Todo" ) {
973 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 973 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
974 } 974 }
975 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 975 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
976 item->incidence()->setRevision(item->incidence()->revision()+1); 976 item->incidence()->setRevision(item->incidence()->revision()+1);
977 item->setItemDate(startDt.date()); 977 item->setItemDate(startDt.date());
978 //item->updateItem(); 978 //item->updateItem();
979 if ( item->incidence()->type() == "Todo" ) { 979 if ( item->incidence()->type() == "Todo" ) {
980 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 980 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
981 981
982 } 982 }
983 else 983 else
984 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 984 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
985 item->updateItem(); 985 item->updateItem();
986} 986}
987 987
988void KOAgendaView::showDates( const QDate &start, const QDate &end ) 988void KOAgendaView::showDates( const QDate &start, const QDate &end )
989{ 989{
990 // kdDebug() << "KOAgendaView::selectDates" << endl; 990 // kdDebug() << "KOAgendaView::selectDates" << endl;
991 991
992 mSelectedDates.clear(); 992 mSelectedDates.clear();
993 // qDebug("KOAgendaView::showDates "); 993 // qDebug("KOAgendaView::showDates ");
994 QDate d = start; 994 QDate d = start;
995 while (d <= end) { 995 while (d <= end) {
996 mSelectedDates.append(d); 996 mSelectedDates.append(d);
997 d = d.addDays( 1 ); 997 d = d.addDays( 1 );
998 } 998 }
999 999
1000 // and update the view 1000 // and update the view
1001 fillAgenda(); 1001 fillAgenda();
1002} 1002}
1003 1003
1004 1004
1005void KOAgendaView::showEvents(QPtrList<Event>) 1005void KOAgendaView::showEvents(QPtrList<Event>)
1006{ 1006{
1007 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1007 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1008} 1008}
1009 1009
1010void KOAgendaView::changeEventDisplay(Event *, int) 1010void KOAgendaView::changeEventDisplay(Event *, int)
1011{ 1011{
1012 // qDebug("KOAgendaView::changeEventDisplay "); 1012 // qDebug("KOAgendaView::changeEventDisplay ");
1013 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1013 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1014 // this should be re-written to be MUCH smarter. Right now we 1014 // this should be re-written to be MUCH smarter. Right now we
1015 // are just playing dumb. 1015 // are just playing dumb.
1016 fillAgenda(); 1016 fillAgenda();
1017} 1017}
1018 1018
1019void KOAgendaView::fillAgenda(const QDate &) 1019void KOAgendaView::fillAgenda(const QDate &)
1020{ 1020{
1021 // qDebug("KOAgendaView::fillAgenda "); 1021 // qDebug("KOAgendaView::fillAgenda ");
1022 fillAgenda(); 1022 fillAgenda();
1023} 1023}
1024 1024
1025void KOAgendaView::fillAgenda() 1025void KOAgendaView::fillAgenda()
1026{ 1026{
1027 if ( globalFlagBlockStartup ) 1027 if ( globalFlagBlockStartup )
1028 return; 1028 return;
1029 if ( globalFlagBlockAgenda == 1 ) 1029 if ( globalFlagBlockAgenda == 1 )
1030 return; 1030 return;
1031 //if ( globalFlagBlockAgenda == 2 ) 1031 //if ( globalFlagBlockAgenda == 2 )
1032 //globalFlagBlockAgenda = 0; 1032 //globalFlagBlockAgenda = 0;
1033 // globalFlagBlockPainting = false; 1033 // globalFlagBlockPainting = false;
1034 if ( globalFlagBlockAgenda == 0 ) 1034 if ( globalFlagBlockAgenda == 0 )
1035 globalFlagBlockAgenda = 1; 1035 globalFlagBlockAgenda = 1;
1036 // clearView(); 1036 // clearView();
1037 //qDebug("fillAgenda()++++ "); 1037 //qDebug("fillAgenda()++++ ");
1038 globalFlagBlockAgendaItemPaint = 1; 1038 globalFlagBlockAgendaItemPaint = 1;
1039 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1039 mAllDayAgenda->changeColumns(mSelectedDates.count());
1040 mAgenda->changeColumns(mSelectedDates.count()); 1040 mAgenda->changeColumns(mSelectedDates.count());
1041 qApp->processEvents(); 1041 qApp->processEvents();
1042 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1042 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1043 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1043 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1044 setHolidayMasks(); 1044 setHolidayMasks();
1045 1045
1046 //mAgenda->hideUnused(); 1046 //mAgenda->hideUnused();
1047 //mAllDayAgenda->hideUnused(); 1047 //mAllDayAgenda->hideUnused();
1048 1048
1049 // mAgenda->blockNextRepaint( false ); 1049 // mAgenda->blockNextRepaint( false );
1050 // mAgenda->viewport()->repaint(); 1050 // mAgenda->viewport()->repaint();
1051 // mAgenda->blockNextRepaint( true ); 1051 // mAgenda->blockNextRepaint( true );
1052 mMinY.resize(mSelectedDates.count()); 1052 mMinY.resize(mSelectedDates.count());
1053 mMaxY.resize(mSelectedDates.count()); 1053 mMaxY.resize(mSelectedDates.count());
1054 1054
1055 QPtrList<Event> dayEvents; 1055 QPtrList<Event> dayEvents;
1056 1056
1057 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1057 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1058 // Therefore, get all of them. 1058 // Therefore, get all of them.
1059 QPtrList<Todo> todos = calendar()->todos(); 1059 QPtrList<Todo> todos = calendar()->todos();
1060 1060
1061 mAgenda->setDateList(mSelectedDates); 1061 mAgenda->setDateList(mSelectedDates);
1062 1062
1063 QDate today = QDate::currentDate(); 1063 QDate today = QDate::currentDate();
1064 1064
1065 DateList::ConstIterator dit; 1065 DateList::ConstIterator dit;
1066 int curCol = 0; 1066 int curCol = 0;
1067 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1067 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1068 QDate currentDate = *dit; 1068 QDate currentDate = *dit;
1069 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1069 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1070 // << endl; 1070 // << endl;
1071 1071
1072 dayEvents = calendar()->events(currentDate,true); 1072 dayEvents = calendar()->events(currentDate,true);
1073 1073
1074 // Default values, which can never be reached 1074 // Default values, which can never be reached
1075 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1075 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1076 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1076 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1077 1077
1078 unsigned int numEvent; 1078 unsigned int numEvent;
1079 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1079 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1080 Event *event = dayEvents.at(numEvent); 1080 Event *event = dayEvents.at(numEvent);
1081 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1081 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1082 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1082 if ( event->uid().left(15) == QString("last-syncEvent-") )
1083 continue; 1083 continue;
1084 // kdDebug() << " Event: " << event->summary() << endl; 1084 // kdDebug() << " Event: " << event->summary() << endl;
1085 1085
1086 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1086 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1087 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1087 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1088 1088
1089 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1089 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1090 1090
1091 if (event->doesFloat()) { 1091 if (event->doesFloat()) {
1092 if (event->recurrence()->doesRecur()) { 1092 if (event->recurrence()->doesRecur()) {
1093 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1093 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1094 } else { 1094 } else {
1095 if (beginX <= 0 && curCol == 0) { 1095 if (beginX <= 0 && curCol == 0) {
1096 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1096 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1097 } else if (beginX == curCol) { 1097 } else if (beginX == curCol) {
1098 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1098 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1099 } 1099 }
1100 } 1100 }
1101 } else if (event->isMultiDay()) { 1101 } else if (event->isMultiDay()) {
1102 if ( event->doesRecur () ) { 1102 if ( event->doesRecur () ) {
1103 QDate dateit = currentDate; 1103 QDate dateit = currentDate;
1104 int count = 0; 1104 int count = 0;
1105 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1105 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1106 while (! event->recursOn( dateit ) && count <= max ) { 1106 while (! event->recursOn( dateit ) && count <= max ) {
1107 ++count; 1107 ++count;
1108 dateit = dateit.addDays( -1 ); 1108 dateit = dateit.addDays( -1 );
1109 } 1109 }
1110 bool ok; 1110 bool ok;
1111 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1111 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1112 if ( ok ) 1112 if ( ok )
1113 { 1113 {
1114 int secs = event->dtStart().secsTo( event->dtEnd() ); 1114 int secs = event->dtStart().secsTo( event->dtEnd() );
1115 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1115 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1116 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1116 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1117 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1117 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1118 1118
1119 } 1119 }
1120 } 1120 }
1121 int startY = mAgenda->timeToY(event->dtStart().time()); 1121 int startY = mAgenda->timeToY(event->dtStart().time());
1122 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1122 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1123 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1123 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1124 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1124 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1125 //qDebug("insert!!! "); 1125 //qDebug("insert!!! ");
1126 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1126 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1127 } 1127 }
1128 if (beginX == curCol) { 1128 if (beginX == curCol) {
1129 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1129 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1130 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1130 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1131 } else if (endX == curCol) { 1131 } else if (endX == curCol) {
1132 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1132 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1133 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1133 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1134 } else { 1134 } else {
1135 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1135 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1136 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1136 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1137 } 1137 }
1138 } else { 1138 } else {
1139 int startY = mAgenda->timeToY(event->dtStart().time()); 1139 int startY = mAgenda->timeToY(event->dtStart().time());
1140 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1140 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1141 if (endY < startY) endY = startY; 1141 if (endY < startY) endY = startY;
1142 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1142 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1143 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1143 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1144 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1144 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1145 } 1145 }
1146 } 1146 }
1147 // ---------- [display Todos -------------- 1147 // ---------- [display Todos --------------
1148 unsigned int numTodo; 1148 unsigned int numTodo;
1149 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1149 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1150 Todo *todo = todos.at(numTodo); 1150 Todo *todo = todos.at(numTodo);
1151 1151
1152 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1152 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1153 1153
1154 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1154 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1155 // Already completed items can be displayed on their original due date 1155 // Already completed items can be displayed on their original due date
1156 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1156 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1157 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1157 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1158 1158
1159 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1159 if ( ((todo->dtDue().date() == currentDate) && !overdue) || ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1160 ((currentDate == today) && overdue) ) { 1160 ((currentDate == today) && overdue) ) {
1161 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1161 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1162 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1162 if ( KOPrefs::instance()->mShowTodoInAgenda )
1163 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1163 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1164 } 1164 }
1165 else { 1165 else {
1166 1166 QDateTime dt;
1167 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1167 if ( todo->hasCompletedDate() )
1168 dt = todo->completed();
1169 else
1170 dt = todo->dtDue();;
1171
1172
1173 int endY = mAgenda->timeToY(dt.time()) - 1;
1168 int hi = (18/KOPrefs::instance()->mHourSize); 1174 int hi = (18/KOPrefs::instance()->mHourSize);
1169 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1175 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1170 int startY = endY -hi; 1176 int startY = endY -hi;
1171 1177
1172 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1178 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1173 1179
1174 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1180 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1175 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1181 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1176 } 1182 }
1177 } 1183 }
1178 } 1184 }
1179 // ---------- display Todos] -------------- 1185 // ---------- display Todos] --------------
1180 1186
1181 ++curCol; 1187 ++curCol;
1182 } 1188 }
1183 mAgenda->hideUnused(); 1189 mAgenda->hideUnused();
1184 mAllDayAgenda->hideUnused(); 1190 mAllDayAgenda->hideUnused();
1185 mAgenda->checkScrollBoundaries(); 1191 mAgenda->checkScrollBoundaries();
1186 1192
1187 deleteSelectedDateTime(); 1193 deleteSelectedDateTime();
1188 1194
1189 createDayLabels(); 1195 createDayLabels();
1190 emit incidenceSelected( 0 ); 1196 emit incidenceSelected( 0 );
1191 1197
1192 if ( globalFlagBlockAgenda == 2 ) { 1198 if ( globalFlagBlockAgenda == 2 ) {
1193 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1199 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1194 setStartHour( KOPrefs::instance()->mDayBegins ); 1200 setStartHour( KOPrefs::instance()->mDayBegins );
1195 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1201 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1196 setStartHour( QTime::currentTime ().hour() ); 1202 setStartHour( QTime::currentTime ().hour() );
1197 // qApp->processEvents(); 1203 // qApp->processEvents();
1198 } 1204 }
1199 qApp->processEvents(); 1205 qApp->processEvents();
1200 //qDebug("qApp->processEvents(); END "); 1206 //qDebug("qApp->processEvents(); END ");
1201 globalFlagBlockAgenda = 0; 1207 globalFlagBlockAgenda = 0;
1202 1208
1203 // mAgenda->hideUnused(); 1209 // mAgenda->hideUnused();
1204 //mAllDayAgenda->hideUnused(); 1210 //mAllDayAgenda->hideUnused();
1205 mAllDayAgenda->drawContentsToPainter(); 1211 mAllDayAgenda->drawContentsToPainter();
1206 mAgenda->drawContentsToPainter(); 1212 mAgenda->drawContentsToPainter();
1207 repaintAgenda(); 1213 repaintAgenda();
1208 // mAgenda->finishUpdate(); 1214 // mAgenda->finishUpdate();
1209 //mAllDayAgenda->finishUpdate(); 1215 //mAllDayAgenda->finishUpdate();
1210 1216
1211 // repaintAgenda(); 1217 // repaintAgenda();
1212 //qApp->processEvents(); 1218 //qApp->processEvents();
1213 // globalFlagBlockAgenda = 0; 1219 // globalFlagBlockAgenda = 0;
1214} 1220}
1215void KOAgendaView::repaintAgenda() 1221void KOAgendaView::repaintAgenda()
1216{ 1222{
1217 // mAllDayAgenda->drawContentsToPainter(); 1223 // mAllDayAgenda->drawContentsToPainter();
1218// mAllDayAgenda->viewport()->repaint( false ); 1224// mAllDayAgenda->viewport()->repaint( false );
1219// mAgenda->drawContentsToPainter(); 1225// mAgenda->drawContentsToPainter();
1220// mAgenda->viewport()->repaint( false ); 1226// mAgenda->viewport()->repaint( false );
1221// qApp->processEvents(); 1227// qApp->processEvents();
1222 1228
1223 //qDebug("KOAgendaView::repaintAgenda() "); 1229 //qDebug("KOAgendaView::repaintAgenda() ");
1224 //qApp->processEvents(); 1230 //qApp->processEvents();
1225 mAgenda->viewport()->repaint( false ); 1231 mAgenda->viewport()->repaint( false );
1226 mAllDayAgenda->viewport()->repaint( false ); 1232 mAllDayAgenda->viewport()->repaint( false );
1227 mAgenda->finishUpdate(); 1233 mAgenda->finishUpdate();
1228 mAllDayAgenda->finishUpdate(); 1234 mAllDayAgenda->finishUpdate();
1229} 1235}
1230 1236
1231 1237
1232void KOAgendaView::clearView() 1238void KOAgendaView::clearView()
1233{ 1239{
1234 // kdDebug() << "ClearView" << endl; 1240 // kdDebug() << "ClearView" << endl;
1235 mAllDayAgenda->clear(); 1241 mAllDayAgenda->clear();
1236 mAgenda->clear(); 1242 mAgenda->clear();
1237} 1243}
1238 1244
1239void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1245void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1240 const QDate &td) 1246 const QDate &td)
1241{ 1247{
1242#ifndef KORG_NOPRINTER 1248#ifndef KORG_NOPRINTER
1243 if (fd == td) 1249 if (fd == td)
1244 calPrinter->preview(CalPrinter::Day, fd, td); 1250 calPrinter->preview(CalPrinter::Day, fd, td);
1245 else 1251 else
1246 calPrinter->preview(CalPrinter::Week, fd, td); 1252 calPrinter->preview(CalPrinter::Week, fd, td);
1247#endif 1253#endif
1248} 1254}
1249 1255
1250// void KOAgendaView::updateMovedTodo() 1256// void KOAgendaView::updateMovedTodo()
1251// { 1257// {
1252// // updateConfig(); 1258// // updateConfig();
1253// // emit updateTodoViews(); 1259// // emit updateTodoViews();
1254// } 1260// }
1255 1261
1256void KOAgendaView::newEvent(int gx, int gy) 1262void KOAgendaView::newEvent(int gx, int gy)
1257{ 1263{
1258 if (!mSelectedDates.count()) return; 1264 if (!mSelectedDates.count()) return;
1259 1265
1260 QDate day = mSelectedDates[gx]; 1266 QDate day = mSelectedDates[gx];
1261 1267
1262 QTime time = mAgenda->gyToTime(gy); 1268 QTime time = mAgenda->gyToTime(gy);
1263 QDateTime dt(day,time); 1269 QDateTime dt(day,time);
1264 // if ( dt < QDateTime::currentDateTime () ) 1270 // if ( dt < QDateTime::currentDateTime () )
1265 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1271 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1266 emit newEventSignal(dt); 1272 emit newEventSignal(dt);
1267} 1273}
1268 1274
1269void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1275void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1270{ 1276{
1271 if (!mSelectedDates.count()) return; 1277 if (!mSelectedDates.count()) return;
1272 1278
1273 QDate dayStart = mSelectedDates[gxStart]; 1279 QDate dayStart = mSelectedDates[gxStart];
1274 QDate dayEnd = mSelectedDates[gxEnd]; 1280 QDate dayEnd = mSelectedDates[gxEnd];
1275 1281
1276 QTime timeStart = mAgenda->gyToTime(gyStart); 1282 QTime timeStart = mAgenda->gyToTime(gyStart);
1277 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1283 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1278 1284
1279 QDateTime dtStart(dayStart,timeStart); 1285 QDateTime dtStart(dayStart,timeStart);
1280 QDateTime dtEnd(dayEnd,timeEnd); 1286 QDateTime dtEnd(dayEnd,timeEnd);
1281 1287
1282 emit newEventSignal(dtStart,dtEnd); 1288 emit newEventSignal(dtStart,dtEnd);
1283} 1289}
1284 1290
1285void KOAgendaView::newEventAllDay(int gx, int ) 1291void KOAgendaView::newEventAllDay(int gx, int )
1286{ 1292{
1287 if (!mSelectedDates.count()) return; 1293 if (!mSelectedDates.count()) return;
1288 1294
1289 QDate day = mSelectedDates[gx]; 1295 QDate day = mSelectedDates[gx];
1290 1296
1291 emit newEventSignal(day); 1297 emit newEventSignal(day);
1292} 1298}
1293void KOAgendaView::newTodoAllDay(int gx, int ) 1299void KOAgendaView::newTodoAllDay(int gx, int )
1294{ 1300{
1295 if (!mSelectedDates.count()) return; 1301 if (!mSelectedDates.count()) return;
1296 1302
1297 QDateTime day (mSelectedDates[gx] ); 1303 QDateTime day (mSelectedDates[gx] );
1298 emit newTodoSignal(day, true); 1304 emit newTodoSignal(day, true);
1299} 1305}
1300void KOAgendaView::newTodo(int gx, int gy ) 1306void KOAgendaView::newTodo(int gx, int gy )
1301{ 1307{
1302 if (!mSelectedDates.count()) return; 1308 if (!mSelectedDates.count()) return;
1303 QDate dayStart = mSelectedDates[gx]; 1309 QDate dayStart = mSelectedDates[gx];
1304 QTime timeStart = mAgenda->gyToTime(gy); 1310 QTime timeStart = mAgenda->gyToTime(gy);
1305 QDateTime dt (dayStart,timeStart); 1311 QDateTime dt (dayStart,timeStart);
1306 emit newTodoSignal( dt, false ); 1312 emit newTodoSignal( dt, false );
1307} 1313}
1308 1314
1309void KOAgendaView::updateEventIndicatorTop(int newY) 1315void KOAgendaView::updateEventIndicatorTop(int newY)
1310{ 1316{
1311 uint i; 1317 uint i;
1312 for(i=0;i<mMinY.size();++i) { 1318 for(i=0;i<mMinY.size();++i) {
1313 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1319 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1314 else mEventIndicatorTop->enableColumn(i,false); 1320 else mEventIndicatorTop->enableColumn(i,false);
1315 } 1321 }
1316 1322
1317 mEventIndicatorTop->update(); 1323 mEventIndicatorTop->update();
1318} 1324}
1319 1325
1320void KOAgendaView::updateEventIndicatorBottom(int newY) 1326void KOAgendaView::updateEventIndicatorBottom(int newY)
1321{ 1327{
1322 uint i; 1328 uint i;
1323 for(i=0;i<mMaxY.size();++i) { 1329 for(i=0;i<mMaxY.size();++i) {
1324 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1330 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1325 else mEventIndicatorBottom->enableColumn(i,false); 1331 else mEventIndicatorBottom->enableColumn(i,false);
1326 } 1332 }
1327 1333
1328 mEventIndicatorBottom->update(); 1334 mEventIndicatorBottom->update();
1329} 1335}
1330 1336
1331void KOAgendaView::startDrag(Event *event) 1337void KOAgendaView::startDrag(Event *event)
1332{ 1338{
1333#ifndef KORG_NODND 1339#ifndef KORG_NODND
1334 DndFactory factory( calendar() ); 1340 DndFactory factory( calendar() );
1335 ICalDrag *vd = factory.createDrag(event,this); 1341 ICalDrag *vd = factory.createDrag(event,this);
1336 if (vd->drag()) { 1342 if (vd->drag()) {
1337 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1343 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1338 } 1344 }
1339#endif 1345#endif
1340} 1346}
1341 1347
1342void KOAgendaView::readSettings() 1348void KOAgendaView::readSettings()
1343{ 1349{
1344 readSettings(KOGlobals::config()); 1350 readSettings(KOGlobals::config());
1345} 1351}
1346 1352
1347void KOAgendaView::readSettings(KConfig *config) 1353void KOAgendaView::readSettings(KConfig *config)
1348{ 1354{
1349 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1355 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1350 1356
1351 config->setGroup("Views"); 1357 config->setGroup("Views");
1352 1358
1353 //#ifndef KORG_NOSPLITTER 1359 //#ifndef KORG_NOSPLITTER
1354 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1360 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1355 if (sizes.count() == 2) { 1361 if (sizes.count() == 2) {
1356 if ( sizes[0] < 20 ) { 1362 if ( sizes[0] < 20 ) {
1357 sizes[1] = sizes[1] +20 - sizes[0]; 1363 sizes[1] = sizes[1] +20 - sizes[0];
1358 sizes[0] = 20; 1364 sizes[0] = 20;
1359 } 1365 }
1360 mSplitterAgenda->setSizes(sizes); 1366 mSplitterAgenda->setSizes(sizes);
1361 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1367 // qDebug("read %d %d ",sizes[0],sizes[1] );
1362 } 1368 }
1363 //#endif 1369 //#endif
1364 1370
1365 // updateConfig(); 1371 // updateConfig();
1366} 1372}
1367 1373
1368void KOAgendaView::writeSettings(KConfig *config) 1374void KOAgendaView::writeSettings(KConfig *config)
1369{ 1375{
1370 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1376 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1371 1377
1372 config->setGroup("Views"); 1378 config->setGroup("Views");
1373 1379
1374 //#ifndef KORG_NOSPLITTER 1380 //#ifndef KORG_NOSPLITTER
1375 QValueList<int> list = mSplitterAgenda->sizes(); 1381 QValueList<int> list = mSplitterAgenda->sizes();
1376 config->writeEntry("Separator AgendaView",list); 1382 config->writeEntry("Separator AgendaView",list);
1377 //qDebug("write %d %d ", list[0],list[1] ); 1383 //qDebug("write %d %d ", list[0],list[1] );
1378 //#endif 1384 //#endif
1379} 1385}
1380 1386
1381void KOAgendaView::setHolidayMasks() 1387void KOAgendaView::setHolidayMasks()
1382{ 1388{
1383 mHolidayMask.resize(mSelectedDates.count()); 1389 mHolidayMask.resize(mSelectedDates.count());
1384 1390
1385 uint i; 1391 uint i;
1386 for(i=0;i<mSelectedDates.count();++i) { 1392 for(i=0;i<mSelectedDates.count();++i) {
1387 QDate date = mSelectedDates[i]; 1393 QDate date = mSelectedDates[i];
1388 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1394 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1389 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1395 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1390 bool showHoliday = false; 1396 bool showHoliday = false;
1391 if ( KOPrefs::instance()->mExcludeHolidays ) { 1397 if ( KOPrefs::instance()->mExcludeHolidays ) {
1392 QPtrList<Event> events = calendar()->events( date, true ); 1398 QPtrList<Event> events = calendar()->events( date, true );
1393 Event *event; 1399 Event *event;
1394 for( event = events.first(); event; event = events.next() ) { 1400 for( event = events.first(); event; event = events.next() ) {
1395 if ( event->categories().contains("Holiday") || 1401 if ( event->categories().contains("Holiday") ||
1396 event->categories().contains(i18n("Holiday"))) { 1402 event->categories().contains(i18n("Holiday"))) {
1397 showHoliday = true; 1403 showHoliday = true;
1398 break; 1404 break;
1399 } 1405 }
1400 } 1406 }
1401 1407
1402 } 1408 }
1403 1409
1404#ifndef KORG_NOPLUGINS 1410#ifndef KORG_NOPLUGINS
1405 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1411 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1406 !KOCore::self()->holiday(date).isEmpty(); 1412 !KOCore::self()->holiday(date).isEmpty();
1407#endif 1413#endif
1408 bool showDay = showSaturday || showSunday || showHoliday; 1414 bool showDay = showSaturday || showSunday || showHoliday;
1409 1415
1410 if (showDay) { 1416 if (showDay) {
1411 mHolidayMask.at(i) = true; 1417 mHolidayMask.at(i) = true;
1412 } else { 1418 } else {
1413 mHolidayMask.at(i) = false; 1419 mHolidayMask.at(i) = false;
1414 } 1420 }
1415 } 1421 }
1416 1422
1417 mAgenda->setHolidayMask(&mHolidayMask); 1423 mAgenda->setHolidayMask(&mHolidayMask);
1418 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1424 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1419} 1425}
1420 1426
1421void KOAgendaView::setContentsPos(int y) 1427void KOAgendaView::setContentsPos(int y)
1422{ 1428{
1423 mAgenda->setContentsPos(0,y); 1429 mAgenda->setContentsPos(0,y);
1424} 1430}
1425 1431
1426void KOAgendaView::setExpandedButton( bool expanded ) 1432void KOAgendaView::setExpandedButton( bool expanded )
1427{ 1433{
1428 if ( expanded ) { 1434 if ( expanded ) {
1429 mExpandButton->setPixmap( mExpandedPixmap ); 1435 mExpandButton->setPixmap( mExpandedPixmap );
1430 } else { 1436 } else {
1431 mExpandButton->setPixmap( mNotExpandedPixmap ); 1437 mExpandButton->setPixmap( mNotExpandedPixmap );
1432 } 1438 }
1433} 1439}
1434 1440
1435void KOAgendaView::clearSelection() 1441void KOAgendaView::clearSelection()
1436{ 1442{
1437 mAgenda->deselectItem(); 1443 mAgenda->deselectItem();
1438 mAllDayAgenda->deselectItem(); 1444 mAllDayAgenda->deselectItem();
1439} 1445}
1440 1446
1441void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1447void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1442 int gxEnd, int gyEnd) 1448 int gxEnd, int gyEnd)
1443{ 1449{
1444 mTimeSpanInAllDay = true; 1450 mTimeSpanInAllDay = true;
1445 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1451 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1446} 1452}
1447 1453
1448 1454
1449 1455
1450 1456
1451void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1457void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1452 int gxEnd, int gyEnd) 1458 int gxEnd, int gyEnd)
1453{ 1459{
1454 if (!mSelectedDates.count()) return; 1460 if (!mSelectedDates.count()) return;
1455 1461
1456 QDate dayStart = mSelectedDates[gxStart]; 1462 QDate dayStart = mSelectedDates[gxStart];
1457 QDate dayEnd = mSelectedDates[gxEnd]; 1463 QDate dayEnd = mSelectedDates[gxEnd];
1458 1464
1459 QTime timeStart = mAgenda->gyToTime(gyStart); 1465 QTime timeStart = mAgenda->gyToTime(gyStart);
1460 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1466 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1461 1467
1462 QDateTime dtStart(dayStart,timeStart); 1468 QDateTime dtStart(dayStart,timeStart);
1463 QDateTime dtEnd(dayEnd,timeEnd); 1469 QDateTime dtEnd(dayEnd,timeEnd);
1464 1470
1465 mTimeSpanBegin = dtStart; 1471 mTimeSpanBegin = dtStart;
1466 mTimeSpanEnd = dtEnd; 1472 mTimeSpanEnd = dtEnd;
1467 1473
1468} 1474}
1469 1475
1470void KOAgendaView::deleteSelectedDateTime() 1476void KOAgendaView::deleteSelectedDateTime()
1471{ 1477{
1472 mTimeSpanBegin.setDate(QDate()); 1478 mTimeSpanBegin.setDate(QDate());
1473 mTimeSpanEnd.setDate(QDate()); 1479 mTimeSpanEnd.setDate(QDate());
1474 mTimeSpanInAllDay = false; 1480 mTimeSpanInAllDay = false;
1475} 1481}
1476 1482
1477void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1483void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1478{ 1484{
1479 e->ignore(); 1485 e->ignore();
1480} 1486}
1481 1487
1482void KOAgendaView::scrollOneHourUp() 1488void KOAgendaView::scrollOneHourUp()
1483{ 1489{
1484 1490
1485 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1491 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1486} 1492}
1487void KOAgendaView::scrollOneHourDown() 1493void KOAgendaView::scrollOneHourDown()
1488{ 1494{
1489 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1495 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1490} 1496}
1491 1497
1492void KOAgendaView::setStartHour( int h ) 1498void KOAgendaView::setStartHour( int h )
1493{ 1499{
1494 mAgenda->setStartHour( h ); 1500 mAgenda->setStartHour( h );
1495 1501
1496} 1502}
1497 1503
1498void KOAgendaView::updateTodo( Todo * t, int ) 1504void KOAgendaView::updateTodo( Todo * t, int )
1499{ 1505{
1500 1506
1501 bool remove = false; 1507 bool remove = false;
1502 bool removeAD = false; 1508 bool removeAD = false;
1503 if ( ! t->hasDueDate() ) { 1509 if ( ! t->hasDueDate() ) {
1504 remove = true; 1510 remove = true;
1505 removeAD = true; 1511 removeAD = true;
1506 } 1512 }
1507 else { 1513 else {
1508 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1514 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1509 if ( overdue && 1515 if ( overdue &&
1510 QDate::currentDate() >= mSelectedDates.first() && 1516 QDate::currentDate() >= mSelectedDates.first() &&
1511 QDate::currentDate() <= mSelectedDates.last()) { 1517 QDate::currentDate() <= mSelectedDates.last()) {
1512 removeAD = false; 1518 removeAD = false;
1513 remove = true; 1519 remove = true;
1514 } 1520 }
1515 else { 1521 else {
1516 if ( t->dtDue().date() < mSelectedDates.first() || 1522 if ( t->dtDue().date() < mSelectedDates.first() ||
1517 t->dtDue().date() > mSelectedDates.last() ) { 1523 t->dtDue().date() > mSelectedDates.last() ) {
1518 remove = true; 1524 remove = true;
1519 removeAD = true; 1525 removeAD = true;
1520 } else { 1526 } else {
1521 remove = t->doesFloat(); 1527 remove = t->doesFloat();
1522 removeAD = !remove; 1528 removeAD = !remove;
1523 } 1529 }
1524 } 1530 }
1525 } 1531 }
1526 int days = mSelectedDates.first().daysTo( t->dtDue().date() ); 1532 int days = mSelectedDates.first().daysTo( t->dtDue().date() );
1527 // qDebug("daysto %d ", days ); 1533 // qDebug("daysto %d ", days );
1528 mAgenda->updateTodo( t , days, remove); 1534 mAgenda->updateTodo( t , days, remove);
1529 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1535 if ( KOPrefs::instance()->mShowTodoInAgenda )
1530 mAllDayAgenda->updateTodo( t , days, removeAD); 1536 mAllDayAgenda->updateTodo( t , days, removeAD);
1531 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1537 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1532 1538
1533} 1539}
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 2f0fa9e..36a2947 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,599 +1,604 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.h>
56#else //DESKTOP_VERSION 56#else //DESKTOP_VERSION
57#include <externalapphandler.h> 57#include <externalapphandler.h>
58#include <qtopia/qcopenvelope_qws.h> 58#include <qtopia/qcopenvelope_qws.h>
59#endif //DESKTOP_VERSION 59#endif //DESKTOP_VERSION
60 60
61KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 61KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
62 : QTextBrowser(parent,name) 62 : QTextBrowser(parent,name)
63{ 63{
64 mSyncMode = false; 64 mSyncMode = false;
65 mColorMode = 0; 65 mColorMode = 0;
66} 66}
67 67
68KOEventViewer::~KOEventViewer() 68KOEventViewer::~KOEventViewer()
69{ 69{
70} 70}
71 71
72void KOEventViewer::setSource(const QString& n) 72void KOEventViewer::setSource(const QString& n)
73{ 73{
74 74
75 if ( n.left(3) == "uid" ) 75 if ( n.left(3) == "uid" )
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 { 77 {
78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
79 KABC::AddressBook::Iterator it; 79 KABC::AddressBook::Iterator it;
80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
81 // LR I do not understand, why the uid string is different on zaurus and desktop 81 // LR I do not understand, why the uid string is different on zaurus and desktop
82 QString uid = "uid://"+(*it).uid(); 82 QString uid = "uid://"+(*it).uid();
83 83
84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
85 if (n == uid ) { 85 if (n == uid ) {
86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
87 QDialog dia( this,"dia123", true ); 87 QDialog dia( this,"dia123", true );
88 dia.setCaption( i18n("Details of attendee") ); 88 dia.setCaption( i18n("Details of attendee") );
89 QVBoxLayout lay ( &dia ); 89 QVBoxLayout lay ( &dia );
90 KABC::AddresseeView av ( &dia ); 90 KABC::AddresseeView av ( &dia );
91 av.setAddressee( (*it) ); 91 av.setAddressee( (*it) );
92 lay.addWidget( &av ); 92 lay.addWidget( &av );
93 if ( QApplication::desktop()->width() < 480 ) 93 if ( QApplication::desktop()->width() < 480 )
94 dia.resize( 220, 240); 94 dia.resize( 220, 240);
95 else { 95 else {
96 dia.resize( 400,400); 96 dia.resize( 400,400);
97 } 97 }
98 dia.exec(); 98 dia.exec();
99 break; 99 break;
100 } 100 }
101 } 101 }
102 return; 102 return;
103 } 103 }
104#else 104#else
105 { 105 {
106 if ( "uid:organizer" == n ) { 106 if ( "uid:organizer" == n ) {
107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
108 return; 108 return;
109 } 109 }
110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
111 if (attendees.count()) { 111 if (attendees.count()) {
112 Attendee *a; 112 Attendee *a;
113 for(a=attendees.first();a;a=attendees.next()) { 113 for(a=attendees.first();a;a=attendees.next()) {
114 if ( "uid:"+a->uid() == n ) { 114 if ( "uid:"+a->uid() == n ) {
115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
116 return; 116 return;
117 } 117 }
118 } 118 }
119 } 119 }
120 return; 120 return;
121 } 121 }
122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
123 // the result should now arrive through method insertAttendees 123 // the result should now arrive through method insertAttendees
124 //QString uid = "uid:"+(*it).uid(); 124 //QString uid = "uid:"+(*it).uid();
125#endif 125#endif
126 if ( n.left(6) == "mailto" ) { 126 if ( n.left(6) == "mailto" ) {
127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
128#ifndef DESKTOP_VERSION 128#ifndef DESKTOP_VERSION
129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
130 e << n.mid(7); 130 e << n.mid(7);
131#endif 131#endif
132 132
133 } 133 }
134 134
135 135
136#ifndef KORG_NODCOP 136#ifndef KORG_NODCOP
137 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 137 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
138 QString tmpStr; 138 QString tmpStr;
139 if (n.startsWith("mailto:")) { 139 if (n.startsWith("mailto:")) {
140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
141 //emit showIncidence(n); 141 //emit showIncidence(n);
142 return; 142 return;
143 } else if (n.startsWith("uid:")) { 143 } else if (n.startsWith("uid:")) {
144 DCOPClient *client = KApplication::kApplication()->dcopClient(); 144 DCOPClient *client = KApplication::kApplication()->dcopClient();
145 const QByteArray noParamData; 145 const QByteArray noParamData;
146 const QByteArray paramData; 146 const QByteArray paramData;
147 QByteArray replyData; 147 QByteArray replyData;
148 QCString replyTypeStr; 148 QCString replyTypeStr;
149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
150 bool foundAbbrowser = PING_ABBROWSER; 150 bool foundAbbrowser = PING_ABBROWSER;
151 151
152 if (foundAbbrowser) { 152 if (foundAbbrowser) {
153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
154 //client->send("kaddressbook","KAddressBookIface", 154 //client->send("kaddressbook","KAddressBookIface",
155 QDataStream arg(paramData, IO_WriteOnly); 155 QDataStream arg(paramData, IO_WriteOnly);
156 arg << n.mid(6); 156 arg << n.mid(6);
157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
158 return; 158 return;
159 } else { 159 } else {
160 /* 160 /*
161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
162 We start it without its main interface 162 We start it without its main interface
163 */ 163 */
164 KIconLoader* iconLoader = new KIconLoader(); 164 KIconLoader* iconLoader = new KIconLoader();
165 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 165 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
166 ActionManager::setStartedKAddressBook(true); 166 ActionManager::setStartedKAddressBook(true);
167 tmpStr = "kaddressbook --editor-only --uid "; 167 tmpStr = "kaddressbook --editor-only --uid ";
168 tmpStr += KProcess::quote(n.mid(6)); 168 tmpStr += KProcess::quote(n.mid(6));
169 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 169 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
170 return; 170 return;
171 } 171 }
172 } else { 172 } else {
173 //QTextBrowser::setSource(n); 173 //QTextBrowser::setSource(n);
174 } 174 }
175#endif 175#endif
176} 176}
177 177
178void KOEventViewer::addTag(const QString & tag,const QString & text) 178void KOEventViewer::addTag(const QString & tag,const QString & text)
179{ 179{
180 int number=text.contains("\n"); 180 int number=text.contains("\n");
181 QString str = "<" + tag + ">"; 181 QString str = "<" + tag + ">";
182 QString tmpText=text; 182 QString tmpText=text;
183 QString tmpStr=str; 183 QString tmpStr=str;
184 if(number !=-1) 184 if(number !=-1)
185 { 185 {
186 if (number > 0) { 186 if (number > 0) {
187 int pos=0; 187 int pos=0;
188 QString tmp; 188 QString tmp;
189 for(int i=0;i<=number;i++) { 189 for(int i=0;i<=number;i++) {
190 pos=tmpText.find("\n"); 190 pos=tmpText.find("\n");
191 tmp=tmpText.left(pos); 191 tmp=tmpText.left(pos);
192 tmpText=tmpText.right(tmpText.length()-pos-1); 192 tmpText=tmpText.right(tmpText.length()-pos-1);
193 tmpStr+=tmp+"<br>"; 193 tmpStr+=tmp+"<br>";
194 } 194 }
195 } 195 }
196 else tmpStr += tmpText; 196 else tmpStr += tmpText;
197 tmpStr+="</" + tag + ">"; 197 tmpStr+="</" + tag + ">";
198 mText.append(tmpStr); 198 mText.append(tmpStr);
199 } 199 }
200 else 200 else
201 { 201 {
202 str += text + "</" + tag + ">"; 202 str += text + "</" + tag + ">";
203 mText.append(str); 203 mText.append(str);
204 } 204 }
205} 205}
206 206
207void KOEventViewer::setColorMode( int m ) 207void KOEventViewer::setColorMode( int m )
208{ 208{
209 mColorMode = m; 209 mColorMode = m;
210} 210}
211void KOEventViewer::appendEvent(Event *event, int mode ) 211void KOEventViewer::appendEvent(Event *event, int mode )
212{ 212{
213 mMailSubject = ""; 213 mMailSubject = "";
214 mCurrentIncidence = event; 214 mCurrentIncidence = event;
215 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 215 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
216 topLevelWidget()->setCaption(i18n("Event Viewer")); 216 topLevelWidget()->setCaption(i18n("Event Viewer"));
217 if ( mode == 0 ) { 217 if ( mode == 0 ) {
218 addTag("h2",event->summary()); 218 addTag("h2",event->summary());
219 } 219 }
220 else { 220 else {
221 if ( mColorMode == 1 ) { 221 if ( mColorMode == 1 ) {
222 mText +="<font color=\"#00A000\">"; 222 mText +="<font color=\"#00A000\">";
223 } 223 }
224 if ( mColorMode == 2 ) { 224 if ( mColorMode == 2 ) {
225 mText +="<font color=\"#C00000\">"; 225 mText +="<font color=\"#C00000\">";
226 } 226 }
227 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 227 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
228 if ( mode == 1 ) { 228 if ( mode == 1 ) {
229 addTag("h2",i18n( "Local: " ) +event->summary()); 229 addTag("h2",i18n( "Local: " ) +event->summary());
230 } else { 230 } else {
231 addTag("h2",i18n( "Remote: " ) +event->summary()); 231 addTag("h2",i18n( "Remote: " ) +event->summary());
232 } 232 }
233 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 233 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
234 if ( mColorMode ) 234 if ( mColorMode )
235 mText += "</font>"; 235 mText += "</font>";
236 } 236 }
237 mMailSubject += i18n( "Meeting " )+ event->summary(); 237 mMailSubject += i18n( "Meeting " )+ event->summary();
238 if (event->cancelled ()) { 238 if (event->cancelled ()) {
239 mText +="<font color=\"#B00000\">"; 239 mText +="<font color=\"#B00000\">";
240 addTag("i",i18n("This event has been cancelled!")); 240 addTag("i",i18n("This event has been cancelled!"));
241 mText.append("<br>"); 241 mText.append("<br>");
242 mText += "</font>"; 242 mText += "</font>";
243 mMailSubject += i18n("(cancelled)"); 243 mMailSubject += i18n("(cancelled)");
244 } 244 }
245 if (!event->location().isEmpty()) { 245 if (!event->location().isEmpty()) {
246 addTag("b",i18n("Location: ")); 246 addTag("b",i18n("Location: "));
247 mText.append(event->location()+"<br>"); 247 mText.append(event->location()+"<br>");
248 mMailSubject += i18n(" at ") + event->location(); 248 mMailSubject += i18n(" at ") + event->location();
249 } 249 }
250 if (event->doesFloat()) { 250 if (event->doesFloat()) {
251 if (event->isMultiDay()) { 251 if (event->isMultiDay()) {
252 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 252 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
253 .arg(event->dtStartDateStr(shortDate)) 253 .arg(event->dtStartDateStr(shortDate))
254 .arg(event->dtEndDateStr(shortDate))); 254 .arg(event->dtEndDateStr(shortDate)));
255 } else { 255 } else {
256 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 256 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
257 } 257 }
258 } else { 258 } else {
259 if (event->isMultiDay()) { 259 if (event->isMultiDay()) {
260 mText.append(i18n("<p><b>From:</b> %1</p> ") 260 mText.append(i18n("<p><b>From:</b> %1</p> ")
261 .arg(event->dtStartStr( shortDate))); 261 .arg(event->dtStartStr( shortDate)));
262 mText.append(i18n("<p><b>To:</b> %1</p>") 262 mText.append(i18n("<p><b>To:</b> %1</p>")
263 .arg(event->dtEndStr(shortDate))); 263 .arg(event->dtEndStr(shortDate)));
264 } else { 264 } else {
265 mText.append(i18n("<p><b>On:</b> %1</p> ") 265 mText.append(i18n("<p><b>On:</b> %1</p> ")
266 .arg(event->dtStartDateStr( shortDate ))); 266 .arg(event->dtStartDateStr( shortDate )));
267 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 267 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
268 .arg(event->dtStartTimeStr()) 268 .arg(event->dtStartTimeStr())
269 .arg(event->dtEndTimeStr())); 269 .arg(event->dtEndTimeStr()));
270 } 270 }
271 } 271 }
272 272
273 if (event->recurrence()->doesRecur()) { 273 if (event->recurrence()->doesRecur()) {
274 274
275 QString recurText = event->recurrence()->recurrenceText(); 275 QString recurText = event->recurrence()->recurrenceText();
276 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 276 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
277 bool last; 277 bool last;
278 QDate start = QDate::currentDate(); 278 QDate start = QDate::currentDate();
279 QDate next; 279 QDate next;
280 next = event->recurrence()->getPreviousDate( start , &last ); 280 next = event->recurrence()->getPreviousDate( start , &last );
281 if ( !last ) { 281 if ( !last ) {
282 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 282 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
283 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 283 addTag("p",i18n("<b>Next recurrence is on:</b>") );
284 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 284 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
285 QDateTime nextdt = QDateTime( next, event->dtStart().time()); 285 QDateTime nextdt = QDateTime( next, event->dtStart().time());
286 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); 286 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
287 287
288 } else { 288 } else {
289 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 289 addTag("p",i18n("<b>Last recurrence was on:</b>") );
290 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 290 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
291 } 291 }
292 } else { 292 } else {
293 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 293 mMailSubject += i18n(" - " )+event->dtStartStr( true );
294 294
295 } 295 }
296 296
297 297
298 if (event->isAlarmEnabled()) { 298 if (event->isAlarmEnabled()) {
299 Alarm *alarm =event->alarms().first() ; 299 Alarm *alarm =event->alarms().first() ;
300 QDateTime t = alarm->time(); 300 QDateTime t = alarm->time();
301 int min = t.secsTo( event->dtStart() )/60; 301 int min = t.secsTo( event->dtStart() )/60;
302 QString s =i18n("( %1 min before )").arg( min ); 302 QString s =i18n("( %1 min before )").arg( min );
303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
305 //addTag("p",s); 305 //addTag("p",s);
306 } 306 }
307 307
308 addTag("b",i18n("Access: ")); 308 addTag("b",i18n("Access: "));
309 mText.append(event->secrecyStr()+"<br>"); 309 mText.append(event->secrecyStr()+"<br>");
310 if (!event->description().isEmpty()) { 310 if (!event->description().isEmpty()) {
311 addTag("p",i18n("<b>Details: </b>")); 311 addTag("p",i18n("<b>Details: </b>"));
312 addTag("p",event->description()); 312 addTag("p",event->description());
313 } 313 }
314 314
315 formatCategories(event); 315 formatCategories(event);
316 316
317 formatReadOnly(event); 317 formatReadOnly(event);
318 formatAttendees(event); 318 formatAttendees(event);
319 319
320 setText(mText); 320 setText(mText);
321 //QWhatsThis::add(this,mText); 321 //QWhatsThis::add(this,mText);
322 322
323} 323}
324 324
325void KOEventViewer::appendTodo(Todo *event, int mode ) 325void KOEventViewer::appendTodo(Todo *event, int mode )
326{ 326{
327 mMailSubject = ""; 327 mMailSubject = "";
328 mCurrentIncidence = event; 328 mCurrentIncidence = event;
329 topLevelWidget()->setCaption(i18n("Todo Viewer")); 329 topLevelWidget()->setCaption(i18n("Todo Viewer"));
330 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 330 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
331 if (mode == 0 ) 331 if (mode == 0 )
332 addTag("h2",event->summary()); 332 addTag("h2",event->summary());
333 else { 333 else {
334 if ( mColorMode == 1 ) { 334 if ( mColorMode == 1 ) {
335 mText +="<font color=\"#00A000\">"; 335 mText +="<font color=\"#00A000\">";
336 } 336 }
337 if ( mColorMode == 2 ) { 337 if ( mColorMode == 2 ) {
338 mText +="<font color=\"#B00000\">"; 338 mText +="<font color=\"#B00000\">";
339 } 339 }
340 if ( mode == 1 ) { 340 if ( mode == 1 ) {
341 addTag("h2",i18n( "Local: " ) +event->summary()); 341 addTag("h2",i18n( "Local: " ) +event->summary());
342 } else { 342 } else {
343 addTag("h2",i18n( "Remote: " ) +event->summary()); 343 addTag("h2",i18n( "Remote: " ) +event->summary());
344 } 344 }
345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
346 if ( mColorMode ) 346 if ( mColorMode )
347 mText += "</font>"; 347 mText += "</font>";
348 } 348 }
349 mMailSubject += i18n( "Todo " )+ event->summary(); 349 mMailSubject += i18n( "Todo " )+ event->summary();
350 if (event->cancelled ()) { 350 if (event->cancelled ()) {
351 mText +="<font color=\"#B00000\">"; 351 mText +="<font color=\"#B00000\">";
352 addTag("i",i18n("This todo has been cancelled!")); 352 addTag("i",i18n("This todo has been cancelled!"));
353 mText.append("<br>"); 353 mText.append("<br>");
354 mText += "</font>"; 354 mText += "</font>";
355 mMailSubject += i18n("(cancelled)"); 355 mMailSubject += i18n("(cancelled)");
356 } 356 }
357 357
358 if (!event->location().isEmpty()) { 358 if (!event->location().isEmpty()) {
359 addTag("b",i18n("Location: ")); 359 addTag("b",i18n("Location: "));
360 mText.append(event->location()+"<br>"); 360 mText.append(event->location()+"<br>");
361 mMailSubject += i18n(" at ") + event->location(); 361 mMailSubject += i18n(" at ") + event->location();
362 } 362 }
363 if (event->hasStartDate()) { 363 if (event->hasStartDate()) {
364 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 364 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
365 } 365 }
366 if (event->hasDueDate()) { 366 if (event->hasDueDate()) {
367 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 367 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
368 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 368 mMailSubject += i18n(" - " )+event->dtDueStr( true );
369 } 369 }
370 addTag("b",i18n("Access: ")); 370 addTag("b",i18n("Access: "));
371 mText.append(event->secrecyStr()+"<br>"); 371 mText.append(event->secrecyStr()+"<br>");
372 if (!event->description().isEmpty()) { 372 if (!event->description().isEmpty()) {
373 addTag("p",i18n("<b>Details: </b>")); 373 addTag("p",i18n("<b>Details: </b>"));
374 addTag("p",event->description()); 374 addTag("p",event->description());
375 } 375 }
376 376
377 formatCategories(event); 377 formatCategories(event);
378 378
379 mText.append(i18n("<p><b>Priority:</b> %2</p>") 379 mText.append(i18n("<p><b>Priority:</b> %2</p>")
380 .arg(QString::number(event->priority()))); 380 .arg(QString::number(event->priority())));
381 381
382 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
383 mText.append(i18n("<p><i>Completed on %1</i></p>")
384 .arg( event->completedStr() ));
385 } else {
382 mText.append(i18n("<p><i>%1 % completed</i></p>") 386 mText.append(i18n("<p><i>%1 % completed</i></p>")
383 .arg(event->percentComplete())); 387 .arg(event->percentComplete()));
388 }
384 389
385 formatReadOnly(event); 390 formatReadOnly(event);
386 formatAttendees(event); 391 formatAttendees(event);
387 if ( event->relatedTo() ) { 392 if ( event->relatedTo() ) {
388 addTag("b",i18n("Parent todo: ")); 393 addTag("b",i18n("Parent todo: "));
389 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 394 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
390 } 395 }
391 QPtrList<Incidence> Relations = event->relations(); 396 QPtrList<Incidence> Relations = event->relations();
392 Incidence *to; 397 Incidence *to;
393 if ( Relations.first() ) 398 if ( Relations.first() )
394 addTag("b",i18n("Sub todos:<br>")); 399 addTag("b",i18n("Sub todos:<br>"));
395 for (to=Relations.first();to;to=Relations.next()) { 400 for (to=Relations.first();to;to=Relations.next()) {
396 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 401 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
397 402
398 } 403 }
399 setText(mText); 404 setText(mText);
400} 405}
401 406
402void KOEventViewer::formatCategories(Incidence *event) 407void KOEventViewer::formatCategories(Incidence *event)
403{ 408{
404 if (!event->categoriesStr().isEmpty()) { 409 if (!event->categoriesStr().isEmpty()) {
405 if (event->categories().count() == 1) { 410 if (event->categories().count() == 1) {
406 addTag("h3",i18n("Category")); 411 addTag("h3",i18n("Category"));
407 } else { 412 } else {
408 addTag("h3",i18n("Categories")); 413 addTag("h3",i18n("Categories"));
409 } 414 }
410 addTag("p",event->categoriesStr()); 415 addTag("p",event->categoriesStr());
411 } 416 }
412} 417}
413void KOEventViewer::formatAttendees(Incidence *event) 418void KOEventViewer::formatAttendees(Incidence *event)
414{ 419{
415 QPtrList<Attendee> attendees = event->attendees(); 420 QPtrList<Attendee> attendees = event->attendees();
416 if (attendees.count()) { 421 if (attendees.count()) {
417 422
418 423
419 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 424 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
420 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 425 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
421 addTag("h3",i18n("Organizer")); 426 addTag("h3",i18n("Organizer"));
422 mText.append("<ul><li>"); 427 mText.append("<ul><li>");
423#ifndef KORG_NOKABC 428#ifndef KORG_NOKABC
424 429
425#ifdef DESKTOP_VERSION 430#ifdef DESKTOP_VERSION
426 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 431 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
427 KABC::Addressee::List addressList; 432 KABC::Addressee::List addressList;
428 addressList = add_book->findByEmail(event->organizer()); 433 addressList = add_book->findByEmail(event->organizer());
429 KABC::Addressee o = addressList.first(); 434 KABC::Addressee o = addressList.first();
430 if (!o.isEmpty() && addressList.size()<2) { 435 if (!o.isEmpty() && addressList.size()<2) {
431 mText += "<a href=\"uid:" + o.uid() + "\">"; 436 mText += "<a href=\"uid:" + o.uid() + "\">";
432 mText += o.formattedName(); 437 mText += o.formattedName();
433 mText += "</a>\n"; 438 mText += "</a>\n";
434 } else { 439 } else {
435 mText.append(event->organizer()); 440 mText.append(event->organizer());
436 } 441 }
437#else //DESKTOP_VERSION 442#else //DESKTOP_VERSION
438 mText += "<a href=\"uid:organizer\">"; 443 mText += "<a href=\"uid:organizer\">";
439 mText += event->organizer(); 444 mText += event->organizer();
440 mText += "</a>\n"; 445 mText += "</a>\n";
441#endif //DESKTOP_VERSION 446#endif //DESKTOP_VERSION
442 447
443 448
444#else 449#else
445 mText.append(event->organizer()); 450 mText.append(event->organizer());
446#endif 451#endif
447 452
448 if (iconPath) { 453 if (iconPath) {
449 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 454 mText += " <a href=\"mailto:" + event->organizer() + "\">";
450 mText += "<IMG src=\"" + iconPath + "\">"; 455 mText += "<IMG src=\"" + iconPath + "\">";
451 mText += "</a>\n"; 456 mText += "</a>\n";
452 } 457 }
453 mText.append("</li></ul>"); 458 mText.append("</li></ul>");
454 459
455 addTag("h3",i18n("Attendees")); 460 addTag("h3",i18n("Attendees"));
456 Attendee *a; 461 Attendee *a;
457 mText.append("<ul>"); 462 mText.append("<ul>");
458 for(a=attendees.first();a;a=attendees.next()) { 463 for(a=attendees.first();a;a=attendees.next()) {
459#ifndef KORG_NOKABC 464#ifndef KORG_NOKABC
460#ifdef DESKTOP_VERSION 465#ifdef DESKTOP_VERSION
461 if (a->name().isEmpty()) { 466 if (a->name().isEmpty()) {
462 addressList = add_book->findByEmail(a->email()); 467 addressList = add_book->findByEmail(a->email());
463 KABC::Addressee o = addressList.first(); 468 KABC::Addressee o = addressList.first();
464 if (!o.isEmpty() && addressList.size()<2) { 469 if (!o.isEmpty() && addressList.size()<2) {
465 mText += "<a href=\"uid:" + o.uid() + "\">"; 470 mText += "<a href=\"uid:" + o.uid() + "\">";
466 mText += o.formattedName(); 471 mText += o.formattedName();
467 mText += "</a>\n"; 472 mText += "</a>\n";
468 } else { 473 } else {
469 mText += "<li>"; 474 mText += "<li>";
470 mText.append(a->email()); 475 mText.append(a->email());
471 mText += "\n"; 476 mText += "\n";
472 } 477 }
473 } else { 478 } else {
474 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 479 mText += "<li><a href=\"uid:" + a->uid() + "\">";
475 if (!a->name().isEmpty()) mText += a->name(); 480 if (!a->name().isEmpty()) mText += a->name();
476 else mText += a->email(); 481 else mText += a->email();
477 mText += "</a>\n"; 482 mText += "</a>\n";
478 } 483 }
479#else //DESKTOP_VERSION 484#else //DESKTOP_VERSION
480 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 485 mText += "<li><a href=\"uid:" + a->uid() + "\">";
481 if (!a->name().isEmpty()) mText += a->name(); 486 if (!a->name().isEmpty()) mText += a->name();
482 else mText += a->email(); 487 else mText += a->email();
483 mText += "</a>\n"; 488 mText += "</a>\n";
484#endif //DESKTOP_VERSION 489#endif //DESKTOP_VERSION
485#else 490#else
486 //qDebug("nokabc "); 491 //qDebug("nokabc ");
487 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 492 mText += "<li><a href=\"uid:" + a->uid() + "\">";
488 if (!a->name().isEmpty()) mText += a->name(); 493 if (!a->name().isEmpty()) mText += a->name();
489 else mText += a->email(); 494 else mText += a->email();
490 mText += "</a>\n"; 495 mText += "</a>\n";
491#endif 496#endif
492 497
493 498
494 if (!a->email().isEmpty()) { 499 if (!a->email().isEmpty()) {
495 if (iconPath) { 500 if (iconPath) {
496 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 501 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
497 if ( a->RSVP() ) 502 if ( a->RSVP() )
498 mText += "<IMG src=\"" + iconPath + "\">"; 503 mText += "<IMG src=\"" + iconPath + "\">";
499 else 504 else
500 mText += "<IMG src=\"" + NOiconPath + "\">"; 505 mText += "<IMG src=\"" + NOiconPath + "\">";
501 mText += "</a>\n"; 506 mText += "</a>\n";
502 } 507 }
503 } 508 }
504 if (a->status() != Attendee::NeedsAction ) 509 if (a->status() != Attendee::NeedsAction )
505 mText +="[" + a->statusStr() + "] "; 510 mText +="[" + a->statusStr() + "] ";
506 if (a->role() == Attendee::Chair ) 511 if (a->role() == Attendee::Chair )
507 mText +="(" + a->roleStr().left(1) + ".)"; 512 mText +="(" + a->roleStr().left(1) + ".)";
508 } 513 }
509 mText.append("</li></ul>"); 514 mText.append("</li></ul>");
510 } 515 }
511 516
512} 517}
513void KOEventViewer::appendJournal(Journal *jour, int mode ) 518void KOEventViewer::appendJournal(Journal *jour, int mode )
514{ 519{
515 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 520 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
516 if (mode == 0 ) { 521 if (mode == 0 ) {
517 addTag("h2",i18n("Journal from: ")); 522 addTag("h2",i18n("Journal from: "));
518 } 523 }
519 else { 524 else {
520 if ( mode == 1 ) { 525 if ( mode == 1 ) {
521 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 526 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
522 } else { 527 } else {
523 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 528 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
524 } 529 }
525 } 530 }
526 topLevelWidget()->setCaption("Journal Viewer"); 531 topLevelWidget()->setCaption("Journal Viewer");
527 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 532 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
528 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 533 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
529 if (!jour->description().isEmpty()) { 534 if (!jour->description().isEmpty()) {
530 addTag("p",jour->description()); 535 addTag("p",jour->description());
531 } 536 }
532 setText(mText); 537 setText(mText);
533} 538}
534 539
535void KOEventViewer::formatReadOnly(Incidence *event) 540void KOEventViewer::formatReadOnly(Incidence *event)
536{ 541{
537 if (event->isReadOnly()) { 542 if (event->isReadOnly()) {
538 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 543 addTag("p","<em>(" + i18n("read-only") + ")</em>");
539 } 544 }
540} 545}
541void KOEventViewer::setSyncMode( bool b ) 546void KOEventViewer::setSyncMode( bool b )
542{ 547{
543 mSyncMode = b; 548 mSyncMode = b;
544} 549}
545 550
546 551
547void KOEventViewer::setTodo(Todo *event, bool clearV ) 552void KOEventViewer::setTodo(Todo *event, bool clearV )
548{ 553{
549 if ( clearV ) 554 if ( clearV )
550 clearEvents(); 555 clearEvents();
551 if ( mSyncMode ) { 556 if ( mSyncMode ) {
552 if ( clearV ) 557 if ( clearV )
553 appendTodo(event,1 ); 558 appendTodo(event,1 );
554 else 559 else
555 appendTodo(event,2); 560 appendTodo(event,2);
556 } else 561 } else
557 appendTodo(event); 562 appendTodo(event);
558} 563}
559void KOEventViewer::setJournal(Journal *event, bool clearV ) 564void KOEventViewer::setJournal(Journal *event, bool clearV )
560{ 565{
561 if ( clearV ) 566 if ( clearV )
562 clearEvents(); 567 clearEvents();
563 if ( mSyncMode ) { 568 if ( mSyncMode ) {
564 if ( clearV ) 569 if ( clearV )
565 appendJournal(event, 1); 570 appendJournal(event, 1);
566 else 571 else
567 appendJournal(event, 2); 572 appendJournal(event, 2);
568 } else 573 } else
569 appendJournal(event); 574 appendJournal(event);
570} 575}
571 576
572void KOEventViewer::setEvent(Event *event) 577void KOEventViewer::setEvent(Event *event)
573{ 578{
574 clearEvents(); 579 clearEvents();
575 if ( mSyncMode ) 580 if ( mSyncMode )
576 appendEvent(event, 1); 581 appendEvent(event, 1);
577 else 582 else
578 appendEvent(event); 583 appendEvent(event);
579} 584}
580 585
581void KOEventViewer::addEvent(Event *event) 586void KOEventViewer::addEvent(Event *event)
582{ 587{
583 if ( mSyncMode ) 588 if ( mSyncMode )
584 appendEvent(event, 2); 589 appendEvent(event, 2);
585 else 590 else
586 appendEvent(event); 591 appendEvent(event);
587} 592}
588 593
589void KOEventViewer::clearEvents(bool now) 594void KOEventViewer::clearEvents(bool now)
590{ 595{
591 mText = ""; 596 mText = "";
592 if (now) setText(mText); 597 if (now) setText(mText);
593} 598}
594 599
595void KOEventViewer::addText(QString text) 600void KOEventViewer::addText(QString text)
596{ 601{
597 mText.append(text); 602 mText.append(text);
598 setText(mText); 603 setText(mText);
599} 604}
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index 3979ed2..f6f7258 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -1,259 +1,260 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <klocale.h> 20#include <klocale.h>
21 21
22#include <libkcal/event.h> 22#include <libkcal/event.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24 24
25#include "koeventviewer.h" 25#include "koeventviewer.h"
26#include "koprefs.h" 26#include "koprefs.h"
27#include <libkcal/todo.h> 27#include <libkcal/todo.h>
28#include "qapp.h" 28#include "qapp.h"
29 29
30#include "koeventviewerdialog.h" 30#include "koeventviewerdialog.h"
31extern int globalFlagBlockAgenda; 31extern int globalFlagBlockAgenda;
32 32
33KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) 33KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name)
34 : KDialogBase(parent,name, 34 : KDialogBase(parent,name,
35#ifndef DESKTOP_VERSION 35#ifndef DESKTOP_VERSION
36 true , 36 true ,
37#else 37#else
38 false, 38 false,
39#endif 39#endif
40 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) 40 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda"))
41{ 41{
42 42
43 mEventViewer = new KOEventViewer(this); 43 mEventViewer = new KOEventViewer(this);
44 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 44 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
45 setMainWidget(mEventViewer); 45 setMainWidget(mEventViewer);
46 setButtonText(Ok, i18n("Edit") ); 46 setButtonText(Ok, i18n("Edit") );
47 47
48 QObject::connect(findButton( Ok ),SIGNAL(clicked()), 48 QObject::connect(findButton( Ok ),SIGNAL(clicked()),
49 SLOT(editIncidence())); 49 SLOT(editIncidence()));
50 QObject::connect(this,SIGNAL(user1Clicked()), 50 QObject::connect(this,SIGNAL(user1Clicked()),
51 SLOT(showIncidence())); 51 SLOT(showIncidence()));
52 mIncidence = 0; 52 mIncidence = 0;
53 // TODO: Set a sensible size (based on the content?). 53 // TODO: Set a sensible size (based on the content?).
54 //showMaximized(); 54 //showMaximized();
55 //qDebug("++++++++++++KOEventViewerDialog() "); 55 //qDebug("++++++++++++KOEventViewerDialog() ");
56 // if ( KOPrefs::instance()->mCompactDialogs ) { 56 // if ( KOPrefs::instance()->mCompactDialogs ) {
57// setFixedSize( 240,284 ); 57// setFixedSize( 240,284 );
58// move( 0, 15 ); 58// move( 0, 15 );
59// } else { 59// } else {
60// setMinimumSize(300,200); 60// setMinimumSize(300,200);
61// resize(320,300); 61// resize(320,300);
62// } 62// }
63 mSyncMode = false; 63 mSyncMode = false;
64 mSyncResult = 0; 64 mSyncResult = 0;
65 65
66} 66}
67 67
68KOEventViewerDialog::~KOEventViewerDialog() 68KOEventViewerDialog::~KOEventViewerDialog()
69{ 69{
70 //qDebug("-------~KOEventViewerDialog() "); 70 //qDebug("-------~KOEventViewerDialog() ");
71} 71}
72void KOEventViewerDialog::showMe() 72void KOEventViewerDialog::showMe()
73{ 73{
74 74
75#ifdef DESKTOP_VERSION 75#ifdef DESKTOP_VERSION
76 show(); 76 show();
77#else 77#else
78 showMaximized(); 78 showMaximized();
79#endif 79#endif
80 setFocus(); 80 setFocus();
81 setActiveWindow(); 81 setActiveWindow();
82 82
83} 83}
84void KOEventViewerDialog::setSyncMode( bool b ) 84void KOEventViewerDialog::setSyncMode( bool b )
85{ 85{
86 mSyncMode = b; 86 mSyncMode = b;
87 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); 87 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode );
88 if ( mSyncMode ) { 88 if ( mSyncMode ) {
89 findButton( Close )->setText( i18n("Cancel Sync")); 89 findButton( Close )->setText( i18n("Cancel Sync"));
90 findButton( Ok )->setText( i18n("Remote")); 90 findButton( Ok )->setText( i18n("Remote"));
91 findButton( User1 )->setText( i18n("Local")); 91 findButton( User1 )->setText( i18n("Local"));
92 } else { 92 } else {
93 findButton( Close )->setText( i18n("Close")); 93 findButton( Close )->setText( i18n("Close"));
94 findButton( Ok )->setText( i18n("Edit")); 94 findButton( Ok )->setText( i18n("Edit"));
95 findButton( User1 )->setText( i18n("Agenda")); 95 findButton( User1 )->setText( i18n("Agenda"));
96 } 96 }
97 mEventViewer->setSyncMode( b ); 97 mEventViewer->setSyncMode( b );
98} 98}
99void KOEventViewerDialog::setColorMode( int m ) 99void KOEventViewerDialog::setColorMode( int m )
100{ 100{
101 mEventViewer->setColorMode( m ); 101 mEventViewer->setColorMode( m );
102} 102}
103int KOEventViewerDialog::executeS( bool local ) 103int KOEventViewerDialog::executeS( bool local )
104{ 104{
105 mSyncResult = 3; 105 mSyncResult = 3;
106 if ( local ) 106 if ( local )
107 findButton( User1 )->setFocus(); 107 findButton( User1 )->setFocus();
108 else 108 else
109 findButton( Ok )->setFocus(); 109 findButton( Ok )->setFocus();
110 exec(); 110 exec();
111 return mSyncResult; 111 return mSyncResult;
112} 112}
113 113
114void KOEventViewerDialog::updateConfig() 114void KOEventViewerDialog::updateConfig()
115{ 115{
116 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 116 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
117 117
118} 118}
119void KOEventViewerDialog::setEvent(Event *event) 119void KOEventViewerDialog::setEvent(Event *event)
120{ 120{
121 mEventViewer->setEvent(event); 121 mEventViewer->setEvent(event);
122 mIncidence = event; 122 mIncidence = event;
123 findButton( Close )->setFocus(); 123 findButton( Close )->setFocus();
124 if ( !mSyncMode ) { 124 if ( !mSyncMode ) {
125 findButton( User1 )->setText( i18n("Agenda")); 125 findButton( User1 )->setText( i18n("Agenda"));
126 } 126 }
127} 127}
128void KOEventViewerDialog::setIncidence(Incidence *in ) 128void KOEventViewerDialog::setIncidence(Incidence *in )
129{ 129{
130 if ( in->type() == "Event" ) 130 if ( in->type() == "Event" )
131 setEvent( (Event*) in ); 131 setEvent( (Event*) in );
132 else if ( in->type() =="Todo" ) 132 else if ( in->type() =="Todo" )
133 setTodo( (Todo*) in ); 133 setTodo( (Todo*) in );
134 else if ( in->type() =="Journal" ) 134 else if ( in->type() =="Journal" )
135 setJournal( (Journal*) in ); 135 setJournal( (Journal*) in );
136} 136}
137void KOEventViewerDialog::addIncidence(Incidence *in) 137void KOEventViewerDialog::addIncidence(Incidence *in)
138{ 138{
139 if ( in->type() == "Event" ) 139 if ( in->type() == "Event" )
140 addEvent( (Event*) in ); 140 addEvent( (Event*) in );
141 else if ( in->type() =="Todo" ) 141 else if ( in->type() =="Todo" )
142 mEventViewer->setTodo( (Todo*) in, false ); 142 mEventViewer->setTodo( (Todo*) in, false );
143 else if ( in->type() =="Journal" ) 143 else if ( in->type() =="Journal" )
144 mEventViewer->setJournal( (Journal*) in, false ); 144 mEventViewer->setJournal( (Journal*) in, false );
145 if ( mSyncMode ) { 145 if ( mSyncMode ) {
146 findButton( User1 )->setFocus(); 146 findButton( User1 )->setFocus();
147 setCaption(i18n("Conflict! Please choose entry")); 147 setCaption(i18n("Conflict! Please choose entry"));
148 } 148 }
149} 149}
150 150
151void KOEventViewerDialog::addEvent(Event *event) 151void KOEventViewerDialog::addEvent(Event *event)
152{ 152{
153 mEventViewer->addEvent(event); 153 mEventViewer->addEvent(event);
154 mIncidence = event; 154 mIncidence = event;
155 findButton( Close )->setFocus(); 155 findButton( Close )->setFocus();
156 if ( !mSyncMode ) { 156 if ( !mSyncMode ) {
157 findButton( User1 )->setText( i18n("Agenda")); 157 findButton( User1 )->setText( i18n("Agenda"));
158 } 158 }
159} 159}
160 160
161void KOEventViewerDialog::setTodo(Todo *event) 161void KOEventViewerDialog::setTodo(Todo *event)
162{ 162{
163 mEventViewer->setTodo(event); 163 mEventViewer->setTodo(event);
164 mIncidence = (Incidence*)event; 164 mIncidence = (Incidence*)event;
165 findButton( Close )->setFocus(); 165 findButton( Close )->setFocus();
166 if ( !mSyncMode ) { 166 if ( !mSyncMode ) {
167 findButton( User1 )->setText( i18n("Set complete")); 167 findButton( User1 )->setText( i18n("Set complete"));
168 } 168 }
169} 169}
170void KOEventViewerDialog::setJournal(Journal *j) 170void KOEventViewerDialog::setJournal(Journal *j)
171{ 171{
172 mEventViewer->setJournal(j); 172 mEventViewer->setJournal(j);
173 mIncidence = (Incidence*)j; 173 mIncidence = (Incidence*)j;
174 findButton( Close )->setFocus(); 174 findButton( Close )->setFocus();
175 if ( !mSyncMode ) { 175 if ( !mSyncMode ) {
176 findButton( User1 )->setText( i18n("Agenda")); 176 findButton( User1 )->setText( i18n("Agenda"));
177 } 177 }
178} 178}
179 179
180void KOEventViewerDialog::addText(QString text) 180void KOEventViewerDialog::addText(QString text)
181{ 181{
182 mEventViewer->addText(text); 182 mEventViewer->addText(text);
183 findButton( Close )->setFocus(); 183 findButton( Close )->setFocus();
184} 184}
185void KOEventViewerDialog::editIncidence() 185void KOEventViewerDialog::editIncidence()
186{ 186{
187 if ( mSyncMode ) { 187 if ( mSyncMode ) {
188 mSyncResult = 2; 188 mSyncResult = 2;
189 accept(); 189 accept();
190 return; 190 return;
191 } 191 }
192 if ( mIncidence ){ 192 if ( mIncidence ){
193#ifndef DESKTOP_VERSION 193#ifndef DESKTOP_VERSION
194 hide(); 194 hide();
195#endif 195#endif
196 emit editIncidence( mIncidence ); 196 emit editIncidence( mIncidence );
197 } 197 }
198} 198}
199void KOEventViewerDialog::showIncidence() 199void KOEventViewerDialog::showIncidence()
200{ 200{
201 201
202 if ( mSyncMode ) { 202 if ( mSyncMode ) {
203 mSyncResult = 1; 203 mSyncResult = 1;
204 accept(); 204 accept();
205 return; 205 return;
206 } 206 }
207 207
208 if ( mIncidence ){ 208 if ( mIncidence ){
209#ifndef DESKTOP_VERSION 209#ifndef DESKTOP_VERSION
210 hide(); 210 hide();
211#endif 211#endif
212 QDate date; 212 QDate date;
213 if ( mIncidence->type() == "Todo" ) { 213 if ( mIncidence->type() == "Todo" ) {
214 /* 214 /*
215 if ( ((Todo*)mIncidence)->hasDueDate() ) 215 if ( ((Todo*)mIncidence)->hasDueDate() )
216 date = ((Todo*)mIncidence)->dtDue().date(); 216 date = ((Todo*)mIncidence)->dtDue().date();
217 else { 217 else {
218 globalFlagBlockAgenda = 2; 218 globalFlagBlockAgenda = 2;
219 emit showAgendaView( false ); 219 emit showAgendaView( false );
220 return; 220 return;
221 } 221 }
222 */ 222 */
223 ((Todo*)mIncidence)->setCompleted( true ); 223 ((Todo*)mIncidence)->setCompleted( true );
224 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() );
224 hide(); 225 hide();
225 emit todoCompleted(((Todo*)mIncidence)); 226 emit todoCompleted(((Todo*)mIncidence));
226 return; 227 return;
227 228
228 } else 229 } else
229 date = mIncidence->dtStart().date(); 230 date = mIncidence->dtStart().date();
230 globalFlagBlockAgenda = 1; 231 globalFlagBlockAgenda = 1;
231 emit showAgendaView( false ); 232 emit showAgendaView( false );
232 globalFlagBlockAgenda = 2; 233 globalFlagBlockAgenda = 2;
233 emit jumpToTime( date ); 234 emit jumpToTime( date );
234 } 235 }
235} 236}
236void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) 237void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
237{ 238{
238 switch ( e->key() ) { 239 switch ( e->key() ) {
239 240
240 case Qt::Key_A : 241 case Qt::Key_A :
241 case Qt::Key_L : 242 case Qt::Key_L :
242 showIncidence(); 243 showIncidence();
243 break; 244 break;
244 case Qt::Key_E : 245 case Qt::Key_E :
245 case Qt::Key_R : 246 case Qt::Key_R :
246 editIncidence(); 247 editIncidence();
247 break; 248 break;
248 case Qt::Key_C: 249 case Qt::Key_C:
249 case Qt::Key_Escape: 250 case Qt::Key_Escape:
250 close(); 251 close();
251 break; 252 break;
252 case Qt::Key_I: 253 case Qt::Key_I:
253 accept(); 254 accept();
254 break; 255 break;
255 default: 256 default:
256 break; 257 break;
257 } 258 }
258 259
259} 260}