-rw-r--r-- | korganizer/calendarview.cpp | 5 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 163 | ||||
-rw-r--r-- | korganizer/komonthview.h | 4 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 1 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 16 |
7 files changed, 174 insertions, 17 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index cca73f2..be78057 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -785,3132 +785,3137 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
785 | else if ( local->type() =="Journal" ) | 785 | else if ( local->type() =="Journal" ) |
786 | equ = (*((Journal*) local) == *((Journal*) remote)); | 786 | equ = (*((Journal*) local) == *((Journal*) remote)); |
787 | if ( equ ) { | 787 | if ( equ ) { |
788 | //qDebug("equal "); | 788 | //qDebug("equal "); |
789 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 789 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
790 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 790 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
791 | } | 791 | } |
792 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 792 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
793 | return 0; | 793 | return 0; |
794 | 794 | ||
795 | }//else //debug only | 795 | }//else //debug only |
796 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 796 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
797 | } | 797 | } |
798 | int result; | 798 | int result; |
799 | bool localIsNew; | 799 | bool localIsNew; |
800 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 800 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
801 | 801 | ||
802 | if ( full && mode < SYNC_PREF_NEWEST ) | 802 | if ( full && mode < SYNC_PREF_NEWEST ) |
803 | mode = SYNC_PREF_ASK; | 803 | mode = SYNC_PREF_ASK; |
804 | 804 | ||
805 | switch( mode ) { | 805 | switch( mode ) { |
806 | case SYNC_PREF_LOCAL: | 806 | case SYNC_PREF_LOCAL: |
807 | if ( lastSync > remoteMod ) | 807 | if ( lastSync > remoteMod ) |
808 | return 1; | 808 | return 1; |
809 | if ( lastSync > localMod ) | 809 | if ( lastSync > localMod ) |
810 | return 2; | 810 | return 2; |
811 | return 1; | 811 | return 1; |
812 | break; | 812 | break; |
813 | case SYNC_PREF_REMOTE: | 813 | case SYNC_PREF_REMOTE: |
814 | if ( lastSync > remoteMod ) | 814 | if ( lastSync > remoteMod ) |
815 | return 1; | 815 | return 1; |
816 | if ( lastSync > localMod ) | 816 | if ( lastSync > localMod ) |
817 | return 2; | 817 | return 2; |
818 | return 2; | 818 | return 2; |
819 | break; | 819 | break; |
820 | case SYNC_PREF_NEWEST: | 820 | case SYNC_PREF_NEWEST: |
821 | if ( localMod > remoteMod ) | 821 | if ( localMod > remoteMod ) |
822 | return 1; | 822 | return 1; |
823 | else | 823 | else |
824 | return 2; | 824 | return 2; |
825 | break; | 825 | break; |
826 | case SYNC_PREF_ASK: | 826 | case SYNC_PREF_ASK: |
827 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 827 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
828 | if ( lastSync > remoteMod ) | 828 | if ( lastSync > remoteMod ) |
829 | return 1; | 829 | return 1; |
830 | if ( lastSync > localMod ) | 830 | if ( lastSync > localMod ) |
831 | return 2; | 831 | return 2; |
832 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 832 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
833 | localIsNew = localMod >= remoteMod; | 833 | localIsNew = localMod >= remoteMod; |
834 | if ( localIsNew ) | 834 | if ( localIsNew ) |
835 | getEventViewerDialog()->setColorMode( 1 ); | 835 | getEventViewerDialog()->setColorMode( 1 ); |
836 | else | 836 | else |
837 | getEventViewerDialog()->setColorMode( 2 ); | 837 | getEventViewerDialog()->setColorMode( 2 ); |
838 | getEventViewerDialog()->setIncidence(local); | 838 | getEventViewerDialog()->setIncidence(local); |
839 | if ( localIsNew ) | 839 | if ( localIsNew ) |
840 | getEventViewerDialog()->setColorMode( 2 ); | 840 | getEventViewerDialog()->setColorMode( 2 ); |
841 | else | 841 | else |
842 | getEventViewerDialog()->setColorMode( 1 ); | 842 | getEventViewerDialog()->setColorMode( 1 ); |
843 | getEventViewerDialog()->addIncidence(remote); | 843 | getEventViewerDialog()->addIncidence(remote); |
844 | getEventViewerDialog()->setColorMode( 0 ); | 844 | getEventViewerDialog()->setColorMode( 0 ); |
845 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 845 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
846 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 846 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
847 | getEventViewerDialog()->showMe(); | 847 | getEventViewerDialog()->showMe(); |
848 | result = getEventViewerDialog()->executeS( localIsNew ); | 848 | result = getEventViewerDialog()->executeS( localIsNew ); |
849 | return result; | 849 | return result; |
850 | 850 | ||
851 | break; | 851 | break; |
852 | case SYNC_PREF_FORCE_LOCAL: | 852 | case SYNC_PREF_FORCE_LOCAL: |
853 | return 1; | 853 | return 1; |
854 | break; | 854 | break; |
855 | case SYNC_PREF_FORCE_REMOTE: | 855 | case SYNC_PREF_FORCE_REMOTE: |
856 | return 2; | 856 | return 2; |
857 | break; | 857 | break; |
858 | 858 | ||
859 | default: | 859 | default: |
860 | // SYNC_PREF_TAKE_BOTH not implemented | 860 | // SYNC_PREF_TAKE_BOTH not implemented |
861 | break; | 861 | break; |
862 | } | 862 | } |
863 | return 0; | 863 | return 0; |
864 | } | 864 | } |
865 | Event* CalendarView::getLastSyncEvent() | 865 | Event* CalendarView::getLastSyncEvent() |
866 | { | 866 | { |
867 | Event* lse; | 867 | Event* lse; |
868 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 868 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
869 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 869 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
870 | if (!lse) { | 870 | if (!lse) { |
871 | lse = new Event(); | 871 | lse = new Event(); |
872 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 872 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
873 | QString sum = ""; | 873 | QString sum = ""; |
874 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 874 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
875 | sum = "E: "; | 875 | sum = "E: "; |
876 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 876 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
877 | lse->setDtStart( mLastCalendarSync ); | 877 | lse->setDtStart( mLastCalendarSync ); |
878 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 878 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
879 | lse->setCategories( i18n("SyncEvent") ); | 879 | lse->setCategories( i18n("SyncEvent") ); |
880 | lse->setReadOnly( true ); | 880 | lse->setReadOnly( true ); |
881 | mCalendar->addEvent( lse ); | 881 | mCalendar->addEvent( lse ); |
882 | } | 882 | } |
883 | 883 | ||
884 | return lse; | 884 | return lse; |
885 | 885 | ||
886 | } | 886 | } |
887 | 887 | ||
888 | // we check, if the to delete event has a id for a profile | 888 | // we check, if the to delete event has a id for a profile |
889 | // if yes, we set this id in the profile to delete | 889 | // if yes, we set this id in the profile to delete |
890 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 890 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
891 | { | 891 | { |
892 | if ( lastSync.count() == 0 ) { | 892 | if ( lastSync.count() == 0 ) { |
893 | //qDebug(" lastSync.count() == 0"); | 893 | //qDebug(" lastSync.count() == 0"); |
894 | return; | 894 | return; |
895 | } | 895 | } |
896 | if ( toDelete->type() == "Journal" ) | 896 | if ( toDelete->type() == "Journal" ) |
897 | return; | 897 | return; |
898 | 898 | ||
899 | Event* eve = lastSync.first(); | 899 | Event* eve = lastSync.first(); |
900 | 900 | ||
901 | while ( eve ) { | 901 | while ( eve ) { |
902 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 902 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
903 | if ( !id.isEmpty() ) { | 903 | if ( !id.isEmpty() ) { |
904 | QString des = eve->description(); | 904 | QString des = eve->description(); |
905 | QString pref = "e"; | 905 | QString pref = "e"; |
906 | if ( toDelete->type() == "Todo" ) | 906 | if ( toDelete->type() == "Todo" ) |
907 | pref = "t"; | 907 | pref = "t"; |
908 | des += pref+ id + ","; | 908 | des += pref+ id + ","; |
909 | eve->setReadOnly( false ); | 909 | eve->setReadOnly( false ); |
910 | eve->setDescription( des ); | 910 | eve->setDescription( des ); |
911 | //qDebug("setdes %s ", des.latin1()); | 911 | //qDebug("setdes %s ", des.latin1()); |
912 | eve->setReadOnly( true ); | 912 | eve->setReadOnly( true ); |
913 | } | 913 | } |
914 | eve = lastSync.next(); | 914 | eve = lastSync.next(); |
915 | } | 915 | } |
916 | 916 | ||
917 | } | 917 | } |
918 | void CalendarView::checkExternalId( Incidence * inc ) | 918 | void CalendarView::checkExternalId( Incidence * inc ) |
919 | { | 919 | { |
920 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 920 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
921 | checkExternSyncEvent( lastSync, inc ); | 921 | checkExternSyncEvent( lastSync, inc ); |
922 | 922 | ||
923 | } | 923 | } |
924 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 924 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
925 | { | 925 | { |
926 | bool syncOK = true; | 926 | bool syncOK = true; |
927 | int addedEvent = 0; | 927 | int addedEvent = 0; |
928 | int addedEventR = 0; | 928 | int addedEventR = 0; |
929 | int deletedEventR = 0; | 929 | int deletedEventR = 0; |
930 | int deletedEventL = 0; | 930 | int deletedEventL = 0; |
931 | int changedLocal = 0; | 931 | int changedLocal = 0; |
932 | int changedRemote = 0; | 932 | int changedRemote = 0; |
933 | int filteredIN = 0; | 933 | int filteredIN = 0; |
934 | int filteredOUT = 0; | 934 | int filteredOUT = 0; |
935 | //QPtrList<Event> el = local->rawEvents(); | 935 | //QPtrList<Event> el = local->rawEvents(); |
936 | Event* eventR; | 936 | Event* eventR; |
937 | QString uid; | 937 | QString uid; |
938 | int take; | 938 | int take; |
939 | Event* eventL; | 939 | Event* eventL; |
940 | Event* eventRSync; | 940 | Event* eventRSync; |
941 | Event* eventLSync; | 941 | Event* eventLSync; |
942 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 942 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
943 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 943 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
944 | bool fullDateRange = false; | 944 | bool fullDateRange = false; |
945 | local->resetTempSyncStat(); | 945 | local->resetTempSyncStat(); |
946 | mLastCalendarSync = QDateTime::currentDateTime(); | 946 | mLastCalendarSync = QDateTime::currentDateTime(); |
947 | if ( mSyncManager->syncWithDesktop() ) { | 947 | if ( mSyncManager->syncWithDesktop() ) { |
948 | remote->resetPilotStat(1); | 948 | remote->resetPilotStat(1); |
949 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 949 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
950 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 950 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
951 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 951 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
952 | } else { | 952 | } else { |
953 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 953 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
954 | } | 954 | } |
955 | } | 955 | } |
956 | QDateTime modifiedCalendar = mLastCalendarSync; | 956 | QDateTime modifiedCalendar = mLastCalendarSync; |
957 | eventLSync = getLastSyncEvent(); | 957 | eventLSync = getLastSyncEvent(); |
958 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 958 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
959 | if ( eventR ) { | 959 | if ( eventR ) { |
960 | eventRSync = (Event*) eventR->clone(); | 960 | eventRSync = (Event*) eventR->clone(); |
961 | remote->deleteEvent(eventR ); | 961 | remote->deleteEvent(eventR ); |
962 | 962 | ||
963 | } else { | 963 | } else { |
964 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 964 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
965 | eventRSync = (Event*)eventLSync->clone(); | 965 | eventRSync = (Event*)eventLSync->clone(); |
966 | } else { | 966 | } else { |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | eventRSync = new Event(); | 968 | eventRSync = new Event(); |
969 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 969 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
970 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 970 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
971 | eventRSync->setDtStart( mLastCalendarSync ); | 971 | eventRSync->setDtStart( mLastCalendarSync ); |
972 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 972 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
973 | eventRSync->setCategories( i18n("SyncEvent") ); | 973 | eventRSync->setCategories( i18n("SyncEvent") ); |
974 | } | 974 | } |
975 | } | 975 | } |
976 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 976 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
977 | fullDateRange = true; | 977 | fullDateRange = true; |
978 | 978 | ||
979 | if ( ! fullDateRange ) { | 979 | if ( ! fullDateRange ) { |
980 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 980 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
981 | 981 | ||
982 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 982 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
983 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 983 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
984 | fullDateRange = true; | 984 | fullDateRange = true; |
985 | } | 985 | } |
986 | } | 986 | } |
987 | if ( mSyncManager->syncWithDesktop() ) { | 987 | if ( mSyncManager->syncWithDesktop() ) { |
988 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 988 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
989 | } | 989 | } |
990 | if ( fullDateRange ) | 990 | if ( fullDateRange ) |
991 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 991 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
992 | else | 992 | else |
993 | mLastCalendarSync = eventLSync->dtStart(); | 993 | mLastCalendarSync = eventLSync->dtStart(); |
994 | // for resyncing if own file has changed | 994 | // for resyncing if own file has changed |
995 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 995 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
996 | mLastCalendarSync = loadedFileVersion; | 996 | mLastCalendarSync = loadedFileVersion; |
997 | //qDebug("setting mLastCalendarSync "); | 997 | //qDebug("setting mLastCalendarSync "); |
998 | } | 998 | } |
999 | //qDebug("*************************** "); | 999 | //qDebug("*************************** "); |
1000 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1000 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1001 | QPtrList<Incidence> er = remote->rawIncidences(); | 1001 | QPtrList<Incidence> er = remote->rawIncidences(); |
1002 | Incidence* inR = er.first(); | 1002 | Incidence* inR = er.first(); |
1003 | Incidence* inL; | 1003 | Incidence* inL; |
1004 | QProgressBar bar( er.count(),0 ); | 1004 | QProgressBar bar( er.count(),0 ); |
1005 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1005 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1006 | 1006 | ||
1007 | // ************** setting up filter ************* | 1007 | // ************** setting up filter ************* |
1008 | CalFilter *filterIN = 0; | 1008 | CalFilter *filterIN = 0; |
1009 | CalFilter *filterOUT = 0; | 1009 | CalFilter *filterOUT = 0; |
1010 | CalFilter *filter = mFilters.first(); | 1010 | CalFilter *filter = mFilters.first(); |
1011 | while(filter) { | 1011 | while(filter) { |
1012 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1012 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1013 | filterIN = filter; | 1013 | filterIN = filter; |
1014 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1014 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1015 | filterOUT = filter; | 1015 | filterOUT = filter; |
1016 | filter = mFilters.next(); | 1016 | filter = mFilters.next(); |
1017 | } | 1017 | } |
1018 | int w = 300; | 1018 | int w = 300; |
1019 | if ( QApplication::desktop()->width() < 320 ) | 1019 | if ( QApplication::desktop()->width() < 320 ) |
1020 | w = 220; | 1020 | w = 220; |
1021 | int h = bar.sizeHint().height() ; | 1021 | int h = bar.sizeHint().height() ; |
1022 | int dw = QApplication::desktop()->width(); | 1022 | int dw = QApplication::desktop()->width(); |
1023 | int dh = QApplication::desktop()->height(); | 1023 | int dh = QApplication::desktop()->height(); |
1024 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1024 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1025 | bar.show(); | 1025 | bar.show(); |
1026 | int modulo = (er.count()/10)+1; | 1026 | int modulo = (er.count()/10)+1; |
1027 | int incCounter = 0; | 1027 | int incCounter = 0; |
1028 | while ( inR ) { | 1028 | while ( inR ) { |
1029 | if ( ! bar.isVisible() ) | 1029 | if ( ! bar.isVisible() ) |
1030 | return false; | 1030 | return false; |
1031 | if ( incCounter % modulo == 0 ) | 1031 | if ( incCounter % modulo == 0 ) |
1032 | bar.setProgress( incCounter ); | 1032 | bar.setProgress( incCounter ); |
1033 | ++incCounter; | 1033 | ++incCounter; |
1034 | uid = inR->uid(); | 1034 | uid = inR->uid(); |
1035 | bool skipIncidence = false; | 1035 | bool skipIncidence = false; |
1036 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1036 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1037 | skipIncidence = true; | 1037 | skipIncidence = true; |
1038 | QString idS; | 1038 | QString idS; |
1039 | qApp->processEvents(); | 1039 | qApp->processEvents(); |
1040 | if ( !skipIncidence ) { | 1040 | if ( !skipIncidence ) { |
1041 | inL = local->incidence( uid ); | 1041 | inL = local->incidence( uid ); |
1042 | if ( inL ) { // maybe conflict - same uid in both calendars | 1042 | if ( inL ) { // maybe conflict - same uid in both calendars |
1043 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1043 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1044 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1044 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1045 | if ( take == 3 ) | 1045 | if ( take == 3 ) |
1046 | return false; | 1046 | return false; |
1047 | if ( take == 1 ) {// take local ********************** | 1047 | if ( take == 1 ) {// take local ********************** |
1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1049 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1049 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1050 | else | 1050 | else |
1051 | idS = inR->IDStr(); | 1051 | idS = inR->IDStr(); |
1052 | remote->deleteIncidence( inR ); | 1052 | remote->deleteIncidence( inR ); |
1053 | inR = inL->clone(); | 1053 | inR = inL->clone(); |
1054 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1054 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1055 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1055 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1056 | inR->setIDStr( idS ); | 1056 | inR->setIDStr( idS ); |
1057 | remote->addIncidence( inR ); | 1057 | remote->addIncidence( inR ); |
1058 | if ( mSyncManager->syncWithDesktop() ) | 1058 | if ( mSyncManager->syncWithDesktop() ) |
1059 | inR->setPilotId( 2 ); | 1059 | inR->setPilotId( 2 ); |
1060 | ++changedRemote; | 1060 | ++changedRemote; |
1061 | } else {// take remote ********************** | 1061 | } else {// take remote ********************** |
1062 | idS = inL->IDStr(); | 1062 | idS = inL->IDStr(); |
1063 | int pid = inL->pilotId(); | 1063 | int pid = inL->pilotId(); |
1064 | local->deleteIncidence( inL ); | 1064 | local->deleteIncidence( inL ); |
1065 | inL = inR->clone(); | 1065 | inL = inR->clone(); |
1066 | if ( mSyncManager->syncWithDesktop() ) | 1066 | if ( mSyncManager->syncWithDesktop() ) |
1067 | inL->setPilotId( pid ); | 1067 | inL->setPilotId( pid ); |
1068 | inL->setIDStr( idS ); | 1068 | inL->setIDStr( idS ); |
1069 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1069 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1070 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1070 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1071 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1071 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1072 | } | 1072 | } |
1073 | local->addIncidence( inL ); | 1073 | local->addIncidence( inL ); |
1074 | ++changedLocal; | 1074 | ++changedLocal; |
1075 | } | 1075 | } |
1076 | } | 1076 | } |
1077 | } else { // no conflict ********** add or delete remote | 1077 | } else { // no conflict ********** add or delete remote |
1078 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1078 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1079 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1079 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1080 | QString des = eventLSync->description(); | 1080 | QString des = eventLSync->description(); |
1081 | QString pref = "e"; | 1081 | QString pref = "e"; |
1082 | if ( inR->type() == "Todo" ) | 1082 | if ( inR->type() == "Todo" ) |
1083 | pref = "t"; | 1083 | pref = "t"; |
1084 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1084 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1085 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1085 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1086 | //remote->deleteIncidence( inR ); | 1086 | //remote->deleteIncidence( inR ); |
1087 | ++deletedEventR; | 1087 | ++deletedEventR; |
1088 | } else { | 1088 | } else { |
1089 | inR->setLastModified( modifiedCalendar ); | 1089 | inR->setLastModified( modifiedCalendar ); |
1090 | inL = inR->clone(); | 1090 | inL = inR->clone(); |
1091 | inL->setIDStr( ":" ); | 1091 | inL->setIDStr( ":" ); |
1092 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1092 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1093 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1093 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1094 | local->addIncidence( inL ); | 1094 | local->addIncidence( inL ); |
1095 | ++addedEvent; | 1095 | ++addedEvent; |
1096 | 1096 | ||
1097 | } | 1097 | } |
1098 | } else { | 1098 | } else { |
1099 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1099 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1100 | inR->setLastModified( modifiedCalendar ); | 1100 | inR->setLastModified( modifiedCalendar ); |
1101 | inL = inR->clone(); | 1101 | inL = inR->clone(); |
1102 | inL->setIDStr( ":" ); | 1102 | inL->setIDStr( ":" ); |
1103 | local->addIncidence( inL ); | 1103 | local->addIncidence( inL ); |
1104 | ++addedEvent; | 1104 | ++addedEvent; |
1105 | 1105 | ||
1106 | } else { | 1106 | } else { |
1107 | checkExternSyncEvent(eventRSyncSharp, inR); | 1107 | checkExternSyncEvent(eventRSyncSharp, inR); |
1108 | remote->deleteIncidence( inR ); | 1108 | remote->deleteIncidence( inR ); |
1109 | ++deletedEventR; | 1109 | ++deletedEventR; |
1110 | } | 1110 | } |
1111 | } | 1111 | } |
1112 | } else { | 1112 | } else { |
1113 | ++filteredIN; | 1113 | ++filteredIN; |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | inR = er.next(); | 1117 | inR = er.next(); |
1118 | } | 1118 | } |
1119 | QPtrList<Incidence> el = local->rawIncidences(); | 1119 | QPtrList<Incidence> el = local->rawIncidences(); |
1120 | inL = el.first(); | 1120 | inL = el.first(); |
1121 | modulo = (el.count()/10)+1; | 1121 | modulo = (el.count()/10)+1; |
1122 | bar.setCaption (i18n("Add / remove events") ); | 1122 | bar.setCaption (i18n("Add / remove events") ); |
1123 | bar.setTotalSteps ( el.count() ) ; | 1123 | bar.setTotalSteps ( el.count() ) ; |
1124 | bar.show(); | 1124 | bar.show(); |
1125 | incCounter = 0; | 1125 | incCounter = 0; |
1126 | 1126 | ||
1127 | while ( inL ) { | 1127 | while ( inL ) { |
1128 | 1128 | ||
1129 | qApp->processEvents(); | 1129 | qApp->processEvents(); |
1130 | if ( ! bar.isVisible() ) | 1130 | if ( ! bar.isVisible() ) |
1131 | return false; | 1131 | return false; |
1132 | if ( incCounter % modulo == 0 ) | 1132 | if ( incCounter % modulo == 0 ) |
1133 | bar.setProgress( incCounter ); | 1133 | bar.setProgress( incCounter ); |
1134 | ++incCounter; | 1134 | ++incCounter; |
1135 | uid = inL->uid(); | 1135 | uid = inL->uid(); |
1136 | bool skipIncidence = false; | 1136 | bool skipIncidence = false; |
1137 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1137 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1138 | skipIncidence = true; | 1138 | skipIncidence = true; |
1139 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1139 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1140 | skipIncidence = true; | 1140 | skipIncidence = true; |
1141 | if ( !skipIncidence ) { | 1141 | if ( !skipIncidence ) { |
1142 | inR = remote->incidence( uid ); | 1142 | inR = remote->incidence( uid ); |
1143 | if ( ! inR ) { | 1143 | if ( ! inR ) { |
1144 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1144 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1145 | // no conflict ********** add or delete local | 1145 | // no conflict ********** add or delete local |
1146 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1146 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1147 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1147 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1148 | checkExternSyncEvent(eventLSyncSharp, inL); | 1148 | checkExternSyncEvent(eventLSyncSharp, inL); |
1149 | local->deleteIncidence( inL ); | 1149 | local->deleteIncidence( inL ); |
1150 | ++deletedEventL; | 1150 | ++deletedEventL; |
1151 | } else { | 1151 | } else { |
1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1153 | inL->removeID(mCurrentSyncDevice ); | 1153 | inL->removeID(mCurrentSyncDevice ); |
1154 | ++addedEventR; | 1154 | ++addedEventR; |
1155 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1155 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1156 | inL->setLastModified( modifiedCalendar ); | 1156 | inL->setLastModified( modifiedCalendar ); |
1157 | inR = inL->clone(); | 1157 | inR = inL->clone(); |
1158 | inR->setIDStr( ":" ); | 1158 | inR->setIDStr( ":" ); |
1159 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1159 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1160 | remote->addIncidence( inR ); | 1160 | remote->addIncidence( inR ); |
1161 | } | 1161 | } |
1162 | } | 1162 | } |
1163 | } else { | 1163 | } else { |
1164 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1164 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1165 | checkExternSyncEvent(eventLSyncSharp, inL); | 1165 | checkExternSyncEvent(eventLSyncSharp, inL); |
1166 | local->deleteIncidence( inL ); | 1166 | local->deleteIncidence( inL ); |
1167 | ++deletedEventL; | 1167 | ++deletedEventL; |
1168 | } else { | 1168 | } else { |
1169 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1169 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1170 | ++addedEventR; | 1170 | ++addedEventR; |
1171 | inL->setLastModified( modifiedCalendar ); | 1171 | inL->setLastModified( modifiedCalendar ); |
1172 | inR = inL->clone(); | 1172 | inR = inL->clone(); |
1173 | inR->setIDStr( ":" ); | 1173 | inR->setIDStr( ":" ); |
1174 | remote->addIncidence( inR ); | 1174 | remote->addIncidence( inR ); |
1175 | } | 1175 | } |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | } else { | 1178 | } else { |
1179 | ++filteredOUT; | 1179 | ++filteredOUT; |
1180 | } | 1180 | } |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
1183 | inL = el.next(); | 1183 | inL = el.next(); |
1184 | } | 1184 | } |
1185 | int delFut = 0; | 1185 | int delFut = 0; |
1186 | int remRem = 0; | 1186 | int remRem = 0; |
1187 | if ( mSyncManager->mWriteBackInFuture ) { | 1187 | if ( mSyncManager->mWriteBackInFuture ) { |
1188 | er = remote->rawIncidences(); | 1188 | er = remote->rawIncidences(); |
1189 | remRem = er.count(); | 1189 | remRem = er.count(); |
1190 | inR = er.first(); | 1190 | inR = er.first(); |
1191 | QDateTime dt; | 1191 | QDateTime dt; |
1192 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1192 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1193 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1193 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1194 | while ( inR ) { | 1194 | while ( inR ) { |
1195 | if ( inR->type() == "Todo" ) { | 1195 | if ( inR->type() == "Todo" ) { |
1196 | Todo * t = (Todo*)inR; | 1196 | Todo * t = (Todo*)inR; |
1197 | if ( t->hasDueDate() ) | 1197 | if ( t->hasDueDate() ) |
1198 | dt = t->dtDue(); | 1198 | dt = t->dtDue(); |
1199 | else | 1199 | else |
1200 | dt = cur.addSecs( 62 ); | 1200 | dt = cur.addSecs( 62 ); |
1201 | } | 1201 | } |
1202 | else if (inR->type() == "Event" ) { | 1202 | else if (inR->type() == "Event" ) { |
1203 | bool ok; | 1203 | bool ok; |
1204 | dt = inR->getNextOccurence( cur, &ok ); | 1204 | dt = inR->getNextOccurence( cur, &ok ); |
1205 | if ( !ok ) | 1205 | if ( !ok ) |
1206 | dt = cur.addSecs( -62 ); | 1206 | dt = cur.addSecs( -62 ); |
1207 | } | 1207 | } |
1208 | else | 1208 | else |
1209 | dt = inR->dtStart(); | 1209 | dt = inR->dtStart(); |
1210 | if ( dt < cur || dt > end ) { | 1210 | if ( dt < cur || dt > end ) { |
1211 | remote->deleteIncidence( inR ); | 1211 | remote->deleteIncidence( inR ); |
1212 | ++delFut; | 1212 | ++delFut; |
1213 | } | 1213 | } |
1214 | inR = er.next(); | 1214 | inR = er.next(); |
1215 | } | 1215 | } |
1216 | } | 1216 | } |
1217 | bar.hide(); | 1217 | bar.hide(); |
1218 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1218 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1219 | eventLSync->setReadOnly( false ); | 1219 | eventLSync->setReadOnly( false ); |
1220 | eventLSync->setDtStart( mLastCalendarSync ); | 1220 | eventLSync->setDtStart( mLastCalendarSync ); |
1221 | eventRSync->setDtStart( mLastCalendarSync ); | 1221 | eventRSync->setDtStart( mLastCalendarSync ); |
1222 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1222 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1223 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1223 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1224 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1224 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1225 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1225 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1226 | eventLSync->setReadOnly( true ); | 1226 | eventLSync->setReadOnly( true ); |
1227 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1227 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1228 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1228 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1229 | remote->addEvent( eventRSync ); | 1229 | remote->addEvent( eventRSync ); |
1230 | else | 1230 | else |
1231 | delete eventRSync; | 1231 | delete eventRSync; |
1232 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1232 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1233 | QString mes; | 1233 | QString mes; |
1234 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1234 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1235 | QString delmess; | 1235 | QString delmess; |
1236 | if ( delFut ) { | 1236 | if ( delFut ) { |
1237 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1237 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1238 | mes += delmess; | 1238 | mes += delmess; |
1239 | } | 1239 | } |
1240 | mes = i18n("Local calendar changed!\n") +mes; | 1240 | mes = i18n("Local calendar changed!\n") +mes; |
1241 | mCalendar->checkAlarmForIncidence( 0, true ); | 1241 | mCalendar->checkAlarmForIncidence( 0, true ); |
1242 | qDebug( mes ); | 1242 | qDebug( mes ); |
1243 | if ( mSyncManager->mShowSyncSummary ) { | 1243 | if ( mSyncManager->mShowSyncSummary ) { |
1244 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1244 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1245 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1245 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1246 | qDebug("KO: WB cancelled "); | 1246 | qDebug("KO: WB cancelled "); |
1247 | return false; | 1247 | return false; |
1248 | } | 1248 | } |
1249 | } | 1249 | } |
1250 | return syncOK; | 1250 | return syncOK; |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | void CalendarView::setSyncDevice( QString s ) | 1253 | void CalendarView::setSyncDevice( QString s ) |
1254 | { | 1254 | { |
1255 | mCurrentSyncDevice= s; | 1255 | mCurrentSyncDevice= s; |
1256 | } | 1256 | } |
1257 | void CalendarView::setSyncName( QString s ) | 1257 | void CalendarView::setSyncName( QString s ) |
1258 | { | 1258 | { |
1259 | mCurrentSyncName= s; | 1259 | mCurrentSyncName= s; |
1260 | } | 1260 | } |
1261 | bool CalendarView::syncCalendar(QString filename, int mode) | 1261 | bool CalendarView::syncCalendar(QString filename, int mode) |
1262 | { | 1262 | { |
1263 | //qDebug("syncCalendar %s ", filename.latin1()); | 1263 | //qDebug("syncCalendar %s ", filename.latin1()); |
1264 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1264 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1265 | CalendarLocal* calendar = new CalendarLocal(); | 1265 | CalendarLocal* calendar = new CalendarLocal(); |
1266 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1266 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1267 | FileStorage* storage = new FileStorage( calendar ); | 1267 | FileStorage* storage = new FileStorage( calendar ); |
1268 | bool syncOK = false; | 1268 | bool syncOK = false; |
1269 | storage->setFileName( filename ); | 1269 | storage->setFileName( filename ); |
1270 | // qDebug("loading ... "); | 1270 | // qDebug("loading ... "); |
1271 | if ( storage->load() ) { | 1271 | if ( storage->load() ) { |
1272 | getEventViewerDialog()->setSyncMode( true ); | 1272 | getEventViewerDialog()->setSyncMode( true ); |
1273 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1273 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1274 | getEventViewerDialog()->setSyncMode( false ); | 1274 | getEventViewerDialog()->setSyncMode( false ); |
1275 | if ( syncOK ) { | 1275 | if ( syncOK ) { |
1276 | if ( mSyncManager->mWriteBackFile ) | 1276 | if ( mSyncManager->mWriteBackFile ) |
1277 | { | 1277 | { |
1278 | storage->setSaveFormat( new ICalFormat() ); | 1278 | storage->setSaveFormat( new ICalFormat() ); |
1279 | storage->save(); | 1279 | storage->save(); |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | setModified( true ); | 1282 | setModified( true ); |
1283 | } | 1283 | } |
1284 | delete storage; | 1284 | delete storage; |
1285 | delete calendar; | 1285 | delete calendar; |
1286 | if ( syncOK ) | 1286 | if ( syncOK ) |
1287 | updateView(); | 1287 | updateView(); |
1288 | return syncOK; | 1288 | return syncOK; |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | void CalendarView::syncExternal( int mode ) | 1291 | void CalendarView::syncExternal( int mode ) |
1292 | { | 1292 | { |
1293 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1293 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1294 | 1294 | ||
1295 | qApp->processEvents(); | 1295 | qApp->processEvents(); |
1296 | CalendarLocal* calendar = new CalendarLocal(); | 1296 | CalendarLocal* calendar = new CalendarLocal(); |
1297 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1297 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1298 | bool syncOK = false; | 1298 | bool syncOK = false; |
1299 | bool loadSuccess = false; | 1299 | bool loadSuccess = false; |
1300 | PhoneFormat* phoneFormat = 0; | 1300 | PhoneFormat* phoneFormat = 0; |
1301 | emit tempDisableBR(true); | 1301 | emit tempDisableBR(true); |
1302 | #ifndef DESKTOP_VERSION | 1302 | #ifndef DESKTOP_VERSION |
1303 | SharpFormat* sharpFormat = 0; | 1303 | SharpFormat* sharpFormat = 0; |
1304 | if ( mode == 0 ) { // sharp | 1304 | if ( mode == 0 ) { // sharp |
1305 | sharpFormat = new SharpFormat () ; | 1305 | sharpFormat = new SharpFormat () ; |
1306 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1306 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1307 | 1307 | ||
1308 | } else | 1308 | } else |
1309 | #endif | 1309 | #endif |
1310 | if ( mode == 1 ) { // phone | 1310 | if ( mode == 1 ) { // phone |
1311 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1311 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1312 | mSyncManager->mPhoneDevice, | 1312 | mSyncManager->mPhoneDevice, |
1313 | mSyncManager->mPhoneConnection, | 1313 | mSyncManager->mPhoneConnection, |
1314 | mSyncManager->mPhoneModel); | 1314 | mSyncManager->mPhoneModel); |
1315 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1315 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1316 | 1316 | ||
1317 | } else { | 1317 | } else { |
1318 | emit tempDisableBR(false); | 1318 | emit tempDisableBR(false); |
1319 | return; | 1319 | return; |
1320 | } | 1320 | } |
1321 | if ( loadSuccess ) { | 1321 | if ( loadSuccess ) { |
1322 | getEventViewerDialog()->setSyncMode( true ); | 1322 | getEventViewerDialog()->setSyncMode( true ); |
1323 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1323 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1324 | getEventViewerDialog()->setSyncMode( false ); | 1324 | getEventViewerDialog()->setSyncMode( false ); |
1325 | qApp->processEvents(); | 1325 | qApp->processEvents(); |
1326 | if ( syncOK ) { | 1326 | if ( syncOK ) { |
1327 | if ( mSyncManager->mWriteBackFile ) | 1327 | if ( mSyncManager->mWriteBackFile ) |
1328 | { | 1328 | { |
1329 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1329 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1330 | Incidence* inc = iL.first(); | 1330 | Incidence* inc = iL.first(); |
1331 | if ( phoneFormat ) { | 1331 | if ( phoneFormat ) { |
1332 | while ( inc ) { | 1332 | while ( inc ) { |
1333 | inc->removeID(mCurrentSyncDevice); | 1333 | inc->removeID(mCurrentSyncDevice); |
1334 | inc = iL.next(); | 1334 | inc = iL.next(); |
1335 | } | 1335 | } |
1336 | } | 1336 | } |
1337 | #ifndef DESKTOP_VERSION | 1337 | #ifndef DESKTOP_VERSION |
1338 | if ( sharpFormat ) | 1338 | if ( sharpFormat ) |
1339 | sharpFormat->save(calendar); | 1339 | sharpFormat->save(calendar); |
1340 | #endif | 1340 | #endif |
1341 | if ( phoneFormat ) | 1341 | if ( phoneFormat ) |
1342 | phoneFormat->save(calendar); | 1342 | phoneFormat->save(calendar); |
1343 | iL = calendar->rawIncidences(); | 1343 | iL = calendar->rawIncidences(); |
1344 | inc = iL.first(); | 1344 | inc = iL.first(); |
1345 | Incidence* loc; | 1345 | Incidence* loc; |
1346 | while ( inc ) { | 1346 | while ( inc ) { |
1347 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1347 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1348 | loc = mCalendar->incidence(inc->uid() ); | 1348 | loc = mCalendar->incidence(inc->uid() ); |
1349 | if ( loc ) { | 1349 | if ( loc ) { |
1350 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1350 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1351 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1351 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1352 | } | 1352 | } |
1353 | } | 1353 | } |
1354 | inc = iL.next(); | 1354 | inc = iL.next(); |
1355 | } | 1355 | } |
1356 | Incidence* lse = getLastSyncEvent(); | 1356 | Incidence* lse = getLastSyncEvent(); |
1357 | if ( lse ) { | 1357 | if ( lse ) { |
1358 | lse->setReadOnly( false ); | 1358 | lse->setReadOnly( false ); |
1359 | lse->setDescription( "" ); | 1359 | lse->setDescription( "" ); |
1360 | lse->setReadOnly( true ); | 1360 | lse->setReadOnly( true ); |
1361 | } | 1361 | } |
1362 | } | 1362 | } |
1363 | } else { | 1363 | } else { |
1364 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1364 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1365 | } | 1365 | } |
1366 | setModified( true ); | 1366 | setModified( true ); |
1367 | } else { | 1367 | } else { |
1368 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1368 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1369 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1369 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1370 | question, i18n("Ok")) ; | 1370 | question, i18n("Ok")) ; |
1371 | 1371 | ||
1372 | } | 1372 | } |
1373 | delete calendar; | 1373 | delete calendar; |
1374 | updateView(); | 1374 | updateView(); |
1375 | emit tempDisableBR(false); | 1375 | emit tempDisableBR(false); |
1376 | return ;//syncOK; | 1376 | return ;//syncOK; |
1377 | 1377 | ||
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | bool CalendarView::importBday() | 1380 | bool CalendarView::importBday() |
1381 | { | 1381 | { |
1382 | #ifndef KORG_NOKABC | 1382 | #ifndef KORG_NOKABC |
1383 | 1383 | ||
1384 | #ifdef DESKTOP_VERSION | 1384 | #ifdef DESKTOP_VERSION |
1385 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1385 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1386 | KABC::AddressBook::Iterator it; | 1386 | KABC::AddressBook::Iterator it; |
1387 | int count = 0; | 1387 | int count = 0; |
1388 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1388 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1389 | ++count; | 1389 | ++count; |
1390 | } | 1390 | } |
1391 | QProgressBar bar(count,0 ); | 1391 | QProgressBar bar(count,0 ); |
1392 | int w = 300; | 1392 | int w = 300; |
1393 | if ( QApplication::desktop()->width() < 320 ) | 1393 | if ( QApplication::desktop()->width() < 320 ) |
1394 | w = 220; | 1394 | w = 220; |
1395 | int h = bar.sizeHint().height() ; | 1395 | int h = bar.sizeHint().height() ; |
1396 | int dw = QApplication::desktop()->width(); | 1396 | int dw = QApplication::desktop()->width(); |
1397 | int dh = QApplication::desktop()->height(); | 1397 | int dh = QApplication::desktop()->height(); |
1398 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1398 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1399 | bar.show(); | 1399 | bar.show(); |
1400 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1400 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1401 | qApp->processEvents(); | 1401 | qApp->processEvents(); |
1402 | count = 0; | 1402 | count = 0; |
1403 | int addCount = 0; | 1403 | int addCount = 0; |
1404 | KCal::Attendee* a = 0; | 1404 | KCal::Attendee* a = 0; |
1405 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1405 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1406 | if ( ! bar.isVisible() ) | 1406 | if ( ! bar.isVisible() ) |
1407 | return false; | 1407 | return false; |
1408 | bar.setProgress( count++ ); | 1408 | bar.setProgress( count++ ); |
1409 | qApp->processEvents(); | 1409 | qApp->processEvents(); |
1410 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1410 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1411 | if ( (*it).birthday().date().isValid() ){ | 1411 | if ( (*it).birthday().date().isValid() ){ |
1412 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1412 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1413 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1413 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1414 | ++addCount; | 1414 | ++addCount; |
1415 | } | 1415 | } |
1416 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1416 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1417 | if ( anni.isValid() ){ | 1417 | if ( anni.isValid() ){ |
1418 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1418 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1419 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1419 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1420 | ++addCount; | 1420 | ++addCount; |
1421 | } | 1421 | } |
1422 | } | 1422 | } |
1423 | updateView(); | 1423 | updateView(); |
1424 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1424 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1425 | #else //DESKTOP_VERSION | 1425 | #else //DESKTOP_VERSION |
1426 | 1426 | ||
1427 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1427 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1428 | // the result should now arrive through method insertBirthdays | 1428 | // the result should now arrive through method insertBirthdays |
1429 | 1429 | ||
1430 | #endif //DESKTOP_VERSION | 1430 | #endif //DESKTOP_VERSION |
1431 | 1431 | ||
1432 | #endif //KORG_NOKABC | 1432 | #endif //KORG_NOKABC |
1433 | 1433 | ||
1434 | 1434 | ||
1435 | return true; | 1435 | return true; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1438 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1439 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1439 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1440 | const QStringList& anniversaryList, const QStringList& realNameList, | 1440 | const QStringList& anniversaryList, const QStringList& realNameList, |
1441 | const QStringList& emailList, const QStringList& assembledNameList, | 1441 | const QStringList& emailList, const QStringList& assembledNameList, |
1442 | const QStringList& uidList) | 1442 | const QStringList& uidList) |
1443 | { | 1443 | { |
1444 | //qDebug("KO::CalendarView::insertBirthdays"); | 1444 | //qDebug("KO::CalendarView::insertBirthdays"); |
1445 | if (uid == this->name()) | 1445 | if (uid == this->name()) |
1446 | { | 1446 | { |
1447 | int count = birthdayList.count(); | 1447 | int count = birthdayList.count(); |
1448 | int addCount = 0; | 1448 | int addCount = 0; |
1449 | KCal::Attendee* a = 0; | 1449 | KCal::Attendee* a = 0; |
1450 | 1450 | ||
1451 | //qDebug("CalView 1 %i", count); | 1451 | //qDebug("CalView 1 %i", count); |
1452 | 1452 | ||
1453 | QProgressBar bar(count,0 ); | 1453 | QProgressBar bar(count,0 ); |
1454 | int w = 300; | 1454 | int w = 300; |
1455 | if ( QApplication::desktop()->width() < 320 ) | 1455 | if ( QApplication::desktop()->width() < 320 ) |
1456 | w = 220; | 1456 | w = 220; |
1457 | int h = bar.sizeHint().height() ; | 1457 | int h = bar.sizeHint().height() ; |
1458 | int dw = QApplication::desktop()->width(); | 1458 | int dw = QApplication::desktop()->width(); |
1459 | int dh = QApplication::desktop()->height(); | 1459 | int dh = QApplication::desktop()->height(); |
1460 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1460 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1461 | bar.show(); | 1461 | bar.show(); |
1462 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1462 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1463 | qApp->processEvents(); | 1463 | qApp->processEvents(); |
1464 | 1464 | ||
1465 | QDate birthday; | 1465 | QDate birthday; |
1466 | QDate anniversary; | 1466 | QDate anniversary; |
1467 | QString realName; | 1467 | QString realName; |
1468 | QString email; | 1468 | QString email; |
1469 | QString assembledName; | 1469 | QString assembledName; |
1470 | QString uid; | 1470 | QString uid; |
1471 | bool ok = true; | 1471 | bool ok = true; |
1472 | for ( int i = 0; i < count; i++) | 1472 | for ( int i = 0; i < count; i++) |
1473 | { | 1473 | { |
1474 | if ( ! bar.isVisible() ) | 1474 | if ( ! bar.isVisible() ) |
1475 | return; | 1475 | return; |
1476 | bar.setProgress( i ); | 1476 | bar.setProgress( i ); |
1477 | qApp->processEvents(); | 1477 | qApp->processEvents(); |
1478 | 1478 | ||
1479 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1479 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1480 | if (!ok) { | 1480 | if (!ok) { |
1481 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1481 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1484 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1485 | if (!ok) { | 1485 | if (!ok) { |
1486 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1486 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1487 | } | 1487 | } |
1488 | realName = realNameList[i]; | 1488 | realName = realNameList[i]; |
1489 | email = emailList[i]; | 1489 | email = emailList[i]; |
1490 | assembledName = assembledNameList[i]; | 1490 | assembledName = assembledNameList[i]; |
1491 | uid = uidList[i]; | 1491 | uid = uidList[i]; |
1492 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1492 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1493 | 1493 | ||
1494 | if ( birthday.isValid() ){ | 1494 | if ( birthday.isValid() ){ |
1495 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1495 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1496 | KCal::Attendee::ReqParticipant,uid) ; | 1496 | KCal::Attendee::ReqParticipant,uid) ; |
1497 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1497 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1498 | ++addCount; | 1498 | ++addCount; |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | if ( anniversary.isValid() ){ | 1501 | if ( anniversary.isValid() ){ |
1502 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1502 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1503 | KCal::Attendee::ReqParticipant,uid) ; | 1503 | KCal::Attendee::ReqParticipant,uid) ; |
1504 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1504 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1505 | ++addCount; | 1505 | ++addCount; |
1506 | } | 1506 | } |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | updateView(); | 1509 | updateView(); |
1510 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1510 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1511 | 1511 | ||
1512 | } | 1512 | } |
1513 | 1513 | ||
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | 1516 | ||
1517 | 1517 | ||
1518 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1518 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1519 | { | 1519 | { |
1520 | //qDebug("addAnni "); | 1520 | //qDebug("addAnni "); |
1521 | Event * ev = new Event(); | 1521 | Event * ev = new Event(); |
1522 | ev->setOrganizer(KOPrefs::instance()->email()); | 1522 | ev->setOrganizer(KOPrefs::instance()->email()); |
1523 | if ( a ) { | 1523 | if ( a ) { |
1524 | ev->addAttendee( a ); | 1524 | ev->addAttendee( a ); |
1525 | } | 1525 | } |
1526 | QString kind; | 1526 | QString kind; |
1527 | if ( birthday ) { | 1527 | if ( birthday ) { |
1528 | kind = i18n( "Birthday" ); | 1528 | kind = i18n( "Birthday" ); |
1529 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1529 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1530 | } | 1530 | } |
1531 | else { | 1531 | else { |
1532 | kind = i18n( "Anniversary" ); | 1532 | kind = i18n( "Anniversary" ); |
1533 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1533 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1534 | } | 1534 | } |
1535 | ev->setCategories( kind ); | 1535 | ev->setCategories( kind ); |
1536 | ev->setDtStart( QDateTime(date) ); | 1536 | ev->setDtStart( QDateTime(date) ); |
1537 | ev->setDtEnd( QDateTime(date) ); | 1537 | ev->setDtEnd( QDateTime(date) ); |
1538 | ev->setFloats( true ); | 1538 | ev->setFloats( true ); |
1539 | Recurrence * rec = ev->recurrence(); | 1539 | Recurrence * rec = ev->recurrence(); |
1540 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1540 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1541 | rec->addYearlyNum( date.month() ); | 1541 | rec->addYearlyNum( date.month() ); |
1542 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1542 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1543 | delete ev; | 1543 | delete ev; |
1544 | return false; | 1544 | return false; |
1545 | } | 1545 | } |
1546 | return true; | 1546 | return true; |
1547 | 1547 | ||
1548 | } | 1548 | } |
1549 | bool CalendarView::importQtopia( const QString &categories, | 1549 | bool CalendarView::importQtopia( const QString &categories, |
1550 | const QString &datebook, | 1550 | const QString &datebook, |
1551 | const QString &todolist ) | 1551 | const QString &todolist ) |
1552 | { | 1552 | { |
1553 | 1553 | ||
1554 | QtopiaFormat qtopiaFormat; | 1554 | QtopiaFormat qtopiaFormat; |
1555 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1555 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1556 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1556 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1557 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1557 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1558 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1558 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1559 | 1559 | ||
1560 | updateView(); | 1560 | updateView(); |
1561 | return true; | 1561 | return true; |
1562 | 1562 | ||
1563 | #if 0 | 1563 | #if 0 |
1564 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1564 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1565 | mCurrentSyncDevice = "qtopia-XML"; | 1565 | mCurrentSyncDevice = "qtopia-XML"; |
1566 | if ( mSyncManager->mAskForPreferences ) | 1566 | if ( mSyncManager->mAskForPreferences ) |
1567 | edit_sync_options(); | 1567 | edit_sync_options(); |
1568 | qApp->processEvents(); | 1568 | qApp->processEvents(); |
1569 | CalendarLocal* calendar = new CalendarLocal(); | 1569 | CalendarLocal* calendar = new CalendarLocal(); |
1570 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1570 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1571 | bool syncOK = false; | 1571 | bool syncOK = false; |
1572 | QtopiaFormat qtopiaFormat; | 1572 | QtopiaFormat qtopiaFormat; |
1573 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1573 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1574 | bool loadOk = true; | 1574 | bool loadOk = true; |
1575 | if ( !categories.isEmpty() ) | 1575 | if ( !categories.isEmpty() ) |
1576 | loadOk = qtopiaFormat.load( calendar, categories ); | 1576 | loadOk = qtopiaFormat.load( calendar, categories ); |
1577 | if ( loadOk && !datebook.isEmpty() ) | 1577 | if ( loadOk && !datebook.isEmpty() ) |
1578 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1578 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1579 | if ( loadOk && !todolist.isEmpty() ) | 1579 | if ( loadOk && !todolist.isEmpty() ) |
1580 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1580 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1581 | 1581 | ||
1582 | if ( loadOk ) { | 1582 | if ( loadOk ) { |
1583 | getEventViewerDialog()->setSyncMode( true ); | 1583 | getEventViewerDialog()->setSyncMode( true ); |
1584 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1584 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1585 | getEventViewerDialog()->setSyncMode( false ); | 1585 | getEventViewerDialog()->setSyncMode( false ); |
1586 | qApp->processEvents(); | 1586 | qApp->processEvents(); |
1587 | if ( syncOK ) { | 1587 | if ( syncOK ) { |
1588 | if ( mSyncManager->mWriteBackFile ) | 1588 | if ( mSyncManager->mWriteBackFile ) |
1589 | { | 1589 | { |
1590 | // write back XML file | 1590 | // write back XML file |
1591 | 1591 | ||
1592 | } | 1592 | } |
1593 | setModified( true ); | 1593 | setModified( true ); |
1594 | } | 1594 | } |
1595 | } else { | 1595 | } else { |
1596 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1596 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1597 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1597 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1598 | question, i18n("Ok")) ; | 1598 | question, i18n("Ok")) ; |
1599 | } | 1599 | } |
1600 | delete calendar; | 1600 | delete calendar; |
1601 | updateView(); | 1601 | updateView(); |
1602 | return syncOK; | 1602 | return syncOK; |
1603 | 1603 | ||
1604 | 1604 | ||
1605 | #endif | 1605 | #endif |
1606 | 1606 | ||
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | void CalendarView::setSyncEventsReadOnly() | 1609 | void CalendarView::setSyncEventsReadOnly() |
1610 | { | 1610 | { |
1611 | Event * ev; | 1611 | Event * ev; |
1612 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1612 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1613 | ev = eL.first(); | 1613 | ev = eL.first(); |
1614 | while ( ev ) { | 1614 | while ( ev ) { |
1615 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1615 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1616 | ev->setReadOnly( true ); | 1616 | ev->setReadOnly( true ); |
1617 | ev = eL.next(); | 1617 | ev = eL.next(); |
1618 | } | 1618 | } |
1619 | } | 1619 | } |
1620 | bool CalendarView::openCalendar(QString filename, bool merge) | 1620 | bool CalendarView::openCalendar(QString filename, bool merge) |
1621 | { | 1621 | { |
1622 | 1622 | ||
1623 | if (filename.isEmpty()) { | 1623 | if (filename.isEmpty()) { |
1624 | return false; | 1624 | return false; |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | if (!QFile::exists(filename)) { | 1627 | if (!QFile::exists(filename)) { |
1628 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1628 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1629 | return false; | 1629 | return false; |
1630 | } | 1630 | } |
1631 | 1631 | ||
1632 | globalFlagBlockAgenda = 1; | 1632 | globalFlagBlockAgenda = 1; |
1633 | if (!merge) mCalendar->close(); | 1633 | if (!merge) mCalendar->close(); |
1634 | 1634 | ||
1635 | mStorage->setFileName( filename ); | 1635 | mStorage->setFileName( filename ); |
1636 | 1636 | ||
1637 | if ( mStorage->load() ) { | 1637 | if ( mStorage->load() ) { |
1638 | if ( merge ) ;//setModified( true ); | 1638 | if ( merge ) ;//setModified( true ); |
1639 | else { | 1639 | else { |
1640 | //setModified( true ); | 1640 | //setModified( true ); |
1641 | mViewManager->setDocumentId( filename ); | 1641 | mViewManager->setDocumentId( filename ); |
1642 | mDialogManager->setDocumentId( filename ); | 1642 | mDialogManager->setDocumentId( filename ); |
1643 | mTodoList->setDocumentId( filename ); | 1643 | mTodoList->setDocumentId( filename ); |
1644 | } | 1644 | } |
1645 | globalFlagBlockAgenda = 2; | 1645 | globalFlagBlockAgenda = 2; |
1646 | // if ( getLastSyncEvent() ) | 1646 | // if ( getLastSyncEvent() ) |
1647 | // getLastSyncEvent()->setReadOnly( true ); | 1647 | // getLastSyncEvent()->setReadOnly( true ); |
1648 | mCalendar->reInitAlarmSettings(); | 1648 | mCalendar->reInitAlarmSettings(); |
1649 | setSyncEventsReadOnly(); | 1649 | setSyncEventsReadOnly(); |
1650 | updateUnmanagedViews(); | 1650 | updateUnmanagedViews(); |
1651 | updateView(); | 1651 | updateView(); |
1652 | if ( filename != MainWindow::defaultFileName() ) { | 1652 | if ( filename != MainWindow::defaultFileName() ) { |
1653 | saveCalendar( MainWindow::defaultFileName() ); | 1653 | saveCalendar( MainWindow::defaultFileName() ); |
1654 | } else { | 1654 | } else { |
1655 | QFileInfo finf ( MainWindow::defaultFileName()); | 1655 | QFileInfo finf ( MainWindow::defaultFileName()); |
1656 | if ( finf.exists() ) { | 1656 | if ( finf.exists() ) { |
1657 | setLoadedFileVersion( finf.lastModified () ); | 1657 | setLoadedFileVersion( finf.lastModified () ); |
1658 | } | 1658 | } |
1659 | } | 1659 | } |
1660 | return true; | 1660 | return true; |
1661 | } else { | 1661 | } else { |
1662 | // while failing to load, the calendar object could | 1662 | // while failing to load, the calendar object could |
1663 | // have become partially populated. Clear it out. | 1663 | // have become partially populated. Clear it out. |
1664 | if ( !merge ) { | 1664 | if ( !merge ) { |
1665 | mCalendar->close(); | 1665 | mCalendar->close(); |
1666 | mViewManager->setDocumentId( filename ); | 1666 | mViewManager->setDocumentId( filename ); |
1667 | mDialogManager->setDocumentId( filename ); | 1667 | mDialogManager->setDocumentId( filename ); |
1668 | mTodoList->setDocumentId( filename ); | 1668 | mTodoList->setDocumentId( filename ); |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1671 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1672 | 1672 | ||
1673 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1673 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1674 | globalFlagBlockAgenda = 2; | 1674 | globalFlagBlockAgenda = 2; |
1675 | mCalendar->reInitAlarmSettings(); | 1675 | mCalendar->reInitAlarmSettings(); |
1676 | setSyncEventsReadOnly(); | 1676 | setSyncEventsReadOnly(); |
1677 | updateUnmanagedViews(); | 1677 | updateUnmanagedViews(); |
1678 | updateView(); | 1678 | updateView(); |
1679 | } | 1679 | } |
1680 | return false; | 1680 | return false; |
1681 | } | 1681 | } |
1682 | void CalendarView::showOpenError() | 1682 | void CalendarView::showOpenError() |
1683 | { | 1683 | { |
1684 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1684 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1685 | } | 1685 | } |
1686 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1686 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1687 | { | 1687 | { |
1688 | loadedFileVersion = dt; | 1688 | loadedFileVersion = dt; |
1689 | } | 1689 | } |
1690 | bool CalendarView::checkFileChanged(QString fn) | 1690 | bool CalendarView::checkFileChanged(QString fn) |
1691 | { | 1691 | { |
1692 | QFileInfo finf ( fn ); | 1692 | QFileInfo finf ( fn ); |
1693 | if ( !finf.exists() ) | 1693 | if ( !finf.exists() ) |
1694 | return true; | 1694 | return true; |
1695 | QDateTime dt = finf.lastModified (); | 1695 | QDateTime dt = finf.lastModified (); |
1696 | if ( dt <= loadedFileVersion ) | 1696 | if ( dt <= loadedFileVersion ) |
1697 | return false; | 1697 | return false; |
1698 | return true; | 1698 | return true; |
1699 | 1699 | ||
1700 | } | 1700 | } |
1701 | void CalendarView::watchSavedFile() | 1701 | void CalendarView::watchSavedFile() |
1702 | { | 1702 | { |
1703 | QFileInfo finf ( MainWindow::defaultFileName()); | 1703 | QFileInfo finf ( MainWindow::defaultFileName()); |
1704 | if ( !finf.exists() ) | 1704 | if ( !finf.exists() ) |
1705 | return; | 1705 | return; |
1706 | QDateTime dt = finf.lastModified (); | 1706 | QDateTime dt = finf.lastModified (); |
1707 | if ( dt < loadedFileVersion ) { | 1707 | if ( dt < loadedFileVersion ) { |
1708 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1708 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1709 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1709 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1710 | return; | 1710 | return; |
1711 | } | 1711 | } |
1712 | loadedFileVersion = dt; | 1712 | loadedFileVersion = dt; |
1713 | } | 1713 | } |
1714 | 1714 | ||
1715 | bool CalendarView::checkFileVersion(QString fn) | 1715 | bool CalendarView::checkFileVersion(QString fn) |
1716 | { | 1716 | { |
1717 | QFileInfo finf ( fn ); | 1717 | QFileInfo finf ( fn ); |
1718 | if ( !finf.exists() ) | 1718 | if ( !finf.exists() ) |
1719 | return true; | 1719 | return true; |
1720 | QDateTime dt = finf.lastModified (); | 1720 | QDateTime dt = finf.lastModified (); |
1721 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1721 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1722 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1722 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1723 | if ( dt <= loadedFileVersion ) | 1723 | if ( dt <= loadedFileVersion ) |
1724 | return true; | 1724 | return true; |
1725 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1725 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1726 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1726 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1727 | i18n("Sync+save")); | 1727 | i18n("Sync+save")); |
1728 | 1728 | ||
1729 | if ( km == KMessageBox::Cancel ) | 1729 | if ( km == KMessageBox::Cancel ) |
1730 | return false; | 1730 | return false; |
1731 | if ( km == KMessageBox::Yes ) | 1731 | if ( km == KMessageBox::Yes ) |
1732 | return true; | 1732 | return true; |
1733 | 1733 | ||
1734 | setSyncDevice("deleteaftersync" ); | 1734 | setSyncDevice("deleteaftersync" ); |
1735 | mSyncManager->mAskForPreferences = true; | 1735 | mSyncManager->mAskForPreferences = true; |
1736 | mSyncManager->mSyncAlgoPrefs = 3; | 1736 | mSyncManager->mSyncAlgoPrefs = 3; |
1737 | mSyncManager->mWriteBackFile = false; | 1737 | mSyncManager->mWriteBackFile = false; |
1738 | mSyncManager->mWriteBackExistingOnly = false; | 1738 | mSyncManager->mWriteBackExistingOnly = false; |
1739 | mSyncManager->mShowSyncSummary = false; | 1739 | mSyncManager->mShowSyncSummary = false; |
1740 | syncCalendar( fn, 3 ); | 1740 | syncCalendar( fn, 3 ); |
1741 | Event * e = getLastSyncEvent(); | 1741 | Event * e = getLastSyncEvent(); |
1742 | mCalendar->deleteEvent ( e ); | 1742 | mCalendar->deleteEvent ( e ); |
1743 | updateView(); | 1743 | updateView(); |
1744 | return true; | 1744 | return true; |
1745 | } | 1745 | } |
1746 | 1746 | ||
1747 | bool CalendarView::saveCalendar( QString filename ) | 1747 | bool CalendarView::saveCalendar( QString filename ) |
1748 | { | 1748 | { |
1749 | 1749 | ||
1750 | // Store back all unsaved data into calendar object | 1750 | // Store back all unsaved data into calendar object |
1751 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1751 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1752 | if ( mViewManager->currentView() ) | 1752 | if ( mViewManager->currentView() ) |
1753 | mViewManager->currentView()->flushView(); | 1753 | mViewManager->currentView()->flushView(); |
1754 | 1754 | ||
1755 | 1755 | ||
1756 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1756 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1757 | mStorage->setSaveFormat( new ICalFormat() ); | 1757 | mStorage->setSaveFormat( new ICalFormat() ); |
1758 | mStorage->setFileName( filename ); | 1758 | mStorage->setFileName( filename ); |
1759 | bool success; | 1759 | bool success; |
1760 | success = mStorage->save(); | 1760 | success = mStorage->save(); |
1761 | if ( !success ) { | 1761 | if ( !success ) { |
1762 | return false; | 1762 | return false; |
1763 | } | 1763 | } |
1764 | if ( filename == MainWindow::defaultFileName() ) { | 1764 | if ( filename == MainWindow::defaultFileName() ) { |
1765 | setLoadedFileVersion( lfv ); | 1765 | setLoadedFileVersion( lfv ); |
1766 | watchSavedFile(); | 1766 | watchSavedFile(); |
1767 | } | 1767 | } |
1768 | return true; | 1768 | return true; |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | void CalendarView::closeCalendar() | 1771 | void CalendarView::closeCalendar() |
1772 | { | 1772 | { |
1773 | 1773 | ||
1774 | // child windows no longer valid | 1774 | // child windows no longer valid |
1775 | emit closingDown(); | 1775 | emit closingDown(); |
1776 | 1776 | ||
1777 | mCalendar->close(); | 1777 | mCalendar->close(); |
1778 | setModified(false); | 1778 | setModified(false); |
1779 | updateView(); | 1779 | updateView(); |
1780 | } | 1780 | } |
1781 | 1781 | ||
1782 | void CalendarView::archiveCalendar() | 1782 | void CalendarView::archiveCalendar() |
1783 | { | 1783 | { |
1784 | mDialogManager->showArchiveDialog(); | 1784 | mDialogManager->showArchiveDialog(); |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | 1787 | ||
1788 | void CalendarView::readSettings() | 1788 | void CalendarView::readSettings() |
1789 | { | 1789 | { |
1790 | 1790 | ||
1791 | 1791 | ||
1792 | // mViewManager->showAgendaView(); | 1792 | // mViewManager->showAgendaView(); |
1793 | QString str; | 1793 | QString str; |
1794 | //qDebug("CalendarView::readSettings() "); | 1794 | //qDebug("CalendarView::readSettings() "); |
1795 | // read settings from the KConfig, supplying reasonable | 1795 | // read settings from the KConfig, supplying reasonable |
1796 | // defaults where none are to be found | 1796 | // defaults where none are to be found |
1797 | KConfig *config = KOGlobals::config(); | 1797 | KConfig *config = KOGlobals::config(); |
1798 | #ifndef KORG_NOSPLITTER | 1798 | #ifndef KORG_NOSPLITTER |
1799 | config->setGroup("KOrganizer Geometry"); | 1799 | config->setGroup("KOrganizer Geometry"); |
1800 | 1800 | ||
1801 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1801 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1802 | if (sizes.count() != 2) { | 1802 | if (sizes.count() != 2) { |
1803 | sizes << mDateNavigator->minimumSizeHint().width(); | 1803 | sizes << mDateNavigator->minimumSizeHint().width(); |
1804 | sizes << 300; | 1804 | sizes << 300; |
1805 | } | 1805 | } |
1806 | mPanner->setSizes(sizes); | 1806 | mPanner->setSizes(sizes); |
1807 | 1807 | ||
1808 | sizes = config->readIntListEntry("Separator2"); | 1808 | sizes = config->readIntListEntry("Separator2"); |
1809 | if ( ( mResourceView && sizes.count() == 4 ) || | 1809 | if ( ( mResourceView && sizes.count() == 4 ) || |
1810 | ( !mResourceView && sizes.count() == 3 ) ) { | 1810 | ( !mResourceView && sizes.count() == 3 ) ) { |
1811 | mLeftSplitter->setSizes(sizes); | 1811 | mLeftSplitter->setSizes(sizes); |
1812 | } | 1812 | } |
1813 | #endif | 1813 | #endif |
1814 | globalFlagBlockAgenda = 1; | 1814 | globalFlagBlockAgenda = 1; |
1815 | mViewManager->showAgendaView(); | 1815 | mViewManager->showAgendaView(); |
1816 | //mViewManager->readSettings( config ); | 1816 | //mViewManager->readSettings( config ); |
1817 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1817 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1818 | readFilterSettings(config); | 1818 | readFilterSettings(config); |
1819 | config->setGroup( "Views" ); | 1819 | config->setGroup( "Views" ); |
1820 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1820 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1821 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1821 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1822 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1822 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1823 | else mNavigator->selectDates( dateCount ); | 1823 | else mNavigator->selectDates( dateCount ); |
1824 | // mViewManager->readSettings( config ); | 1824 | // mViewManager->readSettings( config ); |
1825 | updateConfig(); | 1825 | updateConfig(); |
1826 | globalFlagBlockAgenda = 2; | 1826 | globalFlagBlockAgenda = 2; |
1827 | mViewManager->readSettings( config ); | 1827 | mViewManager->readSettings( config ); |
1828 | #ifdef DESKTOP_VERSION | 1828 | #ifdef DESKTOP_VERSION |
1829 | config->setGroup("WidgetLayout"); | 1829 | config->setGroup("WidgetLayout"); |
1830 | QStringList list; | 1830 | QStringList list; |
1831 | list = config->readListEntry("MainLayout"); | 1831 | list = config->readListEntry("MainLayout"); |
1832 | int x,y,w,h; | 1832 | int x,y,w,h; |
1833 | if ( ! list.isEmpty() ) { | 1833 | if ( ! list.isEmpty() ) { |
1834 | x = list[0].toInt(); | 1834 | x = list[0].toInt(); |
1835 | y = list[1].toInt(); | 1835 | y = list[1].toInt(); |
1836 | w = list[2].toInt(); | 1836 | w = list[2].toInt(); |
1837 | h = list[3].toInt(); | 1837 | h = list[3].toInt(); |
1838 | topLevelWidget()->setGeometry(x,y,w,h); | 1838 | topLevelWidget()->setGeometry(x,y,w,h); |
1839 | 1839 | ||
1840 | } else { | 1840 | } else { |
1841 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1841 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1842 | } | 1842 | } |
1843 | list = config->readListEntry("EditEventLayout"); | 1843 | list = config->readListEntry("EditEventLayout"); |
1844 | if ( ! list.isEmpty() ) { | 1844 | if ( ! list.isEmpty() ) { |
1845 | x = list[0].toInt(); | 1845 | x = list[0].toInt(); |
1846 | y = list[1].toInt(); | 1846 | y = list[1].toInt(); |
1847 | w = list[2].toInt(); | 1847 | w = list[2].toInt(); |
1848 | h = list[3].toInt(); | 1848 | h = list[3].toInt(); |
1849 | mEventEditor->setGeometry(x,y,w,h); | 1849 | mEventEditor->setGeometry(x,y,w,h); |
1850 | 1850 | ||
1851 | } | 1851 | } |
1852 | list = config->readListEntry("EditTodoLayout"); | 1852 | list = config->readListEntry("EditTodoLayout"); |
1853 | if ( ! list.isEmpty() ) { | 1853 | if ( ! list.isEmpty() ) { |
1854 | x = list[0].toInt(); | 1854 | x = list[0].toInt(); |
1855 | y = list[1].toInt(); | 1855 | y = list[1].toInt(); |
1856 | w = list[2].toInt(); | 1856 | w = list[2].toInt(); |
1857 | h = list[3].toInt(); | 1857 | h = list[3].toInt(); |
1858 | mTodoEditor->setGeometry(x,y,w,h); | 1858 | mTodoEditor->setGeometry(x,y,w,h); |
1859 | 1859 | ||
1860 | } | 1860 | } |
1861 | list = config->readListEntry("ViewerLayout"); | 1861 | list = config->readListEntry("ViewerLayout"); |
1862 | if ( ! list.isEmpty() ) { | 1862 | if ( ! list.isEmpty() ) { |
1863 | x = list[0].toInt(); | 1863 | x = list[0].toInt(); |
1864 | y = list[1].toInt(); | 1864 | y = list[1].toInt(); |
1865 | w = list[2].toInt(); | 1865 | w = list[2].toInt(); |
1866 | h = list[3].toInt(); | 1866 | h = list[3].toInt(); |
1867 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1867 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1868 | } | 1868 | } |
1869 | #endif | 1869 | #endif |
1870 | 1870 | ||
1871 | } | 1871 | } |
1872 | 1872 | ||
1873 | 1873 | ||
1874 | void CalendarView::writeSettings() | 1874 | void CalendarView::writeSettings() |
1875 | { | 1875 | { |
1876 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1876 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1877 | 1877 | ||
1878 | KConfig *config = KOGlobals::config(); | 1878 | KConfig *config = KOGlobals::config(); |
1879 | 1879 | ||
1880 | #ifndef KORG_NOSPLITTER | 1880 | #ifndef KORG_NOSPLITTER |
1881 | config->setGroup("KOrganizer Geometry"); | 1881 | config->setGroup("KOrganizer Geometry"); |
1882 | 1882 | ||
1883 | QValueList<int> list = mPanner->sizes(); | 1883 | QValueList<int> list = mPanner->sizes(); |
1884 | config->writeEntry("Separator1",list); | 1884 | config->writeEntry("Separator1",list); |
1885 | 1885 | ||
1886 | list = mLeftSplitter->sizes(); | 1886 | list = mLeftSplitter->sizes(); |
1887 | config->writeEntry("Separator2",list); | 1887 | config->writeEntry("Separator2",list); |
1888 | #endif | 1888 | #endif |
1889 | 1889 | ||
1890 | mViewManager->writeSettings( config ); | 1890 | mViewManager->writeSettings( config ); |
1891 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1891 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1892 | mDialogManager->writeSettings( config ); | 1892 | mDialogManager->writeSettings( config ); |
1893 | //KOPrefs::instance()->usrWriteConfig(); | 1893 | //KOPrefs::instance()->usrWriteConfig(); |
1894 | KOPrefs::instance()->writeConfig(); | 1894 | KOPrefs::instance()->writeConfig(); |
1895 | 1895 | ||
1896 | writeFilterSettings(config); | 1896 | writeFilterSettings(config); |
1897 | 1897 | ||
1898 | config->setGroup( "Views" ); | 1898 | config->setGroup( "Views" ); |
1899 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1899 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1900 | 1900 | ||
1901 | #ifdef DESKTOP_VERSION | 1901 | #ifdef DESKTOP_VERSION |
1902 | config->setGroup("WidgetLayout"); | 1902 | config->setGroup("WidgetLayout"); |
1903 | QStringList list ;//= config->readListEntry("MainLayout"); | 1903 | QStringList list ;//= config->readListEntry("MainLayout"); |
1904 | int x,y,w,h; | 1904 | int x,y,w,h; |
1905 | QWidget* wid; | 1905 | QWidget* wid; |
1906 | wid = topLevelWidget(); | 1906 | wid = topLevelWidget(); |
1907 | x = wid->geometry().x(); | 1907 | x = wid->geometry().x(); |
1908 | y = wid->geometry().y(); | 1908 | y = wid->geometry().y(); |
1909 | w = wid->width(); | 1909 | w = wid->width(); |
1910 | h = wid->height(); | 1910 | h = wid->height(); |
1911 | list.clear(); | 1911 | list.clear(); |
1912 | list << QString::number( x ); | 1912 | list << QString::number( x ); |
1913 | list << QString::number( y ); | 1913 | list << QString::number( y ); |
1914 | list << QString::number( w ); | 1914 | list << QString::number( w ); |
1915 | list << QString::number( h ); | 1915 | list << QString::number( h ); |
1916 | config->writeEntry("MainLayout",list ); | 1916 | config->writeEntry("MainLayout",list ); |
1917 | 1917 | ||
1918 | wid = mEventEditor; | 1918 | wid = mEventEditor; |
1919 | x = wid->geometry().x(); | 1919 | x = wid->geometry().x(); |
1920 | y = wid->geometry().y(); | 1920 | y = wid->geometry().y(); |
1921 | w = wid->width(); | 1921 | w = wid->width(); |
1922 | h = wid->height(); | 1922 | h = wid->height(); |
1923 | list.clear(); | 1923 | list.clear(); |
1924 | list << QString::number( x ); | 1924 | list << QString::number( x ); |
1925 | list << QString::number( y ); | 1925 | list << QString::number( y ); |
1926 | list << QString::number( w ); | 1926 | list << QString::number( w ); |
1927 | list << QString::number( h ); | 1927 | list << QString::number( h ); |
1928 | config->writeEntry("EditEventLayout",list ); | 1928 | config->writeEntry("EditEventLayout",list ); |
1929 | 1929 | ||
1930 | wid = mTodoEditor; | 1930 | wid = mTodoEditor; |
1931 | x = wid->geometry().x(); | 1931 | x = wid->geometry().x(); |
1932 | y = wid->geometry().y(); | 1932 | y = wid->geometry().y(); |
1933 | w = wid->width(); | 1933 | w = wid->width(); |
1934 | h = wid->height(); | 1934 | h = wid->height(); |
1935 | list.clear(); | 1935 | list.clear(); |
1936 | list << QString::number( x ); | 1936 | list << QString::number( x ); |
1937 | list << QString::number( y ); | 1937 | list << QString::number( y ); |
1938 | list << QString::number( w ); | 1938 | list << QString::number( w ); |
1939 | list << QString::number( h ); | 1939 | list << QString::number( h ); |
1940 | config->writeEntry("EditTodoLayout",list ); | 1940 | config->writeEntry("EditTodoLayout",list ); |
1941 | wid = getEventViewerDialog(); | 1941 | wid = getEventViewerDialog(); |
1942 | x = wid->geometry().x(); | 1942 | x = wid->geometry().x(); |
1943 | y = wid->geometry().y(); | 1943 | y = wid->geometry().y(); |
1944 | w = wid->width(); | 1944 | w = wid->width(); |
1945 | h = wid->height(); | 1945 | h = wid->height(); |
1946 | list.clear(); | 1946 | list.clear(); |
1947 | list << QString::number( x ); | 1947 | list << QString::number( x ); |
1948 | list << QString::number( y ); | 1948 | list << QString::number( y ); |
1949 | list << QString::number( w ); | 1949 | list << QString::number( w ); |
1950 | list << QString::number( h ); | 1950 | list << QString::number( h ); |
1951 | config->writeEntry("ViewerLayout",list ); | 1951 | config->writeEntry("ViewerLayout",list ); |
1952 | wid = mDialogManager->getSearchDialog(); | 1952 | wid = mDialogManager->getSearchDialog(); |
1953 | if ( wid ) { | 1953 | if ( wid ) { |
1954 | x = wid->geometry().x(); | 1954 | x = wid->geometry().x(); |
1955 | y = wid->geometry().y(); | 1955 | y = wid->geometry().y(); |
1956 | w = wid->width(); | 1956 | w = wid->width(); |
1957 | h = wid->height(); | 1957 | h = wid->height(); |
1958 | list.clear(); | 1958 | list.clear(); |
1959 | list << QString::number( x ); | 1959 | list << QString::number( x ); |
1960 | list << QString::number( y ); | 1960 | list << QString::number( y ); |
1961 | list << QString::number( w ); | 1961 | list << QString::number( w ); |
1962 | list << QString::number( h ); | 1962 | list << QString::number( h ); |
1963 | config->writeEntry("SearchLayout",list ); | 1963 | config->writeEntry("SearchLayout",list ); |
1964 | } | 1964 | } |
1965 | #endif | 1965 | #endif |
1966 | 1966 | ||
1967 | 1967 | ||
1968 | config->sync(); | 1968 | config->sync(); |
1969 | } | 1969 | } |
1970 | 1970 | ||
1971 | void CalendarView::readFilterSettings(KConfig *config) | 1971 | void CalendarView::readFilterSettings(KConfig *config) |
1972 | { | 1972 | { |
1973 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1973 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1974 | 1974 | ||
1975 | mFilters.clear(); | 1975 | mFilters.clear(); |
1976 | 1976 | ||
1977 | config->setGroup("General"); | 1977 | config->setGroup("General"); |
1978 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1978 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1979 | 1979 | ||
1980 | QStringList::ConstIterator it = filterList.begin(); | 1980 | QStringList::ConstIterator it = filterList.begin(); |
1981 | QStringList::ConstIterator end = filterList.end(); | 1981 | QStringList::ConstIterator end = filterList.end(); |
1982 | while(it != end) { | 1982 | while(it != end) { |
1983 | // kdDebug() << " filter: " << (*it) << endl; | 1983 | // kdDebug() << " filter: " << (*it) << endl; |
1984 | 1984 | ||
1985 | CalFilter *filter; | 1985 | CalFilter *filter; |
1986 | filter = new CalFilter(*it); | 1986 | filter = new CalFilter(*it); |
1987 | config->setGroup("Filter_" + (*it)); | 1987 | config->setGroup("Filter_" + (*it)); |
1988 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1988 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1989 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1989 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1990 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1990 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1991 | mFilters.append(filter); | 1991 | mFilters.append(filter); |
1992 | 1992 | ||
1993 | ++it; | 1993 | ++it; |
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | if (mFilters.count() == 0) { | 1996 | if (mFilters.count() == 0) { |
1997 | CalFilter *filter = new CalFilter(i18n("Default")); | 1997 | CalFilter *filter = new CalFilter(i18n("Default")); |
1998 | mFilters.append(filter); | 1998 | mFilters.append(filter); |
1999 | } | 1999 | } |
2000 | mFilterView->updateFilters(); | 2000 | mFilterView->updateFilters(); |
2001 | config->setGroup("FilterView"); | 2001 | config->setGroup("FilterView"); |
2002 | 2002 | ||
2003 | mFilterView->blockSignals(true); | 2003 | mFilterView->blockSignals(true); |
2004 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2004 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2005 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2005 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2006 | mFilterView->blockSignals(false); | 2006 | mFilterView->blockSignals(false); |
2007 | // We do it manually to avoid it being done twice by the above calls | 2007 | // We do it manually to avoid it being done twice by the above calls |
2008 | updateFilter(); | 2008 | updateFilter(); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | void CalendarView::writeFilterSettings(KConfig *config) | 2011 | void CalendarView::writeFilterSettings(KConfig *config) |
2012 | { | 2012 | { |
2013 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2013 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2014 | 2014 | ||
2015 | QStringList filterList; | 2015 | QStringList filterList; |
2016 | 2016 | ||
2017 | CalFilter *filter = mFilters.first(); | 2017 | CalFilter *filter = mFilters.first(); |
2018 | while(filter) { | 2018 | while(filter) { |
2019 | // kdDebug() << " fn: " << filter->name() << endl; | 2019 | // kdDebug() << " fn: " << filter->name() << endl; |
2020 | filterList << filter->name(); | 2020 | filterList << filter->name(); |
2021 | config->setGroup("Filter_" + filter->name()); | 2021 | config->setGroup("Filter_" + filter->name()); |
2022 | config->writeEntry("Criteria",filter->criteria()); | 2022 | config->writeEntry("Criteria",filter->criteria()); |
2023 | config->writeEntry("CategoryList",filter->categoryList()); | 2023 | config->writeEntry("CategoryList",filter->categoryList()); |
2024 | filter = mFilters.next(); | 2024 | filter = mFilters.next(); |
2025 | } | 2025 | } |
2026 | config->setGroup("General"); | 2026 | config->setGroup("General"); |
2027 | config->writeEntry("CalendarFilters",filterList); | 2027 | config->writeEntry("CalendarFilters",filterList); |
2028 | 2028 | ||
2029 | config->setGroup("FilterView"); | 2029 | config->setGroup("FilterView"); |
2030 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2030 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2031 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2031 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2032 | } | 2032 | } |
2033 | 2033 | ||
2034 | 2034 | ||
2035 | void CalendarView::goToday() | 2035 | void CalendarView::goToday() |
2036 | { | 2036 | { |
2037 | if ( mViewManager->currentView()->isMonthView() ) | 2037 | if ( mViewManager->currentView()->isMonthView() ) |
2038 | mNavigator->selectTodayMonth(); | 2038 | mNavigator->selectTodayMonth(); |
2039 | else | 2039 | else |
2040 | mNavigator->selectToday(); | 2040 | mNavigator->selectToday(); |
2041 | } | 2041 | } |
2042 | 2042 | ||
2043 | void CalendarView::goNext() | 2043 | void CalendarView::goNext() |
2044 | { | 2044 | { |
2045 | mNavigator->selectNext(); | 2045 | mNavigator->selectNext(); |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | void CalendarView::goPrevious() | 2048 | void CalendarView::goPrevious() |
2049 | { | 2049 | { |
2050 | mNavigator->selectPrevious(); | 2050 | mNavigator->selectPrevious(); |
2051 | } | 2051 | } |
2052 | void CalendarView::goNextMonth() | 2052 | void CalendarView::goNextMonth() |
2053 | { | 2053 | { |
2054 | mNavigator->selectNextMonth(); | 2054 | mNavigator->selectNextMonth(); |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void CalendarView::goPreviousMonth() | 2057 | void CalendarView::goPreviousMonth() |
2058 | { | 2058 | { |
2059 | mNavigator->selectPreviousMonth(); | 2059 | mNavigator->selectPreviousMonth(); |
2060 | } | 2060 | } |
2061 | void CalendarView::writeLocale() | 2061 | void CalendarView::writeLocale() |
2062 | { | 2062 | { |
2063 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2063 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2064 | #if 0 | 2064 | #if 0 |
2065 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2065 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2066 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2066 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2067 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2067 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2068 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2068 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2069 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2069 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2070 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2070 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2071 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2071 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2072 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2072 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2073 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2073 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2074 | KOPrefs::instance()->mDaylightsavingStart, | 2074 | KOPrefs::instance()->mDaylightsavingStart, |
2075 | KOPrefs::instance()->mDaylightsavingEnd ); | 2075 | KOPrefs::instance()->mDaylightsavingEnd ); |
2076 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2076 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2077 | #endif | 2077 | #endif |
2078 | } | 2078 | } |
2079 | void CalendarView::updateConfig() | 2079 | void CalendarView::updateConfig() |
2080 | { | 2080 | { |
2081 | writeLocale(); | 2081 | writeLocale(); |
2082 | if ( KOPrefs::instance()->mUseAppColors ) | 2082 | if ( KOPrefs::instance()->mUseAppColors ) |
2083 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2083 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2084 | emit configChanged(); | 2084 | emit configChanged(); |
2085 | mTodoList->updateConfig(); | 2085 | mTodoList->updateConfig(); |
2086 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2086 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2087 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2087 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2088 | // To make the "fill window" configurations work | 2088 | // To make the "fill window" configurations work |
2089 | //mViewManager->raiseCurrentView(); | 2089 | //mViewManager->raiseCurrentView(); |
2090 | } | 2090 | } |
2091 | 2091 | ||
2092 | 2092 | ||
2093 | void CalendarView::eventChanged(Event *event) | 2093 | void CalendarView::eventChanged(Event *event) |
2094 | { | 2094 | { |
2095 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2095 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2096 | //updateUnmanagedViews(); | 2096 | //updateUnmanagedViews(); |
2097 | } | 2097 | } |
2098 | 2098 | ||
2099 | void CalendarView::eventAdded(Event *event) | 2099 | void CalendarView::eventAdded(Event *event) |
2100 | { | 2100 | { |
2101 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2101 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2102 | } | 2102 | } |
2103 | 2103 | ||
2104 | void CalendarView::eventToBeDeleted(Event *) | 2104 | void CalendarView::eventToBeDeleted(Event *) |
2105 | { | 2105 | { |
2106 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2106 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | void CalendarView::eventDeleted() | 2109 | void CalendarView::eventDeleted() |
2110 | { | 2110 | { |
2111 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2111 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2112 | } | 2112 | } |
2113 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2113 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2114 | { | 2114 | { |
2115 | changeIncidenceDisplay((Incidence *)which, action); | 2115 | changeIncidenceDisplay((Incidence *)which, action); |
2116 | mDateNavigator->updateView(); //LR | 2116 | mDateNavigator->updateView(); //LR |
2117 | //mDialogManager->updateSearchDialog(); | 2117 | //mDialogManager->updateSearchDialog(); |
2118 | 2118 | ||
2119 | if (which) { | 2119 | if (which) { |
2120 | mViewManager->updateWNview(); | 2120 | mViewManager->updateWNview(); |
2121 | //mTodoList->updateView(); | 2121 | //mTodoList->updateView(); |
2122 | } | 2122 | } |
2123 | 2123 | ||
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2126 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2127 | { | 2127 | { |
2128 | updateUnmanagedViews(); | 2128 | updateUnmanagedViews(); |
2129 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2129 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2130 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2130 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2131 | mCalendar->checkAlarmForIncidence( 0, true ); | 2131 | mCalendar->checkAlarmForIncidence( 0, true ); |
2132 | if ( mEventViewerDialog ) | 2132 | if ( mEventViewerDialog ) |
2133 | mEventViewerDialog->hide(); | 2133 | mEventViewerDialog->hide(); |
2134 | } | 2134 | } |
2135 | else | 2135 | else |
2136 | mCalendar->checkAlarmForIncidence( which , false ); | 2136 | mCalendar->checkAlarmForIncidence( which , false ); |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | // most of the changeEventDisplays() right now just call the view's | 2139 | // most of the changeEventDisplays() right now just call the view's |
2140 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2140 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2141 | void CalendarView::changeEventDisplay(Event *which, int action) | 2141 | void CalendarView::changeEventDisplay(Event *which, int action) |
2142 | { | 2142 | { |
2143 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2143 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2144 | changeIncidenceDisplay((Incidence *)which, action); | 2144 | changeIncidenceDisplay((Incidence *)which, action); |
2145 | mDateNavigator->updateView(); | 2145 | mDateNavigator->updateView(); |
2146 | //mDialogManager->updateSearchDialog(); | 2146 | //mDialogManager->updateSearchDialog(); |
2147 | 2147 | ||
2148 | if (which) { | 2148 | if (which) { |
2149 | // If there is an event view visible update the display | 2149 | // If there is an event view visible update the display |
2150 | mViewManager->currentView()->changeEventDisplay(which,action); | 2150 | mViewManager->currentView()->changeEventDisplay(which,action); |
2151 | // TODO: check, if update needed | 2151 | // TODO: check, if update needed |
2152 | // if (which->getTodoStatus()) { | 2152 | // if (which->getTodoStatus()) { |
2153 | mTodoList->updateView(); | 2153 | mTodoList->updateView(); |
2154 | // } | 2154 | // } |
2155 | } else { | 2155 | } else { |
2156 | mViewManager->currentView()->updateView(); | 2156 | mViewManager->currentView()->updateView(); |
2157 | } | 2157 | } |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | 2160 | ||
2161 | void CalendarView::updateTodoViews() | 2161 | void CalendarView::updateTodoViews() |
2162 | { | 2162 | { |
2163 | mTodoList->updateView(); | 2163 | mTodoList->updateView(); |
2164 | mViewManager->currentView()->updateView(); | 2164 | mViewManager->currentView()->updateView(); |
2165 | 2165 | ||
2166 | } | 2166 | } |
2167 | 2167 | ||
2168 | 2168 | ||
2169 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2169 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2170 | { | 2170 | { |
2171 | mTodoList->updateView(); | 2171 | mTodoList->updateView(); |
2172 | mViewManager->updateView(start, end); | 2172 | mViewManager->updateView(start, end); |
2173 | //mDateNavigator->updateView(); | 2173 | //mDateNavigator->updateView(); |
2174 | } | 2174 | } |
2175 | 2175 | ||
2176 | void CalendarView::updateView() | 2176 | void CalendarView::updateView() |
2177 | { | 2177 | { |
2178 | DateList tmpList = mNavigator->selectedDates(); | 2178 | DateList tmpList = mNavigator->selectedDates(); |
2179 | 2179 | ||
2180 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2180 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2181 | mTodoList->updateView(); | 2181 | mTodoList->updateView(); |
2182 | // We assume that the navigator only selects consecutive days. | 2182 | // We assume that the navigator only selects consecutive days. |
2183 | updateView( tmpList.first(), tmpList.last() ); | 2183 | updateView( tmpList.first(), tmpList.last() ); |
2184 | } | 2184 | } |
2185 | 2185 | ||
2186 | void CalendarView::updateUnmanagedViews() | 2186 | void CalendarView::updateUnmanagedViews() |
2187 | { | 2187 | { |
2188 | mDateNavigator->updateDayMatrix(); | 2188 | mDateNavigator->updateDayMatrix(); |
2189 | } | 2189 | } |
2190 | 2190 | ||
2191 | int CalendarView::msgItemDelete(const QString name) | 2191 | int CalendarView::msgItemDelete(const QString name) |
2192 | { | 2192 | { |
2193 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2193 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2194 | i18n("This item will be\npermanently deleted."), | 2194 | i18n("This item will be\npermanently deleted."), |
2195 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2195 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2196 | } | 2196 | } |
2197 | 2197 | ||
2198 | 2198 | ||
2199 | void CalendarView::edit_cut() | 2199 | void CalendarView::edit_cut() |
2200 | { | 2200 | { |
2201 | Event *anEvent=0; | 2201 | Event *anEvent=0; |
2202 | 2202 | ||
2203 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2203 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2204 | 2204 | ||
2205 | if (mViewManager->currentView()->isEventView()) { | 2205 | if (mViewManager->currentView()->isEventView()) { |
2206 | if ( incidence && incidence->type() == "Event" ) { | 2206 | if ( incidence && incidence->type() == "Event" ) { |
2207 | anEvent = static_cast<Event *>(incidence); | 2207 | anEvent = static_cast<Event *>(incidence); |
2208 | } | 2208 | } |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | if (!anEvent) { | 2211 | if (!anEvent) { |
2212 | KNotifyClient::beep(); | 2212 | KNotifyClient::beep(); |
2213 | return; | 2213 | return; |
2214 | } | 2214 | } |
2215 | DndFactory factory( mCalendar ); | 2215 | DndFactory factory( mCalendar ); |
2216 | factory.cutIncidence(anEvent); | 2216 | factory.cutIncidence(anEvent); |
2217 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2217 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | void CalendarView::edit_copy() | 2220 | void CalendarView::edit_copy() |
2221 | { | 2221 | { |
2222 | Event *anEvent=0; | 2222 | Event *anEvent=0; |
2223 | 2223 | ||
2224 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2224 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2225 | 2225 | ||
2226 | if (mViewManager->currentView()->isEventView()) { | 2226 | if (mViewManager->currentView()->isEventView()) { |
2227 | if ( incidence && incidence->type() == "Event" ) { | 2227 | if ( incidence && incidence->type() == "Event" ) { |
2228 | anEvent = static_cast<Event *>(incidence); | 2228 | anEvent = static_cast<Event *>(incidence); |
2229 | } | 2229 | } |
2230 | } | 2230 | } |
2231 | 2231 | ||
2232 | if (!anEvent) { | 2232 | if (!anEvent) { |
2233 | KNotifyClient::beep(); | 2233 | KNotifyClient::beep(); |
2234 | return; | 2234 | return; |
2235 | } | 2235 | } |
2236 | DndFactory factory( mCalendar ); | 2236 | DndFactory factory( mCalendar ); |
2237 | factory.copyIncidence(anEvent); | 2237 | factory.copyIncidence(anEvent); |
2238 | } | 2238 | } |
2239 | 2239 | ||
2240 | void CalendarView::edit_paste() | 2240 | void CalendarView::edit_paste() |
2241 | { | 2241 | { |
2242 | QDate date = mNavigator->selectedDates().first(); | 2242 | QDate date = mNavigator->selectedDates().first(); |
2243 | 2243 | ||
2244 | DndFactory factory( mCalendar ); | 2244 | DndFactory factory( mCalendar ); |
2245 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2245 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2246 | 2246 | ||
2247 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2247 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2248 | } | 2248 | } |
2249 | 2249 | ||
2250 | void CalendarView::edit_options() | 2250 | void CalendarView::edit_options() |
2251 | { | 2251 | { |
2252 | mDialogManager->showOptionsDialog(); | 2252 | mDialogManager->showOptionsDialog(); |
2253 | //writeSettings(); | 2253 | //writeSettings(); |
2254 | } | 2254 | } |
2255 | 2255 | ||
2256 | 2256 | ||
2257 | void CalendarView::slotSelectPickerDate( QDate d) | 2257 | void CalendarView::slotSelectPickerDate( QDate d) |
2258 | { | 2258 | { |
2259 | mDateFrame->hide(); | 2259 | mDateFrame->hide(); |
2260 | if ( mDatePickerMode == 1 ) { | 2260 | if ( mDatePickerMode == 1 ) { |
2261 | mNavigator->slotDaySelect( d ); | 2261 | mNavigator->slotDaySelect( d ); |
2262 | } else if ( mDatePickerMode == 2 ) { | 2262 | } else if ( mDatePickerMode == 2 ) { |
2263 | if ( mMoveIncidence->type() == "Todo" ) { | 2263 | if ( mMoveIncidence->type() == "Todo" ) { |
2264 | Todo * to = (Todo *) mMoveIncidence; | 2264 | Todo * to = (Todo *) mMoveIncidence; |
2265 | QTime tim; | 2265 | QTime tim; |
2266 | if ( to->hasDueDate() ) | 2266 | if ( to->hasDueDate() ) |
2267 | tim = to->dtDue().time(); | 2267 | tim = to->dtDue().time(); |
2268 | else { | 2268 | else { |
2269 | tim = QTime ( 0,0,0 ); | 2269 | tim = QTime ( 0,0,0 ); |
2270 | to->setFloats( true ); | 2270 | to->setFloats( true ); |
2271 | to->setHasDueDate( true ); | 2271 | to->setHasDueDate( true ); |
2272 | } | 2272 | } |
2273 | QDateTime dt ( d,tim ); | 2273 | QDateTime dt ( d,tim ); |
2274 | to->setDtDue( dt ); | 2274 | to->setDtDue( dt ); |
2275 | todoChanged( to ); | 2275 | todoChanged( to ); |
2276 | } else { | 2276 | } else { |
2277 | if ( mMoveIncidence->doesRecur() ) { | 2277 | if ( mMoveIncidence->doesRecur() ) { |
2278 | #if 0 | 2278 | #if 0 |
2279 | // PENDING implement this | 2279 | // PENDING implement this |
2280 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2280 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2281 | mCalendar()->addIncidence( newInc ); | 2281 | mCalendar()->addIncidence( newInc ); |
2282 | if ( mMoveIncidence->type() == "Todo" ) | 2282 | if ( mMoveIncidence->type() == "Todo" ) |
2283 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2283 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2284 | else | 2284 | else |
2285 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2285 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2286 | mMoveIncidence = newInc; | 2286 | mMoveIncidence = newInc; |
2287 | 2287 | ||
2288 | #endif | 2288 | #endif |
2289 | } | 2289 | } |
2290 | QTime tim = mMoveIncidence->dtStart().time(); | 2290 | QTime tim = mMoveIncidence->dtStart().time(); |
2291 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2291 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2292 | QDateTime dt ( d,tim ); | 2292 | QDateTime dt ( d,tim ); |
2293 | mMoveIncidence->setDtStart( dt ); | 2293 | mMoveIncidence->setDtStart( dt ); |
2294 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2294 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2295 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2295 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2296 | } | 2296 | } |
2297 | 2297 | ||
2298 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2298 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2299 | } | 2299 | } |
2300 | } | 2300 | } |
2301 | 2301 | ||
2302 | void CalendarView::removeCategories() | 2302 | void CalendarView::removeCategories() |
2303 | { | 2303 | { |
2304 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2304 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2305 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2305 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2306 | QStringList catIncList; | 2306 | QStringList catIncList; |
2307 | QStringList newCatList; | 2307 | QStringList newCatList; |
2308 | Incidence* inc = incList.first(); | 2308 | Incidence* inc = incList.first(); |
2309 | int i; | 2309 | int i; |
2310 | int count = 0; | 2310 | int count = 0; |
2311 | while ( inc ) { | 2311 | while ( inc ) { |
2312 | newCatList.clear(); | 2312 | newCatList.clear(); |
2313 | catIncList = inc->categories() ; | 2313 | catIncList = inc->categories() ; |
2314 | for( i = 0; i< catIncList.count(); ++i ) { | 2314 | for( i = 0; i< catIncList.count(); ++i ) { |
2315 | if ( catList.contains (catIncList[i])) | 2315 | if ( catList.contains (catIncList[i])) |
2316 | newCatList.append( catIncList[i] ); | 2316 | newCatList.append( catIncList[i] ); |
2317 | } | 2317 | } |
2318 | newCatList.sort(); | 2318 | newCatList.sort(); |
2319 | inc->setCategories( newCatList.join(",") ); | 2319 | inc->setCategories( newCatList.join(",") ); |
2320 | inc = incList.next(); | 2320 | inc = incList.next(); |
2321 | } | 2321 | } |
2322 | } | 2322 | } |
2323 | 2323 | ||
2324 | int CalendarView::addCategories() | 2324 | int CalendarView::addCategories() |
2325 | { | 2325 | { |
2326 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2326 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2327 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2327 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2328 | QStringList catIncList; | 2328 | QStringList catIncList; |
2329 | Incidence* inc = incList.first(); | 2329 | Incidence* inc = incList.first(); |
2330 | int i; | 2330 | int i; |
2331 | int count = 0; | 2331 | int count = 0; |
2332 | while ( inc ) { | 2332 | while ( inc ) { |
2333 | catIncList = inc->categories() ; | 2333 | catIncList = inc->categories() ; |
2334 | for( i = 0; i< catIncList.count(); ++i ) { | 2334 | for( i = 0; i< catIncList.count(); ++i ) { |
2335 | if ( !catList.contains (catIncList[i])) { | 2335 | if ( !catList.contains (catIncList[i])) { |
2336 | catList.append( catIncList[i] ); | 2336 | catList.append( catIncList[i] ); |
2337 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2337 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2338 | ++count; | 2338 | ++count; |
2339 | } | 2339 | } |
2340 | } | 2340 | } |
2341 | inc = incList.next(); | 2341 | inc = incList.next(); |
2342 | } | 2342 | } |
2343 | catList.sort(); | 2343 | catList.sort(); |
2344 | KOPrefs::instance()->mCustomCategories = catList; | 2344 | KOPrefs::instance()->mCustomCategories = catList; |
2345 | return count; | 2345 | return count; |
2346 | } | 2346 | } |
2347 | 2347 | ||
2348 | void CalendarView::manageCategories() | 2348 | void CalendarView::manageCategories() |
2349 | { | 2349 | { |
2350 | KOCatPrefs* cp = new KOCatPrefs(); | 2350 | KOCatPrefs* cp = new KOCatPrefs(); |
2351 | cp->show(); | 2351 | cp->show(); |
2352 | int w =cp->sizeHint().width() ; | 2352 | int w =cp->sizeHint().width() ; |
2353 | int h = cp->sizeHint().height() ; | 2353 | int h = cp->sizeHint().height() ; |
2354 | int dw = QApplication::desktop()->width(); | 2354 | int dw = QApplication::desktop()->width(); |
2355 | int dh = QApplication::desktop()->height(); | 2355 | int dh = QApplication::desktop()->height(); |
2356 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2356 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2357 | if ( !cp->exec() ) { | 2357 | if ( !cp->exec() ) { |
2358 | delete cp; | 2358 | delete cp; |
2359 | return; | 2359 | return; |
2360 | } | 2360 | } |
2361 | int count = 0; | 2361 | int count = 0; |
2362 | if ( cp->addCat() ) { | 2362 | if ( cp->addCat() ) { |
2363 | count = addCategories(); | 2363 | count = addCategories(); |
2364 | if ( count ) { | 2364 | if ( count ) { |
2365 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2365 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2366 | writeSettings(); | 2366 | writeSettings(); |
2367 | } else | 2367 | } else |
2368 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2368 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2369 | } else { | 2369 | } else { |
2370 | removeCategories(); | 2370 | removeCategories(); |
2371 | updateView(); | 2371 | updateView(); |
2372 | } | 2372 | } |
2373 | delete cp; | 2373 | delete cp; |
2374 | } | 2374 | } |
2375 | 2375 | ||
2376 | void CalendarView::beamIncidence(Incidence * Inc) | 2376 | void CalendarView::beamIncidence(Incidence * Inc) |
2377 | { | 2377 | { |
2378 | QPtrList<Incidence> delSel ; | 2378 | QPtrList<Incidence> delSel ; |
2379 | delSel.append(Inc); | 2379 | delSel.append(Inc); |
2380 | beamIncidenceList( delSel ); | 2380 | beamIncidenceList( delSel ); |
2381 | } | 2381 | } |
2382 | void CalendarView::beamCalendar() | 2382 | void CalendarView::beamCalendar() |
2383 | { | 2383 | { |
2384 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2384 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2385 | //qDebug("beamCalendar() "); | 2385 | //qDebug("beamCalendar() "); |
2386 | beamIncidenceList( delSel ); | 2386 | beamIncidenceList( delSel ); |
2387 | } | 2387 | } |
2388 | void CalendarView::beamFilteredCalendar() | 2388 | void CalendarView::beamFilteredCalendar() |
2389 | { | 2389 | { |
2390 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2390 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2391 | //qDebug("beamFilteredCalendar() "); | 2391 | //qDebug("beamFilteredCalendar() "); |
2392 | beamIncidenceList( delSel ); | 2392 | beamIncidenceList( delSel ); |
2393 | } | 2393 | } |
2394 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2394 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2395 | { | 2395 | { |
2396 | if ( beamDialog->exec () == QDialog::Rejected ) | 2396 | if ( beamDialog->exec () == QDialog::Rejected ) |
2397 | return; | 2397 | return; |
2398 | #ifdef DESKTOP_VERSION | 2398 | #ifdef DESKTOP_VERSION |
2399 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2399 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2400 | #else | 2400 | #else |
2401 | QString fn = "/tmp/kopibeamfile"; | 2401 | QString fn = "/tmp/kopibeamfile"; |
2402 | #endif | 2402 | #endif |
2403 | QString mes; | 2403 | QString mes; |
2404 | bool createbup = true; | 2404 | bool createbup = true; |
2405 | if ( createbup ) { | 2405 | if ( createbup ) { |
2406 | QString description = "\n"; | 2406 | QString description = "\n"; |
2407 | CalendarLocal* cal = new CalendarLocal(); | 2407 | CalendarLocal* cal = new CalendarLocal(); |
2408 | if ( beamDialog->beamLocal() ) | 2408 | if ( beamDialog->beamLocal() ) |
2409 | cal->setLocalTime(); | 2409 | cal->setLocalTime(); |
2410 | else | 2410 | else |
2411 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2411 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2412 | Incidence *incidence = delSel.first(); | 2412 | Incidence *incidence = delSel.first(); |
2413 | bool addText = false; | 2413 | bool addText = false; |
2414 | if ( delSel.count() < 10 ) | 2414 | if ( delSel.count() < 10 ) |
2415 | addText = true; | 2415 | addText = true; |
2416 | else { | 2416 | else { |
2417 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2417 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2418 | } | 2418 | } |
2419 | while ( incidence ) { | 2419 | while ( incidence ) { |
2420 | Incidence *in = incidence->clone(); | 2420 | Incidence *in = incidence->clone(); |
2421 | if ( ! in->summary().isEmpty() ) { | 2421 | if ( ! in->summary().isEmpty() ) { |
2422 | in->setDescription(""); | 2422 | in->setDescription(""); |
2423 | } else { | 2423 | } else { |
2424 | in->setSummary( in->description().left(20)); | 2424 | in->setSummary( in->description().left(20)); |
2425 | in->setDescription(""); | 2425 | in->setDescription(""); |
2426 | } | 2426 | } |
2427 | if ( addText ) | 2427 | if ( addText ) |
2428 | description += in->summary() + "\n"; | 2428 | description += in->summary() + "\n"; |
2429 | cal->addIncidence( in ); | 2429 | cal->addIncidence( in ); |
2430 | incidence = delSel.next(); | 2430 | incidence = delSel.next(); |
2431 | } | 2431 | } |
2432 | if ( beamDialog->beamVcal() ) { | 2432 | if ( beamDialog->beamVcal() ) { |
2433 | fn += ".vcs"; | 2433 | fn += ".vcs"; |
2434 | FileStorage storage( cal, fn, new VCalFormat ); | 2434 | FileStorage storage( cal, fn, new VCalFormat ); |
2435 | storage.save(); | 2435 | storage.save(); |
2436 | } else { | 2436 | } else { |
2437 | fn += ".ics"; | 2437 | fn += ".ics"; |
2438 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2438 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2439 | storage.save(); | 2439 | storage.save(); |
2440 | } | 2440 | } |
2441 | delete cal; | 2441 | delete cal; |
2442 | mes = i18n("KO/Pi: Ready for beaming"); | 2442 | mes = i18n("KO/Pi: Ready for beaming"); |
2443 | topLevelWidget()->setCaption(mes); | 2443 | topLevelWidget()->setCaption(mes); |
2444 | KApplication::convert2latin1( fn ); | 2444 | KApplication::convert2latin1( fn ); |
2445 | #ifndef DESKTOP_VERSION | 2445 | #ifndef DESKTOP_VERSION |
2446 | Ir *ir = new Ir( this ); | 2446 | Ir *ir = new Ir( this ); |
2447 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2447 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2448 | ir->send( fn, description, "text/x-vCalendar" ); | 2448 | ir->send( fn, description, "text/x-vCalendar" ); |
2449 | #endif | 2449 | #endif |
2450 | } | 2450 | } |
2451 | } | 2451 | } |
2452 | void CalendarView::beamDone( Ir *ir ) | 2452 | void CalendarView::beamDone( Ir *ir ) |
2453 | { | 2453 | { |
2454 | #ifndef DESKTOP_VERSION | 2454 | #ifndef DESKTOP_VERSION |
2455 | delete ir; | 2455 | delete ir; |
2456 | #endif | 2456 | #endif |
2457 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2457 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2458 | topLevelWidget()->raise(); | 2458 | topLevelWidget()->raise(); |
2459 | } | 2459 | } |
2460 | 2460 | ||
2461 | void CalendarView::moveIncidence(Incidence * inc ) | 2461 | void CalendarView::moveIncidence(Incidence * inc ) |
2462 | { | 2462 | { |
2463 | if ( !inc ) return; | 2463 | if ( !inc ) return; |
2464 | // qDebug("showDatePickerForIncidence( ) "); | 2464 | // qDebug("showDatePickerForIncidence( ) "); |
2465 | if ( mDateFrame->isVisible() ) | 2465 | if ( mDateFrame->isVisible() ) |
2466 | mDateFrame->hide(); | 2466 | mDateFrame->hide(); |
2467 | else { | 2467 | else { |
2468 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2468 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2469 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2469 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2470 | int dw = QApplication::desktop()->width(); | 2470 | int dw = QApplication::desktop()->width(); |
2471 | int dh = QApplication::desktop()->height(); | 2471 | int dh = QApplication::desktop()->height(); |
2472 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2472 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2473 | mDateFrame->show(); | 2473 | mDateFrame->show(); |
2474 | } | 2474 | } |
2475 | mDatePickerMode = 2; | 2475 | mDatePickerMode = 2; |
2476 | mMoveIncidence = inc ; | 2476 | mMoveIncidence = inc ; |
2477 | QDate da; | 2477 | QDate da; |
2478 | if ( mMoveIncidence->type() == "Todo" ) { | 2478 | if ( mMoveIncidence->type() == "Todo" ) { |
2479 | Todo * to = (Todo *) mMoveIncidence; | 2479 | Todo * to = (Todo *) mMoveIncidence; |
2480 | if ( to->hasDueDate() ) | 2480 | if ( to->hasDueDate() ) |
2481 | da = to->dtDue().date(); | 2481 | da = to->dtDue().date(); |
2482 | else | 2482 | else |
2483 | da = QDate::currentDate(); | 2483 | da = QDate::currentDate(); |
2484 | } else { | 2484 | } else { |
2485 | da = mMoveIncidence->dtStart().date(); | 2485 | da = mMoveIncidence->dtStart().date(); |
2486 | } | 2486 | } |
2487 | //PENDING set date for recurring incidence to date of recurrence | 2487 | //PENDING set date for recurring incidence to date of recurrence |
2488 | //mMoveIncidenceOldDate; | 2488 | //mMoveIncidenceOldDate; |
2489 | mDatePicker->setDate( da ); | 2489 | mDatePicker->setDate( da ); |
2490 | } | 2490 | } |
2491 | void CalendarView::showDatePicker( ) | 2491 | void CalendarView::showDatePicker( ) |
2492 | { | 2492 | { |
2493 | //qDebug("CalendarView::showDatePicker( ) "); | 2493 | //qDebug("CalendarView::showDatePicker( ) "); |
2494 | if ( mDateFrame->isVisible() ) | 2494 | if ( mDateFrame->isVisible() ) |
2495 | mDateFrame->hide(); | 2495 | mDateFrame->hide(); |
2496 | else { | 2496 | else { |
2497 | int w =mDatePicker->sizeHint().width() ; | 2497 | int w =mDatePicker->sizeHint().width() ; |
2498 | int h = mDatePicker->sizeHint().height() ; | 2498 | int h = mDatePicker->sizeHint().height() ; |
2499 | int dw = QApplication::desktop()->width(); | 2499 | int dw = QApplication::desktop()->width(); |
2500 | int dh = QApplication::desktop()->height(); | 2500 | int dh = QApplication::desktop()->height(); |
2501 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2501 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2502 | mDateFrame->show(); | 2502 | mDateFrame->show(); |
2503 | } | 2503 | } |
2504 | mDatePickerMode = 1; | 2504 | mDatePickerMode = 1; |
2505 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2505 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2506 | } | 2506 | } |
2507 | 2507 | ||
2508 | void CalendarView::showEventEditor() | 2508 | void CalendarView::showEventEditor() |
2509 | { | 2509 | { |
2510 | #ifdef DESKTOP_VERSION | 2510 | #ifdef DESKTOP_VERSION |
2511 | mEventEditor->show(); | 2511 | mEventEditor->show(); |
2512 | #else | 2512 | #else |
2513 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2513 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2514 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2514 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2515 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2515 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2516 | qApp->processEvents(); | 2516 | qApp->processEvents(); |
2517 | delete mEventEditor; | 2517 | delete mEventEditor; |
2518 | mEventEditor = mDialogManager->getEventEditor(); | 2518 | mEventEditor = mDialogManager->getEventEditor(); |
2519 | topLevelWidget()->setCaption( i18n("") ); | 2519 | topLevelWidget()->setCaption( i18n("") ); |
2520 | } | 2520 | } |
2521 | mEventEditor->showMaximized(); | 2521 | mEventEditor->showMaximized(); |
2522 | #endif | 2522 | #endif |
2523 | } | 2523 | } |
2524 | void CalendarView::showTodoEditor() | 2524 | void CalendarView::showTodoEditor() |
2525 | { | 2525 | { |
2526 | #ifdef DESKTOP_VERSION | 2526 | #ifdef DESKTOP_VERSION |
2527 | mTodoEditor->show(); | 2527 | mTodoEditor->show(); |
2528 | #else | 2528 | #else |
2529 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2529 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2530 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2530 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2531 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2531 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2532 | qApp->processEvents(); | 2532 | qApp->processEvents(); |
2533 | delete mTodoEditor; | 2533 | delete mTodoEditor; |
2534 | mTodoEditor = mDialogManager->getTodoEditor(); | 2534 | mTodoEditor = mDialogManager->getTodoEditor(); |
2535 | topLevelWidget()->setCaption( i18n("") ); | 2535 | topLevelWidget()->setCaption( i18n("") ); |
2536 | } | 2536 | } |
2537 | mTodoEditor->showMaximized(); | 2537 | mTodoEditor->showMaximized(); |
2538 | #endif | 2538 | #endif |
2539 | } | 2539 | } |
2540 | 2540 | ||
2541 | void CalendarView::cloneIncidence() | 2541 | void CalendarView::cloneIncidence() |
2542 | { | 2542 | { |
2543 | Incidence *incidence = currentSelection(); | 2543 | Incidence *incidence = currentSelection(); |
2544 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2544 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2545 | if ( incidence ) { | 2545 | if ( incidence ) { |
2546 | cloneIncidence(incidence); | 2546 | cloneIncidence(incidence); |
2547 | } | 2547 | } |
2548 | } | 2548 | } |
2549 | void CalendarView::moveIncidence() | 2549 | void CalendarView::moveIncidence() |
2550 | { | 2550 | { |
2551 | Incidence *incidence = currentSelection(); | 2551 | Incidence *incidence = currentSelection(); |
2552 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2552 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2553 | if ( incidence ) { | 2553 | if ( incidence ) { |
2554 | moveIncidence(incidence); | 2554 | moveIncidence(incidence); |
2555 | } | 2555 | } |
2556 | } | 2556 | } |
2557 | void CalendarView::beamIncidence() | 2557 | void CalendarView::beamIncidence() |
2558 | { | 2558 | { |
2559 | Incidence *incidence = currentSelection(); | 2559 | Incidence *incidence = currentSelection(); |
2560 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2560 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2561 | if ( incidence ) { | 2561 | if ( incidence ) { |
2562 | beamIncidence(incidence); | 2562 | beamIncidence(incidence); |
2563 | } | 2563 | } |
2564 | } | 2564 | } |
2565 | void CalendarView::toggleCancelIncidence() | 2565 | void CalendarView::toggleCancelIncidence() |
2566 | { | 2566 | { |
2567 | Incidence *incidence = currentSelection(); | 2567 | Incidence *incidence = currentSelection(); |
2568 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2568 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2569 | if ( incidence ) { | 2569 | if ( incidence ) { |
2570 | cancelIncidence(incidence); | 2570 | cancelIncidence(incidence); |
2571 | } | 2571 | } |
2572 | } | 2572 | } |
2573 | 2573 | ||
2574 | 2574 | ||
2575 | void CalendarView::cancelIncidence(Incidence * inc ) | 2575 | void CalendarView::cancelIncidence(Incidence * inc ) |
2576 | { | 2576 | { |
2577 | inc->setCancelled( ! inc->cancelled() ); | 2577 | inc->setCancelled( ! inc->cancelled() ); |
2578 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2578 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2579 | updateView(); | 2579 | updateView(); |
2580 | } | 2580 | } |
2581 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2581 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2582 | { | 2582 | { |
2583 | Incidence * newInc = orgInc->clone(); | 2583 | Incidence * newInc = orgInc->clone(); |
2584 | newInc->recreate(); | 2584 | newInc->recreate(); |
2585 | 2585 | ||
2586 | if ( newInc->type() == "Todo" ) { | 2586 | if ( newInc->type() == "Todo" ) { |
2587 | Todo* t = (Todo*) newInc; | 2587 | Todo* t = (Todo*) newInc; |
2588 | showTodoEditor(); | 2588 | showTodoEditor(); |
2589 | mTodoEditor->editTodo( t ); | 2589 | mTodoEditor->editTodo( t ); |
2590 | if ( mTodoEditor->exec() ) { | 2590 | if ( mTodoEditor->exec() ) { |
2591 | mCalendar->addTodo( t ); | 2591 | mCalendar->addTodo( t ); |
2592 | updateView(); | 2592 | updateView(); |
2593 | } else { | 2593 | } else { |
2594 | delete t; | 2594 | delete t; |
2595 | } | 2595 | } |
2596 | } | 2596 | } |
2597 | else { | 2597 | else { |
2598 | Event* e = (Event*) newInc; | 2598 | Event* e = (Event*) newInc; |
2599 | showEventEditor(); | 2599 | showEventEditor(); |
2600 | mEventEditor->editEvent( e ); | 2600 | mEventEditor->editEvent( e ); |
2601 | if ( mEventEditor->exec() ) { | 2601 | if ( mEventEditor->exec() ) { |
2602 | mCalendar->addEvent( e ); | 2602 | mCalendar->addEvent( e ); |
2603 | updateView(); | 2603 | updateView(); |
2604 | } else { | 2604 | } else { |
2605 | delete e; | 2605 | delete e; |
2606 | } | 2606 | } |
2607 | } | 2607 | } |
2608 | } | 2608 | } |
2609 | 2609 | ||
2610 | void CalendarView::newEvent() | 2610 | void CalendarView::newEvent() |
2611 | { | 2611 | { |
2612 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2612 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2613 | KOAgendaView *aView = mViewManager->agendaView(); | 2613 | KOAgendaView *aView = mViewManager->agendaView(); |
2614 | if (aView) { | 2614 | if (aView) { |
2615 | if (aView->selectionStart().isValid()) { | 2615 | if (aView->selectionStart().isValid()) { |
2616 | if (aView->selectedIsAllDay()) { | 2616 | if (aView->selectedIsAllDay()) { |
2617 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2617 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2618 | } else { | 2618 | } else { |
2619 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2619 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2620 | } | 2620 | } |
2621 | return; | 2621 | return; |
2622 | } | 2622 | } |
2623 | } | 2623 | } |
2624 | 2624 | ||
2625 | QDate date = mNavigator->selectedDates().first(); | 2625 | QDate date = mNavigator->selectedDates().first(); |
2626 | QDateTime current = QDateTime::currentDateTime(); | 2626 | QDateTime current = QDateTime::currentDateTime(); |
2627 | if ( date <= current.date() ) { | 2627 | if ( date <= current.date() ) { |
2628 | int hour = current.time().hour() +1; | 2628 | int hour = current.time().hour() +1; |
2629 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2629 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2630 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2630 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2631 | } else | 2631 | } else |
2632 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2632 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2633 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2633 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2634 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2634 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2635 | } | 2635 | } |
2636 | 2636 | ||
2637 | void CalendarView::newEvent(QDateTime fh) | 2637 | void CalendarView::newEvent(QDateTime fh) |
2638 | { | 2638 | { |
2639 | newEvent(fh, | 2639 | newEvent(fh, |
2640 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2640 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2641 | } | 2641 | } |
2642 | 2642 | ||
2643 | void CalendarView::newEvent(QDate dt) | 2643 | void CalendarView::newEvent(QDate dt) |
2644 | { | 2644 | { |
2645 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2645 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2646 | QDateTime(dt, QTime(0,0,0)), true); | 2646 | QDateTime(dt, QTime(0,0,0)), true); |
2647 | } | 2647 | } |
2648 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2648 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2649 | { | 2649 | { |
2650 | newEvent(fromHint, toHint, false); | 2650 | newEvent(fromHint, toHint, false); |
2651 | } | 2651 | } |
2652 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2652 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2653 | { | 2653 | { |
2654 | 2654 | ||
2655 | showEventEditor(); | 2655 | showEventEditor(); |
2656 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2656 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2657 | if ( mFilterView->filtersEnabled() ) { | 2657 | if ( mFilterView->filtersEnabled() ) { |
2658 | CalFilter *filter = mFilterView->selectedFilter(); | 2658 | CalFilter *filter = mFilterView->selectedFilter(); |
2659 | if (filter && filter->showCategories()) { | 2659 | if (filter && filter->showCategories()) { |
2660 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2660 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2661 | } | 2661 | } |
2662 | if ( filter ) | 2662 | if ( filter ) |
2663 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2663 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2664 | } | 2664 | } |
2665 | } | 2665 | } |
2666 | void CalendarView::todoAdded(Todo * t) | 2666 | void CalendarView::todoAdded(Todo * t) |
2667 | { | 2667 | { |
2668 | 2668 | ||
2669 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2669 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2670 | updateTodoViews(); | 2670 | updateTodoViews(); |
2671 | } | 2671 | } |
2672 | void CalendarView::todoChanged(Todo * t) | 2672 | void CalendarView::todoChanged(Todo * t) |
2673 | { | 2673 | { |
2674 | emit todoModified( t, 4 ); | 2674 | emit todoModified( t, 4 ); |
2675 | // updateTodoViews(); | 2675 | // updateTodoViews(); |
2676 | } | 2676 | } |
2677 | void CalendarView::todoToBeDeleted(Todo *) | 2677 | void CalendarView::todoToBeDeleted(Todo *) |
2678 | { | 2678 | { |
2679 | //qDebug("todoToBeDeleted(Todo *) "); | 2679 | //qDebug("todoToBeDeleted(Todo *) "); |
2680 | updateTodoViews(); | 2680 | updateTodoViews(); |
2681 | } | 2681 | } |
2682 | void CalendarView::todoDeleted() | 2682 | void CalendarView::todoDeleted() |
2683 | { | 2683 | { |
2684 | //qDebug(" todoDeleted()"); | 2684 | //qDebug(" todoDeleted()"); |
2685 | updateTodoViews(); | 2685 | updateTodoViews(); |
2686 | } | 2686 | } |
2687 | 2687 | ||
2688 | 2688 | ||
2689 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2689 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2690 | { | 2690 | { |
2691 | showTodoEditor(); | 2691 | showTodoEditor(); |
2692 | mTodoEditor->newTodo(dt,0,allday); | 2692 | mTodoEditor->newTodo(dt,0,allday); |
2693 | if ( mFilterView->filtersEnabled() ) { | 2693 | if ( mFilterView->filtersEnabled() ) { |
2694 | CalFilter *filter = mFilterView->selectedFilter(); | 2694 | CalFilter *filter = mFilterView->selectedFilter(); |
2695 | if (filter && filter->showCategories()) { | 2695 | if (filter && filter->showCategories()) { |
2696 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2696 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2697 | } | 2697 | } |
2698 | if ( filter ) | 2698 | if ( filter ) |
2699 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2699 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2700 | } | 2700 | } |
2701 | } | 2701 | } |
2702 | 2702 | ||
2703 | void CalendarView::newTodo() | 2703 | void CalendarView::newTodo() |
2704 | { | 2704 | { |
2705 | newTodoDateTime( QDateTime(),true ); | 2705 | newTodoDateTime( QDateTime(),true ); |
2706 | } | 2706 | } |
2707 | 2707 | ||
2708 | void CalendarView::newSubTodo() | 2708 | void CalendarView::newSubTodo() |
2709 | { | 2709 | { |
2710 | Todo *todo = selectedTodo(); | 2710 | Todo *todo = selectedTodo(); |
2711 | if ( todo ) newSubTodo( todo ); | 2711 | if ( todo ) newSubTodo( todo ); |
2712 | } | 2712 | } |
2713 | 2713 | ||
2714 | void CalendarView::newSubTodo(Todo *parentEvent) | 2714 | void CalendarView::newSubTodo(Todo *parentEvent) |
2715 | { | 2715 | { |
2716 | 2716 | ||
2717 | showTodoEditor(); | 2717 | showTodoEditor(); |
2718 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2718 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2719 | } | 2719 | } |
2720 | 2720 | ||
2721 | void CalendarView::newFloatingEvent() | 2721 | void CalendarView::newFloatingEvent() |
2722 | { | 2722 | { |
2723 | DateList tmpList = mNavigator->selectedDates(); | 2723 | DateList tmpList = mNavigator->selectedDates(); |
2724 | QDate date = tmpList.first(); | 2724 | QDate date = tmpList.first(); |
2725 | 2725 | ||
2726 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2726 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2727 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2727 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2728 | } | 2728 | } |
2729 | 2729 | ||
2730 | 2730 | ||
2731 | void CalendarView::editEvent( Event *event ) | 2731 | void CalendarView::editEvent( Event *event ) |
2732 | { | 2732 | { |
2733 | 2733 | ||
2734 | if ( !event ) return; | 2734 | if ( !event ) return; |
2735 | if ( event->isReadOnly() ) { | 2735 | if ( event->isReadOnly() ) { |
2736 | showEvent( event ); | 2736 | showEvent( event ); |
2737 | return; | 2737 | return; |
2738 | } | 2738 | } |
2739 | showEventEditor(); | 2739 | showEventEditor(); |
2740 | mEventEditor->editEvent( event , mFlagEditDescription); | 2740 | mEventEditor->editEvent( event , mFlagEditDescription); |
2741 | } | 2741 | } |
2742 | void CalendarView::editJournal( Journal *jour ) | 2742 | void CalendarView::editJournal( Journal *jour ) |
2743 | { | 2743 | { |
2744 | if ( !jour ) return; | 2744 | if ( !jour ) return; |
2745 | mDialogManager->hideSearchDialog(); | 2745 | mDialogManager->hideSearchDialog(); |
2746 | mViewManager->showJournalView(); | 2746 | mViewManager->showJournalView(); |
2747 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2747 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2748 | } | 2748 | } |
2749 | void CalendarView::editTodo( Todo *todo ) | 2749 | void CalendarView::editTodo( Todo *todo ) |
2750 | { | 2750 | { |
2751 | if ( !todo ) return; | 2751 | if ( !todo ) return; |
2752 | 2752 | ||
2753 | if ( todo->isReadOnly() ) { | 2753 | if ( todo->isReadOnly() ) { |
2754 | showTodo( todo ); | 2754 | showTodo( todo ); |
2755 | return; | 2755 | return; |
2756 | } | 2756 | } |
2757 | showTodoEditor(); | 2757 | showTodoEditor(); |
2758 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2758 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2759 | 2759 | ||
2760 | } | 2760 | } |
2761 | 2761 | ||
2762 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2762 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2763 | { | 2763 | { |
2764 | if ( !mEventViewerDialog ) { | 2764 | if ( !mEventViewerDialog ) { |
2765 | mEventViewerDialog = new KOEventViewerDialog(this); | 2765 | mEventViewerDialog = new KOEventViewerDialog(this); |
2766 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2766 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2767 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2767 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2768 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2768 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2769 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2769 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2770 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2770 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2771 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2771 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2772 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2772 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2773 | this, SLOT( todoChanged(Todo *) ) ); | 2773 | this, SLOT( todoChanged(Todo *) ) ); |
2774 | mEventViewerDialog->resize( 640, 480 ); | 2774 | mEventViewerDialog->resize( 640, 480 ); |
2775 | 2775 | ||
2776 | } | 2776 | } |
2777 | return mEventViewerDialog; | 2777 | return mEventViewerDialog; |
2778 | } | 2778 | } |
2779 | void CalendarView::showEvent(Event *event) | 2779 | void CalendarView::showEvent(Event *event) |
2780 | { | 2780 | { |
2781 | getEventViewerDialog()->setEvent(event); | 2781 | getEventViewerDialog()->setEvent(event); |
2782 | getEventViewerDialog()->showMe(); | 2782 | getEventViewerDialog()->showMe(); |
2783 | } | 2783 | } |
2784 | 2784 | ||
2785 | void CalendarView::showTodo(Todo *event) | 2785 | void CalendarView::showTodo(Todo *event) |
2786 | { | 2786 | { |
2787 | getEventViewerDialog()->setTodo(event); | 2787 | getEventViewerDialog()->setTodo(event); |
2788 | getEventViewerDialog()->showMe(); | 2788 | getEventViewerDialog()->showMe(); |
2789 | } | 2789 | } |
2790 | void CalendarView::showJournal( Journal *jour ) | 2790 | void CalendarView::showJournal( Journal *jour ) |
2791 | { | 2791 | { |
2792 | getEventViewerDialog()->setJournal(jour); | 2792 | getEventViewerDialog()->setJournal(jour); |
2793 | getEventViewerDialog()->showMe(); | 2793 | getEventViewerDialog()->showMe(); |
2794 | 2794 | ||
2795 | } | 2795 | } |
2796 | // void CalendarView::todoModified (Todo *event, int changed) | 2796 | // void CalendarView::todoModified (Todo *event, int changed) |
2797 | // { | 2797 | // { |
2798 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2798 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2799 | // // kdDebug() << "Todo modified and open" << endl; | 2799 | // // kdDebug() << "Todo modified and open" << endl; |
2800 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2800 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2801 | // // temp->modified (changed); | 2801 | // // temp->modified (changed); |
2802 | 2802 | ||
2803 | // // } | 2803 | // // } |
2804 | 2804 | ||
2805 | // mViewManager->updateView(); | 2805 | // mViewManager->updateView(); |
2806 | // } | 2806 | // } |
2807 | 2807 | ||
2808 | void CalendarView::appointment_show() | 2808 | void CalendarView::appointment_show() |
2809 | { | 2809 | { |
2810 | Event *anEvent = 0; | 2810 | Event *anEvent = 0; |
2811 | 2811 | ||
2812 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2812 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2813 | 2813 | ||
2814 | if (mViewManager->currentView()->isEventView()) { | 2814 | if (mViewManager->currentView()->isEventView()) { |
2815 | if ( incidence && incidence->type() == "Event" ) { | 2815 | if ( incidence && incidence->type() == "Event" ) { |
2816 | anEvent = static_cast<Event *>(incidence); | 2816 | anEvent = static_cast<Event *>(incidence); |
2817 | } | 2817 | } |
2818 | } | 2818 | } |
2819 | 2819 | ||
2820 | if (!anEvent) { | 2820 | if (!anEvent) { |
2821 | KNotifyClient::beep(); | 2821 | KNotifyClient::beep(); |
2822 | return; | 2822 | return; |
2823 | } | 2823 | } |
2824 | 2824 | ||
2825 | showEvent(anEvent); | 2825 | showEvent(anEvent); |
2826 | } | 2826 | } |
2827 | 2827 | ||
2828 | void CalendarView::appointment_edit() | 2828 | void CalendarView::appointment_edit() |
2829 | { | 2829 | { |
2830 | Event *anEvent = 0; | 2830 | Event *anEvent = 0; |
2831 | 2831 | ||
2832 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2832 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2833 | 2833 | ||
2834 | if (mViewManager->currentView()->isEventView()) { | 2834 | if (mViewManager->currentView()->isEventView()) { |
2835 | if ( incidence && incidence->type() == "Event" ) { | 2835 | if ( incidence && incidence->type() == "Event" ) { |
2836 | anEvent = static_cast<Event *>(incidence); | 2836 | anEvent = static_cast<Event *>(incidence); |
2837 | } | 2837 | } |
2838 | } | 2838 | } |
2839 | 2839 | ||
2840 | if (!anEvent) { | 2840 | if (!anEvent) { |
2841 | KNotifyClient::beep(); | 2841 | KNotifyClient::beep(); |
2842 | return; | 2842 | return; |
2843 | } | 2843 | } |
2844 | 2844 | ||
2845 | editEvent(anEvent); | 2845 | editEvent(anEvent); |
2846 | } | 2846 | } |
2847 | 2847 | ||
2848 | void CalendarView::appointment_delete() | 2848 | void CalendarView::appointment_delete() |
2849 | { | 2849 | { |
2850 | Event *anEvent = 0; | 2850 | Event *anEvent = 0; |
2851 | 2851 | ||
2852 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2852 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2853 | 2853 | ||
2854 | if (mViewManager->currentView()->isEventView()) { | 2854 | if (mViewManager->currentView()->isEventView()) { |
2855 | if ( incidence && incidence->type() == "Event" ) { | 2855 | if ( incidence && incidence->type() == "Event" ) { |
2856 | anEvent = static_cast<Event *>(incidence); | 2856 | anEvent = static_cast<Event *>(incidence); |
2857 | } | 2857 | } |
2858 | } | 2858 | } |
2859 | 2859 | ||
2860 | if (!anEvent) { | 2860 | if (!anEvent) { |
2861 | KNotifyClient::beep(); | 2861 | KNotifyClient::beep(); |
2862 | return; | 2862 | return; |
2863 | } | 2863 | } |
2864 | 2864 | ||
2865 | deleteEvent(anEvent); | 2865 | deleteEvent(anEvent); |
2866 | } | 2866 | } |
2867 | 2867 | ||
2868 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2868 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2869 | { | 2869 | { |
2870 | if (!sub) return; | 2870 | if (!sub) return; |
2871 | if (!parent) return; | 2871 | if (!parent) return; |
2872 | if ( sub->relatedTo() ) | 2872 | if ( sub->relatedTo() ) |
2873 | sub->relatedTo()->removeRelation(sub); | 2873 | sub->relatedTo()->removeRelation(sub); |
2874 | sub->setRelatedTo(parent); | 2874 | sub->setRelatedTo(parent); |
2875 | sub->setRelatedToUid(parent->uid()); | 2875 | sub->setRelatedToUid(parent->uid()); |
2876 | parent->addRelation(sub); | 2876 | parent->addRelation(sub); |
2877 | sub->updated(); | 2877 | sub->updated(); |
2878 | parent->updated(); | 2878 | parent->updated(); |
2879 | setModified(true); | 2879 | setModified(true); |
2880 | updateView(); | 2880 | updateView(); |
2881 | } | 2881 | } |
2882 | void CalendarView::todo_unsub(Todo *anTodo ) | 2882 | void CalendarView::todo_unsub(Todo *anTodo ) |
2883 | { | 2883 | { |
2884 | // Todo *anTodo = selectedTodo(); | 2884 | // Todo *anTodo = selectedTodo(); |
2885 | if (!anTodo) return; | 2885 | if (!anTodo) return; |
2886 | if (!anTodo->relatedTo()) return; | 2886 | if (!anTodo->relatedTo()) return; |
2887 | anTodo->relatedTo()->removeRelation(anTodo); | 2887 | anTodo->relatedTo()->removeRelation(anTodo); |
2888 | anTodo->setRelatedTo(0); | 2888 | anTodo->setRelatedTo(0); |
2889 | anTodo->updated(); | 2889 | anTodo->updated(); |
2890 | anTodo->setRelatedToUid(""); | 2890 | anTodo->setRelatedToUid(""); |
2891 | setModified(true); | 2891 | setModified(true); |
2892 | updateView(); | 2892 | updateView(); |
2893 | } | 2893 | } |
2894 | 2894 | ||
2895 | void CalendarView::deleteTodo(Todo *todo) | 2895 | void CalendarView::deleteTodo(Todo *todo) |
2896 | { | 2896 | { |
2897 | if (!todo) { | 2897 | if (!todo) { |
2898 | KNotifyClient::beep(); | 2898 | KNotifyClient::beep(); |
2899 | return; | 2899 | return; |
2900 | } | 2900 | } |
2901 | if (KOPrefs::instance()->mConfirm) { | 2901 | if (KOPrefs::instance()->mConfirm) { |
2902 | QString text = todo->summary().left(20); | 2902 | QString text = todo->summary().left(20); |
2903 | if (!todo->relations().isEmpty()) { | 2903 | if (!todo->relations().isEmpty()) { |
2904 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2904 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2905 | 2905 | ||
2906 | } | 2906 | } |
2907 | switch (msgItemDelete(text)) { | 2907 | switch (msgItemDelete(text)) { |
2908 | case KMessageBox::Continue: // OK | 2908 | case KMessageBox::Continue: // OK |
2909 | bool deleteT = false; | 2909 | bool deleteT = false; |
2910 | if (!todo->relations().isEmpty()) { | 2910 | if (!todo->relations().isEmpty()) { |
2911 | deleteT = removeCompletedSubTodos( todo ); | 2911 | deleteT = removeCompletedSubTodos( todo ); |
2912 | } | 2912 | } |
2913 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2913 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2914 | if ( !deleteT ) { | 2914 | if ( !deleteT ) { |
2915 | checkExternalId( todo ); | 2915 | checkExternalId( todo ); |
2916 | calendar()->deleteTodo(todo); | 2916 | calendar()->deleteTodo(todo); |
2917 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2917 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2918 | updateView(); | 2918 | updateView(); |
2919 | } | 2919 | } |
2920 | break; | 2920 | break; |
2921 | } // switch | 2921 | } // switch |
2922 | } else { | 2922 | } else { |
2923 | checkExternalId( todo ); | 2923 | checkExternalId( todo ); |
2924 | mCalendar->deleteTodo(todo); | 2924 | mCalendar->deleteTodo(todo); |
2925 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2925 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2926 | updateView(); | 2926 | updateView(); |
2927 | } | 2927 | } |
2928 | 2928 | ||
2929 | emit updateSearchDialog(); | 2929 | emit updateSearchDialog(); |
2930 | } | 2930 | } |
2931 | void CalendarView::deleteJournal(Journal *jour) | 2931 | void CalendarView::deleteJournal(Journal *jour) |
2932 | { | 2932 | { |
2933 | if (!jour) { | 2933 | if (!jour) { |
2934 | KNotifyClient::beep(); | 2934 | KNotifyClient::beep(); |
2935 | return; | 2935 | return; |
2936 | } | 2936 | } |
2937 | if (KOPrefs::instance()->mConfirm) { | 2937 | if (KOPrefs::instance()->mConfirm) { |
2938 | switch (msgItemDelete( jour->description().left(20))) { | 2938 | switch (msgItemDelete( jour->description().left(20))) { |
2939 | case KMessageBox::Continue: // OK | 2939 | case KMessageBox::Continue: // OK |
2940 | calendar()->deleteJournal(jour); | 2940 | calendar()->deleteJournal(jour); |
2941 | updateView(); | 2941 | updateView(); |
2942 | break; | 2942 | break; |
2943 | } // switch | 2943 | } // switch |
2944 | } else { | 2944 | } else { |
2945 | calendar()->deleteJournal(jour);; | 2945 | calendar()->deleteJournal(jour);; |
2946 | updateView(); | 2946 | updateView(); |
2947 | } | 2947 | } |
2948 | emit updateSearchDialog(); | 2948 | emit updateSearchDialog(); |
2949 | } | 2949 | } |
2950 | 2950 | ||
2951 | void CalendarView::deleteEvent(Event *anEvent) | 2951 | void CalendarView::deleteEvent(Event *anEvent) |
2952 | { | 2952 | { |
2953 | if (!anEvent) { | 2953 | if (!anEvent) { |
2954 | KNotifyClient::beep(); | 2954 | KNotifyClient::beep(); |
2955 | return; | 2955 | return; |
2956 | } | 2956 | } |
2957 | 2957 | ||
2958 | if (anEvent->recurrence()->doesRecur()) { | 2958 | if (anEvent->recurrence()->doesRecur()) { |
2959 | QDate itemDate = mViewManager->currentSelectionDate(); | 2959 | QDate itemDate = mViewManager->currentSelectionDate(); |
2960 | int km; | 2960 | int km; |
2961 | if (!itemDate.isValid()) { | 2961 | if (!itemDate.isValid()) { |
2962 | //kdDebug() << "Date Not Valid" << endl; | 2962 | //kdDebug() << "Date Not Valid" << endl; |
2963 | if (KOPrefs::instance()->mConfirm) { | 2963 | if (KOPrefs::instance()->mConfirm) { |
2964 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2964 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2965 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2965 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2966 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2966 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2967 | if ( km == KMessageBox::Continue ) | 2967 | if ( km == KMessageBox::Continue ) |
2968 | km = KMessageBox::No; // No = all below | 2968 | km = KMessageBox::No; // No = all below |
2969 | } else | 2969 | } else |
2970 | km = KMessageBox::No; | 2970 | km = KMessageBox::No; |
2971 | } else { | 2971 | } else { |
2972 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2972 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2973 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2973 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2974 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2974 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2975 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2975 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2976 | i18n("All")); | 2976 | i18n("All")); |
2977 | } | 2977 | } |
2978 | switch(km) { | 2978 | switch(km) { |
2979 | 2979 | ||
2980 | case KMessageBox::No: // Continue // all | 2980 | case KMessageBox::No: // Continue // all |
2981 | //qDebug("KMessageBox::No "); | 2981 | //qDebug("KMessageBox::No "); |
2982 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2982 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2983 | schedule(Scheduler::Cancel,anEvent); | 2983 | schedule(Scheduler::Cancel,anEvent); |
2984 | 2984 | ||
2985 | checkExternalId( anEvent); | 2985 | checkExternalId( anEvent); |
2986 | mCalendar->deleteEvent(anEvent); | 2986 | mCalendar->deleteEvent(anEvent); |
2987 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2987 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2988 | break; | 2988 | break; |
2989 | 2989 | ||
2990 | // Disabled because it does not work | 2990 | // Disabled because it does not work |
2991 | //#if 0 | 2991 | //#if 0 |
2992 | case KMessageBox::Yes: // just this one | 2992 | case KMessageBox::Yes: // just this one |
2993 | //QDate qd = mNavigator->selectedDates().first(); | 2993 | //QDate qd = mNavigator->selectedDates().first(); |
2994 | //if (!qd.isValid()) { | 2994 | //if (!qd.isValid()) { |
2995 | // kdDebug() << "no date selected, or invalid date" << endl; | 2995 | // kdDebug() << "no date selected, or invalid date" << endl; |
2996 | // KNotifyClient::beep(); | 2996 | // KNotifyClient::beep(); |
2997 | // return; | 2997 | // return; |
2998 | //} | 2998 | //} |
2999 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2999 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3000 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3000 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3001 | anEvent->addExDate(itemDate); | 3001 | anEvent->addExDate(itemDate); |
3002 | int duration = anEvent->recurrence()->duration(); | 3002 | int duration = anEvent->recurrence()->duration(); |
3003 | if ( duration > 0 ) { | 3003 | if ( duration > 0 ) { |
3004 | anEvent->recurrence()->setDuration( duration - 1 ); | 3004 | anEvent->recurrence()->setDuration( duration - 1 ); |
3005 | } | 3005 | } |
3006 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3006 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3007 | } | 3007 | } |
3008 | break; | 3008 | break; |
3009 | //#endif | 3009 | //#endif |
3010 | } // switch | 3010 | } // switch |
3011 | } else { | 3011 | } else { |
3012 | if (KOPrefs::instance()->mConfirm) { | 3012 | if (KOPrefs::instance()->mConfirm) { |
3013 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3013 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3014 | i18n("\nAre you sure you want\nto delete this event?"), | 3014 | i18n("\nAre you sure you want\nto delete this event?"), |
3015 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3015 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3016 | case KMessageBox::Continue: // OK | 3016 | case KMessageBox::Continue: // OK |
3017 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3017 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3018 | schedule(Scheduler::Cancel,anEvent); | 3018 | schedule(Scheduler::Cancel,anEvent); |
3019 | checkExternalId( anEvent); | 3019 | checkExternalId( anEvent); |
3020 | mCalendar->deleteEvent(anEvent); | 3020 | mCalendar->deleteEvent(anEvent); |
3021 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3021 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3022 | break; | 3022 | break; |
3023 | } // switch | 3023 | } // switch |
3024 | } else { | 3024 | } else { |
3025 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3025 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3026 | schedule(Scheduler::Cancel,anEvent); | 3026 | schedule(Scheduler::Cancel,anEvent); |
3027 | checkExternalId( anEvent); | 3027 | checkExternalId( anEvent); |
3028 | mCalendar->deleteEvent(anEvent); | 3028 | mCalendar->deleteEvent(anEvent); |
3029 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3029 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3030 | } | 3030 | } |
3031 | } // if-else | 3031 | } // if-else |
3032 | emit updateSearchDialog(); | 3032 | emit updateSearchDialog(); |
3033 | } | 3033 | } |
3034 | 3034 | ||
3035 | bool CalendarView::deleteEvent(const QString &uid) | 3035 | bool CalendarView::deleteEvent(const QString &uid) |
3036 | { | 3036 | { |
3037 | Event *ev = mCalendar->event(uid); | 3037 | Event *ev = mCalendar->event(uid); |
3038 | if (ev) { | 3038 | if (ev) { |
3039 | deleteEvent(ev); | 3039 | deleteEvent(ev); |
3040 | return true; | 3040 | return true; |
3041 | } else { | 3041 | } else { |
3042 | return false; | 3042 | return false; |
3043 | } | 3043 | } |
3044 | } | 3044 | } |
3045 | 3045 | ||
3046 | /*****************************************************************************/ | 3046 | /*****************************************************************************/ |
3047 | 3047 | ||
3048 | void CalendarView::action_mail() | 3048 | void CalendarView::action_mail() |
3049 | { | 3049 | { |
3050 | #ifndef KORG_NOMAIL | 3050 | #ifndef KORG_NOMAIL |
3051 | KOMailClient mailClient; | 3051 | KOMailClient mailClient; |
3052 | 3052 | ||
3053 | Incidence *incidence = currentSelection(); | 3053 | Incidence *incidence = currentSelection(); |
3054 | 3054 | ||
3055 | if (!incidence) { | 3055 | if (!incidence) { |
3056 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3056 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3057 | return; | 3057 | return; |
3058 | } | 3058 | } |
3059 | if(incidence->attendeeCount() == 0 ) { | 3059 | if(incidence->attendeeCount() == 0 ) { |
3060 | KMessageBox::sorry(this, | 3060 | KMessageBox::sorry(this, |
3061 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3061 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3062 | return; | 3062 | return; |
3063 | } | 3063 | } |
3064 | 3064 | ||
3065 | CalendarLocal cal_tmp; | 3065 | CalendarLocal cal_tmp; |
3066 | Event *event = 0; | 3066 | Event *event = 0; |
3067 | Event *ev = 0; | 3067 | Event *ev = 0; |
3068 | if ( incidence && incidence->type() == "Event" ) { | 3068 | if ( incidence && incidence->type() == "Event" ) { |
3069 | event = static_cast<Event *>(incidence); | 3069 | event = static_cast<Event *>(incidence); |
3070 | ev = new Event(*event); | 3070 | ev = new Event(*event); |
3071 | cal_tmp.addEvent(ev); | 3071 | cal_tmp.addEvent(ev); |
3072 | } | 3072 | } |
3073 | ICalFormat mForm(); | 3073 | ICalFormat mForm(); |
3074 | QString attachment = mForm.toString( &cal_tmp ); | 3074 | QString attachment = mForm.toString( &cal_tmp ); |
3075 | if (ev) delete(ev); | 3075 | if (ev) delete(ev); |
3076 | 3076 | ||
3077 | mailClient.mailAttendees(currentSelection(), attachment); | 3077 | mailClient.mailAttendees(currentSelection(), attachment); |
3078 | 3078 | ||
3079 | #endif | 3079 | #endif |
3080 | 3080 | ||
3081 | #if 0 | 3081 | #if 0 |
3082 | Event *anEvent = 0; | 3082 | Event *anEvent = 0; |
3083 | if (mViewManager->currentView()->isEventView()) { | 3083 | if (mViewManager->currentView()->isEventView()) { |
3084 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3084 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3085 | } | 3085 | } |
3086 | 3086 | ||
3087 | if (!anEvent) { | 3087 | if (!anEvent) { |
3088 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3088 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3089 | return; | 3089 | return; |
3090 | } | 3090 | } |
3091 | if(anEvent->attendeeCount() == 0 ) { | 3091 | if(anEvent->attendeeCount() == 0 ) { |
3092 | KMessageBox::sorry(this, | 3092 | KMessageBox::sorry(this, |
3093 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3093 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3094 | return; | 3094 | return; |
3095 | } | 3095 | } |
3096 | 3096 | ||
3097 | mailobject.emailEvent(anEvent); | 3097 | mailobject.emailEvent(anEvent); |
3098 | #endif | 3098 | #endif |
3099 | } | 3099 | } |
3100 | 3100 | ||
3101 | 3101 | ||
3102 | void CalendarView::schedule_publish(Incidence *incidence) | 3102 | void CalendarView::schedule_publish(Incidence *incidence) |
3103 | { | 3103 | { |
3104 | Event *event = 0; | 3104 | Event *event = 0; |
3105 | Todo *todo = 0; | 3105 | Todo *todo = 0; |
3106 | 3106 | ||
3107 | if (incidence == 0) { | 3107 | if (incidence == 0) { |
3108 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3108 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3109 | if (incidence == 0) { | 3109 | if (incidence == 0) { |
3110 | incidence = mTodoList->selectedIncidences().first(); | 3110 | incidence = mTodoList->selectedIncidences().first(); |
3111 | } | 3111 | } |
3112 | } | 3112 | } |
3113 | if ( incidence && incidence->type() == "Event" ) { | 3113 | if ( incidence && incidence->type() == "Event" ) { |
3114 | event = static_cast<Event *>(incidence); | 3114 | event = static_cast<Event *>(incidence); |
3115 | } else { | 3115 | } else { |
3116 | if ( incidence && incidence->type() == "Todo" ) { | 3116 | if ( incidence && incidence->type() == "Todo" ) { |
3117 | todo = static_cast<Todo *>(incidence); | 3117 | todo = static_cast<Todo *>(incidence); |
3118 | } | 3118 | } |
3119 | } | 3119 | } |
3120 | 3120 | ||
3121 | if (!event && !todo) { | 3121 | if (!event && !todo) { |
3122 | KMessageBox::sorry(this,i18n("No event selected.")); | 3122 | KMessageBox::sorry(this,i18n("No event selected.")); |
3123 | return; | 3123 | return; |
3124 | } | 3124 | } |
3125 | 3125 | ||
3126 | PublishDialog *publishdlg = new PublishDialog(); | 3126 | PublishDialog *publishdlg = new PublishDialog(); |
3127 | if (incidence->attendeeCount()>0) { | 3127 | if (incidence->attendeeCount()>0) { |
3128 | QPtrList<Attendee> attendees = incidence->attendees(); | 3128 | QPtrList<Attendee> attendees = incidence->attendees(); |
3129 | attendees.first(); | 3129 | attendees.first(); |
3130 | while ( attendees.current()!=0 ) { | 3130 | while ( attendees.current()!=0 ) { |
3131 | publishdlg->addAttendee(attendees.current()); | 3131 | publishdlg->addAttendee(attendees.current()); |
3132 | attendees.next(); | 3132 | attendees.next(); |
3133 | } | 3133 | } |
3134 | } | 3134 | } |
3135 | bool send = true; | 3135 | bool send = true; |
3136 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3136 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3137 | if ( publishdlg->exec() != QDialog::Accepted ) | 3137 | if ( publishdlg->exec() != QDialog::Accepted ) |
3138 | send = false; | 3138 | send = false; |
3139 | } | 3139 | } |
3140 | if ( send ) { | 3140 | if ( send ) { |
3141 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3141 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3142 | if ( event ) { | 3142 | if ( event ) { |
3143 | Event *ev = new Event(*event); | 3143 | Event *ev = new Event(*event); |
3144 | ev->registerObserver(0); | 3144 | ev->registerObserver(0); |
3145 | ev->clearAttendees(); | 3145 | ev->clearAttendees(); |
3146 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3146 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3147 | delete(ev); | 3147 | delete(ev); |
3148 | } | 3148 | } |
3149 | } else { | 3149 | } else { |
3150 | if ( todo ) { | 3150 | if ( todo ) { |
3151 | Todo *ev = new Todo(*todo); | 3151 | Todo *ev = new Todo(*todo); |
3152 | ev->registerObserver(0); | 3152 | ev->registerObserver(0); |
3153 | ev->clearAttendees(); | 3153 | ev->clearAttendees(); |
3154 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3154 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3155 | delete(ev); | 3155 | delete(ev); |
3156 | } | 3156 | } |
3157 | } | 3157 | } |
3158 | } | 3158 | } |
3159 | } | 3159 | } |
3160 | delete publishdlg; | 3160 | delete publishdlg; |
3161 | } | 3161 | } |
3162 | 3162 | ||
3163 | void CalendarView::schedule_request(Incidence *incidence) | 3163 | void CalendarView::schedule_request(Incidence *incidence) |
3164 | { | 3164 | { |
3165 | schedule(Scheduler::Request,incidence); | 3165 | schedule(Scheduler::Request,incidence); |
3166 | } | 3166 | } |
3167 | 3167 | ||
3168 | void CalendarView::schedule_refresh(Incidence *incidence) | 3168 | void CalendarView::schedule_refresh(Incidence *incidence) |
3169 | { | 3169 | { |
3170 | schedule(Scheduler::Refresh,incidence); | 3170 | schedule(Scheduler::Refresh,incidence); |
3171 | } | 3171 | } |
3172 | 3172 | ||
3173 | void CalendarView::schedule_cancel(Incidence *incidence) | 3173 | void CalendarView::schedule_cancel(Incidence *incidence) |
3174 | { | 3174 | { |
3175 | schedule(Scheduler::Cancel,incidence); | 3175 | schedule(Scheduler::Cancel,incidence); |
3176 | } | 3176 | } |
3177 | 3177 | ||
3178 | void CalendarView::schedule_add(Incidence *incidence) | 3178 | void CalendarView::schedule_add(Incidence *incidence) |
3179 | { | 3179 | { |
3180 | schedule(Scheduler::Add,incidence); | 3180 | schedule(Scheduler::Add,incidence); |
3181 | } | 3181 | } |
3182 | 3182 | ||
3183 | void CalendarView::schedule_reply(Incidence *incidence) | 3183 | void CalendarView::schedule_reply(Incidence *incidence) |
3184 | { | 3184 | { |
3185 | schedule(Scheduler::Reply,incidence); | 3185 | schedule(Scheduler::Reply,incidence); |
3186 | } | 3186 | } |
3187 | 3187 | ||
3188 | void CalendarView::schedule_counter(Incidence *incidence) | 3188 | void CalendarView::schedule_counter(Incidence *incidence) |
3189 | { | 3189 | { |
3190 | schedule(Scheduler::Counter,incidence); | 3190 | schedule(Scheduler::Counter,incidence); |
3191 | } | 3191 | } |
3192 | 3192 | ||
3193 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3193 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3194 | { | 3194 | { |
3195 | schedule(Scheduler::Declinecounter,incidence); | 3195 | schedule(Scheduler::Declinecounter,incidence); |
3196 | } | 3196 | } |
3197 | 3197 | ||
3198 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3198 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3199 | { | 3199 | { |
3200 | QDateTime start = QDateTime::currentDateTime(); | 3200 | QDateTime start = QDateTime::currentDateTime(); |
3201 | QDateTime end = start.addDays(daysToPublish); | 3201 | QDateTime end = start.addDays(daysToPublish); |
3202 | 3202 | ||
3203 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3203 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3204 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3204 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3205 | 3205 | ||
3206 | 3206 | ||
3207 | PublishDialog *publishdlg = new PublishDialog(); | 3207 | PublishDialog *publishdlg = new PublishDialog(); |
3208 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3208 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3209 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3209 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3210 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3210 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3211 | delete(freebusy); | 3211 | delete(freebusy); |
3212 | } | 3212 | } |
3213 | } | 3213 | } |
3214 | delete publishdlg; | 3214 | delete publishdlg; |
3215 | } | 3215 | } |
3216 | 3216 | ||
3217 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3217 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3218 | { | 3218 | { |
3219 | Event *event = 0; | 3219 | Event *event = 0; |
3220 | Todo *todo = 0; | 3220 | Todo *todo = 0; |
3221 | 3221 | ||
3222 | if (incidence == 0) { | 3222 | if (incidence == 0) { |
3223 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3223 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3224 | if (incidence == 0) { | 3224 | if (incidence == 0) { |
3225 | incidence = mTodoList->selectedIncidences().first(); | 3225 | incidence = mTodoList->selectedIncidences().first(); |
3226 | } | 3226 | } |
3227 | } | 3227 | } |
3228 | if ( incidence && incidence->type() == "Event" ) { | 3228 | if ( incidence && incidence->type() == "Event" ) { |
3229 | event = static_cast<Event *>(incidence); | 3229 | event = static_cast<Event *>(incidence); |
3230 | } | 3230 | } |
3231 | if ( incidence && incidence->type() == "Todo" ) { | 3231 | if ( incidence && incidence->type() == "Todo" ) { |
3232 | todo = static_cast<Todo *>(incidence); | 3232 | todo = static_cast<Todo *>(incidence); |
3233 | } | 3233 | } |
3234 | 3234 | ||
3235 | if (!event && !todo) { | 3235 | if (!event && !todo) { |
3236 | KMessageBox::sorry(this,i18n("No event selected.")); | 3236 | KMessageBox::sorry(this,i18n("No event selected.")); |
3237 | return; | 3237 | return; |
3238 | } | 3238 | } |
3239 | 3239 | ||
3240 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3240 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3241 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3241 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3242 | return; | 3242 | return; |
3243 | } | 3243 | } |
3244 | 3244 | ||
3245 | Event *ev = 0; | 3245 | Event *ev = 0; |
3246 | if (event) ev = new Event(*event); | 3246 | if (event) ev = new Event(*event); |
3247 | Todo *to = 0; | 3247 | Todo *to = 0; |
3248 | if (todo) to = new Todo(*todo); | 3248 | if (todo) to = new Todo(*todo); |
3249 | 3249 | ||
3250 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3250 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3251 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3251 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3252 | if (!me) { | 3252 | if (!me) { |
3253 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3253 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3254 | return; | 3254 | return; |
3255 | } | 3255 | } |
3256 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3256 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3257 | StatusDialog *statdlg = new StatusDialog(this); | 3257 | StatusDialog *statdlg = new StatusDialog(this); |
3258 | if (!statdlg->exec()==QDialog::Accepted) return; | 3258 | if (!statdlg->exec()==QDialog::Accepted) return; |
3259 | me->setStatus( statdlg->status() ); | 3259 | me->setStatus( statdlg->status() ); |
3260 | delete(statdlg); | 3260 | delete(statdlg); |
3261 | } | 3261 | } |
3262 | Attendee *menew = new Attendee(*me); | 3262 | Attendee *menew = new Attendee(*me); |
3263 | if (ev) { | 3263 | if (ev) { |
3264 | ev->clearAttendees(); | 3264 | ev->clearAttendees(); |
3265 | ev->addAttendee(menew,false); | 3265 | ev->addAttendee(menew,false); |
3266 | } else { | 3266 | } else { |
3267 | if (to) { | 3267 | if (to) { |
3268 | todo->clearAttendees(); | 3268 | todo->clearAttendees(); |
3269 | todo->addAttendee(menew,false); | 3269 | todo->addAttendee(menew,false); |
3270 | } | 3270 | } |
3271 | } | 3271 | } |
3272 | } | 3272 | } |
3273 | 3273 | ||
3274 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3274 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3275 | if (ev) { | 3275 | if (ev) { |
3276 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3276 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3277 | } else { | 3277 | } else { |
3278 | if (to) { | 3278 | if (to) { |
3279 | if ( !dlg->addMessage(to,method) ) delete(to); | 3279 | if ( !dlg->addMessage(to,method) ) delete(to); |
3280 | } | 3280 | } |
3281 | } | 3281 | } |
3282 | } | 3282 | } |
3283 | 3283 | ||
3284 | void CalendarView::openAddressbook() | 3284 | void CalendarView::openAddressbook() |
3285 | { | 3285 | { |
3286 | KRun::runCommand("kaddressbook"); | 3286 | KRun::runCommand("kaddressbook"); |
3287 | } | 3287 | } |
3288 | 3288 | ||
3289 | void CalendarView::setModified(bool modified) | 3289 | void CalendarView::setModified(bool modified) |
3290 | { | 3290 | { |
3291 | if ( modified ) | 3291 | if ( modified ) |
3292 | emit signalmodified(); | 3292 | emit signalmodified(); |
3293 | if (mModified != modified) { | 3293 | if (mModified != modified) { |
3294 | mModified = modified; | 3294 | mModified = modified; |
3295 | emit modifiedChanged(mModified); | 3295 | emit modifiedChanged(mModified); |
3296 | } | 3296 | } |
3297 | } | 3297 | } |
3298 | 3298 | ||
3299 | bool CalendarView::isReadOnly() | 3299 | bool CalendarView::isReadOnly() |
3300 | { | 3300 | { |
3301 | return mReadOnly; | 3301 | return mReadOnly; |
3302 | } | 3302 | } |
3303 | 3303 | ||
3304 | void CalendarView::setReadOnly(bool readOnly) | 3304 | void CalendarView::setReadOnly(bool readOnly) |
3305 | { | 3305 | { |
3306 | if (mReadOnly != readOnly) { | 3306 | if (mReadOnly != readOnly) { |
3307 | mReadOnly = readOnly; | 3307 | mReadOnly = readOnly; |
3308 | emit readOnlyChanged(mReadOnly); | 3308 | emit readOnlyChanged(mReadOnly); |
3309 | } | 3309 | } |
3310 | } | 3310 | } |
3311 | 3311 | ||
3312 | bool CalendarView::isModified() | 3312 | bool CalendarView::isModified() |
3313 | { | 3313 | { |
3314 | return mModified; | 3314 | return mModified; |
3315 | } | 3315 | } |
3316 | 3316 | ||
3317 | void CalendarView::printSetup() | 3317 | void CalendarView::printSetup() |
3318 | { | 3318 | { |
3319 | #ifndef KORG_NOPRINTER | 3319 | #ifndef KORG_NOPRINTER |
3320 | createPrinter(); | 3320 | createPrinter(); |
3321 | 3321 | ||
3322 | mCalPrinter->setupPrinter(); | 3322 | mCalPrinter->setupPrinter(); |
3323 | #endif | 3323 | #endif |
3324 | } | 3324 | } |
3325 | 3325 | ||
3326 | void CalendarView::print() | 3326 | void CalendarView::print() |
3327 | { | 3327 | { |
3328 | #ifndef KORG_NOPRINTER | 3328 | #ifndef KORG_NOPRINTER |
3329 | createPrinter(); | 3329 | createPrinter(); |
3330 | 3330 | ||
3331 | DateList tmpDateList = mNavigator->selectedDates(); | 3331 | DateList tmpDateList = mNavigator->selectedDates(); |
3332 | mCalPrinter->print(CalPrinter::Month, | 3332 | mCalPrinter->print(CalPrinter::Month, |
3333 | tmpDateList.first(), tmpDateList.last()); | 3333 | tmpDateList.first(), tmpDateList.last()); |
3334 | #endif | 3334 | #endif |
3335 | } | 3335 | } |
3336 | 3336 | ||
3337 | void CalendarView::printPreview() | 3337 | void CalendarView::printPreview() |
3338 | { | 3338 | { |
3339 | #ifndef KORG_NOPRINTER | 3339 | #ifndef KORG_NOPRINTER |
3340 | kdDebug() << "CalendarView::printPreview()" << endl; | 3340 | kdDebug() << "CalendarView::printPreview()" << endl; |
3341 | 3341 | ||
3342 | createPrinter(); | 3342 | createPrinter(); |
3343 | 3343 | ||
3344 | DateList tmpDateList = mNavigator->selectedDates(); | 3344 | DateList tmpDateList = mNavigator->selectedDates(); |
3345 | 3345 | ||
3346 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3346 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3347 | tmpDateList.last()); | 3347 | tmpDateList.last()); |
3348 | #endif | 3348 | #endif |
3349 | } | 3349 | } |
3350 | 3350 | ||
3351 | void CalendarView::exportICalendar() | 3351 | void CalendarView::exportICalendar() |
3352 | { | 3352 | { |
3353 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3353 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3354 | 3354 | ||
3355 | // Force correct extension | 3355 | // Force correct extension |
3356 | if (filename.right(4) != ".ics") filename += ".ics"; | 3356 | if (filename.right(4) != ".ics") filename += ".ics"; |
3357 | 3357 | ||
3358 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3358 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3359 | storage.save(); | 3359 | storage.save(); |
3360 | } | 3360 | } |
3361 | 3361 | ||
3362 | bool CalendarView::exportVCalendar( QString filename ) | 3362 | bool CalendarView::exportVCalendar( QString filename ) |
3363 | { | 3363 | { |
3364 | if (mCalendar->journals().count() > 0) { | 3364 | if (mCalendar->journals().count() > 0) { |
3365 | int result = KMessageBox::warningContinueCancel(this, | 3365 | int result = KMessageBox::warningContinueCancel(this, |
3366 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3366 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3367 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3367 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3368 | true); | 3368 | true); |
3369 | if (result != KMessageBox::Continue) return false; | 3369 | if (result != KMessageBox::Continue) return false; |
3370 | } | 3370 | } |
3371 | 3371 | ||
3372 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3372 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3373 | 3373 | ||
3374 | // Force correct extension | 3374 | // Force correct extension |
3375 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3375 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3376 | 3376 | ||
3377 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3377 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3378 | return storage.save(); | 3378 | return storage.save(); |
3379 | 3379 | ||
3380 | } | 3380 | } |
3381 | 3381 | ||
3382 | void CalendarView::eventUpdated(Incidence *) | 3382 | void CalendarView::eventUpdated(Incidence *) |
3383 | { | 3383 | { |
3384 | setModified(); | 3384 | setModified(); |
3385 | // Don't call updateView here. The code, which has caused the update of the | 3385 | // Don't call updateView here. The code, which has caused the update of the |
3386 | // event is responsible for updating the view. | 3386 | // event is responsible for updating the view. |
3387 | // updateView(); | 3387 | // updateView(); |
3388 | } | 3388 | } |
3389 | 3389 | ||
3390 | void CalendarView::adaptNavigationUnits() | 3390 | void CalendarView::adaptNavigationUnits() |
3391 | { | 3391 | { |
3392 | if (mViewManager->currentView()->isEventView()) { | 3392 | if (mViewManager->currentView()->isEventView()) { |
3393 | int days = mViewManager->currentView()->currentDateCount(); | 3393 | int days = mViewManager->currentView()->currentDateCount(); |
3394 | if (days == 1) { | 3394 | if (days == 1) { |
3395 | emit changeNavStringPrev(i18n("&Previous Day")); | 3395 | emit changeNavStringPrev(i18n("&Previous Day")); |
3396 | emit changeNavStringNext(i18n("&Next Day")); | 3396 | emit changeNavStringNext(i18n("&Next Day")); |
3397 | } else { | 3397 | } else { |
3398 | emit changeNavStringPrev(i18n("&Previous Week")); | 3398 | emit changeNavStringPrev(i18n("&Previous Week")); |
3399 | emit changeNavStringNext(i18n("&Next Week")); | 3399 | emit changeNavStringNext(i18n("&Next Week")); |
3400 | } | 3400 | } |
3401 | } | 3401 | } |
3402 | } | 3402 | } |
3403 | 3403 | ||
3404 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3404 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3405 | { | 3405 | { |
3406 | if ( incidence ) mTodoList->clearSelection(); | 3406 | if ( incidence ) mTodoList->clearSelection(); |
3407 | processIncidenceSelection( incidence ); | 3407 | processIncidenceSelection( incidence ); |
3408 | } | 3408 | } |
3409 | 3409 | ||
3410 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3410 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3411 | { | 3411 | { |
3412 | if ( incidence && mViewManager->currentView() ) { | 3412 | if ( incidence && mViewManager->currentView() ) { |
3413 | mViewManager->currentView()->clearSelection(); | 3413 | mViewManager->currentView()->clearSelection(); |
3414 | } | 3414 | } |
3415 | processIncidenceSelection( incidence ); | 3415 | processIncidenceSelection( incidence ); |
3416 | } | 3416 | } |
3417 | 3417 | ||
3418 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3418 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3419 | { | 3419 | { |
3420 | if ( incidence == mSelectedIncidence ) return; | 3420 | if ( incidence == mSelectedIncidence ) return; |
3421 | 3421 | ||
3422 | mSelectedIncidence = incidence; | 3422 | mSelectedIncidence = incidence; |
3423 | 3423 | ||
3424 | emit incidenceSelected( mSelectedIncidence ); | 3424 | emit incidenceSelected( mSelectedIncidence ); |
3425 | 3425 | ||
3426 | if ( incidence && incidence->type() == "Event" ) { | 3426 | if ( incidence && incidence->type() == "Event" ) { |
3427 | Event *event = static_cast<Event *>( incidence ); | 3427 | Event *event = static_cast<Event *>( incidence ); |
3428 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3428 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3429 | emit organizerEventsSelected( true ); | 3429 | emit organizerEventsSelected( true ); |
3430 | } else { | 3430 | } else { |
3431 | emit organizerEventsSelected(false); | 3431 | emit organizerEventsSelected(false); |
3432 | } | 3432 | } |
3433 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3433 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3434 | KOPrefs::instance()->email() ) ) { | 3434 | KOPrefs::instance()->email() ) ) { |
3435 | emit groupEventsSelected( true ); | 3435 | emit groupEventsSelected( true ); |
3436 | } else { | 3436 | } else { |
3437 | emit groupEventsSelected(false); | 3437 | emit groupEventsSelected(false); |
3438 | } | 3438 | } |
3439 | return; | 3439 | return; |
3440 | } else { | 3440 | } else { |
3441 | if ( incidence && incidence->type() == "Todo" ) { | 3441 | if ( incidence && incidence->type() == "Todo" ) { |
3442 | emit todoSelected( true ); | 3442 | emit todoSelected( true ); |
3443 | Todo *event = static_cast<Todo *>( incidence ); | 3443 | Todo *event = static_cast<Todo *>( incidence ); |
3444 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3444 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3445 | emit organizerEventsSelected( true ); | 3445 | emit organizerEventsSelected( true ); |
3446 | } else { | 3446 | } else { |
3447 | emit organizerEventsSelected(false); | 3447 | emit organizerEventsSelected(false); |
3448 | } | 3448 | } |
3449 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3449 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3450 | KOPrefs::instance()->email() ) ) { | 3450 | KOPrefs::instance()->email() ) ) { |
3451 | emit groupEventsSelected( true ); | 3451 | emit groupEventsSelected( true ); |
3452 | } else { | 3452 | } else { |
3453 | emit groupEventsSelected(false); | 3453 | emit groupEventsSelected(false); |
3454 | } | 3454 | } |
3455 | return; | 3455 | return; |
3456 | } else { | 3456 | } else { |
3457 | emit todoSelected( false ); | 3457 | emit todoSelected( false ); |
3458 | emit organizerEventsSelected(false); | 3458 | emit organizerEventsSelected(false); |
3459 | emit groupEventsSelected(false); | 3459 | emit groupEventsSelected(false); |
3460 | } | 3460 | } |
3461 | return; | 3461 | return; |
3462 | } | 3462 | } |
3463 | 3463 | ||
3464 | /* if ( incidence && incidence->type() == "Todo" ) { | 3464 | /* if ( incidence && incidence->type() == "Todo" ) { |
3465 | emit todoSelected( true ); | 3465 | emit todoSelected( true ); |
3466 | } else { | 3466 | } else { |
3467 | emit todoSelected( false ); | 3467 | emit todoSelected( false ); |
3468 | }*/ | 3468 | }*/ |
3469 | } | 3469 | } |
3470 | 3470 | ||
3471 | 3471 | ||
3472 | void CalendarView::checkClipboard() | 3472 | void CalendarView::checkClipboard() |
3473 | { | 3473 | { |
3474 | #ifndef KORG_NODND | 3474 | #ifndef KORG_NODND |
3475 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3475 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3476 | emit pasteEnabled(true); | 3476 | emit pasteEnabled(true); |
3477 | } else { | 3477 | } else { |
3478 | emit pasteEnabled(false); | 3478 | emit pasteEnabled(false); |
3479 | } | 3479 | } |
3480 | #endif | 3480 | #endif |
3481 | } | 3481 | } |
3482 | 3482 | ||
3483 | void CalendarView::showDates(const DateList &selectedDates) | 3483 | void CalendarView::showDates(const DateList &selectedDates) |
3484 | { | 3484 | { |
3485 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3485 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3486 | 3486 | ||
3487 | 3487 | ||
3488 | if ( !mBlockShowDates ) { | 3488 | if ( !mBlockShowDates ) { |
3489 | if ( mViewManager->currentView() ) { | 3489 | if ( mViewManager->currentView() ) { |
3490 | updateView( selectedDates.first(), selectedDates.last() ); | 3490 | updateView( selectedDates.first(), selectedDates.last() ); |
3491 | } else { | 3491 | } else { |
3492 | mViewManager->showAgendaView(); | 3492 | mViewManager->showAgendaView(); |
3493 | } | 3493 | } |
3494 | } | 3494 | } |
3495 | 3495 | ||
3496 | QString selDates; | 3496 | QString selDates; |
3497 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3497 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3498 | if (selectedDates.first() < selectedDates.last() ) | 3498 | if (selectedDates.first() < selectedDates.last() ) |
3499 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3499 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3500 | else { | 3500 | else { |
3501 | QString addString; | 3501 | QString addString; |
3502 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3502 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3503 | addString = i18n("Today"); | 3503 | addString = i18n("Today"); |
3504 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3504 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3505 | addString = i18n("Tomorrow"); | 3505 | addString = i18n("Tomorrow"); |
3506 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3506 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3507 | addString = i18n("Yesterday"); | 3507 | addString = i18n("Yesterday"); |
3508 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3508 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3509 | addString = i18n("Day before yesterday"); | 3509 | addString = i18n("Day before yesterday"); |
3510 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3510 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3511 | addString = i18n("Day after tomorrow"); | 3511 | addString = i18n("Day after tomorrow"); |
3512 | if ( !addString.isEmpty() ) { | 3512 | if ( !addString.isEmpty() ) { |
3513 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3513 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3514 | return; | 3514 | return; |
3515 | } | 3515 | } |
3516 | } | 3516 | } |
3517 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3517 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3518 | 3518 | ||
3519 | } | 3519 | } |
3520 | 3520 | ||
3521 | QPtrList<CalFilter> CalendarView::filters() | 3521 | QPtrList<CalFilter> CalendarView::filters() |
3522 | { | 3522 | { |
3523 | return mFilters; | 3523 | return mFilters; |
3524 | 3524 | ||
3525 | } | 3525 | } |
3526 | void CalendarView::editFilters() | 3526 | void CalendarView::editFilters() |
3527 | { | 3527 | { |
3528 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3528 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3529 | 3529 | ||
3530 | CalFilter *filter = mFilters.first(); | 3530 | CalFilter *filter = mFilters.first(); |
3531 | while(filter) { | 3531 | while(filter) { |
3532 | kdDebug() << " Filter: " << filter->name() << endl; | 3532 | kdDebug() << " Filter: " << filter->name() << endl; |
3533 | filter = mFilters.next(); | 3533 | filter = mFilters.next(); |
3534 | } | 3534 | } |
3535 | 3535 | ||
3536 | mDialogManager->showFilterEditDialog(&mFilters); | 3536 | mDialogManager->showFilterEditDialog(&mFilters); |
3537 | } | 3537 | } |
3538 | void CalendarView::toggleFilter() | 3538 | void CalendarView::toggleFilter() |
3539 | { | 3539 | { |
3540 | showFilter(! mFilterView->isVisible()); | 3540 | showFilter(! mFilterView->isVisible()); |
3541 | } | 3541 | } |
3542 | 3542 | ||
3543 | KOFilterView *CalendarView::filterView() | 3543 | KOFilterView *CalendarView::filterView() |
3544 | { | 3544 | { |
3545 | return mFilterView; | 3545 | return mFilterView; |
3546 | } | 3546 | } |
3547 | void CalendarView::selectFilter( int fil ) | 3547 | void CalendarView::selectFilter( int fil ) |
3548 | { | 3548 | { |
3549 | mFilterView->setSelectedFilter( fil ); | 3549 | mFilterView->setSelectedFilter( fil ); |
3550 | } | 3550 | } |
3551 | void CalendarView::showFilter(bool visible) | 3551 | void CalendarView::showFilter(bool visible) |
3552 | { | 3552 | { |
3553 | if (visible) mFilterView->show(); | 3553 | if (visible) mFilterView->show(); |
3554 | else mFilterView->hide(); | 3554 | else mFilterView->hide(); |
3555 | } | 3555 | } |
3556 | void CalendarView::toggleFilerEnabled( ) | 3556 | void CalendarView::toggleFilerEnabled( ) |
3557 | { | 3557 | { |
3558 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3558 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3559 | if ( !mFilterView->filtersEnabled() ) | 3559 | if ( !mFilterView->filtersEnabled() ) |
3560 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3560 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3561 | 3561 | ||
3562 | } | 3562 | } |
3563 | void CalendarView::updateFilter() | 3563 | void CalendarView::updateFilter() |
3564 | { | 3564 | { |
3565 | CalFilter *filter = mFilterView->selectedFilter(); | 3565 | CalFilter *filter = mFilterView->selectedFilter(); |
3566 | if (filter) { | 3566 | if (filter) { |
3567 | if (mFilterView->filtersEnabled()) { | 3567 | if (mFilterView->filtersEnabled()) { |
3568 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3568 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3569 | filter->setEnabled(true); | 3569 | filter->setEnabled(true); |
3570 | } | 3570 | } |
3571 | else filter->setEnabled(false); | 3571 | else filter->setEnabled(false); |
3572 | mCalendar->setFilter(filter); | 3572 | mCalendar->setFilter(filter); |
3573 | updateView(); | 3573 | updateView(); |
3574 | } | 3574 | } |
3575 | } | 3575 | } |
3576 | 3576 | ||
3577 | void CalendarView::filterEdited() | 3577 | void CalendarView::filterEdited() |
3578 | { | 3578 | { |
3579 | mFilterView->updateFilters(); | 3579 | mFilterView->updateFilters(); |
3580 | updateFilter(); | 3580 | updateFilter(); |
3581 | writeSettings(); | 3581 | writeSettings(); |
3582 | } | 3582 | } |
3583 | 3583 | ||
3584 | 3584 | ||
3585 | void CalendarView::takeOverEvent() | 3585 | void CalendarView::takeOverEvent() |
3586 | { | 3586 | { |
3587 | Incidence *incidence = currentSelection(); | 3587 | Incidence *incidence = currentSelection(); |
3588 | 3588 | ||
3589 | if (!incidence) return; | 3589 | if (!incidence) return; |
3590 | 3590 | ||
3591 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3591 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3592 | incidence->recreate(); | 3592 | incidence->recreate(); |
3593 | incidence->setReadOnly(false); | 3593 | incidence->setReadOnly(false); |
3594 | 3594 | ||
3595 | updateView(); | 3595 | updateView(); |
3596 | } | 3596 | } |
3597 | 3597 | ||
3598 | void CalendarView::takeOverCalendar() | 3598 | void CalendarView::takeOverCalendar() |
3599 | { | 3599 | { |
3600 | // TODO: Create Calendar::allIncidences() function and use it here | 3600 | // TODO: Create Calendar::allIncidences() function and use it here |
3601 | 3601 | ||
3602 | QPtrList<Event> events = mCalendar->events(); | 3602 | QPtrList<Event> events = mCalendar->events(); |
3603 | for(uint i=0; i<events.count(); ++i) { | 3603 | for(uint i=0; i<events.count(); ++i) { |
3604 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3604 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3605 | events.at(i)->recreate(); | 3605 | events.at(i)->recreate(); |
3606 | events.at(i)->setReadOnly(false); | 3606 | events.at(i)->setReadOnly(false); |
3607 | } | 3607 | } |
3608 | 3608 | ||
3609 | QPtrList<Todo> todos = mCalendar->todos(); | 3609 | QPtrList<Todo> todos = mCalendar->todos(); |
3610 | for(uint i=0; i<todos.count(); ++i) { | 3610 | for(uint i=0; i<todos.count(); ++i) { |
3611 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3611 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3612 | todos.at(i)->recreate(); | 3612 | todos.at(i)->recreate(); |
3613 | todos.at(i)->setReadOnly(false); | 3613 | todos.at(i)->setReadOnly(false); |
3614 | } | 3614 | } |
3615 | 3615 | ||
3616 | QPtrList<Journal> journals = mCalendar->journals(); | 3616 | QPtrList<Journal> journals = mCalendar->journals(); |
3617 | for(uint i=0; i<journals.count(); ++i) { | 3617 | for(uint i=0; i<journals.count(); ++i) { |
3618 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3618 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3619 | journals.at(i)->recreate(); | 3619 | journals.at(i)->recreate(); |
3620 | journals.at(i)->setReadOnly(false); | 3620 | journals.at(i)->setReadOnly(false); |
3621 | } | 3621 | } |
3622 | 3622 | ||
3623 | updateView(); | 3623 | updateView(); |
3624 | } | 3624 | } |
3625 | 3625 | ||
3626 | void CalendarView::showIntro() | 3626 | void CalendarView::showIntro() |
3627 | { | 3627 | { |
3628 | kdDebug() << "To be implemented." << endl; | 3628 | kdDebug() << "To be implemented." << endl; |
3629 | } | 3629 | } |
3630 | 3630 | ||
3631 | QWidgetStack *CalendarView::viewStack() | 3631 | QWidgetStack *CalendarView::viewStack() |
3632 | { | 3632 | { |
3633 | return mRightFrame; | 3633 | return mRightFrame; |
3634 | } | 3634 | } |
3635 | 3635 | ||
3636 | QWidget *CalendarView::leftFrame() | 3636 | QWidget *CalendarView::leftFrame() |
3637 | { | 3637 | { |
3638 | return mLeftFrame; | 3638 | return mLeftFrame; |
3639 | } | 3639 | } |
3640 | 3640 | ||
3641 | DateNavigator *CalendarView::dateNavigator() | 3641 | DateNavigator *CalendarView::dateNavigator() |
3642 | { | 3642 | { |
3643 | return mNavigator; | 3643 | return mNavigator; |
3644 | } | 3644 | } |
3645 | 3645 | ||
3646 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3646 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3647 | { | 3647 | { |
3648 | return mDateNavigator; | 3648 | return mDateNavigator; |
3649 | } | 3649 | } |
3650 | void CalendarView::toggleDateNavigatorWidget() | 3650 | void CalendarView::toggleDateNavigatorWidget() |
3651 | { | 3651 | { |
3652 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3652 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3653 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3653 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3654 | mDateNavigator->hide(); | 3654 | mDateNavigator->hide(); |
3655 | else | 3655 | else |
3656 | mDateNavigator->show(); | 3656 | mDateNavigator->show(); |
3657 | } | 3657 | } |
3658 | void CalendarView::addView(KOrg::BaseView *view) | 3658 | void CalendarView::addView(KOrg::BaseView *view) |
3659 | { | 3659 | { |
3660 | mViewManager->addView(view); | 3660 | mViewManager->addView(view); |
3661 | } | 3661 | } |
3662 | 3662 | ||
3663 | void CalendarView::showView(KOrg::BaseView *view) | 3663 | void CalendarView::showView(KOrg::BaseView *view) |
3664 | { | 3664 | { |
3665 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3665 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3666 | } | 3666 | } |
3667 | 3667 | ||
3668 | Incidence *CalendarView::currentSelection() | 3668 | Incidence *CalendarView::currentSelection() |
3669 | { | 3669 | { |
3670 | return mViewManager->currentSelection(); | 3670 | return mViewManager->currentSelection(); |
3671 | } | 3671 | } |
3672 | void CalendarView::toggleAllDaySize() | 3672 | void CalendarView::toggleAllDaySize() |
3673 | { | 3673 | { |
3674 | /* | 3674 | /* |
3675 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3675 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3676 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3676 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3677 | else | 3677 | else |
3678 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3678 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3679 | */ | 3679 | */ |
3680 | viewManager()->agendaView()->toggleAllDay(); | 3680 | viewManager()->agendaView()->toggleAllDay(); |
3681 | } | 3681 | } |
3682 | void CalendarView::toggleExpand() | 3682 | void CalendarView::toggleExpand() |
3683 | { | 3683 | { |
3684 | // if ( mLeftFrame->isHidden() ) { | 3684 | // if ( mLeftFrame->isHidden() ) { |
3685 | // mLeftFrame->show(); | 3685 | // mLeftFrame->show(); |
3686 | // emit calendarViewExpanded( false ); | 3686 | // emit calendarViewExpanded( false ); |
3687 | // } else { | 3687 | // } else { |
3688 | // mLeftFrame->hide(); | 3688 | // mLeftFrame->hide(); |
3689 | // emit calendarViewExpanded( true ); | 3689 | // emit calendarViewExpanded( true ); |
3690 | // } | 3690 | // } |
3691 | //qDebug(" CalendarView::toggleExpand()"); | 3691 | //qDebug(" CalendarView::toggleExpand()"); |
3692 | globalFlagBlockAgenda = 1; | 3692 | globalFlagBlockAgenda = 1; |
3693 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3693 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3694 | globalFlagBlockAgenda = 5; | 3694 | globalFlagBlockAgenda = 5; |
3695 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3695 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3696 | //mViewManager->showView( 0, true ); | 3696 | //mViewManager->showView( 0, true ); |
3697 | } | 3697 | } |
3698 | 3698 | ||
3699 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3699 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3700 | { | 3700 | { |
3701 | setModified( modified ); | 3701 | setModified( modified ); |
3702 | } | 3702 | } |
3703 | 3703 | ||
3704 | Todo *CalendarView::selectedTodo() | 3704 | Todo *CalendarView::selectedTodo() |
3705 | { | 3705 | { |
3706 | Incidence *incidence = currentSelection(); | 3706 | Incidence *incidence = currentSelection(); |
3707 | if ( incidence && incidence->type() == "Todo" ) { | 3707 | if ( incidence && incidence->type() == "Todo" ) { |
3708 | return static_cast<Todo *>( incidence ); | 3708 | return static_cast<Todo *>( incidence ); |
3709 | } | 3709 | } |
3710 | 3710 | ||
3711 | incidence = mTodoList->selectedIncidences().first(); | 3711 | incidence = mTodoList->selectedIncidences().first(); |
3712 | if ( incidence && incidence->type() == "Todo" ) { | 3712 | if ( incidence && incidence->type() == "Todo" ) { |
3713 | return static_cast<Todo *>( incidence ); | 3713 | return static_cast<Todo *>( incidence ); |
3714 | } | 3714 | } |
3715 | 3715 | ||
3716 | return 0; | 3716 | return 0; |
3717 | } | 3717 | } |
3718 | 3718 | ||
3719 | void CalendarView::dialogClosing(Incidence *in) | 3719 | void CalendarView::dialogClosing(Incidence *in) |
3720 | { | 3720 | { |
3721 | // mDialogList.remove(in); | 3721 | // mDialogList.remove(in); |
3722 | } | 3722 | } |
3723 | 3723 | ||
3724 | void CalendarView::showIncidence() | 3724 | void CalendarView::showIncidence() |
3725 | { | 3725 | { |
3726 | Incidence *incidence = currentSelection(); | 3726 | Incidence *incidence = currentSelection(); |
3727 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3727 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3728 | if ( incidence ) { | 3728 | if ( incidence ) { |
3729 | ShowIncidenceVisitor v; | 3729 | ShowIncidenceVisitor v; |
3730 | v.act( incidence, this ); | 3730 | v.act( incidence, this ); |
3731 | } | 3731 | } |
3732 | } | 3732 | } |
3733 | void CalendarView::editIncidenceDescription() | 3733 | void CalendarView::editIncidenceDescription() |
3734 | { | 3734 | { |
3735 | mFlagEditDescription = true; | 3735 | mFlagEditDescription = true; |
3736 | editIncidence(); | 3736 | editIncidence(); |
3737 | mFlagEditDescription = false; | 3737 | mFlagEditDescription = false; |
3738 | } | 3738 | } |
3739 | void CalendarView::editIncidence() | 3739 | void CalendarView::editIncidence() |
3740 | { | 3740 | { |
3741 | // qDebug("editIncidence() "); | 3741 | // qDebug("editIncidence() "); |
3742 | Incidence *incidence = currentSelection(); | 3742 | Incidence *incidence = currentSelection(); |
3743 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3743 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3744 | if ( incidence ) { | 3744 | if ( incidence ) { |
3745 | EditIncidenceVisitor v; | 3745 | EditIncidenceVisitor v; |
3746 | v.act( incidence, this ); | 3746 | v.act( incidence, this ); |
3747 | } | 3747 | } |
3748 | } | 3748 | } |
3749 | 3749 | ||
3750 | void CalendarView::deleteIncidence() | 3750 | void CalendarView::deleteIncidence() |
3751 | { | 3751 | { |
3752 | Incidence *incidence = currentSelection(); | 3752 | Incidence *incidence = currentSelection(); |
3753 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3753 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3754 | if ( incidence ) { | 3754 | if ( incidence ) { |
3755 | deleteIncidence(incidence); | 3755 | deleteIncidence(incidence); |
3756 | } | 3756 | } |
3757 | } | 3757 | } |
3758 | 3758 | ||
3759 | void CalendarView::showIncidence(Incidence *incidence) | 3759 | void CalendarView::showIncidence(Incidence *incidence) |
3760 | { | 3760 | { |
3761 | if ( incidence ) { | 3761 | if ( incidence ) { |
3762 | ShowIncidenceVisitor v; | 3762 | ShowIncidenceVisitor v; |
3763 | v.act( incidence, this ); | 3763 | v.act( incidence, this ); |
3764 | } | 3764 | } |
3765 | } | 3765 | } |
3766 | 3766 | ||
3767 | void CalendarView::editIncidence(Incidence *incidence) | 3767 | void CalendarView::editIncidence(Incidence *incidence) |
3768 | { | 3768 | { |
3769 | if ( incidence ) { | 3769 | if ( incidence ) { |
3770 | 3770 | ||
3771 | EditIncidenceVisitor v; | 3771 | EditIncidenceVisitor v; |
3772 | v.act( incidence, this ); | 3772 | v.act( incidence, this ); |
3773 | 3773 | ||
3774 | } | 3774 | } |
3775 | } | 3775 | } |
3776 | 3776 | ||
3777 | void CalendarView::deleteIncidence(Incidence *incidence) | 3777 | void CalendarView::deleteIncidence(Incidence *incidence) |
3778 | { | 3778 | { |
3779 | //qDebug(" CalendarView::deleteIncidence "); | 3779 | //qDebug(" CalendarView::deleteIncidence "); |
3780 | if ( incidence ) { | 3780 | if ( incidence ) { |
3781 | DeleteIncidenceVisitor v; | 3781 | DeleteIncidenceVisitor v; |
3782 | v.act( incidence, this ); | 3782 | v.act( incidence, this ); |
3783 | } | 3783 | } |
3784 | } | 3784 | } |
3785 | 3785 | ||
3786 | 3786 | ||
3787 | void CalendarView::lookForOutgoingMessages() | 3787 | void CalendarView::lookForOutgoingMessages() |
3788 | { | 3788 | { |
3789 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3789 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3790 | ogd->loadMessages(); | 3790 | ogd->loadMessages(); |
3791 | } | 3791 | } |
3792 | 3792 | ||
3793 | void CalendarView::lookForIncomingMessages() | 3793 | void CalendarView::lookForIncomingMessages() |
3794 | { | 3794 | { |
3795 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3795 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3796 | icd->retrieve(); | 3796 | icd->retrieve(); |
3797 | } | 3797 | } |
3798 | 3798 | ||
3799 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3799 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3800 | { | 3800 | { |
3801 | bool deleteTodo = true; | 3801 | bool deleteTodo = true; |
3802 | QPtrList<Incidence> subTodos; | 3802 | QPtrList<Incidence> subTodos; |
3803 | Incidence *aTodo; | 3803 | Incidence *aTodo; |
3804 | subTodos = t->relations(); | 3804 | subTodos = t->relations(); |
3805 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3805 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3806 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3806 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3807 | deleteTodo = false; | 3807 | deleteTodo = false; |
3808 | } | 3808 | } |
3809 | if ( deleteTodo ) { | 3809 | if ( deleteTodo ) { |
3810 | if ( t->isCompleted() ) { | 3810 | if ( t->isCompleted() ) { |
3811 | checkExternalId( t ); | 3811 | checkExternalId( t ); |
3812 | mCalendar->deleteTodo( t ); | 3812 | mCalendar->deleteTodo( t ); |
3813 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3813 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3814 | } | 3814 | } |
3815 | else | 3815 | else |
3816 | deleteTodo = false; | 3816 | deleteTodo = false; |
3817 | } | 3817 | } |
3818 | return deleteTodo; | 3818 | return deleteTodo; |
3819 | 3819 | ||
3820 | } | 3820 | } |
3821 | void CalendarView::purgeCompleted() | 3821 | void CalendarView::purgeCompleted() |
3822 | { | 3822 | { |
3823 | int result = KMessageBox::warningContinueCancel(this, | 3823 | int result = KMessageBox::warningContinueCancel(this, |
3824 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3824 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3825 | 3825 | ||
3826 | if (result == KMessageBox::Continue) { | 3826 | if (result == KMessageBox::Continue) { |
3827 | 3827 | ||
3828 | QPtrList<Todo> todoCal; | 3828 | QPtrList<Todo> todoCal; |
3829 | QPtrList<Todo> rootTodos; | 3829 | QPtrList<Todo> rootTodos; |
3830 | //QPtrList<Incidence> rel; | 3830 | //QPtrList<Incidence> rel; |
3831 | Todo *aTodo;//, *rTodo; | 3831 | Todo *aTodo;//, *rTodo; |
3832 | Incidence *rIncidence; | 3832 | Incidence *rIncidence; |
3833 | bool childDelete = false; | 3833 | bool childDelete = false; |
3834 | bool deletedOne = true; | 3834 | bool deletedOne = true; |
3835 | todoCal = calendar()->todos(); | 3835 | todoCal = calendar()->todos(); |
3836 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3836 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3837 | if ( !aTodo->relatedTo() ) | 3837 | if ( !aTodo->relatedTo() ) |
3838 | rootTodos.append( aTodo ); | 3838 | rootTodos.append( aTodo ); |
3839 | } | 3839 | } |
3840 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3840 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3841 | removeCompletedSubTodos( aTodo ); | 3841 | removeCompletedSubTodos( aTodo ); |
3842 | } | 3842 | } |
3843 | 3843 | ||
3844 | updateView(); | 3844 | updateView(); |
3845 | } | 3845 | } |
3846 | } | 3846 | } |
3847 | 3847 | ||
3848 | void CalendarView::slotCalendarChanged() | 3848 | void CalendarView::slotCalendarChanged() |
3849 | { | 3849 | { |
3850 | ; | 3850 | ; |
3851 | } | 3851 | } |
3852 | 3852 | ||
3853 | NavigatorBar *CalendarView::navigatorBar() | 3853 | NavigatorBar *CalendarView::navigatorBar() |
3854 | { | 3854 | { |
3855 | return mNavigatorBar; | 3855 | return mNavigatorBar; |
3856 | } | 3856 | } |
3857 | void CalendarView::showNavigatorBar( bool b) | ||
3858 | { | ||
3859 | if ( b ) mNavigatorBar->show(); | ||
3860 | else mNavigatorBar->hide(); | ||
3861 | } | ||
3857 | 3862 | ||
3858 | 3863 | ||
3859 | 3864 | ||
3860 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3865 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3861 | { | 3866 | { |
3862 | //qDebug(" alendarView::keyPressEvent "); | 3867 | //qDebug(" alendarView::keyPressEvent "); |
3863 | e->ignore(); | 3868 | e->ignore(); |
3864 | } | 3869 | } |
3865 | 3870 | ||
3866 | 3871 | ||
3867 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3872 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3868 | { | 3873 | { |
3869 | // mSyncManager = manager; | 3874 | // mSyncManager = manager; |
3870 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3875 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3871 | qDebug("KO: SyncKDE request detected!"); | 3876 | qDebug("KO: SyncKDE request detected!"); |
3872 | } | 3877 | } |
3873 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3878 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3874 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3879 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3875 | return syncCalendar( filename, mode ); | 3880 | return syncCalendar( filename, mode ); |
3876 | } | 3881 | } |
3877 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3882 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3878 | { | 3883 | { |
3879 | //mSyncManager = manager; | 3884 | //mSyncManager = manager; |
3880 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3885 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3881 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3886 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3882 | if ( resource == "sharp" ) | 3887 | if ( resource == "sharp" ) |
3883 | syncExternal( 0 ); | 3888 | syncExternal( 0 ); |
3884 | if ( resource == "phone" ) | 3889 | if ( resource == "phone" ) |
3885 | syncExternal( 1 ); | 3890 | syncExternal( 1 ); |
3886 | // pending setmodified | 3891 | // pending setmodified |
3887 | return true; | 3892 | return true; |
3888 | } | 3893 | } |
3889 | void CalendarView::setSyncManager(KSyncManager* manager) | 3894 | void CalendarView::setSyncManager(KSyncManager* manager) |
3890 | { | 3895 | { |
3891 | mSyncManager = manager; | 3896 | mSyncManager = manager; |
3892 | } | 3897 | } |
3893 | 3898 | ||
3894 | void CalendarView::removeSyncInfo( QString syncProfile) | 3899 | void CalendarView::removeSyncInfo( QString syncProfile) |
3895 | { | 3900 | { |
3896 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3901 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3897 | mCalendar->removeSyncInfo( syncProfile ); | 3902 | mCalendar->removeSyncInfo( syncProfile ); |
3898 | 3903 | ||
3899 | } | 3904 | } |
3900 | 3905 | ||
3901 | void CalendarView::undo_delete() | 3906 | void CalendarView::undo_delete() |
3902 | { | 3907 | { |
3903 | //qDebug("undo_delete() "); | 3908 | //qDebug("undo_delete() "); |
3904 | Incidence* undo = mCalendar->undoIncidence(); | 3909 | Incidence* undo = mCalendar->undoIncidence(); |
3905 | if ( !undo ) { | 3910 | if ( !undo ) { |
3906 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3911 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3907 | i18n("KO/Pi")); | 3912 | i18n("KO/Pi")); |
3908 | return; | 3913 | return; |
3909 | } | 3914 | } |
3910 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3915 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3911 | i18n("\nAre you sure you want\nto restore this?"), | 3916 | i18n("\nAre you sure you want\nto restore this?"), |
3912 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3917 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3913 | mCalendar->undoDeleteIncidence(); | 3918 | mCalendar->undoDeleteIncidence(); |
3914 | updateView(); | 3919 | updateView(); |
3915 | } | 3920 | } |
3916 | } | 3921 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 7c59a8d..6ea8287 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,612 +1,613 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | 42 | ||
43 | #include <korganizer/calendarviewbase.h> | 43 | #include <korganizer/calendarviewbase.h> |
44 | 44 | ||
45 | #include <ksyncmanager.h> | 45 | #include <ksyncmanager.h> |
46 | 46 | ||
47 | class QWidgetStack; | 47 | class QWidgetStack; |
48 | class QSplitter; | 48 | class QSplitter; |
49 | 49 | ||
50 | class CalPrinter; | 50 | class CalPrinter; |
51 | class KOFilterView; | 51 | class KOFilterView; |
52 | class KOViewManager; | 52 | class KOViewManager; |
53 | class KODialogManager; | 53 | class KODialogManager; |
54 | class KOTodoView; | 54 | class KOTodoView; |
55 | class KDateNavigator; | 55 | class KDateNavigator; |
56 | class DateNavigator; | 56 | class DateNavigator; |
57 | class KOIncidenceEditor; | 57 | class KOIncidenceEditor; |
58 | class KDatePicker; | 58 | class KDatePicker; |
59 | class ResourceView; | 59 | class ResourceView; |
60 | class NavigatorBar; | 60 | class NavigatorBar; |
61 | class KOEventEditor; | 61 | class KOEventEditor; |
62 | class KOTodoEditor ; | 62 | class KOTodoEditor ; |
63 | class KOEventViewerDialog; | 63 | class KOEventViewerDialog; |
64 | class KOBeamPrefs; | 64 | class KOBeamPrefs; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | class AlarmDialog; | 66 | class AlarmDialog; |
67 | class KCal::Attendee; | 67 | class KCal::Attendee; |
68 | 68 | ||
69 | namespace KCal { class FileStorage; } | 69 | namespace KCal { class FileStorage; } |
70 | 70 | ||
71 | using namespace KCal; | 71 | using namespace KCal; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | This is the main calendar widget. It provides the different vies on t he | 74 | This is the main calendar widget. It provides the different vies on t he |
75 | calendar data as well as the date navigator. It also handles synchronisation | 75 | calendar data as well as the date navigator. It also handles synchronisation |
76 | of the different views and controls the different dialogs like preferences, | 76 | of the different views and controls the different dialogs like preferences, |
77 | event editor, search dialog etc. | 77 | event editor, search dialog etc. |
78 | 78 | ||
79 | @short main calendar view widget | 79 | @short main calendar view widget |
80 | @author Cornelius Schumacher | 80 | @author Cornelius Schumacher |
81 | */ | 81 | */ |
82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
83 | { | 83 | { |
84 | Q_OBJECT | 84 | Q_OBJECT |
85 | public: | 85 | public: |
86 | /** | 86 | /** |
87 | Constructs a new calendar view widget. | 87 | Constructs a new calendar view widget. |
88 | 88 | ||
89 | @param calendar calendar document | 89 | @param calendar calendar document |
90 | @param parent parent window | 90 | @param parent parent window |
91 | @param name Qt internal widget object name | 91 | @param name Qt internal widget object name |
92 | */ | 92 | */ |
93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 94 | const char *name = 0 ); |
95 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 95 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
96 | const char *name = 0 ); | 96 | const char *name = 0 ); |
97 | virtual ~CalendarView(); | 97 | virtual ~CalendarView(); |
98 | 98 | ||
99 | Calendar *calendar() { return mCalendar; } | 99 | Calendar *calendar() { return mCalendar; } |
100 | 100 | ||
101 | KOViewManager *viewManager(); | 101 | KOViewManager *viewManager(); |
102 | KODialogManager *dialogManager(); | 102 | KODialogManager *dialogManager(); |
103 | 103 | ||
104 | QDate startDate(); | 104 | QDate startDate(); |
105 | QDate endDate(); | 105 | QDate endDate(); |
106 | 106 | ||
107 | QWidgetStack *viewStack(); | 107 | QWidgetStack *viewStack(); |
108 | QWidget *leftFrame(); | 108 | QWidget *leftFrame(); |
109 | NavigatorBar *navigatorBar(); | 109 | NavigatorBar *navigatorBar(); |
110 | 110 | ||
111 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
112 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
113 | 113 | ||
114 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
115 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
116 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
117 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
118 | 118 | ||
119 | signals: | 119 | signals: |
120 | void tempDisableBR(bool); | 120 | void tempDisableBR(bool); |
121 | /** This todo has been modified */ | 121 | /** This todo has been modified */ |
122 | void todoModified(Todo *, int); | 122 | void todoModified(Todo *, int); |
123 | 123 | ||
124 | /** when change is made to options dialog, the topwidget will catch this | 124 | /** when change is made to options dialog, the topwidget will catch this |
125 | * and emit this signal which notifies all widgets which have registered | 125 | * and emit this signal which notifies all widgets which have registered |
126 | * for notification to update their settings. */ | 126 | * for notification to update their settings. */ |
127 | void configChanged(); | 127 | void configChanged(); |
128 | /** emitted when the topwidget is closing down, so that any attached | 128 | /** emitted when the topwidget is closing down, so that any attached |
129 | child windows can also close. */ | 129 | child windows can also close. */ |
130 | void closingDown(); | 130 | void closingDown(); |
131 | /** emitted right before we die */ | 131 | /** emitted right before we die */ |
132 | void closed(QWidget *); | 132 | void closed(QWidget *); |
133 | 133 | ||
134 | /** Emitted when state of modified flag changes */ | 134 | /** Emitted when state of modified flag changes */ |
135 | void modifiedChanged(bool); | 135 | void modifiedChanged(bool); |
136 | void signalmodified(); | 136 | void signalmodified(); |
137 | 137 | ||
138 | /** Emitted when state of read-only flag changes */ | 138 | /** Emitted when state of read-only flag changes */ |
139 | void readOnlyChanged(bool); | 139 | void readOnlyChanged(bool); |
140 | 140 | ||
141 | /** Emitted when the unit of navigation changes */ | 141 | /** Emitted when the unit of navigation changes */ |
142 | void changeNavStringPrev(const QString &); | 142 | void changeNavStringPrev(const QString &); |
143 | void changeNavStringNext(const QString &); | 143 | void changeNavStringNext(const QString &); |
144 | 144 | ||
145 | /** Emitted when state of events selection has changed and user is organizer*/ | 145 | /** Emitted when state of events selection has changed and user is organizer*/ |
146 | void organizerEventsSelected(bool); | 146 | void organizerEventsSelected(bool); |
147 | /** Emitted when state of events selection has changed and user is attendee*/ | 147 | /** Emitted when state of events selection has changed and user is attendee*/ |
148 | void groupEventsSelected(bool); | 148 | void groupEventsSelected(bool); |
149 | /** | 149 | /** |
150 | Emitted when an incidence gets selected. If the selection is cleared the | 150 | Emitted when an incidence gets selected. If the selection is cleared the |
151 | signal is emitted with 0 as argument. | 151 | signal is emitted with 0 as argument. |
152 | */ | 152 | */ |
153 | void incidenceSelected( Incidence * ); | 153 | void incidenceSelected( Incidence * ); |
154 | /** Emitted, when a todoitem is selected or deselected. */ | 154 | /** Emitted, when a todoitem is selected or deselected. */ |
155 | void todoSelected( bool ); | 155 | void todoSelected( bool ); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Emitted, when clipboard content changes. Parameter indicates if paste | 158 | Emitted, when clipboard content changes. Parameter indicates if paste |
159 | is possible or not. | 159 | is possible or not. |
160 | */ | 160 | */ |
161 | void pasteEnabled(bool); | 161 | void pasteEnabled(bool); |
162 | 162 | ||
163 | /** Emitted, when the number of incoming messages has changed. */ | 163 | /** Emitted, when the number of incoming messages has changed. */ |
164 | void numIncomingChanged(int); | 164 | void numIncomingChanged(int); |
165 | 165 | ||
166 | /** Emitted, when the number of outgoing messages has changed. */ | 166 | /** Emitted, when the number of outgoing messages has changed. */ |
167 | void numOutgoingChanged(int); | 167 | void numOutgoingChanged(int); |
168 | 168 | ||
169 | /** Send status message, which can e.g. be displayed in the status bar. */ | 169 | /** Send status message, which can e.g. be displayed in the status bar. */ |
170 | void statusMessage(const QString &); | 170 | void statusMessage(const QString &); |
171 | 171 | ||
172 | void calendarViewExpanded( bool ); | 172 | void calendarViewExpanded( bool ); |
173 | void updateSearchDialog(); | 173 | void updateSearchDialog(); |
174 | 174 | ||
175 | 175 | ||
176 | public slots: | 176 | public slots: |
177 | void showNavigatorBar(bool); | ||
177 | void showOpenError(); | 178 | void showOpenError(); |
178 | void watchSavedFile(); | 179 | void watchSavedFile(); |
179 | void recheckTimerAlarm(); | 180 | void recheckTimerAlarm(); |
180 | void checkNextTimerAlarm(); | 181 | void checkNextTimerAlarm(); |
181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 182 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 183 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 184 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
184 | 185 | ||
185 | /** options dialog made a changed to the configuration. we catch this | 186 | /** options dialog made a changed to the configuration. we catch this |
186 | * and notify all widgets which need to update their configuration. */ | 187 | * and notify all widgets which need to update their configuration. */ |
187 | void updateConfig(); | 188 | void updateConfig(); |
188 | 189 | ||
189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 190 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
190 | const QStringList& anniversaryList, const QStringList& realNameList, | 191 | const QStringList& anniversaryList, const QStringList& realNameList, |
191 | const QStringList& emailList, const QStringList& assembledNameList, | 192 | const QStringList& emailList, const QStringList& assembledNameList, |
192 | const QStringList& uidList); | 193 | const QStringList& uidList); |
193 | 194 | ||
194 | /** | 195 | /** |
195 | Load calendar from file \a filename. If \a merge is true, load | 196 | Load calendar from file \a filename. If \a merge is true, load |
196 | calendar into existing one, if it is false, clear calendar, before | 197 | calendar into existing one, if it is false, clear calendar, before |
197 | loading. Return true, if calendar could be successfully loaded. | 198 | loading. Return true, if calendar could be successfully loaded. |
198 | */ | 199 | */ |
199 | bool openCalendar(QString filename, bool merge=false); | 200 | bool openCalendar(QString filename, bool merge=false); |
200 | bool syncCalendar(QString filename,int mode = 0 ); | 201 | bool syncCalendar(QString filename,int mode = 0 ); |
201 | 202 | ||
202 | /** | 203 | /** |
203 | Save calendar data to file. Return true if calendar could be | 204 | Save calendar data to file. Return true if calendar could be |
204 | successfully saved. | 205 | successfully saved. |
205 | */ | 206 | */ |
206 | bool saveCalendar(QString filename); | 207 | bool saveCalendar(QString filename); |
207 | 208 | ||
208 | /** | 209 | /** |
209 | Close calendar. Clear calendar data and reset views to display an empty | 210 | Close calendar. Clear calendar data and reset views to display an empty |
210 | calendar. | 211 | calendar. |
211 | */ | 212 | */ |
212 | void closeCalendar(); | 213 | void closeCalendar(); |
213 | 214 | ||
214 | /** Archive old events of calendar */ | 215 | /** Archive old events of calendar */ |
215 | void archiveCalendar(); | 216 | void archiveCalendar(); |
216 | 217 | ||
217 | void showIncidence(); | 218 | void showIncidence(); |
218 | void editIncidence(); | 219 | void editIncidence(); |
219 | void editIncidenceDescription(); | 220 | void editIncidenceDescription(); |
220 | void deleteIncidence(); | 221 | void deleteIncidence(); |
221 | void cloneIncidence(); | 222 | void cloneIncidence(); |
222 | void moveIncidence(); | 223 | void moveIncidence(); |
223 | void beamIncidence(); | 224 | void beamIncidence(); |
224 | void toggleCancelIncidence(); | 225 | void toggleCancelIncidence(); |
225 | 226 | ||
226 | /** create an editeventwin with supplied date/time, and if bool is true, | 227 | /** create an editeventwin with supplied date/time, and if bool is true, |
227 | * make the event take all day. */ | 228 | * make the event take all day. */ |
228 | void newEvent(QDateTime, QDateTime, bool allDay ); | 229 | void newEvent(QDateTime, QDateTime, bool allDay ); |
229 | void newEvent(QDateTime, QDateTime); | 230 | void newEvent(QDateTime, QDateTime); |
230 | void newEvent(QDateTime fh); | 231 | void newEvent(QDateTime fh); |
231 | void newEvent(QDate dt); | 232 | void newEvent(QDate dt); |
232 | /** create new event without having a date hint. Takes current date as | 233 | /** create new event without having a date hint. Takes current date as |
233 | default hint. */ | 234 | default hint. */ |
234 | void newEvent(); | 235 | void newEvent(); |
235 | void newFloatingEvent(); | 236 | void newFloatingEvent(); |
236 | 237 | ||
237 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 238 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
238 | void showIncidence(Incidence *); | 239 | void showIncidence(Incidence *); |
239 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 240 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
240 | void editIncidence(Incidence *); | 241 | void editIncidence(Incidence *); |
241 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 242 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
242 | void deleteIncidence(Incidence *); | 243 | void deleteIncidence(Incidence *); |
243 | void cloneIncidence(Incidence *); | 244 | void cloneIncidence(Incidence *); |
244 | void cancelIncidence(Incidence *); | 245 | void cancelIncidence(Incidence *); |
245 | /** Create an editor for the supplied event. */ | 246 | /** Create an editor for the supplied event. */ |
246 | void editEvent(Event *); | 247 | void editEvent(Event *); |
247 | /** Delete the supplied event. */ | 248 | /** Delete the supplied event. */ |
248 | void deleteEvent(Event *); | 249 | void deleteEvent(Event *); |
249 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 250 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
250 | found. */ | 251 | found. */ |
251 | bool deleteEvent(const QString &uid); | 252 | bool deleteEvent(const QString &uid); |
252 | /** Create a read-only viewer dialog for the supplied event. */ | 253 | /** Create a read-only viewer dialog for the supplied event. */ |
253 | void showEvent(Event *); | 254 | void showEvent(Event *); |
254 | 255 | ||
255 | void editJournal(Journal *); | 256 | void editJournal(Journal *); |
256 | void showJournal(Journal *); | 257 | void showJournal(Journal *); |
257 | void deleteJournal(Journal *); | 258 | void deleteJournal(Journal *); |
258 | /** Create an editor dialog for a todo */ | 259 | /** Create an editor dialog for a todo */ |
259 | void editTodo(Todo *); | 260 | void editTodo(Todo *); |
260 | /** Create a read-only viewer dialog for the supplied todo */ | 261 | /** Create a read-only viewer dialog for the supplied todo */ |
261 | void showTodo(Todo *); | 262 | void showTodo(Todo *); |
262 | /** create new todo */ | 263 | /** create new todo */ |
263 | void newTodo(); | 264 | void newTodo(); |
264 | void newTodoDateTime(QDateTime, bool allday); | 265 | void newTodoDateTime(QDateTime, bool allday); |
265 | /** create new todo with a parent todo */ | 266 | /** create new todo with a parent todo */ |
266 | void newSubTodo(); | 267 | void newSubTodo(); |
267 | /** create new todo with a parent todo */ | 268 | /** create new todo with a parent todo */ |
268 | void newSubTodo(Todo *); | 269 | void newSubTodo(Todo *); |
269 | /** Delete todo */ | 270 | /** Delete todo */ |
270 | void deleteTodo(Todo *); | 271 | void deleteTodo(Todo *); |
271 | 272 | ||
272 | 273 | ||
273 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 274 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
274 | * emitted as result. */ | 275 | * emitted as result. */ |
275 | void checkClipboard(); | 276 | void checkClipboard(); |
276 | 277 | ||
277 | /** using the KConfig associated with the kapp variable, read in the | 278 | /** using the KConfig associated with the kapp variable, read in the |
278 | * settings from the config file. | 279 | * settings from the config file. |
279 | */ | 280 | */ |
280 | void readSettings(); | 281 | void readSettings(); |
281 | 282 | ||
282 | /** write current state to config file. */ | 283 | /** write current state to config file. */ |
283 | void writeSettings(); | 284 | void writeSettings(); |
284 | 285 | ||
285 | /** read settings for calendar filters */ | 286 | /** read settings for calendar filters */ |
286 | void readFilterSettings(KConfig *config); | 287 | void readFilterSettings(KConfig *config); |
287 | 288 | ||
288 | /** write settings for calendar filters */ | 289 | /** write settings for calendar filters */ |
289 | void writeFilterSettings(KConfig *config); | 290 | void writeFilterSettings(KConfig *config); |
290 | 291 | ||
291 | /** passes on the message that an event has changed to the currently | 292 | /** passes on the message that an event has changed to the currently |
292 | * activated view so that it can make appropriate display changes. */ | 293 | * activated view so that it can make appropriate display changes. */ |
293 | void changeEventDisplay(Event *, int); | 294 | void changeEventDisplay(Event *, int); |
294 | void changeIncidenceDisplay(Incidence *, int); | 295 | void changeIncidenceDisplay(Incidence *, int); |
295 | void changeTodoDisplay(Todo *, int); | 296 | void changeTodoDisplay(Todo *, int); |
296 | 297 | ||
297 | void eventAdded(Event *); | 298 | void eventAdded(Event *); |
298 | void eventChanged(Event *); | 299 | void eventChanged(Event *); |
299 | void eventToBeDeleted(Event *); | 300 | void eventToBeDeleted(Event *); |
300 | void eventDeleted(); | 301 | void eventDeleted(); |
301 | 302 | ||
302 | void todoAdded(Todo *); | 303 | void todoAdded(Todo *); |
303 | void todoChanged(Todo *); | 304 | void todoChanged(Todo *); |
304 | void todoToBeDeleted(Todo *); | 305 | void todoToBeDeleted(Todo *); |
305 | void todoDeleted(); | 306 | void todoDeleted(); |
306 | 307 | ||
307 | void updateView(const QDate &start, const QDate &end); | 308 | void updateView(const QDate &start, const QDate &end); |
308 | void updateView(); | 309 | void updateView(); |
309 | 310 | ||
310 | /** Full update of visible todo views */ | 311 | /** Full update of visible todo views */ |
311 | void updateTodoViews(); | 312 | void updateTodoViews(); |
312 | 313 | ||
313 | void updateUnmanagedViews(); | 314 | void updateUnmanagedViews(); |
314 | 315 | ||
315 | /** cut the current appointment to the clipboard */ | 316 | /** cut the current appointment to the clipboard */ |
316 | void edit_cut(); | 317 | void edit_cut(); |
317 | 318 | ||
318 | /** copy the current appointment(s) to the clipboard */ | 319 | /** copy the current appointment(s) to the clipboard */ |
319 | void edit_copy(); | 320 | void edit_copy(); |
320 | 321 | ||
321 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 322 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
322 | void edit_paste(); | 323 | void edit_paste(); |
323 | 324 | ||
324 | /** edit viewing and configuration options. */ | 325 | /** edit viewing and configuration options. */ |
325 | void edit_options(); | 326 | void edit_options(); |
326 | /** | 327 | /** |
327 | Functions for printing, previewing a print, and setting up printing | 328 | Functions for printing, previewing a print, and setting up printing |
328 | parameters. | 329 | parameters. |
329 | */ | 330 | */ |
330 | void print(); | 331 | void print(); |
331 | void printSetup(); | 332 | void printSetup(); |
332 | void printPreview(); | 333 | void printPreview(); |
333 | 334 | ||
334 | /** Export as iCalendar file */ | 335 | /** Export as iCalendar file */ |
335 | void exportICalendar(); | 336 | void exportICalendar(); |
336 | 337 | ||
337 | /** Export as vCalendar file */ | 338 | /** Export as vCalendar file */ |
338 | bool exportVCalendar( QString fn); | 339 | bool exportVCalendar( QString fn); |
339 | 340 | ||
340 | /** pop up a dialog to show an existing appointment. */ | 341 | /** pop up a dialog to show an existing appointment. */ |
341 | void appointment_show(); | 342 | void appointment_show(); |
342 | /** | 343 | /** |
343 | * pop up an Appointment Dialog to edit an existing appointment.Get | 344 | * pop up an Appointment Dialog to edit an existing appointment.Get |
344 | * information on the appointment from the list of unique IDs that is | 345 | * information on the appointment from the list of unique IDs that is |
345 | * currently in the View, called currIds. | 346 | * currently in the View, called currIds. |
346 | */ | 347 | */ |
347 | void appointment_edit(); | 348 | void appointment_edit(); |
348 | /** | 349 | /** |
349 | * pop up dialog confirming deletion of currently selected event in the | 350 | * pop up dialog confirming deletion of currently selected event in the |
350 | * View. | 351 | * View. |
351 | */ | 352 | */ |
352 | void appointment_delete(); | 353 | void appointment_delete(); |
353 | 354 | ||
354 | /** mails the currently selected event to a particular user as a vCalendar | 355 | /** mails the currently selected event to a particular user as a vCalendar |
355 | attachment. */ | 356 | attachment. */ |
356 | void action_mail(); | 357 | void action_mail(); |
357 | 358 | ||
358 | /* frees a subtodo from it's relation */ | 359 | /* frees a subtodo from it's relation */ |
359 | void todo_unsub( Todo * ); | 360 | void todo_unsub( Todo * ); |
360 | void todo_resub( Todo * parent, Todo * sub ); | 361 | void todo_resub( Todo * parent, Todo * sub ); |
361 | 362 | ||
362 | /** Take ownership of selected event. */ | 363 | /** Take ownership of selected event. */ |
363 | void takeOverEvent(); | 364 | void takeOverEvent(); |
364 | 365 | ||
365 | /** Take ownership of all events in calendar. */ | 366 | /** Take ownership of all events in calendar. */ |
366 | void takeOverCalendar(); | 367 | void takeOverCalendar(); |
367 | 368 | ||
368 | /** query whether or not the calendar is "dirty". */ | 369 | /** query whether or not the calendar is "dirty". */ |
369 | bool isModified(); | 370 | bool isModified(); |
370 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 371 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
371 | void setModified(bool modified=true); | 372 | void setModified(bool modified=true); |
372 | 373 | ||
373 | /** query if the calendar is read-only. */ | 374 | /** query if the calendar is read-only. */ |
374 | bool isReadOnly(); | 375 | bool isReadOnly(); |
375 | /** set state of calendar to read-only */ | 376 | /** set state of calendar to read-only */ |
376 | void setReadOnly(bool readOnly=true); | 377 | void setReadOnly(bool readOnly=true); |
377 | 378 | ||
378 | void eventUpdated(Incidence *); | 379 | void eventUpdated(Incidence *); |
379 | 380 | ||
380 | /* iTIP scheduling actions */ | 381 | /* iTIP scheduling actions */ |
381 | void schedule_publish(Incidence *incidence = 0); | 382 | void schedule_publish(Incidence *incidence = 0); |
382 | void schedule_request(Incidence *incidence = 0); | 383 | void schedule_request(Incidence *incidence = 0); |
383 | void schedule_refresh(Incidence *incidence = 0); | 384 | void schedule_refresh(Incidence *incidence = 0); |
384 | void schedule_cancel(Incidence *incidence = 0); | 385 | void schedule_cancel(Incidence *incidence = 0); |
385 | void schedule_add(Incidence *incidence = 0); | 386 | void schedule_add(Incidence *incidence = 0); |
386 | void schedule_reply(Incidence *incidence = 0); | 387 | void schedule_reply(Incidence *incidence = 0); |
387 | void schedule_counter(Incidence *incidence = 0); | 388 | void schedule_counter(Incidence *incidence = 0); |
388 | void schedule_declinecounter(Incidence *incidence = 0); | 389 | void schedule_declinecounter(Incidence *incidence = 0); |
389 | void schedule_publish_freebusy(int daysToPublish = 30); | 390 | void schedule_publish_freebusy(int daysToPublish = 30); |
390 | 391 | ||
391 | void openAddressbook(); | 392 | void openAddressbook(); |
392 | 393 | ||
393 | void editFilters(); | 394 | void editFilters(); |
394 | void toggleFilerEnabled(); | 395 | void toggleFilerEnabled(); |
395 | QPtrList<CalFilter> filters(); | 396 | QPtrList<CalFilter> filters(); |
396 | void toggleFilter(); | 397 | void toggleFilter(); |
397 | void showFilter(bool visible); | 398 | void showFilter(bool visible); |
398 | void updateFilter(); | 399 | void updateFilter(); |
399 | void filterEdited(); | 400 | void filterEdited(); |
400 | void selectFilter( int ); | 401 | void selectFilter( int ); |
401 | KOFilterView *filterView(); | 402 | KOFilterView *filterView(); |
402 | 403 | ||
403 | void showIntro(); | 404 | void showIntro(); |
404 | 405 | ||
405 | /** Move the curdatepient view date to today */ | 406 | /** Move the curdatepient view date to today */ |
406 | void goToday(); | 407 | void goToday(); |
407 | 408 | ||
408 | /** Move to the next date(s) in the current view */ | 409 | /** Move to the next date(s) in the current view */ |
409 | void goNext(); | 410 | void goNext(); |
410 | 411 | ||
411 | /** Move to the previous date(s) in the current view */ | 412 | /** Move to the previous date(s) in the current view */ |
412 | void goPrevious(); | 413 | void goPrevious(); |
413 | /** Move to the next date(s) in the current view */ | 414 | /** Move to the next date(s) in the current view */ |
414 | void goNextMonth(); | 415 | void goNextMonth(); |
415 | 416 | ||
416 | /** Move to the previous date(s) in the current view */ | 417 | /** Move to the previous date(s) in the current view */ |
417 | void goPreviousMonth(); | 418 | void goPreviousMonth(); |
418 | 419 | ||
419 | void toggleExpand(); | 420 | void toggleExpand(); |
420 | void toggleDateNavigatorWidget(); | 421 | void toggleDateNavigatorWidget(); |
421 | void toggleAllDaySize(); | 422 | void toggleAllDaySize(); |
422 | void dialogClosing(Incidence *); | 423 | void dialogClosing(Incidence *); |
423 | 424 | ||
424 | /** Look for new messages in the inbox */ | 425 | /** Look for new messages in the inbox */ |
425 | void lookForIncomingMessages(); | 426 | void lookForIncomingMessages(); |
426 | /** Look for new messages in the outbox */ | 427 | /** Look for new messages in the outbox */ |
427 | void lookForOutgoingMessages(); | 428 | void lookForOutgoingMessages(); |
428 | 429 | ||
429 | void processMainViewSelection( Incidence * ); | 430 | void processMainViewSelection( Incidence * ); |
430 | void processTodoListSelection( Incidence * ); | 431 | void processTodoListSelection( Incidence * ); |
431 | 432 | ||
432 | void processIncidenceSelection( Incidence * ); | 433 | void processIncidenceSelection( Incidence * ); |
433 | 434 | ||
434 | void purgeCompleted(); | 435 | void purgeCompleted(); |
435 | bool removeCompletedSubTodos( Todo* ); | 436 | bool removeCompletedSubTodos( Todo* ); |
436 | void slotCalendarChanged(); | 437 | void slotCalendarChanged(); |
437 | bool importBday(); | 438 | bool importBday(); |
438 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 439 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
439 | bool importQtopia( const QString &categoriesFile, | 440 | bool importQtopia( const QString &categoriesFile, |
440 | const QString &datebookFile, | 441 | const QString &datebookFile, |
441 | const QString &tasklistFile ); | 442 | const QString &tasklistFile ); |
442 | void syncExternal( int mode ); | 443 | void syncExternal( int mode ); |
443 | void slotSelectPickerDate( QDate ) ; | 444 | void slotSelectPickerDate( QDate ) ; |
444 | void showDatePicker( ) ; | 445 | void showDatePicker( ) ; |
445 | void moveIncidence(Incidence *) ; | 446 | void moveIncidence(Incidence *) ; |
446 | void beamIncidence(Incidence *) ; | 447 | void beamIncidence(Incidence *) ; |
447 | void beamCalendar() ; | 448 | void beamCalendar() ; |
448 | void beamFilteredCalendar() ; | 449 | void beamFilteredCalendar() ; |
449 | void beamIncidenceList(QPtrList<Incidence>) ; | 450 | void beamIncidenceList(QPtrList<Incidence>) ; |
450 | void manageCategories(); | 451 | void manageCategories(); |
451 | int addCategories(); | 452 | int addCategories(); |
452 | void removeCategories(); | 453 | void removeCategories(); |
453 | void setSyncDevice( QString ); | 454 | void setSyncDevice( QString ); |
454 | void setSyncName( QString ); | 455 | void setSyncName( QString ); |
455 | void showDay( QDate ); | 456 | void showDay( QDate ); |
456 | void undo_delete(); | 457 | void undo_delete(); |
457 | protected slots: | 458 | protected slots: |
458 | void timerAlarm(); | 459 | void timerAlarm(); |
459 | void suspendAlarm(); | 460 | void suspendAlarm(); |
460 | void beamDone( Ir *ir ); | 461 | void beamDone( Ir *ir ); |
461 | /** Select a view or adapt the current view to display the specified dates. */ | 462 | /** Select a view or adapt the current view to display the specified dates. */ |
462 | void showDates( const KCal::DateList & ); | 463 | void showDates( const KCal::DateList & ); |
463 | void selectWeekNum ( int ); | 464 | void selectWeekNum ( int ); |
464 | 465 | ||
465 | public: | 466 | public: |
466 | // show a standard warning | 467 | // show a standard warning |
467 | // returns KMsgBox::yesNoCancel() | 468 | // returns KMsgBox::yesNoCancel() |
468 | int msgCalModified(); | 469 | int msgCalModified(); |
469 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 470 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
470 | 471 | ||
471 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 472 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
472 | virtual void removeSyncInfo( QString syncProfile); | 473 | virtual void removeSyncInfo( QString syncProfile); |
473 | void setSyncManager(KSyncManager* manager); | 474 | void setSyncManager(KSyncManager* manager); |
474 | void setLoadedFileVersion(QDateTime); | 475 | void setLoadedFileVersion(QDateTime); |
475 | bool checkFileVersion(QString fn); | 476 | bool checkFileVersion(QString fn); |
476 | bool checkFileChanged(QString fn); | 477 | bool checkFileChanged(QString fn); |
477 | Event* getLastSyncEvent(); | 478 | Event* getLastSyncEvent(); |
478 | /** Adapt navigation units correpsonding to step size of navigation of the | 479 | /** Adapt navigation units correpsonding to step size of navigation of the |
479 | * current view. | 480 | * current view. |
480 | */ | 481 | */ |
481 | void adaptNavigationUnits(); | 482 | void adaptNavigationUnits(); |
482 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 483 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
483 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 484 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
484 | //Attendee* getYourAttendee(Event *event); | 485 | //Attendee* getYourAttendee(Event *event); |
485 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 486 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
486 | protected: | 487 | protected: |
487 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 488 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
488 | 489 | ||
489 | // returns KMsgBox::OKCandel() | 490 | // returns KMsgBox::OKCandel() |
490 | int msgItemDelete(const QString name); | 491 | int msgItemDelete(const QString name); |
491 | void showEventEditor(); | 492 | void showEventEditor(); |
492 | void showTodoEditor(); | 493 | void showTodoEditor(); |
493 | void writeLocale(); | 494 | void writeLocale(); |
494 | Todo *selectedTodo(); | 495 | Todo *selectedTodo(); |
495 | 496 | ||
496 | private: | 497 | private: |
497 | bool mBlockShowDates; | 498 | bool mBlockShowDates; |
498 | KSyncManager* mSyncManager; | 499 | KSyncManager* mSyncManager; |
499 | AlarmDialog * mAlarmDialog; | 500 | AlarmDialog * mAlarmDialog; |
500 | QString mAlarmNotification; | 501 | QString mAlarmNotification; |
501 | QString mSuspendAlarmNotification; | 502 | QString mSuspendAlarmNotification; |
502 | QTimer* mSuspendTimer; | 503 | QTimer* mSuspendTimer; |
503 | QTimer* mAlarmTimer; | 504 | QTimer* mAlarmTimer; |
504 | QTimer* mRecheckAlarmTimer; | 505 | QTimer* mRecheckAlarmTimer; |
505 | void computeAlarm( QString ); | 506 | void computeAlarm( QString ); |
506 | void startAlarm( QString, QString ); | 507 | void startAlarm( QString, QString ); |
507 | void setSyncEventsReadOnly(); | 508 | void setSyncEventsReadOnly(); |
508 | 509 | ||
509 | QDateTime loadedFileVersion; | 510 | QDateTime loadedFileVersion; |
510 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 511 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
511 | void checkExternalId( Incidence * inc ); | 512 | void checkExternalId( Incidence * inc ); |
512 | int mGlobalSyncMode; | 513 | int mGlobalSyncMode; |
513 | QString mCurrentSyncDevice; | 514 | QString mCurrentSyncDevice; |
514 | QString mCurrentSyncName; | 515 | QString mCurrentSyncName; |
515 | KOBeamPrefs* beamDialog; | 516 | KOBeamPrefs* beamDialog; |
516 | void init(); | 517 | void init(); |
517 | int mDatePickerMode; | 518 | int mDatePickerMode; |
518 | bool mFlagEditDescription; | 519 | bool mFlagEditDescription; |
519 | QDateTime mLastCalendarSync; | 520 | QDateTime mLastCalendarSync; |
520 | void createPrinter(); | 521 | void createPrinter(); |
521 | 522 | ||
522 | void calendarModified( bool, Calendar * ); | 523 | void calendarModified( bool, Calendar * ); |
523 | 524 | ||
524 | CalPrinter *mCalPrinter; | 525 | CalPrinter *mCalPrinter; |
525 | 526 | ||
526 | QSplitter *mPanner; | 527 | QSplitter *mPanner; |
527 | QSplitter *mLeftSplitter; | 528 | QSplitter *mLeftSplitter; |
528 | QWidget *mLeftFrame; | 529 | QWidget *mLeftFrame; |
529 | QWidgetStack *mRightFrame; | 530 | QWidgetStack *mRightFrame; |
530 | 531 | ||
531 | KDatePicker* mDatePicker; | 532 | KDatePicker* mDatePicker; |
532 | QVBox* mDateFrame; | 533 | QVBox* mDateFrame; |
533 | NavigatorBar *mNavigatorBar; | 534 | NavigatorBar *mNavigatorBar; |
534 | 535 | ||
535 | KDateNavigator *mDateNavigator; // widget showing small month view. | 536 | KDateNavigator *mDateNavigator; // widget showing small month view. |
536 | 537 | ||
537 | KOFilterView *mFilterView; | 538 | KOFilterView *mFilterView; |
538 | 539 | ||
539 | ResourceView *mResourceView; | 540 | ResourceView *mResourceView; |
540 | 541 | ||
541 | // calendar object for this viewing instance | 542 | // calendar object for this viewing instance |
542 | Calendar *mCalendar; | 543 | Calendar *mCalendar; |
543 | 544 | ||
544 | CalendarResourceManager *mResourceManager; | 545 | CalendarResourceManager *mResourceManager; |
545 | 546 | ||
546 | FileStorage *mStorage; | 547 | FileStorage *mStorage; |
547 | 548 | ||
548 | DateNavigator *mNavigator; | 549 | DateNavigator *mNavigator; |
549 | 550 | ||
550 | KOViewManager *mViewManager; | 551 | KOViewManager *mViewManager; |
551 | KODialogManager *mDialogManager; | 552 | KODialogManager *mDialogManager; |
552 | 553 | ||
553 | // Calendar filters | 554 | // Calendar filters |
554 | QPtrList<CalFilter> mFilters; | 555 | QPtrList<CalFilter> mFilters; |
555 | 556 | ||
556 | // various housekeeping variables. | 557 | // various housekeeping variables. |
557 | bool mModified; // flag indicating if calendar is modified | 558 | bool mModified; // flag indicating if calendar is modified |
558 | bool mReadOnly; // flag indicating if calendar is read-only | 559 | bool mReadOnly; // flag indicating if calendar is read-only |
559 | QDate mSaveSingleDate; | 560 | QDate mSaveSingleDate; |
560 | 561 | ||
561 | Incidence *mSelectedIncidence; | 562 | Incidence *mSelectedIncidence; |
562 | Incidence *mMoveIncidence; | 563 | Incidence *mMoveIncidence; |
563 | QDate mMoveIncidenceOldDate; | 564 | QDate mMoveIncidenceOldDate; |
564 | KOTodoView *mTodoList; | 565 | KOTodoView *mTodoList; |
565 | KOEventEditor * mEventEditor; | 566 | KOEventEditor * mEventEditor; |
566 | KOTodoEditor * mTodoEditor; | 567 | KOTodoEditor * mTodoEditor; |
567 | KOEventViewerDialog * mEventViewerDialog; | 568 | KOEventViewerDialog * mEventViewerDialog; |
568 | void keyPressEvent ( QKeyEvent *e) ; | 569 | void keyPressEvent ( QKeyEvent *e) ; |
569 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 570 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
570 | }; | 571 | }; |
571 | 572 | ||
572 | 573 | ||
573 | class CalendarViewVisitor : public Incidence::Visitor | 574 | class CalendarViewVisitor : public Incidence::Visitor |
574 | { | 575 | { |
575 | public: | 576 | public: |
576 | CalendarViewVisitor() : mView( 0 ) {} | 577 | CalendarViewVisitor() : mView( 0 ) {} |
577 | 578 | ||
578 | bool act( Incidence *incidence, CalendarView *view ) | 579 | bool act( Incidence *incidence, CalendarView *view ) |
579 | { | 580 | { |
580 | mView = view; | 581 | mView = view; |
581 | return incidence->accept( *this ); | 582 | return incidence->accept( *this ); |
582 | } | 583 | } |
583 | 584 | ||
584 | protected: | 585 | protected: |
585 | CalendarView *mView; | 586 | CalendarView *mView; |
586 | }; | 587 | }; |
587 | 588 | ||
588 | class ShowIncidenceVisitor : public CalendarViewVisitor | 589 | class ShowIncidenceVisitor : public CalendarViewVisitor |
589 | { | 590 | { |
590 | protected: | 591 | protected: |
591 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 592 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
592 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 593 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
593 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 594 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
594 | }; | 595 | }; |
595 | 596 | ||
596 | class EditIncidenceVisitor : public CalendarViewVisitor | 597 | class EditIncidenceVisitor : public CalendarViewVisitor |
597 | { | 598 | { |
598 | protected: | 599 | protected: |
599 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 600 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
600 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 601 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
601 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 602 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
602 | }; | 603 | }; |
603 | 604 | ||
604 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 605 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
605 | { | 606 | { |
606 | protected: | 607 | protected: |
607 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 608 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
608 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 609 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
609 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 610 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
610 | }; | 611 | }; |
611 | 612 | ||
612 | #endif | 613 | #endif |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6411156..9888566 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1269 +1,1408 @@ | |||
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 <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 27 | #include <qtooltip.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
45 | #include "calprinter.h" | 45 | #include "calprinter.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #ifndef KORG_NOPLUGINS | 48 | #ifndef KORG_NOPLUGINS |
49 | #include "kocore.h" | 49 | #include "kocore.h" |
50 | #endif | 50 | #endif |
51 | #include "koglobals.h" | 51 | #include "koglobals.h" |
52 | #include <libkcal/kincidenceformatter.h> | 52 | #include <libkcal/kincidenceformatter.h> |
53 | 53 | ||
54 | #include "komonthview.h" | 54 | #include "komonthview.h" |
55 | 55 | ||
56 | #define PIXMAP_SIZE 5 | 56 | #define PIXMAP_SIZE 5 |
57 | #ifdef DESKTOP_VERSION | 57 | #ifdef DESKTOP_VERSION |
58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
59 | #endif | 59 | #endif |
60 | class KNOWhatsThis :public QWhatsThis | 60 | class KNOWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | virtual QString text( const QPoint& p) | 67 | virtual QString text( const QPoint& p) |
68 | { | 68 | { |
69 | return _wid->getWhatsThisText(p) ; | 69 | return _wid->getWhatsThisText(p) ; |
70 | }; | 70 | }; |
71 | private: | 71 | private: |
72 | KNoScrollListBox* _wid; | 72 | KNoScrollListBox* _wid; |
73 | 73 | ||
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
78 | : QListBox(parent, name, WRepaintNoErase) | 78 | : QListBox(parent, name, WRepaintNoErase) |
79 | { | 79 | { |
80 | #ifndef DESKTOP_VERSION | 80 | #ifndef DESKTOP_VERSION |
81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
82 | #endif | 82 | #endif |
83 | mWT = new KNOWhatsThis(this); | 83 | mWT = new KNOWhatsThis(this); |
84 | } | 84 | } |
85 | KNoScrollListBox::~KNoScrollListBox() | 85 | KNoScrollListBox::~KNoScrollListBox() |
86 | { | 86 | { |
87 | 87 | ||
88 | } | 88 | } |
89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
90 | { | 90 | { |
91 | QListBoxItem* item = itemAt ( p ); | 91 | QListBoxItem* item = itemAt ( p ); |
92 | if ( ! item ) { | 92 | if ( ! item ) { |
93 | return i18n("Click in the cell\nto add an event!"); | 93 | return i18n("Click in the cell\nto add an event!"); |
94 | } | 94 | } |
95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
96 | } | 96 | } |
97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
98 | { | 98 | { |
99 | 99 | ||
100 | switch(e->key()) { | 100 | switch(e->key()) { |
101 | case Key_Right: | 101 | case Key_Right: |
102 | // if ( e->state() == Qt::ControlButton ) | 102 | // if ( e->state() == Qt::ControlButton ) |
103 | { | 103 | { |
104 | e->ignore(); | 104 | e->ignore(); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | scrollBy(4,0); | 107 | scrollBy(4,0); |
108 | break; | 108 | break; |
109 | case Key_Left: | 109 | case Key_Left: |
110 | // if ( e->state() == Qt::ControlButton ) | 110 | // if ( e->state() == Qt::ControlButton ) |
111 | { | 111 | { |
112 | e->ignore(); | 112 | e->ignore(); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | scrollBy(-4,0); | 115 | scrollBy(-4,0); |
116 | break; | 116 | break; |
117 | case Key_Up: | 117 | case Key_Up: |
118 | if(count() < 2) { | 118 | if(count() < 2) { |
119 | e->ignore(); | 119 | e->ignore(); |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | setCurrentItem((currentItem()+count()-1)%count()); | 122 | setCurrentItem((currentItem()+count()-1)%count()); |
123 | if(!itemVisible(currentItem())) { | 123 | if(!itemVisible(currentItem())) { |
124 | if((unsigned int) currentItem() == (count()-1)) { | 124 | if((unsigned int) currentItem() == (count()-1)) { |
125 | setTopItem(currentItem()-numItemsVisible()+1); | 125 | setTopItem(currentItem()-numItemsVisible()+1); |
126 | } else { | 126 | } else { |
127 | setTopItem(topItem()-1); | 127 | setTopItem(topItem()-1); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | break; | 130 | break; |
131 | case Key_Down: | 131 | case Key_Down: |
132 | if(count() < 2) { | 132 | if(count() < 2) { |
133 | e->ignore(); | 133 | e->ignore(); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | setCurrentItem((currentItem()+1)%count()); | 136 | setCurrentItem((currentItem()+1)%count()); |
137 | if(!itemVisible(currentItem())) { | 137 | if(!itemVisible(currentItem())) { |
138 | if(currentItem() == 0) { | 138 | if(currentItem() == 0) { |
139 | setTopItem(0); | 139 | setTopItem(0); |
140 | } else { | 140 | } else { |
141 | setTopItem(topItem()+1); | 141 | setTopItem(topItem()+1); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | break; | 144 | break; |
145 | case Key_Shift: | 145 | case Key_Shift: |
146 | emit shiftDown(); | 146 | emit shiftDown(); |
147 | break; | 147 | break; |
148 | default: | 148 | default: |
149 | e->ignore(); | 149 | e->ignore(); |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
155 | { | 155 | { |
156 | switch(e->key()) { | 156 | switch(e->key()) { |
157 | case Key_Shift: | 157 | case Key_Shift: |
158 | emit shiftUp(); | 158 | emit shiftUp(); |
159 | break; | 159 | break; |
160 | default: | 160 | default: |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
166 | { | 166 | { |
167 | QListBox::mousePressEvent(e); | 167 | QListBox::mousePressEvent(e); |
168 | 168 | ||
169 | if(e->button() == RightButton) { | 169 | if(e->button() == RightButton) { |
170 | emit rightClick(); | 170 | emit rightClick(); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
175 | : QListBoxItem() | 175 | : QListBoxItem() |
176 | { | 176 | { |
177 | setText( s ); | 177 | setText( s ); |
178 | 178 | ||
179 | mIncidence = incidence; | 179 | mIncidence = incidence; |
180 | mDate = qd; | 180 | mDate = qd; |
181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
182 | mRecur = false; | 182 | mRecur = false; |
183 | mAlarm = false; | 183 | mAlarm = false; |
184 | mReply = false; | 184 | mReply = false; |
185 | mInfo = false; | 185 | mInfo = false; |
186 | } | 186 | } |
187 | 187 | ||
188 | void MonthViewItem::paint(QPainter *p) | 188 | void MonthViewItem::paint(QPainter *p) |
189 | { | 189 | { |
190 | #if QT_VERSION >= 0x030000 | 190 | #if QT_VERSION >= 0x030000 |
191 | bool sel = isSelected(); | 191 | bool sel = isSelected(); |
192 | #else | 192 | #else |
193 | bool sel = selected(); | 193 | bool sel = selected(); |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | 196 | ||
197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
198 | { | 198 | { |
199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
202 | } | 202 | } |
203 | int x = 1; | 203 | int x = 1; |
204 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 204 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
205 | int size = PIXMAP_SIZE; | 205 | int size = PIXMAP_SIZE; |
206 | if ( QApplication::desktop()->width() < 300 ) | 206 | if ( QApplication::desktop()->width() < 300 ) |
207 | size = 3; | 207 | size = 3; |
208 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 208 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
209 | if ( mInfo ) { | 209 | if ( mInfo ) { |
210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
211 | x += size + 1; | 211 | x += size + 1; |
212 | } | 212 | } |
213 | if ( mRecur ) { | 213 | if ( mRecur ) { |
214 | p->fillRect ( x, y,size,size, Qt::blue ); | 214 | p->fillRect ( x, y,size,size, Qt::blue ); |
215 | x += size + 1; | 215 | x += size + 1; |
216 | } | 216 | } |
217 | if ( mAlarm ) { | 217 | if ( mAlarm ) { |
218 | p->fillRect ( x, y,size,size, Qt::red ); | 218 | p->fillRect ( x, y,size,size, Qt::red ); |
219 | x += size + 1; | 219 | x += size + 1; |
220 | } | 220 | } |
221 | if ( mReply ) { | 221 | if ( mReply ) { |
222 | p->fillRect ( x, y,size,size, Qt::yellow ); | 222 | p->fillRect ( x, y,size,size, Qt::yellow ); |
223 | x += size + 1; | 223 | x += size + 1; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | QFontMetrics fm = p->fontMetrics(); | 226 | QFontMetrics fm = p->fontMetrics(); |
227 | int yPos; | 227 | int yPos; |
228 | int pmheight = size; | 228 | int pmheight = size; |
229 | if( pmheight < fm.height() ) | 229 | if( pmheight < fm.height() ) |
230 | yPos = fm.ascent() + fm.leading()/2; | 230 | yPos = fm.ascent() + fm.leading()/2; |
231 | else | 231 | else |
232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
233 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 233 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
235 | p->drawText( x, yPos, text() ); | 235 | p->drawText( x, yPos, text() ); |
236 | if ( mIncidence->cancelled() ) { | 236 | if ( mIncidence->cancelled() ) { |
237 | int wid = fm.width( text() ); | 237 | int wid = fm.width( text() ); |
238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); | 238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); |
239 | } | 239 | } |
240 | 240 | ||
241 | } | 241 | } |
242 | 242 | ||
243 | int MonthViewItem::height(const QListBox *lb) const | 243 | int MonthViewItem::height(const QListBox *lb) const |
244 | { | 244 | { |
245 | return lb->fontMetrics().lineSpacing()+1; | 245 | return lb->fontMetrics().lineSpacing()+1; |
246 | } | 246 | } |
247 | 247 | ||
248 | int MonthViewItem::width(const QListBox *lb) const | 248 | int MonthViewItem::width(const QListBox *lb) const |
249 | { | 249 | { |
250 | int size = PIXMAP_SIZE; | 250 | int size = PIXMAP_SIZE; |
251 | if ( QApplication::desktop()->width() < 300 ) | 251 | if ( QApplication::desktop()->width() < 300 ) |
252 | size = 3; | 252 | size = 3; |
253 | int x = 1; | 253 | int x = 1; |
254 | if ( mInfo ) { | 254 | if ( mInfo ) { |
255 | x += size + 1; | 255 | x += size + 1; |
256 | } | 256 | } |
257 | if( mRecur ) { | 257 | if( mRecur ) { |
258 | x += size+1; | 258 | x += size+1; |
259 | } | 259 | } |
260 | if( mAlarm ) { | 260 | if( mAlarm ) { |
261 | x += size+1; | 261 | x += size+1; |
262 | } | 262 | } |
263 | if( mReply ) { | 263 | if( mReply ) { |
264 | x += size+1; | 264 | x += size+1; |
265 | } | 265 | } |
266 | 266 | ||
267 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 267 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | MonthViewCell::MonthViewCell( KOMonthView *parent) | 271 | MonthViewCell::MonthViewCell( KOMonthView *parent) |
272 | : QWidget( parent ), | 272 | : QWidget( parent ), |
273 | mMonthView( parent ) | 273 | mMonthView( parent ) |
274 | { | 274 | { |
275 | 275 | ||
276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
277 | 277 | ||
278 | // mLabel = new QLabel( this );QPushButton | 278 | // mLabel = new QLabel( this );QPushButton |
279 | mLabel = new QPushButton( this ); | 279 | mLabel = new QPushButton( this ); |
280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
281 | //mLabel->setLineWidth( 1 ); | 281 | //mLabel->setLineWidth( 1 ); |
282 | //mLabel->setAlignment( AlignCenter ); | 282 | //mLabel->setAlignment( AlignCenter ); |
283 | mLabel->setFlat( true ); | 283 | mLabel->setFlat( true ); |
284 | mItemList = new KNoScrollListBox( this ); | 284 | mItemList = new KNoScrollListBox( this ); |
285 | mItemList->setMinimumSize( 10, 10 ); | 285 | mItemList->setMinimumSize( 10, 10 ); |
286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
287 | mItemList->setLineWidth( 1 ); | 287 | mItemList->setLineWidth( 1 ); |
288 | topLayout->addWidget( mItemList ); | 288 | topLayout->addWidget( mItemList ); |
289 | mLabel->raise(); | 289 | mLabel->raise(); |
290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
291 | mStandardPalette = palette(); | 291 | mStandardPalette = palette(); |
292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
293 | 293 | ||
294 | enableScrollBars( false ); | 294 | enableScrollBars( false ); |
295 | updateConfig(); | 295 | updateConfig(); |
296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
299 | SLOT( defaultAction( QListBoxItem * ) ) ); | 299 | SLOT( defaultAction( QListBoxItem * ) ) ); |
300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
301 | const QPoint &) ), | 301 | const QPoint &) ), |
302 | SLOT( contextMenu( QListBoxItem * ) ) ); | 302 | SLOT( contextMenu( QListBoxItem * ) ) ); |
303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
304 | SLOT( selection( QListBoxItem * ) ) ); | 304 | SLOT( selection( QListBoxItem * ) ) ); |
305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
306 | SLOT( cellClicked( QListBoxItem * ) ) ); | 306 | SLOT( cellClicked( QListBoxItem * ) ) ); |
307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
308 | SLOT( selection( QListBoxItem * ) ) ); | 308 | SLOT( selection( QListBoxItem * ) ) ); |
309 | } | 309 | } |
310 | #ifdef DESKTOP_VERSION | 310 | #ifdef DESKTOP_VERSION |
311 | QToolTipGroup *MonthViewCell::toolTipGroup() | 311 | QToolTipGroup *MonthViewCell::toolTipGroup() |
312 | { | 312 | { |
313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
314 | return mToolTipGroup; | 314 | return mToolTipGroup; |
315 | } | 315 | } |
316 | #endif | 316 | #endif |
317 | 317 | ||
318 | void MonthViewCell::setDate( const QDate &date ) | 318 | void MonthViewCell::setDate( const QDate &date ) |
319 | { | 319 | { |
320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
321 | mDate = date; | 321 | mDate = date; |
322 | 322 | ||
323 | 323 | ||
324 | 324 | ||
325 | //resizeEvent( 0 ); | 325 | //resizeEvent( 0 ); |
326 | } | 326 | } |
327 | 327 | ||
328 | QDate MonthViewCell::date() const | 328 | QDate MonthViewCell::date() const |
329 | { | 329 | { |
330 | return mDate; | 330 | return mDate; |
331 | } | 331 | } |
332 | 332 | ||
333 | void MonthViewCell::setPrimary( bool primary ) | 333 | void MonthViewCell::setPrimary( bool primary ) |
334 | { | 334 | { |
335 | mPrimary = primary; | 335 | mPrimary = primary; |
336 | //setMyPalette(); | 336 | //setMyPalette(); |
337 | } | 337 | } |
338 | void MonthViewCell::setMyPalette() | 338 | void MonthViewCell::setMyPalette() |
339 | { | 339 | { |
340 | 340 | ||
341 | if ( mHoliday) { | 341 | if ( mHoliday) { |
342 | setPalette( mHolidayPalette ); | 342 | setPalette( mHolidayPalette ); |
343 | } else { | 343 | } else { |
344 | if ( mPrimary ) { | 344 | if ( mPrimary ) { |
345 | setPalette( mPrimaryPalette ); | 345 | setPalette( mPrimaryPalette ); |
346 | } else { | 346 | } else { |
347 | setPalette( mNonPrimaryPalette ); | 347 | setPalette( mNonPrimaryPalette ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | QPalette pal = palette(); | 350 | QPalette pal = palette(); |
351 | 351 | ||
352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
353 | } | 353 | } |
354 | QPalette MonthViewCell::getPalette () | 354 | QPalette MonthViewCell::getPalette () |
355 | { | 355 | { |
356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
357 | return mStandardPalette; | 357 | return mStandardPalette; |
358 | if ( mHoliday) { | 358 | if ( mHoliday) { |
359 | return mHolidayPalette ; | 359 | return mHolidayPalette ; |
360 | } else { | 360 | } else { |
361 | if ( mPrimary ) { | 361 | if ( mPrimary ) { |
362 | return mPrimaryPalette ; | 362 | return mPrimaryPalette ; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | return mNonPrimaryPalette; | 365 | return mNonPrimaryPalette; |
366 | } | 366 | } |
367 | bool MonthViewCell::isPrimary() const | 367 | bool MonthViewCell::isPrimary() const |
368 | { | 368 | { |
369 | return mPrimary; | 369 | return mPrimary; |
370 | } | 370 | } |
371 | 371 | ||
372 | void MonthViewCell::setHoliday( bool holiday ) | 372 | void MonthViewCell::setHoliday( bool holiday ) |
373 | { | 373 | { |
374 | mHoliday = holiday; | 374 | mHoliday = holiday; |
375 | //setMyPalette(); | 375 | //setMyPalette(); |
376 | } | 376 | } |
377 | 377 | ||
378 | void MonthViewCell::setHoliday( const QString &holiday ) | 378 | void MonthViewCell::setHoliday( const QString &holiday ) |
379 | { | 379 | { |
380 | mHolidayString = holiday; | 380 | mHolidayString = holiday; |
381 | 381 | ||
382 | if ( !holiday.isEmpty() ) { | 382 | if ( !holiday.isEmpty() ) { |
383 | setHoliday( true ); | 383 | setHoliday( true ); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
387 | { | 387 | { |
388 | 388 | ||
389 | e->ignore(); | 389 | e->ignore(); |
390 | 390 | ||
391 | } | 391 | } |
392 | void MonthViewCell::clear() | 392 | void MonthViewCell::clear() |
393 | { | 393 | { |
394 | mItemList->clear(); | 394 | mItemList->clear(); |
395 | QApplication::removePostedEvents ( mItemList ); | 395 | QApplication::removePostedEvents ( mItemList ); |
396 | QApplication::removePostedEvents ( mLabel ); | 396 | QApplication::removePostedEvents ( mLabel ); |
397 | QApplication::removePostedEvents ( this ); | 397 | QApplication::removePostedEvents ( this ); |
398 | } | 398 | } |
399 | 399 | ||
400 | void MonthViewCell::startUpdateCell() | 400 | void MonthViewCell::startUpdateCell() |
401 | { | 401 | { |
402 | 402 | ||
403 | if ( !mMonthView->isUpdatePossible() ) | 403 | if ( !mMonthView->isUpdatePossible() ) |
404 | return; | 404 | return; |
405 | /* | 405 | /* |
406 | if ( !isVisible() ){ | 406 | if ( !isVisible() ){ |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | */ | 409 | */ |
410 | // qDebug("MonthViewCell::updateCell() "); | 410 | // qDebug("MonthViewCell::updateCell() "); |
411 | setPrimary( mDate.month()%2 ); | 411 | setPrimary( mDate.month()%2 ); |
412 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 412 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
413 | if ( mDate == QDate::currentDate() ) { | 413 | if ( mDate == QDate::currentDate() ) { |
414 | mItemList->setLineWidth( 3 ); | 414 | mItemList->setLineWidth( 3 ); |
415 | } else { | 415 | } else { |
416 | mItemList->setLineWidth( 1 ); | 416 | mItemList->setLineWidth( 1 ); |
417 | } | 417 | } |
418 | mItemList->clear(); | 418 | mItemList->clear(); |
419 | 419 | ||
420 | #ifdef DESKTOP_VERSION | 420 | #ifdef DESKTOP_VERSION |
421 | QToolTip::remove(this); | 421 | QToolTip::remove(this); |
422 | #endif | 422 | #endif |
423 | mToolTip = ""; | 423 | mToolTip = ""; |
424 | //qApp->processEvents(); | 424 | //qApp->processEvents(); |
425 | if ( !mHolidayString.isEmpty() ) { | 425 | if ( !mHolidayString.isEmpty() ) { |
426 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 426 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
427 | item->setPalette( mHolidayPalette ); | 427 | item->setPalette( mHolidayPalette ); |
428 | mItemList->insertItem( item ); | 428 | mItemList->insertItem( item ); |
429 | mToolTip += mHolidayString+"\n"; | 429 | mToolTip += mHolidayString+"\n"; |
430 | } | 430 | } |
431 | } | 431 | } |
432 | 432 | ||
433 | void MonthViewCell::insertEvent(Event *event) | 433 | void MonthViewCell::insertEvent(Event *event) |
434 | { | 434 | { |
435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
437 | return; | 437 | return; |
438 | else | 438 | else |
439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | 442 | ||
443 | if ( event->categories().contains("Holiday") || | 443 | if ( event->categories().contains("Holiday") || |
444 | event->categories().contains(i18n("Holiday"))) { | 444 | event->categories().contains(i18n("Holiday"))) { |
445 | setHoliday( true ); | 445 | setHoliday( true ); |
446 | if ( mDate.dayOfWeek() == 7 ) | 446 | if ( mDate.dayOfWeek() == 7 ) |
447 | mItemList->setLineWidth( 3 ); | 447 | mItemList->setLineWidth( 3 ); |
448 | } | 448 | } |
449 | QString text; | 449 | QString text; |
450 | if (event->isMultiDay()) { | 450 | if (event->isMultiDay()) { |
451 | QString prefix = "<->"; | 451 | QString prefix = "<->"; |
452 | if ( event->doesRecur() ) { | 452 | if ( event->doesRecur() ) { |
453 | if ( event->recursOn( mDate) ) | 453 | if ( event->recursOn( mDate) ) |
454 | prefix ="->" ; | 454 | prefix ="->" ; |
455 | else { | 455 | else { |
456 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 456 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
457 | if ( event->recursOn( mDate.addDays( -days)) ) | 457 | if ( event->recursOn( mDate.addDays( -days)) ) |
458 | prefix ="<-" ; | 458 | prefix ="<-" ; |
459 | } | 459 | } |
460 | 460 | ||
461 | } else { | 461 | } else { |
462 | if (mDate == event->dtStart().date()) { | 462 | if (mDate == event->dtStart().date()) { |
463 | prefix ="->" ; | 463 | prefix ="->" ; |
464 | } else if (mDate == event->dtEnd().date()) { | 464 | } else if (mDate == event->dtEnd().date()) { |
465 | prefix ="<-" ; | 465 | prefix ="<-" ; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | if ( !event->doesFloat() ) { | ||
469 | if ( mDate == event->dtStart().date () ) | ||
470 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; | ||
471 | else if ( mDate == event->dtEnd().date () ) | ||
472 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | ||
473 | |||
474 | } | ||
468 | text = prefix + event->summary(); | 475 | text = prefix + event->summary(); |
469 | mToolTip += text; | 476 | mToolTip += text; |
470 | } else { | 477 | } else { |
471 | if (event->doesFloat()) { | 478 | if (event->doesFloat()) { |
472 | text = event->summary(); | 479 | text = event->summary(); |
473 | mToolTip += text; | 480 | mToolTip += text; |
474 | } | 481 | } |
475 | else { | 482 | else { |
476 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 483 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
477 | text += " " + event->summary(); | 484 | text += " " + event->summary(); |
478 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 485 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
479 | } | 486 | } |
480 | } | 487 | } |
481 | 488 | ||
482 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 489 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
483 | QPalette pal; | 490 | QPalette pal; |
484 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 491 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
485 | QStringList categories = event->categories(); | 492 | QStringList categories = event->categories(); |
486 | QString cat = categories.first(); | 493 | QString cat = categories.first(); |
487 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 494 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
488 | pal = getPalette(); | 495 | pal = getPalette(); |
489 | if (cat.isEmpty()) { | 496 | if (cat.isEmpty()) { |
490 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 497 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
491 | } else { | 498 | } else { |
492 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 499 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
493 | } | 500 | } |
494 | 501 | ||
495 | } else { | 502 | } else { |
496 | if (cat.isEmpty()) { | 503 | if (cat.isEmpty()) { |
497 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 504 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
498 | } else { | 505 | } else { |
499 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 506 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
500 | } | 507 | } |
501 | } | 508 | } |
502 | 509 | ||
503 | } else { | 510 | } else { |
504 | pal = mStandardPalette ; | 511 | pal = mStandardPalette ; |
505 | } | 512 | } |
506 | item->setPalette( pal ); | 513 | item->setPalette( pal ); |
507 | item->setRecur( event->recurrence()->doesRecur() ); | 514 | item->setRecur( event->recurrence()->doesRecur() ); |
508 | item->setAlarm( event->isAlarmEnabled() ); | 515 | item->setAlarm( event->isAlarmEnabled() ); |
509 | item->setMoreInfo( event->description().length() > 0 ); | 516 | item->setMoreInfo( event->description().length() > 0 ); |
510 | #ifdef DESKTOP_VERSION | 517 | #ifdef DESKTOP_VERSION |
511 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 518 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
512 | KOPrefs::instance()->email()); | 519 | KOPrefs::instance()->email()); |
513 | if ( me != 0 ) { | 520 | if ( me != 0 ) { |
514 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 521 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
515 | item->setReply(true); | 522 | item->setReply(true); |
516 | else | 523 | else |
517 | item->setReply(false); | 524 | item->setReply(false); |
518 | } else | 525 | } else |
519 | item->setReply(false); | 526 | item->setReply(false); |
520 | #endif | 527 | #endif |
521 | mItemList->insertItem( item ); | 528 | mItemList->insertItem( item ); |
522 | mToolTip += "\n"; | 529 | mToolTip += "\n"; |
523 | } | 530 | } |
524 | void MonthViewCell::insertTodo(Todo *todo) | 531 | void MonthViewCell::insertTodo(Todo *todo) |
525 | { | 532 | { |
526 | QString text; | 533 | QString text; |
527 | if (todo->hasDueDate()) { | 534 | if (todo->hasDueDate()) { |
528 | if (!todo->doesFloat()) { | 535 | if (!todo->doesFloat()) { |
529 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 536 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
530 | text += " "; | 537 | text += " "; |
531 | } | 538 | } |
532 | } | 539 | } |
533 | text += i18n("To-Do: %1").arg(todo->summary()); | 540 | text += i18n("To-Do: %1").arg(todo->summary()); |
534 | 541 | ||
535 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 542 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
536 | //item->setPalette( mStandardPalette ); | 543 | //item->setPalette( mStandardPalette ); |
537 | QPalette pal; | 544 | QPalette pal; |
538 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 545 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
539 | QStringList categories = todo->categories(); | 546 | QStringList categories = todo->categories(); |
540 | QString cat = categories.first(); | 547 | QString cat = categories.first(); |
541 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 548 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
542 | pal = getPalette(); | 549 | pal = getPalette(); |
543 | if (cat.isEmpty()) { | 550 | if (cat.isEmpty()) { |
544 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 551 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
545 | } else { | 552 | } else { |
546 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 553 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
547 | } | 554 | } |
548 | 555 | ||
549 | } else { | 556 | } else { |
550 | if (cat.isEmpty()) { | 557 | if (cat.isEmpty()) { |
551 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 558 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
552 | } else { | 559 | } else { |
553 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 560 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
554 | } | 561 | } |
555 | } | 562 | } |
556 | 563 | ||
557 | } else { | 564 | } else { |
558 | pal = mStandardPalette ; | 565 | pal = mStandardPalette ; |
559 | } | 566 | } |
560 | item->setPalette( pal ); | 567 | item->setPalette( pal ); |
561 | mItemList->insertItem( item ); | 568 | mItemList->insertItem( item ); |
562 | mToolTip += text+"\n"; | 569 | mToolTip += text+"\n"; |
563 | } | 570 | } |
564 | void MonthViewCell::finishUpdateCell() | 571 | void MonthViewCell::finishUpdateCell() |
565 | { | 572 | { |
566 | #ifdef DESKTOP_VERSION | 573 | #ifdef DESKTOP_VERSION |
567 | if (mToolTip != "") | 574 | if (mToolTip != "") |
568 | QToolTip::add(this,mToolTip,toolTipGroup(),""); | 575 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
569 | #endif | 576 | #endif |
570 | 577 | mItemList->sort(); | |
571 | //setMyPalette(); | 578 | //setMyPalette(); |
572 | setMyPalette(); | 579 | setMyPalette(); |
573 | QString text; | 580 | QString text; |
574 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 581 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
575 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 582 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
576 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 583 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
577 | mLabel->resize( mLabelBigSize ); | 584 | mLabel->resize( mLabelBigSize ); |
578 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 585 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
579 | } else { | 586 | } else { |
580 | mLabel->resize( mLabelSize ); | 587 | mLabel->resize( mLabelSize ); |
581 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 588 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
582 | } | 589 | } |
583 | 590 | ||
584 | mLabel->setText( text ); | 591 | mLabel->setText( text ); |
585 | resizeEvent( 0 ); | 592 | resizeEvent( 0 ); |
586 | } | 593 | } |
587 | void MonthViewCell::updateCell() | 594 | void MonthViewCell::updateCell() |
588 | { | 595 | { |
589 | if ( !mMonthView->isUpdatePossible() ) | 596 | if ( !mMonthView->isUpdatePossible() ) |
590 | return; | 597 | return; |
591 | startUpdateCell(); | 598 | startUpdateCell(); |
592 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 599 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
593 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 600 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
594 | Event *event; | 601 | Event *event; |
595 | for( event = events.first(); event; event = events.next() ) { // for event | 602 | for( event = events.first(); event; event = events.next() ) { // for event |
596 | insertEvent(event); | 603 | insertEvent(event); |
597 | } | 604 | } |
598 | // insert due todos | 605 | // insert due todos |
599 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 606 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
600 | Todo *todo; | 607 | Todo *todo; |
601 | for(todo = todos.first(); todo; todo = todos.next()) { | 608 | for(todo = todos.first(); todo; todo = todos.next()) { |
602 | insertTodo( todo ); | 609 | insertTodo( todo ); |
603 | } | 610 | } |
604 | finishUpdateCell(); | 611 | finishUpdateCell(); |
605 | // if ( isVisible()) | 612 | // if ( isVisible()) |
606 | //qApp->processEvents(); | 613 | //qApp->processEvents(); |
607 | } | 614 | } |
608 | 615 | ||
609 | void MonthViewCell::updateConfig() | 616 | void MonthViewCell::updateConfig() |
610 | { | 617 | { |
611 | setFont( KOPrefs::instance()->mMonthViewFont ); | 618 | setFont( KOPrefs::instance()->mMonthViewFont ); |
612 | 619 | ||
613 | QFontMetrics fm( font() ); | 620 | QFontMetrics fm( font() ); |
614 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 621 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
615 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 622 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
616 | mHolidayPalette = mStandardPalette; | 623 | mHolidayPalette = mStandardPalette; |
617 | mPrimaryPalette = mStandardPalette; | 624 | mPrimaryPalette = mStandardPalette; |
618 | mNonPrimaryPalette = mStandardPalette; | 625 | mNonPrimaryPalette = mStandardPalette; |
619 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 626 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
620 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 627 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
621 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 628 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
622 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 629 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
623 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 630 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
624 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 631 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
625 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 632 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
626 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 633 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
627 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 634 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
628 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 635 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
629 | } | 636 | } |
630 | //updateCell(); | 637 | //updateCell(); |
631 | } | 638 | } |
632 | 639 | ||
633 | void MonthViewCell::enableScrollBars( bool enabled ) | 640 | void MonthViewCell::enableScrollBars( bool enabled ) |
634 | { | 641 | { |
635 | if ( enabled ) { | 642 | if ( enabled ) { |
636 | mItemList->setVScrollBarMode(QScrollView::Auto); | 643 | mItemList->setVScrollBarMode(QScrollView::Auto); |
637 | mItemList->setHScrollBarMode(QScrollView::Auto); | 644 | mItemList->setHScrollBarMode(QScrollView::Auto); |
638 | } else { | 645 | } else { |
639 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 646 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
640 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 647 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
641 | } | 648 | } |
642 | } | 649 | } |
643 | 650 | ||
644 | Incidence *MonthViewCell::selectedIncidence() | 651 | Incidence *MonthViewCell::selectedIncidence() |
645 | { | 652 | { |
646 | int index = mItemList->currentItem(); | 653 | int index = mItemList->currentItem(); |
647 | if ( index < 0 ) return 0; | 654 | if ( index < 0 ) return 0; |
648 | 655 | ||
649 | MonthViewItem *item = | 656 | MonthViewItem *item = |
650 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 657 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
651 | 658 | ||
652 | if ( !item ) return 0; | 659 | if ( !item ) return 0; |
653 | 660 | ||
654 | return item->incidence(); | 661 | return item->incidence(); |
655 | } | 662 | } |
656 | 663 | ||
657 | QDate MonthViewCell::selectedIncidenceDate() | 664 | QDate MonthViewCell::selectedIncidenceDate() |
658 | { | 665 | { |
659 | QDate qd; | 666 | QDate qd; |
660 | int index = mItemList->currentItem(); | 667 | int index = mItemList->currentItem(); |
661 | if ( index < 0 ) return qd; | 668 | if ( index < 0 ) return qd; |
662 | 669 | ||
663 | MonthViewItem *item = | 670 | MonthViewItem *item = |
664 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 671 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
665 | 672 | ||
666 | if ( !item ) return qd; | 673 | if ( !item ) return qd; |
667 | 674 | ||
668 | return item->incidenceDate(); | 675 | return item->incidenceDate(); |
669 | } | 676 | } |
670 | 677 | ||
671 | void MonthViewCell::deselect() | 678 | void MonthViewCell::deselect() |
672 | { | 679 | { |
673 | mItemList->clearSelection(); | 680 | mItemList->clearSelection(); |
674 | enableScrollBars( false ); | 681 | enableScrollBars( false ); |
675 | // updateCell(); | 682 | // updateCell(); |
676 | } | 683 | } |
677 | void MonthViewCell::select() | 684 | void MonthViewCell::select() |
678 | { | 685 | { |
679 | ;// updateCell(); | 686 | ;// updateCell(); |
680 | } | 687 | } |
681 | 688 | ||
682 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 689 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
683 | { | 690 | { |
684 | if ( !mMonthView->isUpdatePossible() ) | 691 | if ( !mMonthView->isUpdatePossible() ) |
685 | return; | 692 | return; |
686 | #ifndef DESKTOP_VERSION | 693 | #ifndef DESKTOP_VERSION |
687 | if ( !isVisible() ){ | 694 | if ( !isVisible() ){ |
688 | return; | 695 | return; |
689 | } | 696 | } |
690 | #endif | 697 | #endif |
691 | int size = height() - mLabel->height(); | 698 | int size = height() - mLabel->height() - 2; |
692 | if ( size > 0 ) | 699 | if ( size > 0 ) |
693 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 700 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
694 | size = width() - mLabel->width(); | 701 | size = width() - mLabel->width() -2; |
695 | if ( size > 0 ) | 702 | if ( size > 0 ) |
696 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 703 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
697 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 704 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
698 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 705 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
699 | } | 706 | } |
700 | 707 | ||
701 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 708 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
702 | { | 709 | { |
703 | if ( !item ) return; | 710 | if ( !item ) return; |
704 | 711 | ||
705 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 712 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
706 | Incidence *incidence = eventItem->incidence(); | 713 | Incidence *incidence = eventItem->incidence(); |
707 | if ( incidence ) mMonthView->defaultAction( incidence ); | 714 | if ( incidence ) mMonthView->defaultAction( incidence ); |
708 | } | 715 | } |
709 | void MonthViewCell::showDay() | 716 | void MonthViewCell::showDay() |
710 | { | 717 | { |
711 | emit showDaySignal( date() ); | 718 | emit showDaySignal( date() ); |
712 | } | 719 | } |
713 | void MonthViewCell::newEvent() | 720 | void MonthViewCell::newEvent() |
714 | { | 721 | { |
715 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 722 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
716 | emit newEventSignal( dt ); | 723 | emit newEventSignal( dt ); |
717 | } | 724 | } |
718 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 725 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
719 | { | 726 | { |
720 | static QListBoxItem * lastClicked = 0; | 727 | static QListBoxItem * lastClicked = 0; |
721 | if ( item == 0 ) { | 728 | if ( item == 0 ) { |
722 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 729 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
723 | emit newEventSignal( dt ); | 730 | emit newEventSignal( dt ); |
724 | return; | 731 | return; |
725 | } | 732 | } |
726 | /* | 733 | /* |
727 | if ( lastClicked ) | 734 | if ( lastClicked ) |
728 | if ( ! item ) { | 735 | if ( ! item ) { |
729 | if ( lastClicked->listBox() != item->listBox() ) | 736 | if ( lastClicked->listBox() != item->listBox() ) |
730 | lastClicked->listBox()->clearSelection(); | 737 | lastClicked->listBox()->clearSelection(); |
731 | } | 738 | } |
732 | */ | 739 | */ |
733 | 740 | ||
734 | mMonthView->setSelectedCell( this ); | 741 | mMonthView->setSelectedCell( this ); |
735 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); | 742 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
736 | select(); | 743 | select(); |
737 | } | 744 | } |
738 | 745 | ||
739 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 746 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
740 | { | 747 | { |
741 | if ( !item ) return; | 748 | if ( !item ) return; |
742 | 749 | ||
743 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 750 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
744 | Incidence *incidence = eventItem->incidence(); | 751 | Incidence *incidence = eventItem->incidence(); |
745 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 752 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
746 | } | 753 | } |
747 | 754 | ||
748 | void MonthViewCell::selection( QListBoxItem *item ) | 755 | void MonthViewCell::selection( QListBoxItem *item ) |
749 | { | 756 | { |
750 | if ( !item ) return; | 757 | if ( !item ) return; |
751 | 758 | ||
752 | mMonthView->setSelectedCell( this ); | 759 | mMonthView->setSelectedCell( this ); |
753 | } | 760 | } |
754 | 761 | ||
755 | 762 | ||
756 | // ******************************************************************************* | 763 | // ******************************************************************************* |
757 | // ******************************************************************************* | 764 | // ******************************************************************************* |
758 | // ******************************************************************************* | 765 | // ******************************************************************************* |
759 | 766 | ||
760 | 767 | ||
761 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 768 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
762 | : KOEventView( calendar, parent, name ), | 769 | : KOEventView( calendar, parent, name ), |
763 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 770 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
764 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 771 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
765 | { | 772 | { |
766 | 773 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | |
774 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | ||
775 | if ( mShowWeekView ) | ||
776 | mWeekStartsMonday = true; | ||
767 | updatePossible = false; | 777 | updatePossible = false; |
768 | mCells.setAutoDelete( true ); | 778 | mCells.setAutoDelete( true ); |
769 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 779 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
770 | // mDayLayout = new QGridLayout( this ); | 780 | // mDayLayout = new QGridLayout( this ); |
771 | // create the day of the week labels (Sun, Mon, etc) and add them to | 781 | // create the day of the week labels (Sun, Mon, etc) and add them to |
772 | // the layout. | 782 | // the layout. |
773 | mDayLabels.resize( mDaysPerWeek ); | 783 | mDayLabels.resize( mDaysPerWeek ); |
774 | QFont bfont = font(); | 784 | QFont bfont = font(); |
775 | if ( QApplication::desktop()->width() < 650 ) { | 785 | if ( QApplication::desktop()->width() < 650 ) { |
776 | bfont.setPointSize( bfont.pointSize() - 2 ); | 786 | bfont.setPointSize( bfont.pointSize() - 2 ); |
777 | } | 787 | } |
778 | bfont.setBold( true ); | 788 | bfont.setBold( true ); |
779 | int i; | 789 | int i; |
780 | 790 | ||
781 | for( i = 0; i < mDaysPerWeek; i++ ) { | 791 | for( i = 0; i < mDaysPerWeek; i++ ) { |
782 | QLabel *label = new QLabel( this ); | 792 | QLabel *label = new QLabel( this ); |
783 | label->setFont(bfont); | 793 | label->setFont(bfont); |
784 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 794 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
785 | label->setLineWidth(1); | 795 | label->setLineWidth(1); |
786 | label->setAlignment(AlignCenter); | 796 | label->setAlignment(AlignCenter); |
787 | mDayLabels.insert( i, label ); | 797 | mDayLabels.insert( i, label ); |
788 | } | 798 | } |
789 | 799 | ||
790 | bfont.setBold( false ); | 800 | bfont.setBold( false ); |
791 | mWeekLabels.resize( mNumWeeks+1 ); | 801 | mWeekLabels.resize( mNumWeeks+1 ); |
792 | for( i = 0; i < mNumWeeks+1; i++ ) { | 802 | for( i = 0; i < mNumWeeks+1; i++ ) { |
793 | KOWeekButton *label = new KOWeekButton( this ); | 803 | KOWeekButton *label = new KOWeekButton( this ); |
794 | label->setFont(bfont); | 804 | label->setFont(bfont); |
795 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | 805 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); |
796 | label->setFlat(true); | 806 | label->setFlat(true); |
797 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | 807 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); |
798 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 808 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
799 | //label->setLineWidth(1); | 809 | //label->setLineWidth(1); |
800 | //label->setAlignment(AlignCenter); | 810 | //label->setAlignment(AlignCenter); |
801 | mWeekLabels.insert( i, label ); | 811 | mWeekLabels.insert( i, label ); |
802 | } | 812 | } |
803 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 813 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
804 | int row, col; | 814 | int row, col; |
805 | mCells.resize( mNumCells ); | 815 | mCells.resize( mNumCells ); |
806 | for( row = 0; row < mNumWeeks; ++row ) { | 816 | for( row = 0; row < mNumWeeks; ++row ) { |
807 | for( col = 0; col < mDaysPerWeek; ++col ) { | 817 | for( col = 0; col < mDaysPerWeek; ++col ) { |
808 | MonthViewCell *cell = new MonthViewCell( this ); | 818 | MonthViewCell *cell = new MonthViewCell( this ); |
809 | mCells.insert( row * mDaysPerWeek + col, cell ); | 819 | mCells.insert( row * mDaysPerWeek + col, cell ); |
810 | 820 | ||
811 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 821 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
812 | SLOT( defaultAction( Incidence * ) ) ); | 822 | SLOT( defaultAction( Incidence * ) ) ); |
813 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 823 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
814 | SIGNAL( newEventSignal( QDateTime ) ) ); | 824 | SIGNAL( newEventSignal( QDateTime ) ) ); |
815 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 825 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
816 | SIGNAL( showDaySignal( QDate ) ) ); | 826 | SIGNAL( showDaySignal( QDate ) ) ); |
817 | } | 827 | } |
818 | } | 828 | } |
819 | 829 | ||
830 | connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), | ||
831 | SLOT( switchView() ) ); | ||
820 | mContextMenu = eventPopup(); | 832 | mContextMenu = eventPopup(); |
821 | // updateConfig(); //useless here | 833 | // updateConfig(); //useless here |
822 | 834 | ||
823 | emit incidenceSelected( 0 ); | 835 | emit incidenceSelected( 0 ); |
824 | } | 836 | } |
825 | 837 | ||
826 | KOMonthView::~KOMonthView() | 838 | KOMonthView::~KOMonthView() |
827 | { | 839 | { |
828 | delete mContextMenu; | 840 | delete mContextMenu; |
829 | } | 841 | } |
842 | void KOMonthView::switchView() | ||
843 | { | ||
844 | mShowWeekView = !mShowWeekView; | ||
845 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | ||
846 | emit showNavigator( !mShowWeekView ); | ||
847 | computeLayout(); | ||
848 | updateConfig(); | ||
849 | } | ||
830 | 850 | ||
831 | int KOMonthView::maxDatesHint() | 851 | int KOMonthView::maxDatesHint() |
832 | { | 852 | { |
833 | return mNumCells; | 853 | return mNumCells; |
834 | } | 854 | } |
835 | 855 | ||
836 | int KOMonthView::currentDateCount() | 856 | int KOMonthView::currentDateCount() |
837 | { | 857 | { |
838 | return mNumCells; | 858 | return mNumCells; |
839 | } | 859 | } |
840 | 860 | ||
841 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 861 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
842 | { | 862 | { |
843 | QPtrList<Incidence> selected; | 863 | QPtrList<Incidence> selected; |
844 | 864 | ||
845 | if ( mSelectedCell ) { | 865 | if ( mSelectedCell ) { |
846 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 866 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
847 | if ( incidence ) selected.append( incidence ); | 867 | if ( incidence ) selected.append( incidence ); |
848 | } | 868 | } |
849 | 869 | ||
850 | return selected; | 870 | return selected; |
851 | } | 871 | } |
852 | 872 | ||
853 | DateList KOMonthView::selectedDates() | 873 | DateList KOMonthView::selectedDates() |
854 | { | 874 | { |
855 | DateList selected; | 875 | DateList selected; |
856 | 876 | ||
857 | if ( mSelectedCell ) { | 877 | if ( mSelectedCell ) { |
858 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 878 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
859 | if ( qd.isValid() ) selected.append( qd ); | 879 | if ( qd.isValid() ) selected.append( qd ); |
860 | } | 880 | } |
861 | 881 | ||
862 | return selected; | 882 | return selected; |
863 | } | 883 | } |
864 | 884 | ||
865 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 885 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
866 | const QDate &td) | 886 | const QDate &td) |
867 | { | 887 | { |
868 | #ifndef KORG_NOPRINTER | 888 | #ifndef KORG_NOPRINTER |
869 | calPrinter->preview(CalPrinter::Month, fd, td); | 889 | calPrinter->preview(CalPrinter::Month, fd, td); |
870 | #endif | 890 | #endif |
871 | } | 891 | } |
872 | 892 | ||
873 | void KOMonthView::updateConfig() | 893 | void KOMonthView::updateConfig() |
874 | { | 894 | { |
875 | 895 | ||
876 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 896 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
877 | 897 | ||
898 | if ( mShowWeekView ) | ||
899 | mWeekStartsMonday = true; | ||
878 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 900 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
879 | mWidthLongDayLabel = 0; | 901 | mWidthLongDayLabel = 0; |
880 | 902 | ||
881 | for (int i = 0; i < 7; i++) { | 903 | for (int i = 0; i < 7; i++) { |
882 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 904 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
883 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 905 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
884 | } | 906 | } |
885 | bool temp = mShowSatSunComp ; | 907 | bool temp = mShowSatSunComp ; |
886 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 908 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
887 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 909 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
888 | computeLayout(); | 910 | computeLayout(); |
889 | updateDayLabels(); | 911 | updateDayLabels(); |
890 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 912 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
891 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 913 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
892 | //resizeEvent( 0 ); | 914 | //resizeEvent( 0 ); |
893 | for (uint i = 0; i < mCells.count(); ++i) { | 915 | for (uint i = 0; i < mCells.count(); ++i) { |
894 | mCells[i]->updateConfig(); | 916 | mCells[i]->updateConfig(); |
895 | } | 917 | } |
896 | #ifdef DESKTOP_VERSION | 918 | #ifdef DESKTOP_VERSION |
897 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 919 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
898 | #endif | 920 | #endif |
899 | updateView(); | 921 | updateView(); |
900 | } | 922 | } |
901 | 923 | ||
902 | void KOMonthView::updateDayLabels() | 924 | void KOMonthView::updateDayLabels() |
903 | { | 925 | { |
904 | 926 | ||
905 | for (int i = 0; i < 7; i++) { | 927 | for (int i = 0; i < 7; i++) { |
906 | if (mWeekStartsMonday) { | 928 | if (mWeekStartsMonday) { |
907 | bool show = mShortDayLabels; | 929 | bool show = mShortDayLabels; |
908 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 930 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
909 | show = true; | 931 | show = true; |
910 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 932 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
911 | } else { | 933 | } else { |
912 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 934 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
913 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 935 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
914 | 936 | ||
915 | } | 937 | } |
916 | } | 938 | } |
917 | } | 939 | } |
918 | 940 | ||
919 | void KOMonthView::showDates(const QDate &start, const QDate &) | 941 | void KOMonthView::showDates(const QDate &start, const QDate &) |
920 | { | 942 | { |
921 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 943 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
922 | 944 | ||
923 | 945 | ||
924 | mStartDate = start; | 946 | mStartDate = start; |
925 | 947 | ||
926 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 948 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
927 | 949 | ||
928 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 950 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
929 | mStartDate = mStartDate.addDays( -1 ); | 951 | mStartDate = mStartDate.addDays( -1 ); |
930 | } | 952 | } |
931 | 953 | ||
932 | bool primary = false; | 954 | bool primary = false; |
933 | uint i; | 955 | uint i; |
934 | for( i = 0; i < mCells.size(); ++i ) { | 956 | for( i = 0; i < mCells.size(); ++i ) { |
935 | QDate date = mStartDate.addDays( i ); | 957 | QDate date = mStartDate.addDays( i ); |
936 | mCells[i]->setDate( date ); | 958 | mCells[i]->setDate( date ); |
937 | 959 | ||
938 | #ifndef KORG_NOPLUGINS | 960 | #ifndef KORG_NOPLUGINS |
939 | // add holiday, if present | 961 | // add holiday, if present |
940 | QString hstring(KOCore::self()->holiday(date)); | 962 | QString hstring(KOCore::self()->holiday(date)); |
941 | mCells[i]->setHoliday( hstring ); | 963 | mCells[i]->setHoliday( hstring ); |
942 | #endif | 964 | #endif |
943 | 965 | ||
944 | } | 966 | } |
945 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 967 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
946 | for( i = 0; i < 6; ++i ) { | 968 | for( i = 0; i < 6; ++i ) { |
947 | int wno; | 969 | int wno; |
948 | // remember, according to ISO 8601, the first week of the year is the | 970 | // remember, according to ISO 8601, the first week of the year is the |
949 | // first week that contains a thursday. Thus we must subtract off 4, | 971 | // first week that contains a thursday. Thus we must subtract off 4, |
950 | // not just 1. | 972 | // not just 1. |
951 | int dayOfYear = date.dayOfYear(); | 973 | int dayOfYear = date.dayOfYear(); |
952 | if (dayOfYear % 7 != 0) | 974 | if (dayOfYear % 7 != 0) |
953 | wno = dayOfYear / 7 + 1; | 975 | wno = dayOfYear / 7 + 1; |
954 | else | 976 | else |
955 | wno =dayOfYear / 7; | 977 | wno =dayOfYear / 7; |
956 | mWeekLabels[i]->setWeekNum( wno ); | 978 | mWeekLabels[i]->setWeekNum( wno ); |
957 | date = date.addDays( 7 ); | 979 | date = date.addDays( 7 ); |
958 | } | 980 | } |
959 | updateView(); | 981 | updateView(); |
960 | } | 982 | } |
961 | 983 | ||
962 | void KOMonthView::showEvents(QPtrList<Event>) | 984 | void KOMonthView::showEvents(QPtrList<Event>) |
963 | { | 985 | { |
964 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 986 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
965 | } | 987 | } |
966 | 988 | ||
967 | void KOMonthView::changeEventDisplay(Event *, int) | 989 | void KOMonthView::changeEventDisplay(Event *, int) |
968 | { | 990 | { |
969 | // this should be re-written to be much more efficient, but this | 991 | // this should be re-written to be much more efficient, but this |
970 | // quick-and-dirty-hack gets the job done for right now. | 992 | // quick-and-dirty-hack gets the job done for right now. |
971 | updateView(); | 993 | updateView(); |
972 | } | 994 | } |
973 | 995 | ||
974 | void KOMonthView::updateView() | 996 | void KOMonthView::updateView() |
975 | { | 997 | { |
976 | 998 | ||
977 | if ( !updatePossible ) | 999 | if ( !updatePossible ) |
978 | return; | 1000 | return; |
979 | //QTime ti; | 1001 | //QTime ti; |
980 | //ti.start(); | 1002 | //ti.start(); |
981 | #if 1 | 1003 | #if 1 |
982 | int i; | 1004 | int i; |
983 | for( i = 0; i < mCells.count(); ++i ) { | 1005 | int timeSpan = mCells.size()-1; |
1006 | if ( KOPrefs::instance()->mMonthViewWeek ) | ||
1007 | timeSpan = 6; | ||
1008 | for( i = 0; i < timeSpan + 1; ++i ) { | ||
984 | mCells[i]->startUpdateCell(); | 1009 | mCells[i]->startUpdateCell(); |
985 | } | 1010 | } |
986 | 1011 | ||
987 | QPtrList<Event> events = calendar()->events(); | 1012 | QPtrList<Event> events = calendar()->events(); |
988 | Event *event; | 1013 | Event *event; |
989 | QDateTime dt; | 1014 | QDateTime dt; |
990 | bool ok; | 1015 | bool ok; |
991 | int timeSpan = mCells.size()-1; | ||
992 | QDate endDate = mStartDate.addDays( timeSpan ); | 1016 | QDate endDate = mStartDate.addDays( timeSpan ); |
993 | for( event = events.first(); event; event = events.next() ) { // for event | 1017 | for( event = events.first(); event; event = events.next() ) { // for event |
994 | if ( event->doesRecur() ) { | 1018 | if ( event->doesRecur() ) { |
995 | bool last; | 1019 | bool last; |
996 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1020 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
997 | QDateTime incidenceEnd; | 1021 | QDateTime incidenceEnd; |
998 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1022 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
999 | bool invalid = false; | 1023 | bool invalid = false; |
1000 | while( true ) { | 1024 | while( true ) { |
1001 | if ( incidenceStart.isValid() ) { | 1025 | if ( incidenceStart.isValid() ) { |
1002 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1026 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1003 | int st = incidenceStart.date().daysTo( endDate ); | 1027 | int st = incidenceStart.date().daysTo( endDate ); |
1004 | if ( st >= 0 ) { // start before timeend | 1028 | if ( st >= 0 ) { // start before timeend |
1005 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1029 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1006 | if ( end >= 0 ) { // end after timestart --- got one! | 1030 | if ( end >= 0 ) { // end after timestart --- got one! |
1007 | //normalize | 1031 | //normalize |
1008 | st = timeSpan - st; | 1032 | st = timeSpan - st; |
1009 | if ( st < 0 ) st = 0; | 1033 | if ( st < 0 ) st = 0; |
1010 | if ( end > timeSpan ) end = timeSpan; | 1034 | if ( end > timeSpan ) end = timeSpan; |
1011 | int iii; | 1035 | int iii; |
1012 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1036 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1013 | for ( iii = st;iii<= end;++iii) | 1037 | for ( iii = st;iii<= end;++iii) |
1014 | mCells[iii]->insertEvent( event ); | 1038 | mCells[iii]->insertEvent( event ); |
1015 | } | 1039 | } |
1016 | } | 1040 | } |
1017 | } else { | 1041 | } else { |
1018 | if ( invalid ) | 1042 | if ( invalid ) |
1019 | break; | 1043 | break; |
1020 | invalid = true; | 1044 | invalid = true; |
1021 | //qDebug("invalid %s", event->summary().latin1()); | 1045 | //qDebug("invalid %s", event->summary().latin1()); |
1022 | incidenceStart = QDateTime( mStartDate ); | 1046 | incidenceStart = QDateTime( mStartDate ); |
1023 | } | 1047 | } |
1024 | if ( last ) | 1048 | if ( last ) |
1025 | break; | 1049 | break; |
1026 | bool ok; | 1050 | bool ok; |
1027 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1051 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1028 | if ( ! ok ) | 1052 | if ( ! ok ) |
1029 | break; | 1053 | break; |
1030 | if ( incidenceStart.date() > endDate ) | 1054 | if ( incidenceStart.date() > endDate ) |
1031 | break; | 1055 | break; |
1032 | } | 1056 | } |
1033 | } else { // no recur | 1057 | } else { // no recur |
1034 | int st = event->dtStart().date().daysTo( endDate ); | 1058 | int st = event->dtStart().date().daysTo( endDate ); |
1035 | if ( st >= 0 ) { // start before timeend | 1059 | if ( st >= 0 ) { // start before timeend |
1036 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1060 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1037 | if ( end >= 0 ) { // end after timestart --- got one! | 1061 | if ( end >= 0 ) { // end after timestart --- got one! |
1038 | //normalize | 1062 | //normalize |
1039 | st = timeSpan - st; | 1063 | st = timeSpan - st; |
1040 | if ( st < 0 ) st = 0; | 1064 | if ( st < 0 ) st = 0; |
1041 | if ( end > timeSpan ) end = timeSpan; | 1065 | if ( end > timeSpan ) end = timeSpan; |
1042 | int iii; | 1066 | int iii; |
1043 | for ( iii = st;iii<= end;++iii) | 1067 | for ( iii = st;iii<= end;++iii) |
1044 | mCells[iii]->insertEvent( event ); | 1068 | mCells[iii]->insertEvent( event ); |
1045 | } | 1069 | } |
1046 | } | 1070 | } |
1047 | } | 1071 | } |
1048 | } | 1072 | } |
1049 | // insert due todos | 1073 | // insert due todos |
1050 | QPtrList<Todo> todos = calendar()->todos( ); | 1074 | QPtrList<Todo> todos = calendar()->todos( ); |
1051 | Todo *todo; | 1075 | Todo *todo; |
1052 | for(todo = todos.first(); todo; todo = todos.next()) { | 1076 | for(todo = todos.first(); todo; todo = todos.next()) { |
1053 | //insertTodo( todo ); | 1077 | //insertTodo( todo ); |
1054 | if ( todo->hasDueDate() ) { | 1078 | if ( todo->hasDueDate() ) { |
1055 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1079 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1056 | if ( day >= 0 && day < mCells.size() ) { | 1080 | if ( day >= 0 && day < timeSpan + 1) { |
1057 | mCells[day]->insertTodo( todo ); | 1081 | mCells[day]->insertTodo( todo ); |
1058 | } | 1082 | } |
1059 | } | 1083 | } |
1060 | } | 1084 | } |
1061 | 1085 | ||
1062 | for( i = 0; i < mCells.count(); ++i ) { | 1086 | for( i = 0; i < timeSpan+1; ++i ) { |
1063 | mCells[i]->finishUpdateCell(); | 1087 | mCells[i]->finishUpdateCell(); |
1064 | } | 1088 | } |
1065 | processSelectionChange(); | 1089 | processSelectionChange(); |
1066 | mCells[0]->setFocus(); | 1090 | mCells[0]->setFocus(); |
1067 | 1091 | ||
1068 | 1092 | ||
1069 | #else | 1093 | #else |
1070 | // old code | 1094 | // old code |
1071 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1095 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1072 | int i; | 1096 | int i; |
1073 | for( i = 0; i < mCells.count(); ++i ) { | 1097 | for( i = 0; i < mCells.count(); ++i ) { |
1074 | mCells[i]->updateCell(); | 1098 | mCells[i]->updateCell(); |
1075 | } | 1099 | } |
1076 | 1100 | ||
1077 | //qDebug("KOMonthView::updateView() "); | 1101 | //qDebug("KOMonthView::updateView() "); |
1078 | processSelectionChange(); | 1102 | processSelectionChange(); |
1079 | // qDebug("---------------------------------------------------------------------+ "); | 1103 | // qDebug("---------------------------------------------------------------------+ "); |
1080 | mCells[0]->setFocus(); | 1104 | mCells[0]->setFocus(); |
1081 | #endif | 1105 | #endif |
1082 | 1106 | ||
1083 | //qDebug("update time %d ", ti.elapsed()); | 1107 | //qDebug("update time %d ", ti.elapsed()); |
1084 | } | 1108 | } |
1085 | 1109 | ||
1086 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1110 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1087 | { | 1111 | { |
1088 | computeLayout(); | 1112 | computeLayout(); |
1089 | mCells[0]->setFocus(); | 1113 | mCells[0]->setFocus(); |
1090 | } | 1114 | } |
1115 | void KOMonthView::computeLayoutWeek() | ||
1116 | { | ||
1117 | |||
1118 | int daysToShow; | ||
1119 | bool combinedSatSun = false; | ||
1120 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | ||
1121 | daysToShow = 6; | ||
1122 | combinedSatSun = true; | ||
1123 | } | ||
1124 | int tWid = topLevelWidget()->size().width(); | ||
1125 | int tHei = topLevelWidget()->size().height(); | ||
1126 | |||
1127 | int wid = size().width();//e | ||
1128 | int hei = size().height()-1; | ||
1129 | |||
1130 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | ||
1131 | return; | ||
1132 | |||
1133 | if ( wid < hei ) | ||
1134 | daysToShow = 2; | ||
1135 | else | ||
1136 | daysToShow = 3; | ||
1137 | mShowSatSunComp = true; | ||
1138 | combinedSatSun = true; | ||
1139 | |||
1140 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | ||
1141 | QFontMetrics fm ( mWeekLabels[0]->font() ); | ||
1142 | int weeklabelwid = fm.width( "888" ); | ||
1143 | wid -= weeklabelwid; | ||
1144 | |||
1145 | int colWid = wid / daysToShow; | ||
1146 | int lastCol = wid - ( colWid*6 ); | ||
1147 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | ||
1148 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | ||
1149 | int colModulo = wid % daysToShow; | ||
1150 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | ||
1151 | //qDebug("rowmod %d ", rowModulo); | ||
1152 | int i; | ||
1153 | int x,y,w,h; | ||
1154 | x= 0; | ||
1155 | y= 0; | ||
1156 | w = colWid; | ||
1157 | h = dayLabelHei ; | ||
1158 | for ( i = 0; i < 7; i++) { | ||
1159 | if ( i && !( i % daysToShow) && i < 6) { | ||
1160 | y += hei/(5-daysToShow); | ||
1161 | x = 0; | ||
1162 | } | ||
1163 | if ( i == daysToShow-colModulo ) | ||
1164 | ++w; | ||
1165 | if ( i >= 5 ) { | ||
1166 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | ||
1167 | x -= w/2 ; | ||
1168 | } | ||
1169 | else | ||
1170 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | ||
1171 | x += w; | ||
1172 | } | ||
1173 | x= 0; | ||
1174 | y= dayLabelHei; | ||
1175 | w = colWid; | ||
1176 | h = cellHei; | ||
1177 | for ( i = 0; i < mCells.count(); ++i) { | ||
1178 | if ( i > 6 ) { | ||
1179 | mCells[i]->hide(); | ||
1180 | continue; | ||
1181 | } | ||
1182 | |||
1183 | w = colWid; | ||
1184 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | ||
1185 | ++w; | ||
1186 | } | ||
1187 | if ( i == (daysToShow-1-rowModulo)*7) | ||
1188 | ++h; | ||
1189 | |||
1190 | if ( i >= 5 ) { | ||
1191 | if ( i ==5 ) { | ||
1192 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | ||
1193 | x -= w ;y += h/2; | ||
1194 | } else { | ||
1195 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | ||
1196 | y -= h/2; | ||
1197 | } | ||
1198 | } else | ||
1199 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | ||
1200 | |||
1201 | |||
1202 | x += w; | ||
1203 | if ( x + w/2 > wid ) { | ||
1204 | x = 0; | ||
1205 | y += h+dayLabelHei ; | ||
1206 | } | ||
1207 | } | ||
1208 | y= dayLabelHei; | ||
1209 | h = cellHei ; | ||
1210 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | ||
1211 | for ( i = 1; i < 6; i++) { | ||
1212 | mWeekLabels[i]->hide(); | ||
1213 | } | ||
1214 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | ||
1215 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | ||
1216 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | ||
1217 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | ||
1218 | updateDayLabels(); | ||
1219 | bool forceUpdate = !updatePossible; | ||
1220 | updatePossible = true; | ||
1221 | mWeekLabels[mNumWeeks]->setText( i18n("M")); | ||
1222 | if ( forceUpdate ) | ||
1223 | updateView(); | ||
1224 | } | ||
1091 | void KOMonthView::computeLayout() | 1225 | void KOMonthView::computeLayout() |
1092 | { | 1226 | { |
1093 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1227 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1094 | // note this only changes the text if the requested size crosses the | 1228 | // note this only changes the text if the requested size crosses the |
1095 | // threshold between big enough to support the full name and not big | 1229 | // threshold between big enough to support the full name and not big |
1096 | // enough. | 1230 | // enough. |
1097 | 1231 | if ( mShowWeekView ){ | |
1232 | computeLayoutWeek(); | ||
1233 | return; | ||
1234 | } | ||
1098 | int daysToShow = 7; | 1235 | int daysToShow = 7; |
1099 | bool combinedSatSun = false; | 1236 | bool combinedSatSun = false; |
1100 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1237 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1101 | daysToShow = 6; | 1238 | daysToShow = 6; |
1102 | combinedSatSun = true; | 1239 | combinedSatSun = true; |
1103 | } | 1240 | } |
1104 | int tWid = topLevelWidget()->size().width(); | 1241 | int tWid = topLevelWidget()->size().width(); |
1105 | int tHei = topLevelWidget()->size().height(); | 1242 | int tHei = topLevelWidget()->size().height(); |
1106 | 1243 | ||
1107 | int wid = size().width();//e | 1244 | int wid = size().width();//e |
1108 | int hei = size().height()-1; | 1245 | int hei = size().height()-1; |
1109 | 1246 | ||
1110 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1247 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1111 | return; | 1248 | return; |
1112 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1249 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1113 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1250 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1114 | int weeklabelwid = fm.width( "888" ); | 1251 | int weeklabelwid = fm.width( "888" ); |
1115 | wid -= weeklabelwid; | 1252 | wid -= weeklabelwid; |
1116 | 1253 | ||
1117 | int colWid = wid / daysToShow; | 1254 | int colWid = wid / daysToShow; |
1118 | int lastCol = wid - ( colWid*6 ); | 1255 | int lastCol = wid - ( colWid*6 ); |
1119 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1256 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1120 | int cellHei = (hei - dayLabelHei) /6; | 1257 | int cellHei = (hei - dayLabelHei) /6; |
1121 | int colModulo = wid % daysToShow; | 1258 | int colModulo = wid % daysToShow; |
1122 | int rowModulo = (hei- dayLabelHei) % 6; | 1259 | int rowModulo = (hei- dayLabelHei) % 6; |
1123 | //qDebug("rowmod %d ", rowModulo); | 1260 | //qDebug("rowmod %d ", rowModulo); |
1124 | int i; | 1261 | int i; |
1125 | int x,y,w,h; | 1262 | int x,y,w,h; |
1126 | x= 0; | 1263 | x= 0; |
1127 | y= 0; | 1264 | y= 0; |
1128 | w = colWid; | 1265 | w = colWid; |
1129 | h = dayLabelHei ; | 1266 | h = dayLabelHei ; |
1130 | for ( i = 0; i < 7; i++) { | 1267 | for ( i = 0; i < 7; i++) { |
1131 | if ( i == daysToShow-colModulo ) | 1268 | if ( i == daysToShow-colModulo ) |
1132 | ++w; | 1269 | ++w; |
1133 | if ( combinedSatSun ) { | 1270 | if ( combinedSatSun ) { |
1134 | if ( i >= daysToShow-1 ) { | 1271 | if ( i >= daysToShow-1 ) { |
1135 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1272 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1136 | x -= w/2 ; | 1273 | x -= w/2 ; |
1137 | } | 1274 | } |
1138 | else | 1275 | else |
1139 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1276 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1140 | } else | 1277 | } else |
1141 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1278 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1142 | x += w; | 1279 | x += w; |
1143 | } | 1280 | } |
1144 | x= 0; | 1281 | x= 0; |
1145 | y= dayLabelHei; | 1282 | y= dayLabelHei; |
1146 | w = colWid; | 1283 | w = colWid; |
1147 | h = cellHei ; | 1284 | h = cellHei ; |
1148 | for ( i = 0; i < mCells.count(); ++i) { | 1285 | for ( i = 0; i < mCells.count(); ++i) { |
1149 | 1286 | mCells[i]->show(); | |
1150 | w = colWid; | 1287 | w = colWid; |
1151 | if ( ((i) % 7) >= 7-colModulo ) { | 1288 | if ( ((i) % 7) >= 7-colModulo ) { |
1152 | ++w; | 1289 | ++w; |
1153 | } | 1290 | } |
1154 | if ( i == (6-rowModulo)*7) | 1291 | if ( i == (6-rowModulo)*7) |
1155 | ++h; | 1292 | ++h; |
1156 | if ( combinedSatSun ) { | 1293 | if ( combinedSatSun ) { |
1157 | if ( (i)%7 >= daysToShow-1 ) { | 1294 | if ( (i)%7 >= daysToShow-1 ) { |
1158 | if ( (i)%7 == daysToShow-1 ) { | 1295 | if ( (i)%7 == daysToShow-1 ) { |
1159 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1296 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1160 | x -= w ;y += h/2; | 1297 | x -= w ;y += h/2; |
1161 | } else { | 1298 | } else { |
1162 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1299 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1163 | y -= h/2; | 1300 | y -= h/2; |
1164 | } | 1301 | } |
1165 | } else | 1302 | } else |
1166 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1303 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1167 | 1304 | ||
1168 | } | 1305 | } |
1169 | else | 1306 | else |
1170 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1307 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1171 | x += w; | 1308 | x += w; |
1172 | if ( x + w/2 > wid ) { | 1309 | if ( x + w/2 > wid ) { |
1173 | x = 0; | 1310 | x = 0; |
1174 | y += h; | 1311 | y += h; |
1175 | } | 1312 | } |
1176 | } | 1313 | } |
1177 | y= dayLabelHei; | 1314 | y= dayLabelHei; |
1178 | h = cellHei ; | 1315 | h = cellHei ; |
1179 | for ( i = 0; i < 6; i++) { | 1316 | for ( i = 0; i < 6; i++) { |
1317 | mWeekLabels[i]->show(); | ||
1180 | if ( i == (6-rowModulo)) | 1318 | if ( i == (6-rowModulo)) |
1181 | ++h; | 1319 | ++h; |
1182 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1320 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1183 | y += h; | 1321 | y += h; |
1184 | } | 1322 | } |
1185 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1323 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1186 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1324 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1187 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1325 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1188 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1326 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1189 | updateDayLabels(); | 1327 | updateDayLabels(); |
1190 | bool forceUpdate = !updatePossible; | 1328 | bool forceUpdate = !updatePossible; |
1191 | updatePossible = true; | 1329 | updatePossible = true; |
1330 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | ||
1192 | if ( forceUpdate ) | 1331 | if ( forceUpdate ) |
1193 | updateView(); | 1332 | updateView(); |
1194 | } | 1333 | } |
1195 | 1334 | ||
1196 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1335 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1197 | { | 1336 | { |
1198 | mContextMenu->showIncidencePopup(incidence); | 1337 | mContextMenu->showIncidencePopup(incidence); |
1199 | /* | 1338 | /* |
1200 | if( incidence && incidence->type() == "Event" ) { | 1339 | if( incidence && incidence->type() == "Event" ) { |
1201 | Event *event = static_cast<Event *>(incidence); | 1340 | Event *event = static_cast<Event *>(incidence); |
1202 | mContextMenu->showEventPopup(event); | 1341 | mContextMenu->showEventPopup(event); |
1203 | } else { | 1342 | } else { |
1204 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1343 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1205 | } | 1344 | } |
1206 | */ | 1345 | */ |
1207 | } | 1346 | } |
1208 | MonthViewCell * KOMonthView::selectedCell( ) | 1347 | MonthViewCell * KOMonthView::selectedCell( ) |
1209 | { | 1348 | { |
1210 | return mSelectedCell; | 1349 | return mSelectedCell; |
1211 | } | 1350 | } |
1212 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1351 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1213 | { | 1352 | { |
1214 | // qDebug("KOMonthView::setSelectedCell "); | 1353 | // qDebug("KOMonthView::setSelectedCell "); |
1215 | if ( mSelectedCell && mSelectedCell != cell ) { | 1354 | if ( mSelectedCell && mSelectedCell != cell ) { |
1216 | MonthViewCell * mvc = mSelectedCell; | 1355 | MonthViewCell * mvc = mSelectedCell; |
1217 | mSelectedCell = cell; | 1356 | mSelectedCell = cell; |
1218 | mvc->deselect(); | 1357 | mvc->deselect(); |
1219 | } else | 1358 | } else |
1220 | mSelectedCell = cell; | 1359 | mSelectedCell = cell; |
1221 | // if ( mSelectedCell ) | 1360 | // if ( mSelectedCell ) |
1222 | // mSelectedCell->select(); | 1361 | // mSelectedCell->select(); |
1223 | if ( !mSelectedCell ) | 1362 | if ( !mSelectedCell ) |
1224 | emit incidenceSelected( 0 ); | 1363 | emit incidenceSelected( 0 ); |
1225 | else | 1364 | else |
1226 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1365 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1227 | } | 1366 | } |
1228 | 1367 | ||
1229 | void KOMonthView::processSelectionChange() | 1368 | void KOMonthView::processSelectionChange() |
1230 | { | 1369 | { |
1231 | QPtrList<Incidence> incidences = selectedIncidences(); | 1370 | QPtrList<Incidence> incidences = selectedIncidences(); |
1232 | if (incidences.count() > 0) { | 1371 | if (incidences.count() > 0) { |
1233 | emit incidenceSelected( incidences.first() ); | 1372 | emit incidenceSelected( incidences.first() ); |
1234 | } else { | 1373 | } else { |
1235 | emit incidenceSelected( 0 ); | 1374 | emit incidenceSelected( 0 ); |
1236 | } | 1375 | } |
1237 | } | 1376 | } |
1238 | 1377 | ||
1239 | void KOMonthView::clearSelection() | 1378 | void KOMonthView::clearSelection() |
1240 | { | 1379 | { |
1241 | if ( mSelectedCell ) { | 1380 | if ( mSelectedCell ) { |
1242 | mSelectedCell->deselect(); | 1381 | mSelectedCell->deselect(); |
1243 | mSelectedCell = 0; | 1382 | mSelectedCell = 0; |
1244 | } | 1383 | } |
1245 | } | 1384 | } |
1246 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1385 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1247 | { | 1386 | { |
1248 | //qDebug("KOMonthView::keyPressEvent "); | 1387 | //qDebug("KOMonthView::keyPressEvent "); |
1249 | switch(e->key()) { | 1388 | switch(e->key()) { |
1250 | case Key_Up: | 1389 | case Key_Up: |
1251 | { | 1390 | { |
1252 | emit prevMonth(); | 1391 | emit prevMonth(); |
1253 | mCells[0]->setFocus(); | 1392 | mCells[0]->setFocus(); |
1254 | } | 1393 | } |
1255 | e->accept(); | 1394 | e->accept(); |
1256 | break; | 1395 | break; |
1257 | case Key_Down: | 1396 | case Key_Down: |
1258 | { | 1397 | { |
1259 | emit nextMonth(); | 1398 | emit nextMonth(); |
1260 | mCells[0]->setFocus(); | 1399 | mCells[0]->setFocus(); |
1261 | 1400 | ||
1262 | } | 1401 | } |
1263 | e->accept(); | 1402 | e->accept(); |
1264 | break; | 1403 | break; |
1265 | default: | 1404 | default: |
1266 | e->ignore(); | 1405 | e->ignore(); |
1267 | break; | 1406 | break; |
1268 | } | 1407 | } |
1269 | } | 1408 | } |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index b84065e..0bc3743 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,279 +1,283 @@ | |||
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 | #ifndef _KOMONTHVIEW_H | 20 | #ifndef _KOMONTHVIEW_H |
21 | #define _KOMONTHVIEW_H | 21 | #define _KOMONTHVIEW_H |
22 | 22 | ||
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qintdict.h> | 29 | #include <qintdict.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | #include <qptrvector.h> | 32 | #include <qptrvector.h> |
33 | 33 | ||
34 | #include <libkcal/calendar.h> | 34 | #include <libkcal/calendar.h> |
35 | #include <libkcal/event.h> | 35 | #include <libkcal/event.h> |
36 | 36 | ||
37 | #include "koeventview.h" | 37 | #include "koeventview.h" |
38 | 38 | ||
39 | #ifdef DESKTOP_VERSION | 39 | #ifdef DESKTOP_VERSION |
40 | class QToolTipGroup; | 40 | class QToolTipGroup; |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | class KNOWhatsThis; | 43 | class KNOWhatsThis; |
44 | class KOWeekButton : public QPushButton | 44 | class KOWeekButton : public QPushButton |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 48 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
49 | QPushButton( parent, name) | 49 | QPushButton( parent, name) |
50 | { | 50 | { |
51 | connect( this, SIGNAL( clicked() ), | 51 | connect( this, SIGNAL( clicked() ), |
52 | SLOT( bottonClicked() )); | 52 | SLOT( bottonClicked() )); |
53 | mNumber = -1; | 53 | mNumber = -1; |
54 | } | 54 | } |
55 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 55 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
56 | signals: | 56 | signals: |
57 | void selectWeekNum ( int ); | 57 | void selectWeekNum ( int ); |
58 | private: | 58 | private: |
59 | int mNumber; | 59 | int mNumber; |
60 | private slots : | 60 | private slots : |
61 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 61 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
62 | }; | 62 | }; |
63 | 63 | ||
64 | class KNoScrollListBox: public QListBox | 64 | class KNoScrollListBox: public QListBox |
65 | { | 65 | { |
66 | Q_OBJECT | 66 | Q_OBJECT |
67 | public: | 67 | public: |
68 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 68 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
69 | ~KNoScrollListBox(); | 69 | ~KNoScrollListBox(); |
70 | QString getWhatsThisText(QPoint p) ; | 70 | QString getWhatsThisText(QPoint p) ; |
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void shiftDown(); | 73 | void shiftDown(); |
74 | void shiftUp(); | 74 | void shiftUp(); |
75 | void rightClick(); | 75 | void rightClick(); |
76 | 76 | ||
77 | protected slots: | 77 | protected slots: |
78 | void keyPressEvent(QKeyEvent *); | 78 | void keyPressEvent(QKeyEvent *); |
79 | void keyReleaseEvent(QKeyEvent *); | 79 | void keyReleaseEvent(QKeyEvent *); |
80 | void mousePressEvent(QMouseEvent *); | 80 | void mousePressEvent(QMouseEvent *); |
81 | 81 | ||
82 | private: | 82 | private: |
83 | KNOWhatsThis * mWT; | 83 | KNOWhatsThis * mWT; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | 86 | ||
87 | class MonthViewItem: public QListBoxItem | 87 | class MonthViewItem: public QListBoxItem |
88 | { | 88 | { |
89 | public: | 89 | public: |
90 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 90 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
91 | 91 | ||
92 | void setRecur(bool on) { mRecur = on; } | 92 | void setRecur(bool on) { mRecur = on; } |
93 | void setAlarm(bool on) { mAlarm = on; } | 93 | void setAlarm(bool on) { mAlarm = on; } |
94 | void setReply(bool on) { mReply = on; } | 94 | void setReply(bool on) { mReply = on; } |
95 | void setMoreInfo(bool on) { mInfo = on; } | 95 | void setMoreInfo(bool on) { mInfo = on; } |
96 | 96 | ||
97 | 97 | ||
98 | void setPalette(const QPalette &p) { mPalette = p; } | 98 | void setPalette(const QPalette &p) { mPalette = p; } |
99 | QPalette palette() const { return mPalette; } | 99 | QPalette palette() const { return mPalette; } |
100 | 100 | ||
101 | Incidence *incidence() const { return mIncidence; } | 101 | Incidence *incidence() const { return mIncidence; } |
102 | QDate incidenceDate() { return mDate; } | 102 | QDate incidenceDate() { return mDate; } |
103 | 103 | ||
104 | protected: | 104 | protected: |
105 | virtual void paint(QPainter *); | 105 | virtual void paint(QPainter *); |
106 | virtual int height(const QListBox *) const; | 106 | virtual int height(const QListBox *) const; |
107 | virtual int width(const QListBox *) const; | 107 | virtual int width(const QListBox *) const; |
108 | 108 | ||
109 | private: | 109 | private: |
110 | bool mRecur; | 110 | bool mRecur; |
111 | bool mAlarm; | 111 | bool mAlarm; |
112 | bool mReply; | 112 | bool mReply; |
113 | bool mInfo; | 113 | bool mInfo; |
114 | 114 | ||
115 | QPalette mPalette; | 115 | QPalette mPalette; |
116 | QDate mDate; | 116 | QDate mDate; |
117 | 117 | ||
118 | Incidence *mIncidence; | 118 | Incidence *mIncidence; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | 121 | ||
122 | class KOMonthView; | 122 | class KOMonthView; |
123 | 123 | ||
124 | class MonthViewCell : public QWidget | 124 | class MonthViewCell : public QWidget |
125 | { | 125 | { |
126 | Q_OBJECT | 126 | Q_OBJECT |
127 | public: | 127 | public: |
128 | MonthViewCell( KOMonthView * ); | 128 | MonthViewCell( KOMonthView * ); |
129 | 129 | ||
130 | void setDate( const QDate & ); | 130 | void setDate( const QDate & ); |
131 | QDate date() const; | 131 | QDate date() const; |
132 | 132 | ||
133 | void setPrimary( bool ); | 133 | void setPrimary( bool ); |
134 | bool isPrimary() const; | 134 | bool isPrimary() const; |
135 | 135 | ||
136 | void setHoliday( bool ); | 136 | void setHoliday( bool ); |
137 | void setHoliday( const QString & ); | 137 | void setHoliday( const QString & ); |
138 | 138 | ||
139 | void updateCell(); | 139 | void updateCell(); |
140 | void startUpdateCell(); | 140 | void startUpdateCell(); |
141 | void finishUpdateCell(); | 141 | void finishUpdateCell(); |
142 | void insertEvent(Event *); | 142 | void insertEvent(Event *); |
143 | void insertTodo(Todo *); | 143 | void insertTodo(Todo *); |
144 | 144 | ||
145 | void updateConfig(); | 145 | void updateConfig(); |
146 | 146 | ||
147 | void enableScrollBars( bool ); | 147 | void enableScrollBars( bool ); |
148 | 148 | ||
149 | Incidence *selectedIncidence(); | 149 | Incidence *selectedIncidence(); |
150 | QDate selectedIncidenceDate(); | 150 | QDate selectedIncidenceDate(); |
151 | 151 | ||
152 | void deselect(); | 152 | void deselect(); |
153 | void select(); | 153 | void select(); |
154 | void clear(); | 154 | void clear(); |
155 | 155 | ||
156 | #ifdef DESKTOP_VERSION | 156 | #ifdef DESKTOP_VERSION |
157 | static QToolTipGroup *toolTipGroup(); | 157 | static QToolTipGroup *toolTipGroup(); |
158 | #endif | 158 | #endif |
159 | signals: | 159 | signals: |
160 | void defaultAction( Incidence * ); | 160 | void defaultAction( Incidence * ); |
161 | void newEventSignal( QDateTime ); | 161 | void newEventSignal( QDateTime ); |
162 | void showDaySignal( QDate ); | 162 | void showDaySignal( QDate ); |
163 | 163 | ||
164 | protected: | 164 | protected: |
165 | QString mToolTip; | 165 | QString mToolTip; |
166 | void resizeEvent( QResizeEvent * ); | 166 | void resizeEvent( QResizeEvent * ); |
167 | 167 | ||
168 | protected slots: | 168 | protected slots: |
169 | void defaultAction( QListBoxItem * ); | 169 | void defaultAction( QListBoxItem * ); |
170 | void contextMenu( QListBoxItem * ); | 170 | void contextMenu( QListBoxItem * ); |
171 | void selection( QListBoxItem * ); | 171 | void selection( QListBoxItem * ); |
172 | void cellClicked( QListBoxItem * ); | 172 | void cellClicked( QListBoxItem * ); |
173 | void newEvent(); | 173 | void newEvent(); |
174 | void showDay(); | 174 | void showDay(); |
175 | 175 | ||
176 | private: | 176 | private: |
177 | KOMonthView *mMonthView; | 177 | KOMonthView *mMonthView; |
178 | 178 | ||
179 | QDate mDate; | 179 | QDate mDate; |
180 | bool mPrimary; | 180 | bool mPrimary; |
181 | bool mHoliday; | 181 | bool mHoliday; |
182 | QString mHolidayString; | 182 | QString mHolidayString; |
183 | 183 | ||
184 | //QLabel *mLabel; | 184 | //QLabel *mLabel; |
185 | QPushButton *mLabel; | 185 | QPushButton *mLabel; |
186 | QListBox *mItemList; | 186 | QListBox *mItemList; |
187 | #ifdef DESKTOP_VERSION | 187 | #ifdef DESKTOP_VERSION |
188 | static QToolTipGroup *mToolTipGroup; | 188 | static QToolTipGroup *mToolTipGroup; |
189 | #endif | 189 | #endif |
190 | QSize mLabelSize; | 190 | QSize mLabelSize; |
191 | QSize mLabelBigSize; | 191 | QSize mLabelBigSize; |
192 | QPalette mHolidayPalette; | 192 | QPalette mHolidayPalette; |
193 | QPalette mStandardPalette; | 193 | QPalette mStandardPalette; |
194 | QPalette mPrimaryPalette; | 194 | QPalette mPrimaryPalette; |
195 | QPalette mNonPrimaryPalette; | 195 | QPalette mNonPrimaryPalette; |
196 | void setMyPalette(); | 196 | void setMyPalette(); |
197 | QPalette getPalette (); | 197 | QPalette getPalette (); |
198 | void keyPressEvent ( QKeyEvent * ) ; | 198 | void keyPressEvent ( QKeyEvent * ) ; |
199 | 199 | ||
200 | }; | 200 | }; |
201 | 201 | ||
202 | 202 | ||
203 | class KOMonthView: public KOEventView | 203 | class KOMonthView: public KOEventView |
204 | { | 204 | { |
205 | Q_OBJECT | 205 | Q_OBJECT |
206 | public: | 206 | public: |
207 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 207 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
208 | ~KOMonthView(); | 208 | ~KOMonthView(); |
209 | 209 | ||
210 | /** Returns maximum number of days supported by the komonthview */ | 210 | /** Returns maximum number of days supported by the komonthview */ |
211 | virtual int maxDatesHint(); | 211 | virtual int maxDatesHint(); |
212 | 212 | ||
213 | /** Returns number of currently shown dates. */ | 213 | /** Returns number of currently shown dates. */ |
214 | virtual int currentDateCount(); | 214 | virtual int currentDateCount(); |
215 | 215 | ||
216 | /** returns the currently selected events */ | 216 | /** returns the currently selected events */ |
217 | virtual QPtrList<Incidence> selectedIncidences(); | 217 | virtual QPtrList<Incidence> selectedIncidences(); |
218 | 218 | ||
219 | /** returns dates of the currently selected events */ | 219 | /** returns dates of the currently selected events */ |
220 | virtual DateList selectedDates(); | 220 | virtual DateList selectedDates(); |
221 | 221 | ||
222 | virtual void printPreview(CalPrinter *calPrinter, | 222 | virtual void printPreview(CalPrinter *calPrinter, |
223 | const QDate &, const QDate &); | 223 | const QDate &, const QDate &); |
224 | bool isMonthView() { return true; } | 224 | bool isMonthView() { return true; } |
225 | bool isUpdatePossible() { return updatePossible; } | 225 | bool isUpdatePossible() { return updatePossible; } |
226 | 226 | ||
227 | MonthViewCell * selectedCell(); | 227 | MonthViewCell * selectedCell(); |
228 | public slots: | 228 | public slots: |
229 | virtual void updateView(); | 229 | virtual void updateView(); |
230 | virtual void updateConfig(); | 230 | virtual void updateConfig(); |
231 | virtual void showDates(const QDate &start, const QDate &end); | 231 | virtual void showDates(const QDate &start, const QDate &end); |
232 | virtual void showEvents(QPtrList<Event> eventList); | 232 | virtual void showEvents(QPtrList<Event> eventList); |
233 | 233 | ||
234 | void changeEventDisplay(Event *, int); | 234 | void changeEventDisplay(Event *, int); |
235 | 235 | ||
236 | void clearSelection(); | 236 | void clearSelection(); |
237 | 237 | ||
238 | void showContextMenu( Incidence * ); | 238 | void showContextMenu( Incidence * ); |
239 | 239 | ||
240 | void setSelectedCell( MonthViewCell * ); | 240 | void setSelectedCell( MonthViewCell * ); |
241 | 241 | ||
242 | protected slots: | 242 | protected slots: |
243 | void switchView(); | ||
243 | void processSelectionChange(); | 244 | void processSelectionChange(); |
244 | signals: | 245 | signals: |
245 | void nextMonth(); | 246 | void nextMonth(); |
246 | void prevMonth(); | 247 | void prevMonth(); |
248 | void showNavigator( bool ); | ||
247 | void selectWeekNum ( int ); | 249 | void selectWeekNum ( int ); |
248 | void showDaySignal( QDate ); | 250 | void showDaySignal( QDate ); |
249 | protected: | 251 | protected: |
250 | void resizeEvent(QResizeEvent *); | 252 | void resizeEvent(QResizeEvent *); |
251 | void viewChanged(); | 253 | void viewChanged(); |
252 | void updateDayLabels(); | 254 | void updateDayLabels(); |
253 | 255 | ||
254 | private: | 256 | private: |
257 | bool mShowWeekView; | ||
255 | bool updatePossible; | 258 | bool updatePossible; |
256 | int mDaysPerWeek; | 259 | int mDaysPerWeek; |
257 | int mNumWeeks; | 260 | int mNumWeeks; |
258 | int mNumCells; | 261 | int mNumCells; |
259 | bool mWeekStartsMonday; | 262 | bool mWeekStartsMonday; |
260 | bool mShowSatSunComp; | 263 | bool mShowSatSunComp; |
261 | void computeLayout(); | 264 | void computeLayout(); |
265 | void computeLayoutWeek(); | ||
262 | 266 | ||
263 | QPtrVector<MonthViewCell> mCells; | 267 | QPtrVector<MonthViewCell> mCells; |
264 | QPtrVector<QLabel> mDayLabels; | 268 | QPtrVector<QLabel> mDayLabels; |
265 | QPtrVector<KOWeekButton> mWeekLabels; | 269 | QPtrVector<KOWeekButton> mWeekLabels; |
266 | 270 | ||
267 | bool mShortDayLabels; | 271 | bool mShortDayLabels; |
268 | int mWidthLongDayLabel; | 272 | int mWidthLongDayLabel; |
269 | 273 | ||
270 | QDate mStartDate; | 274 | QDate mStartDate; |
271 | 275 | ||
272 | MonthViewCell *mSelectedCell; | 276 | MonthViewCell *mSelectedCell; |
273 | 277 | ||
274 | KOEventPopupMenu *mContextMenu; | 278 | KOEventPopupMenu *mContextMenu; |
275 | void keyPressEvent ( QKeyEvent * ) ; | 279 | void keyPressEvent ( QKeyEvent * ) ; |
276 | 280 | ||
277 | }; | 281 | }; |
278 | 282 | ||
279 | #endif | 283 | #endif |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 0548f14..2fb7c36 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,476 +1,477 @@ | |||
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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "mainwindow.h" | 47 | #include "mainwindow.h" |
48 | 48 | ||
49 | KOPrefs *KOPrefs::mInstance = 0; | 49 | KOPrefs *KOPrefs::mInstance = 0; |
50 | static KStaticDeleter<KOPrefs> insd; | 50 | static KStaticDeleter<KOPrefs> insd; |
51 | 51 | ||
52 | KOPrefs::KOPrefs() : | 52 | KOPrefs::KOPrefs() : |
53 | KPimPrefs("korganizerrc") | 53 | KPimPrefs("korganizerrc") |
54 | { | 54 | { |
55 | mCategoryColors.setAutoDelete(true); | 55 | mCategoryColors.setAutoDelete(true); |
56 | fillMailDefaults(); | 56 | fillMailDefaults(); |
57 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 57 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
58 | QColor defaultHolidayColor = QColor(255,0,0); | 58 | QColor defaultHolidayColor = QColor(255,0,0); |
59 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 59 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
60 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 60 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
61 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 61 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
62 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 62 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
63 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 63 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
64 | 64 | ||
65 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | 65 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); |
66 | mDefaultViewFont = QFont("helvetica",10); | 66 | mDefaultViewFont = QFont("helvetica",10); |
67 | mDefaultMonthViewFont = QFont("helvetica",8); | 67 | mDefaultMonthViewFont = QFont("helvetica",8); |
68 | mMarcusBainsFont= QFont("helvetica",10); | 68 | mMarcusBainsFont= QFont("helvetica",10); |
69 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | 69 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); |
70 | mEditBoxFont = QFont("helvetica",12); | 70 | mEditBoxFont = QFont("helvetica",12); |
71 | mJornalViewFont = QFont("helvetica",12); | 71 | mJornalViewFont = QFont("helvetica",12); |
72 | 72 | ||
73 | KPrefs::setCurrentGroup("General"); | 73 | KPrefs::setCurrentGroup("General"); |
74 | 74 | ||
75 | 75 | ||
76 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 76 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
77 | 77 | ||
78 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 78 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
79 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 79 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
80 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 80 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
81 | addItemBool("ShowIconList",&mShowIconList,true); | 81 | addItemBool("ShowIconList",&mShowIconList,true); |
82 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 82 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
83 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 83 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
84 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 84 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
85 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 85 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
86 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 86 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
87 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 87 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
88 | addItemBool("ShowIconBack",&mShowIconBack,true); | 88 | addItemBool("ShowIconBack",&mShowIconBack,true); |
89 | addItemBool("ShowIconToday",&mShowIconToday,true); | 89 | addItemBool("ShowIconToday",&mShowIconToday,true); |
90 | addItemBool("ShowIconForward",&mShowIconForward,true); | 90 | addItemBool("ShowIconForward",&mShowIconForward,true); |
91 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 91 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
92 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); | 92 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); |
93 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 93 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
94 | addItemBool("ShowIconNext",&mShowIconNext,true); | 94 | addItemBool("ShowIconNext",&mShowIconNext,true); |
95 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 95 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
96 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 96 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
97 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); | 97 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); |
98 | 98 | ||
99 | addItemBool("AskForQuit",&mAskForQuit,false); | 99 | addItemBool("AskForQuit",&mAskForQuit,false); |
100 | 100 | ||
101 | #ifndef DESKTOP_VERSION | 101 | #ifndef DESKTOP_VERSION |
102 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 102 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
103 | #else | 103 | #else |
104 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 104 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
105 | #endif | 105 | #endif |
106 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 106 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
107 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 107 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
108 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 108 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
109 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 109 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
110 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 110 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
111 | 111 | ||
112 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 112 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
113 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); | 113 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); |
114 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); | 114 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); |
115 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 115 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
116 | addItemInt("AllDay Size",&mAllDaySize,28); | 116 | addItemInt("AllDay Size",&mAllDaySize,28); |
117 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 117 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
118 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 118 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
119 | 119 | ||
120 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 120 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
121 | addItemStringList("EventSummary User",&mEventSummaryUser); | 121 | addItemStringList("EventSummary User",&mEventSummaryUser); |
122 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 122 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
123 | 123 | ||
124 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 124 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
125 | addItemBool("Enable Project View",&mEnableProjectView,false); | 125 | addItemBool("Enable Project View",&mEnableProjectView,false); |
126 | addItemBool("Auto Save",&mAutoSave,false); | 126 | addItemBool("Auto Save",&mAutoSave,false); |
127 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 127 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
128 | addItemBool("Confirm Deletes",&mConfirm,true); | 128 | addItemBool("Confirm Deletes",&mConfirm,true); |
129 | addItemString("Archive File",&mArchiveFile); | 129 | addItemString("Archive File",&mArchiveFile); |
130 | addItemString("Html Export File",&mHtmlExportFile, | 130 | addItemString("Html Export File",&mHtmlExportFile, |
131 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 131 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
132 | addItemBool("Html With Save",&mHtmlWithSave,false); | 132 | addItemBool("Html With Save",&mHtmlWithSave,false); |
133 | 133 | ||
134 | KPrefs::setCurrentGroup("Personal Settings"); | 134 | KPrefs::setCurrentGroup("Personal Settings"); |
135 | 135 | ||
136 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 136 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
137 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 137 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
138 | addItemBool("Bcc",&mBcc,false); | 138 | addItemBool("Bcc",&mBcc,false); |
139 | 139 | ||
140 | KPrefs::setCurrentGroup("Time & Date"); | 140 | KPrefs::setCurrentGroup("Time & Date"); |
141 | 141 | ||
142 | 142 | ||
143 | addItemInt("Default Start Time",&mStartTime,10); | 143 | addItemInt("Default Start Time",&mStartTime,10); |
144 | addItemInt("Default Duration",&mDefaultDuration,2); | 144 | addItemInt("Default Duration",&mDefaultDuration,2); |
145 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 145 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
146 | KPrefs::setCurrentGroup("AlarmSettings"); | 146 | KPrefs::setCurrentGroup("AlarmSettings"); |
147 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 147 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
148 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 148 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
149 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 149 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
150 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 150 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
151 | 151 | ||
152 | 152 | ||
153 | KPrefs::setCurrentGroup("Calendar"); | 153 | KPrefs::setCurrentGroup("Calendar"); |
154 | 154 | ||
155 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 155 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
156 | 156 | ||
157 | KPrefs::setCurrentGroup("Fonts"); | 157 | KPrefs::setCurrentGroup("Fonts"); |
158 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 158 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
159 | addItemFont("TimeBar Font",&mTimeBarFont); | 159 | addItemFont("TimeBar Font",&mTimeBarFont); |
160 | addItemFont("MonthView Font",&mMonthViewFont); | 160 | addItemFont("MonthView Font",&mMonthViewFont); |
161 | addItemFont("AgendaView Font",&mAgendaViewFont); | 161 | addItemFont("AgendaView Font",&mAgendaViewFont); |
162 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 162 | addItemFont("MarcusBains Font",&mMarcusBainsFont); |
163 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 163 | addItemFont("TimeLabels Font",&mTimeLabelsFont); |
164 | addItemFont("TodoView Font",&mTodoViewFont); | 164 | addItemFont("TodoView Font",&mTodoViewFont); |
165 | addItemFont("ListView Font",&mListViewFont); | 165 | addItemFont("ListView Font",&mListViewFont); |
166 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 166 | addItemFont("DateNavigator Font",&mDateNavigatorFont); |
167 | addItemFont("EditBox Font",&mEditBoxFont); | 167 | addItemFont("EditBox Font",&mEditBoxFont); |
168 | addItemFont("JournalView Font",&mJornalViewFont); | 168 | addItemFont("JournalView Font",&mJornalViewFont); |
169 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 169 | addItemFont("WhatsNextView Font",&mWhatsNextFont); |
170 | addItemFont("EventView Font",&mEventViewFont); | 170 | addItemFont("EventView Font",&mEventViewFont); |
171 | 171 | ||
172 | KPrefs::setCurrentGroup("RemoteSyncing"); | 172 | KPrefs::setCurrentGroup("RemoteSyncing"); |
173 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 173 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
174 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 174 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
175 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 175 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
176 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 176 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
177 | 177 | ||
178 | #ifdef _WIN32_ | 178 | #ifdef _WIN32_ |
179 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 179 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
180 | #else | 180 | #else |
181 | QString hdp= locateLocal("data","korganizer")+"/"; | 181 | QString hdp= locateLocal("data","korganizer")+"/"; |
182 | #endif | 182 | #endif |
183 | 183 | ||
184 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 184 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
185 | 185 | ||
186 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 186 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
187 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 187 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
188 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 188 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
189 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 189 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
190 | 190 | ||
191 | 191 | ||
192 | KPrefs::setCurrentGroup("Locale"); | 192 | KPrefs::setCurrentGroup("Locale"); |
193 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 193 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
194 | 194 | ||
195 | 195 | ||
196 | KPrefs::setCurrentGroup("Colors"); | 196 | KPrefs::setCurrentGroup("Colors"); |
197 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 197 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
198 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 198 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
199 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 199 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
200 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); | 200 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); |
201 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 201 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
202 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 202 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
203 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 203 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
204 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 204 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
205 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 205 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
206 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 206 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
207 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 207 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
208 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 208 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
209 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 209 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
210 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); | ||
210 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 211 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
211 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 212 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
212 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 213 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
213 | addItemBool("UseAppColors",&mUseAppColors,false); | 214 | addItemBool("UseAppColors",&mUseAppColors,false); |
214 | 215 | ||
215 | 216 | ||
216 | 217 | ||
217 | KPrefs::setCurrentGroup("Views"); | 218 | KPrefs::setCurrentGroup("Views"); |
218 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); | 219 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); |
219 | addItemInt("Hour Size",&mHourSize,8); | 220 | addItemInt("Hour Size",&mHourSize,8); |
220 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 221 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
221 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 222 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
222 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 223 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
223 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 224 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
224 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 225 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
225 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 226 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
226 | #ifdef DESKTOP_VERION | 227 | #ifdef DESKTOP_VERION |
227 | addItemBool("Enable ToolTips",&mEnableToolTips,true); | 228 | addItemBool("Enable ToolTips",&mEnableToolTips,true); |
228 | #else | 229 | #else |
229 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 230 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
230 | #endif | 231 | #endif |
231 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 232 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
232 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 233 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
233 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 234 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
234 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 235 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
235 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); | 236 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); |
236 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 237 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
237 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 238 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
238 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 239 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
239 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 240 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
240 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; | 241 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; |
241 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); | 242 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); |
242 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 243 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
243 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 244 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
244 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 245 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
245 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 246 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
246 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 247 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
247 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | 248 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); |
248 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 249 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
249 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 250 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
250 | #ifdef DESKTOP_VERSION | 251 | #ifdef DESKTOP_VERSION |
251 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 252 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
252 | #else | 253 | #else |
253 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 254 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
254 | #endif | 255 | #endif |
255 | addItemInt("Day Begins",&mDayBegins,7); | 256 | addItemInt("Day Begins",&mDayBegins,7); |
256 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 257 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
257 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 258 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
258 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 259 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
259 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 260 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
260 | 261 | ||
261 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 262 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
262 | addItemBool("Full View Month",&mFullViewMonth,true); | 263 | addItemBool("Full View Month",&mFullViewMonth,true); |
263 | addItemBool("Full View Todo",&mFullViewTodo,true); | 264 | addItemBool("Full View Todo",&mFullViewTodo,true); |
264 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 265 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
265 | 266 | ||
266 | addItemInt("Next X Days",&mNextXDays,3); | 267 | addItemInt("Next X Days",&mNextXDays,3); |
267 | 268 | ||
268 | KPrefs::setCurrentGroup("Printer"); | 269 | KPrefs::setCurrentGroup("Printer"); |
269 | 270 | ||
270 | KPrefs::setCurrentGroup("Layout"); | 271 | KPrefs::setCurrentGroup("Layout"); |
271 | 272 | ||
272 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 273 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
273 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 274 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
274 | 275 | ||
275 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 276 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
276 | 277 | ||
277 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 278 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
278 | 279 | ||
279 | KPrefs::setCurrentGroup("Group Scheduling"); | 280 | KPrefs::setCurrentGroup("Group Scheduling"); |
280 | 281 | ||
281 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 282 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
282 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 283 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
283 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 284 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
284 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 285 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
285 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 286 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
286 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 287 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
287 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 288 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
288 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 289 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
289 | 290 | ||
290 | KPrefs::setCurrentGroup( "Editors" ); | 291 | KPrefs::setCurrentGroup( "Editors" ); |
291 | 292 | ||
292 | addItemStringList( "EventTemplates", &mEventTemplates ); | 293 | addItemStringList( "EventTemplates", &mEventTemplates ); |
293 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 294 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
294 | 295 | ||
295 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 296 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
296 | 297 | ||
297 | 298 | ||
298 | 299 | ||
299 | } | 300 | } |
300 | 301 | ||
301 | 302 | ||
302 | KOPrefs::~KOPrefs() | 303 | KOPrefs::~KOPrefs() |
303 | { | 304 | { |
304 | if (mInstance == this) | 305 | if (mInstance == this) |
305 | mInstance = insd.setObject(0); | 306 | mInstance = insd.setObject(0); |
306 | 307 | ||
307 | //qDebug("KOPrefs::~KOPrefs() "); | 308 | //qDebug("KOPrefs::~KOPrefs() "); |
308 | } | 309 | } |
309 | 310 | ||
310 | 311 | ||
311 | KOPrefs *KOPrefs::instance() | 312 | KOPrefs *KOPrefs::instance() |
312 | { | 313 | { |
313 | if (!mInstance) { | 314 | if (!mInstance) { |
314 | mInstance = insd.setObject(new KOPrefs()); | 315 | mInstance = insd.setObject(new KOPrefs()); |
315 | mInstance->readConfig(); | 316 | mInstance->readConfig(); |
316 | } | 317 | } |
317 | 318 | ||
318 | return mInstance; | 319 | return mInstance; |
319 | } | 320 | } |
320 | 321 | ||
321 | void KOPrefs::usrSetDefaults() | 322 | void KOPrefs::usrSetDefaults() |
322 | { | 323 | { |
323 | 324 | ||
324 | } | 325 | } |
325 | 326 | ||
326 | void KOPrefs::fillMailDefaults() | 327 | void KOPrefs::fillMailDefaults() |
327 | { | 328 | { |
328 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 329 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
329 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 330 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
330 | } | 331 | } |
331 | 332 | ||
332 | void KOPrefs::setTimeZoneIdDefault() | 333 | void KOPrefs::setTimeZoneIdDefault() |
333 | { | 334 | { |
334 | ; | 335 | ; |
335 | } | 336 | } |
336 | 337 | ||
337 | void KOPrefs::setCategoryDefaults() | 338 | void KOPrefs::setCategoryDefaults() |
338 | { | 339 | { |
339 | mCustomCategories.clear(); | 340 | mCustomCategories.clear(); |
340 | mCustomCategories = getDefaultList(); | 341 | mCustomCategories = getDefaultList(); |
341 | 342 | ||
342 | QStringList::Iterator it; | 343 | QStringList::Iterator it; |
343 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 344 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
344 | setCategoryColor(*it,mDefaultCategoryColor); | 345 | setCategoryColor(*it,mDefaultCategoryColor); |
345 | } | 346 | } |
346 | } | 347 | } |
347 | 348 | ||
348 | QStringList KOPrefs::getDefaultList() | 349 | QStringList KOPrefs::getDefaultList() |
349 | { | 350 | { |
350 | QStringList retval ; | 351 | QStringList retval ; |
351 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | 352 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") |
352 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 353 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
353 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | 354 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") |
354 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | 355 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") |
355 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | 356 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") |
356 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 357 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
357 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 358 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
358 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 359 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
359 | retval.sort(); | 360 | retval.sort(); |
360 | return retval; | 361 | return retval; |
361 | } | 362 | } |
362 | 363 | ||
363 | void KOPrefs::usrReadConfig() | 364 | void KOPrefs::usrReadConfig() |
364 | { | 365 | { |
365 | config()->setGroup("General"); | 366 | config()->setGroup("General"); |
366 | 367 | ||
367 | mCustomCategories = config()->readListEntry("Custom Categories"); | 368 | mCustomCategories = config()->readListEntry("Custom Categories"); |
368 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) { | 369 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) { |
369 | mLocationDefaults.clear(); | 370 | mLocationDefaults.clear(); |
370 | mEventSummaryUser.clear(); | 371 | mEventSummaryUser.clear(); |
371 | mTodoSummaryUser.clear(); | 372 | mTodoSummaryUser.clear(); |
372 | } | 373 | } |
373 | mOldLoadedLanguage = mOldLanguage ; | 374 | mOldLoadedLanguage = mOldLanguage ; |
374 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 375 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
375 | if (mLocationDefaults.isEmpty()) { | 376 | if (mLocationDefaults.isEmpty()) { |
376 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 377 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
377 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 378 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
378 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 379 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
379 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 380 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
380 | mLocationDefaults.sort(); | 381 | mLocationDefaults.sort(); |
381 | } | 382 | } |
382 | 383 | ||
383 | if (mEventSummaryUser.isEmpty()) { | 384 | if (mEventSummaryUser.isEmpty()) { |
384 | mEventSummaryUser = getDefaultList() ; | 385 | mEventSummaryUser = getDefaultList() ; |
385 | } | 386 | } |
386 | if (mTodoSummaryUser.isEmpty()) { | 387 | if (mTodoSummaryUser.isEmpty()) { |
387 | mTodoSummaryUser = getDefaultList() ; | 388 | mTodoSummaryUser = getDefaultList() ; |
388 | } | 389 | } |
389 | 390 | ||
390 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 391 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
391 | 392 | ||
392 | config()->setGroup("Personal Settings"); | 393 | config()->setGroup("Personal Settings"); |
393 | mName = config()->readEntry("user_name",""); | 394 | mName = config()->readEntry("user_name",""); |
394 | mEmail = config()->readEntry("user_email",""); | 395 | mEmail = config()->readEntry("user_email",""); |
395 | fillMailDefaults(); | 396 | fillMailDefaults(); |
396 | 397 | ||
397 | config()->setGroup("Category Colors"); | 398 | config()->setGroup("Category Colors"); |
398 | QStringList::Iterator it; | 399 | QStringList::Iterator it; |
399 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 400 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
400 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 401 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
401 | 402 | ||
402 | } | 403 | } |
403 | 404 | ||
404 | KPimPrefs::usrReadConfig(); | 405 | KPimPrefs::usrReadConfig(); |
405 | } | 406 | } |
406 | 407 | ||
407 | 408 | ||
408 | void KOPrefs::usrWriteConfig() | 409 | void KOPrefs::usrWriteConfig() |
409 | { | 410 | { |
410 | config()->setGroup("General"); | 411 | config()->setGroup("General"); |
411 | config()->writeEntry("Custom Categories",mCustomCategories); | 412 | config()->writeEntry("Custom Categories",mCustomCategories); |
412 | 413 | ||
413 | config()->setGroup("Personal Settings"); | 414 | config()->setGroup("Personal Settings"); |
414 | config()->writeEntry("user_name",mName); | 415 | config()->writeEntry("user_name",mName); |
415 | config()->writeEntry("user_email",mEmail); | 416 | config()->writeEntry("user_email",mEmail); |
416 | 417 | ||
417 | config()->setGroup("Category Colors"); | 418 | config()->setGroup("Category Colors"); |
418 | QDictIterator<QColor> it(mCategoryColors); | 419 | QDictIterator<QColor> it(mCategoryColors); |
419 | while (it.current()) { | 420 | while (it.current()) { |
420 | config()->writeEntry(it.currentKey(),*(it.current())); | 421 | config()->writeEntry(it.currentKey(),*(it.current())); |
421 | ++it; | 422 | ++it; |
422 | } | 423 | } |
423 | 424 | ||
424 | 425 | ||
425 | KPimPrefs::usrWriteConfig(); | 426 | KPimPrefs::usrWriteConfig(); |
426 | } | 427 | } |
427 | 428 | ||
428 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 429 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
429 | { | 430 | { |
430 | mCategoryColors.replace(cat,new QColor(color)); | 431 | mCategoryColors.replace(cat,new QColor(color)); |
431 | } | 432 | } |
432 | 433 | ||
433 | QColor *KOPrefs::categoryColor(QString cat) | 434 | QColor *KOPrefs::categoryColor(QString cat) |
434 | { | 435 | { |
435 | QColor *color = 0; | 436 | QColor *color = 0; |
436 | 437 | ||
437 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 438 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
438 | 439 | ||
439 | if (color) return color; | 440 | if (color) return color; |
440 | else return &mDefaultCategoryColor; | 441 | else return &mDefaultCategoryColor; |
441 | } | 442 | } |
442 | 443 | ||
443 | void KOPrefs::setFullName(const QString &name) | 444 | void KOPrefs::setFullName(const QString &name) |
444 | { | 445 | { |
445 | mName = name; | 446 | mName = name; |
446 | } | 447 | } |
447 | 448 | ||
448 | void KOPrefs::setEmail(const QString &email) | 449 | void KOPrefs::setEmail(const QString &email) |
449 | { | 450 | { |
450 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 451 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
451 | mEmail = email; | 452 | mEmail = email; |
452 | } | 453 | } |
453 | 454 | ||
454 | QString KOPrefs::fullName() | 455 | QString KOPrefs::fullName() |
455 | { | 456 | { |
456 | if (mEmailControlCenter) { | 457 | if (mEmailControlCenter) { |
457 | KEMailSettings settings; | 458 | KEMailSettings settings; |
458 | return settings.getSetting(KEMailSettings::RealName); | 459 | return settings.getSetting(KEMailSettings::RealName); |
459 | } else { | 460 | } else { |
460 | return mName; | 461 | return mName; |
461 | } | 462 | } |
462 | } | 463 | } |
463 | 464 | ||
464 | QString KOPrefs::email() | 465 | QString KOPrefs::email() |
465 | { | 466 | { |
466 | if (mEmailControlCenter) { | 467 | if (mEmailControlCenter) { |
467 | KEMailSettings settings; | 468 | KEMailSettings settings; |
468 | return settings.getSetting(KEMailSettings::EmailAddress); | 469 | return settings.getSetting(KEMailSettings::EmailAddress); |
469 | } else { | 470 | } else { |
470 | return mEmail; | 471 | return mEmail; |
471 | } | 472 | } |
472 | } | 473 | } |
473 | KConfig* KOPrefs::getConfig() | 474 | KConfig* KOPrefs::getConfig() |
474 | { | 475 | { |
475 | return config(); | 476 | return config(); |
476 | } | 477 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 8b849fa..6541af2 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,279 +1,280 @@ | |||
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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <libkdepim/kpimprefs.h> | 27 | #include <libkdepim/kpimprefs.h> |
28 | #include <qdict.h> | 28 | #include <qdict.h> |
29 | 29 | ||
30 | class KConfig; | 30 | class KConfig; |
31 | class QFont; | 31 | class QFont; |
32 | class QColor; | 32 | class QColor; |
33 | class QStringList; | 33 | class QStringList; |
34 | 34 | ||
35 | class KOPrefs : public KPimPrefs | 35 | class KOPrefs : public KPimPrefs |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | enum { FormatVCalendar, FormatICalendar }; | 38 | enum { FormatVCalendar, FormatICalendar }; |
39 | enum { MailClientKMail, MailClientSendmail }; | 39 | enum { MailClientKMail, MailClientSendmail }; |
40 | enum { IMIPDummy, IMIPKMail }; | 40 | enum { IMIPDummy, IMIPKMail }; |
41 | enum { IMIPOutbox, IMIPdirectsend }; | 41 | enum { IMIPOutbox, IMIPdirectsend }; |
42 | enum { neverAuto, addressbookAuto, selectedAuto }; | 42 | enum { neverAuto, addressbookAuto, selectedAuto }; |
43 | enum { standardDestination, askDestination }; | 43 | enum { standardDestination, askDestination }; |
44 | 44 | ||
45 | virtual ~KOPrefs(); | 45 | virtual ~KOPrefs(); |
46 | 46 | ||
47 | /** Get instance of KOPrefs. It is made sure that there is only one | 47 | /** Get instance of KOPrefs. It is made sure that there is only one |
48 | instance. */ | 48 | instance. */ |
49 | static KOPrefs *instance(); | 49 | static KOPrefs *instance(); |
50 | 50 | ||
51 | /** Set preferences to default values */ | 51 | /** Set preferences to default values */ |
52 | void usrSetDefaults(); | 52 | void usrSetDefaults(); |
53 | 53 | ||
54 | /** Read preferences from config file */ | 54 | /** Read preferences from config file */ |
55 | void usrReadConfig(); | 55 | void usrReadConfig(); |
56 | 56 | ||
57 | /** Write preferences to config file */ | 57 | /** Write preferences to config file */ |
58 | void usrWriteConfig(); | 58 | void usrWriteConfig(); |
59 | void setCategoryDefaults(); | 59 | void setCategoryDefaults(); |
60 | 60 | ||
61 | protected: | 61 | protected: |
62 | void setTimeZoneIdDefault(); | 62 | void setTimeZoneIdDefault(); |
63 | 63 | ||
64 | /** Fill empty mail fields with default values. */ | 64 | /** Fill empty mail fields with default values. */ |
65 | void fillMailDefaults(); | 65 | void fillMailDefaults(); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 68 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
69 | object. */ | 69 | object. */ |
70 | KOPrefs(); | 70 | KOPrefs(); |
71 | 71 | ||
72 | static KOPrefs *mInstance; | 72 | static KOPrefs *mInstance; |
73 | QStringList getDefaultList(); | 73 | QStringList getDefaultList(); |
74 | public: | 74 | public: |
75 | // preferences data | 75 | // preferences data |
76 | KConfig* getConfig(); | 76 | KConfig* getConfig(); |
77 | void setFullName(const QString &); | 77 | void setFullName(const QString &); |
78 | QString fullName(); | 78 | QString fullName(); |
79 | void setEmail(const QString &); | 79 | void setEmail(const QString &); |
80 | QString email(); | 80 | QString email(); |
81 | 81 | ||
82 | QString mAdditional; | 82 | QString mAdditional; |
83 | 83 | ||
84 | bool mEmailControlCenter; | 84 | bool mEmailControlCenter; |
85 | 85 | ||
86 | bool mBcc; | 86 | bool mBcc; |
87 | bool mAutoSave; | 87 | bool mAutoSave; |
88 | int mAutoSaveInterval; | 88 | int mAutoSaveInterval; |
89 | bool mConfirm; | 89 | bool mConfirm; |
90 | 90 | ||
91 | bool mEnableGroupScheduling; | 91 | bool mEnableGroupScheduling; |
92 | bool mEnableProjectView; | 92 | bool mEnableProjectView; |
93 | 93 | ||
94 | int mDefaultFormat; | 94 | int mDefaultFormat; |
95 | int mMailClient; | 95 | int mMailClient; |
96 | 96 | ||
97 | int mStartTime; | 97 | int mStartTime; |
98 | int mDefaultDuration; | 98 | int mDefaultDuration; |
99 | int mAlarmTime; | 99 | int mAlarmTime; |
100 | 100 | ||
101 | int mWorkingHoursStart; | 101 | int mWorkingHoursStart; |
102 | int mWorkingHoursEnd; | 102 | int mWorkingHoursEnd; |
103 | bool mExcludeHolidays; | 103 | bool mExcludeHolidays; |
104 | bool mExcludeSaturdays; | 104 | bool mExcludeSaturdays; |
105 | bool mMarcusBainsShowSeconds; | 105 | bool mMarcusBainsShowSeconds; |
106 | 106 | ||
107 | QFont mTimeBarFont; | 107 | QFont mTimeBarFont; |
108 | QFont mMonthViewFont; | 108 | QFont mMonthViewFont; |
109 | QFont mAgendaViewFont; | 109 | QFont mAgendaViewFont; |
110 | QFont mMarcusBainsFont; | 110 | QFont mMarcusBainsFont; |
111 | QFont mTimeLabelsFont; | 111 | QFont mTimeLabelsFont; |
112 | QFont mTodoViewFont; | 112 | QFont mTodoViewFont; |
113 | QFont mListViewFont; | 113 | QFont mListViewFont; |
114 | QFont mDateNavigatorFont; | 114 | QFont mDateNavigatorFont; |
115 | QFont mEditBoxFont; | 115 | QFont mEditBoxFont; |
116 | QFont mJornalViewFont; | 116 | QFont mJornalViewFont; |
117 | QFont mWhatsNextFont; | 117 | QFont mWhatsNextFont; |
118 | QFont mEventViewFont; | 118 | QFont mEventViewFont; |
119 | 119 | ||
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | QColor mHolidayColor; | 123 | QColor mHolidayColor; |
124 | QColor mHighlightColor; | 124 | QColor mHighlightColor; |
125 | QColor mEventColor; | 125 | QColor mEventColor; |
126 | QColor mTodoDoneColor; | 126 | QColor mTodoDoneColor; |
127 | QColor mAgendaBgColor; | 127 | QColor mAgendaBgColor; |
128 | QColor mWorkingHoursColor; | 128 | QColor mWorkingHoursColor; |
129 | QColor mTodoDueTodayColor; | 129 | QColor mTodoDueTodayColor; |
130 | QColor mTodoOverdueColor; | 130 | QColor mTodoOverdueColor; |
131 | QColor mMonthViewEvenColor; | 131 | QColor mMonthViewEvenColor; |
132 | QColor mMonthViewOddColor; | 132 | QColor mMonthViewOddColor; |
133 | QColor mMonthViewHolidayColor; | 133 | QColor mMonthViewHolidayColor; |
134 | bool mMonthViewUsesDayColors; | 134 | bool mMonthViewUsesDayColors; |
135 | bool mMonthViewSatSunTog; | 135 | bool mMonthViewSatSunTog; |
136 | bool mMonthViewWeek; | ||
136 | QColor mAppColor1; | 137 | QColor mAppColor1; |
137 | QColor mAppColor2; | 138 | QColor mAppColor2; |
138 | bool mUseAppColors; | 139 | bool mUseAppColors; |
139 | 140 | ||
140 | int mDayBegins; | 141 | int mDayBegins; |
141 | int mHourSize; | 142 | int mHourSize; |
142 | int mAllDaySize; | 143 | int mAllDaySize; |
143 | bool mShowFullMenu; | 144 | bool mShowFullMenu; |
144 | bool mDailyRecur; | 145 | bool mDailyRecur; |
145 | bool mWeeklyRecur; | 146 | bool mWeeklyRecur; |
146 | bool mMonthDailyRecur; | 147 | bool mMonthDailyRecur; |
147 | bool mMonthWeeklyRecur; | 148 | bool mMonthWeeklyRecur; |
148 | bool mMonthShowIcons; | 149 | bool mMonthShowIcons; |
149 | bool mMonthShowShort; | 150 | bool mMonthShowShort; |
150 | bool mEnableToolTips; | 151 | bool mEnableToolTips; |
151 | bool mEnableMonthScroll; | 152 | bool mEnableMonthScroll; |
152 | bool mFullViewMonth; | 153 | bool mFullViewMonth; |
153 | bool mMonthViewUsesCategoryColor; | 154 | bool mMonthViewUsesCategoryColor; |
154 | bool mFullViewTodo; | 155 | bool mFullViewTodo; |
155 | bool mShowCompletedTodo; | 156 | bool mShowCompletedTodo; |
156 | bool mMarcusBainsEnabled; | 157 | bool mMarcusBainsEnabled; |
157 | int mNextXDays; | 158 | int mNextXDays; |
158 | int mWhatsNextDays; | 159 | int mWhatsNextDays; |
159 | int mWhatsNextPrios; | 160 | int mWhatsNextPrios; |
160 | bool mEnableQuickTodo; | 161 | bool mEnableQuickTodo; |
161 | 162 | ||
162 | bool mCompactDialogs; | 163 | bool mCompactDialogs; |
163 | bool mVerticalScreen; | 164 | bool mVerticalScreen; |
164 | 165 | ||
165 | bool mShowIconNewTodo; | 166 | bool mShowIconNewTodo; |
166 | bool mShowIconNewEvent; | 167 | bool mShowIconNewEvent; |
167 | bool mShowIconSearch; | 168 | bool mShowIconSearch; |
168 | bool mShowIconList; | 169 | bool mShowIconList; |
169 | bool mShowIconDay1; | 170 | bool mShowIconDay1; |
170 | bool mShowIconDay5; | 171 | bool mShowIconDay5; |
171 | bool mShowIconDay7; | 172 | bool mShowIconDay7; |
172 | bool mShowIconMonth; | 173 | bool mShowIconMonth; |
173 | bool mShowIconTodoview; | 174 | bool mShowIconTodoview; |
174 | bool mShowIconBackFast; | 175 | bool mShowIconBackFast; |
175 | bool mShowIconBack; | 176 | bool mShowIconBack; |
176 | bool mShowIconToday; | 177 | bool mShowIconToday; |
177 | bool mShowIconForward; | 178 | bool mShowIconForward; |
178 | bool mShowIconForwardFast; | 179 | bool mShowIconForwardFast; |
179 | bool mShowIconWhatsThis; | 180 | bool mShowIconWhatsThis; |
180 | bool mShowIconNextDays; | 181 | bool mShowIconNextDays; |
181 | bool mShowIconNext; | 182 | bool mShowIconNext; |
182 | bool mShowIconJournal; | 183 | bool mShowIconJournal; |
183 | 184 | ||
184 | bool mShowIconStretch; | 185 | bool mShowIconStretch; |
185 | 186 | ||
186 | bool mToolBarHor; | 187 | bool mToolBarHor; |
187 | bool mToolBarUp; | 188 | bool mToolBarUp; |
188 | bool mToolBarMiniIcons; | 189 | bool mToolBarMiniIcons; |
189 | 190 | ||
190 | bool mAskForQuit; | 191 | bool mAskForQuit; |
191 | bool mUsePassWd; | 192 | bool mUsePassWd; |
192 | bool mShowSyncEvents; | 193 | bool mShowSyncEvents; |
193 | bool mShowTodoInAgenda; | 194 | bool mShowTodoInAgenda; |
194 | bool mShowTimeInAgenda; | 195 | bool mShowTimeInAgenda; |
195 | bool mHideNonStartedTodos; | 196 | bool mHideNonStartedTodos; |
196 | 197 | ||
197 | int mLastSyncTime; | 198 | int mLastSyncTime; |
198 | void setCategoryColor(QString cat,const QColor & color); | 199 | void setCategoryColor(QString cat,const QColor & color); |
199 | QColor *categoryColor(QString cat); | 200 | QColor *categoryColor(QString cat); |
200 | 201 | ||
201 | QString mArchiveFile; | 202 | QString mArchiveFile; |
202 | QString mHtmlExportFile; | 203 | QString mHtmlExportFile; |
203 | bool mHtmlWithSave; | 204 | bool mHtmlWithSave; |
204 | 205 | ||
205 | QStringList mSelectedPlugins; | 206 | QStringList mSelectedPlugins; |
206 | 207 | ||
207 | QString mLastImportFile; | 208 | QString mLastImportFile; |
208 | QString mLastVcalFile; | 209 | QString mLastVcalFile; |
209 | QString mLastSaveFile; | 210 | QString mLastSaveFile; |
210 | QString mLastLoadFile; | 211 | QString mLastLoadFile; |
211 | 212 | ||
212 | 213 | ||
213 | QString mDefaultAlarmFile; | 214 | QString mDefaultAlarmFile; |
214 | int mIMIPScheduler; | 215 | int mIMIPScheduler; |
215 | int mIMIPSend; | 216 | int mIMIPSend; |
216 | QStringList mAdditionalMails; | 217 | QStringList mAdditionalMails; |
217 | int mIMIPAutoRefresh; | 218 | int mIMIPAutoRefresh; |
218 | int mIMIPAutoInsertReply; | 219 | int mIMIPAutoInsertReply; |
219 | int mIMIPAutoInsertRequest; | 220 | int mIMIPAutoInsertRequest; |
220 | int mIMIPAutoFreeBusy; | 221 | int mIMIPAutoFreeBusy; |
221 | int mIMIPAutoFreeBusyReply; | 222 | int mIMIPAutoFreeBusyReply; |
222 | 223 | ||
223 | QStringList mTodoTemplates; | 224 | QStringList mTodoTemplates; |
224 | QStringList mEventTemplates; | 225 | QStringList mEventTemplates; |
225 | 226 | ||
226 | int mDestination; | 227 | int mDestination; |
227 | 228 | ||
228 | 229 | ||
229 | bool mEditOnDoubleClick; | 230 | bool mEditOnDoubleClick; |
230 | bool mViewChangeHoldFullscreen; | 231 | bool mViewChangeHoldFullscreen; |
231 | bool mViewChangeHoldNonFullscreen; | 232 | bool mViewChangeHoldNonFullscreen; |
232 | bool mCenterOnCurrentTime; | 233 | bool mCenterOnCurrentTime; |
233 | bool mSetTimeToDayStartAt; | 234 | bool mSetTimeToDayStartAt; |
234 | bool mHighlightCurrentDay; | 235 | bool mHighlightCurrentDay; |
235 | bool mUseHighlightLightColor; | 236 | bool mUseHighlightLightColor; |
236 | bool mListViewMonthTimespan; | 237 | bool mListViewMonthTimespan; |
237 | bool mWNViewShowsParents; | 238 | bool mWNViewShowsParents; |
238 | bool mWNViewShowsPast; | 239 | bool mWNViewShowsPast; |
239 | bool mWNViewShowLocation; | 240 | bool mWNViewShowLocation; |
240 | bool mTodoViewShowsPercentage; | 241 | bool mTodoViewShowsPercentage; |
241 | bool mTodoViewUsesCatColors; | 242 | bool mTodoViewUsesCatColors; |
242 | bool mTodoViewUsesSmallFont; | 243 | bool mTodoViewUsesSmallFont; |
243 | bool mTodoViewUsesForegroundColor; | 244 | bool mTodoViewUsesForegroundColor; |
244 | bool mMonthViewUsesForegroundColor; | 245 | bool mMonthViewUsesForegroundColor; |
245 | 246 | ||
246 | bool mHightlightDateTimeEdit; | 247 | bool mHightlightDateTimeEdit; |
247 | bool mShortDateInViewer; | 248 | bool mShortDateInViewer; |
248 | 249 | ||
249 | bool mShowDateNavigator; | 250 | bool mShowDateNavigator; |
250 | 251 | ||
251 | QStringList mLocationDefaults; | 252 | QStringList mLocationDefaults; |
252 | QStringList mEventSummaryUser; | 253 | QStringList mEventSummaryUser; |
253 | QStringList mTodoSummaryUser; | 254 | QStringList mTodoSummaryUser; |
254 | 255 | ||
255 | bool mUseInternalAlarmNotification; | 256 | bool mUseInternalAlarmNotification; |
256 | int mAlarmPlayBeeps; | 257 | int mAlarmPlayBeeps; |
257 | int mAlarmSuspendTime; | 258 | int mAlarmSuspendTime; |
258 | int mAlarmSuspendCount; | 259 | int mAlarmSuspendCount; |
259 | int mAlarmBeepInterval; | 260 | int mAlarmBeepInterval; |
260 | int mOldLanguage; | 261 | int mOldLanguage; |
261 | int mOldLoadedLanguage; | 262 | int mOldLoadedLanguage; |
262 | 263 | ||
263 | 264 | ||
264 | QString mActiveSyncPort; | 265 | QString mActiveSyncPort; |
265 | QString mActiveSyncIP; | 266 | QString mActiveSyncIP; |
266 | 267 | ||
267 | private: | 268 | private: |
268 | QDict<QColor> mCategoryColors; | 269 | QDict<QColor> mCategoryColors; |
269 | QColor mDefaultCategoryColor; | 270 | QColor mDefaultCategoryColor; |
270 | 271 | ||
271 | QFont mDefaultTimeBarFont; | 272 | QFont mDefaultTimeBarFont; |
272 | QFont mDefaultViewFont; | 273 | QFont mDefaultViewFont; |
273 | QFont mDefaultMonthViewFont; | 274 | QFont mDefaultMonthViewFont; |
274 | 275 | ||
275 | QString mName; | 276 | QString mName; |
276 | QString mEmail; | 277 | QString mEmail; |
277 | }; | 278 | }; |
278 | 279 | ||
279 | #endif | 280 | #endif |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 7e126d9..6afd203 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,659 +1,665 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001 | 4 | Copyright (c) 2001 |
5 | Cornelius Schumacher <schumacher@kde.org> | 5 | Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") showMonthView(); | 91 | else if (view == "Month") showMonthView(); |
92 | else if (view == "List") showListView(); | 92 | else if (view == "List") showListView(); |
93 | else if (view == "Journal") showJournalView(); | 93 | else if (view == "Journal") showJournalView(); |
94 | else if (view == "TimeSpan") showTimeSpanView(); | 94 | else if (view == "TimeSpan") showTimeSpanView(); |
95 | else if (view == "Todo") showTodoView(); | 95 | else if (view == "Todo") showTodoView(); |
96 | else { | 96 | else { |
97 | showAgendaView(); | 97 | showAgendaView(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | void KOViewManager::showDateView( int view, QDate date) | 101 | void KOViewManager::showDateView( int view, QDate date) |
102 | { | 102 | { |
103 | static int lastMode = 0; | 103 | static int lastMode = 0; |
104 | static int lastCount = 0; | 104 | static int lastCount = 0; |
105 | static bool lastNDMode = false; | 105 | static bool lastNDMode = false; |
106 | static QDate lastDate; | 106 | static QDate lastDate; |
107 | //qDebug("date %d %s", view, date.toString().latin1()); | 107 | //qDebug("date %d %s", view, date.toString().latin1()); |
108 | 108 | ||
109 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); | 109 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); |
110 | bool savemFlagShowNextxDays = mFlagShowNextxDays; | 110 | bool savemFlagShowNextxDays = mFlagShowNextxDays; |
111 | mFlagShowNextxDays = false; | 111 | mFlagShowNextxDays = false; |
112 | if ( view == 3 ) { | 112 | if ( view == 3 ) { |
113 | //mCurrentAgendaView = 1 ; | 113 | //mCurrentAgendaView = 1 ; |
114 | lastDate = mMainView->dateNavigator()->selectedDates().first(); | 114 | lastDate = mMainView->dateNavigator()->selectedDates().first(); |
115 | lastCount = mMainView->dateNavigator()->selectedDates().count(); | 115 | lastCount = mMainView->dateNavigator()->selectedDates().count(); |
116 | lastNDMode = savemFlagShowNextxDays; | 116 | lastNDMode = savemFlagShowNextxDays; |
117 | mMainView->showDay( date ); | 117 | mMainView->showDay( date ); |
118 | } else if (view == 4 ) { | 118 | } else if (view == 4 ) { |
119 | mCurrentAgendaView = 7 ; | 119 | mCurrentAgendaView = 7 ; |
120 | mMainView->dateNavigator()->selectDates( date, 7 ); | 120 | mMainView->dateNavigator()->selectDates( date, 7 ); |
121 | } else if (view == 5 ) { | 121 | } else if (view == 5 ) { |
122 | mCurrentAgendaView = 14 ; | 122 | mCurrentAgendaView = 14 ; |
123 | mMainView->dateNavigator()->selectDates( date, 14); | 123 | mMainView->dateNavigator()->selectDates( date, 14); |
124 | } else if (view == 6 ) { | 124 | } else if (view == 6 ) { |
125 | mMainView->dateNavigator()->blockSignals( true ); | 125 | mMainView->dateNavigator()->blockSignals( true ); |
126 | showMonthView(); | 126 | showMonthView(); |
127 | mMainView->dateNavigator()->selectMonthByDate( date ); | 127 | mMainView->dateNavigator()->selectMonthByDate( date ); |
128 | mMainView->dateNavigator()->blockSignals( false ); | 128 | mMainView->dateNavigator()->blockSignals( false ); |
129 | mMainView->dateNavigator()->selectDate( date ); | 129 | mMainView->dateNavigator()->selectDate( date ); |
130 | } else if (view == 7 ) { | 130 | } else if (view == 7 ) { |
131 | mMainView->dateNavigator()->selectDate( date ); | 131 | mMainView->dateNavigator()->selectDate( date ); |
132 | showJournalView(); | 132 | showJournalView(); |
133 | } else if (view == 8 ) { | 133 | } else if (view == 8 ) { |
134 | globalFlagBlockAgenda = 1; | 134 | globalFlagBlockAgenda = 1; |
135 | if ( mCurrentAgendaView != 3 ) | 135 | if ( mCurrentAgendaView != 3 ) |
136 | mCurrentAgendaView = -1; | 136 | mCurrentAgendaView = -1; |
137 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 137 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
138 | globalFlagBlockAgenda = 2; | 138 | globalFlagBlockAgenda = 2; |
139 | mMainView->dateNavigator()->selectDates( date , | 139 | mMainView->dateNavigator()->selectDates( date , |
140 | KOPrefs::instance()->mNextXDays ); | 140 | KOPrefs::instance()->mNextXDays ); |
141 | mFlagShowNextxDays = true; | 141 | mFlagShowNextxDays = true; |
142 | mCurrentAgendaView = 3 ; | 142 | mCurrentAgendaView = 3 ; |
143 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) | 143 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) |
144 | if ( lastMode ) { | 144 | if ( lastMode ) { |
145 | mCurrentAgendaView = lastCount ; | 145 | mCurrentAgendaView = lastCount ; |
146 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); | 146 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); |
147 | mFlagShowNextxDays = lastNDMode; | 147 | mFlagShowNextxDays = lastNDMode; |
148 | if ( mFlagShowNextxDays ) { | 148 | if ( mFlagShowNextxDays ) { |
149 | mCurrentAgendaView = 3 ; | 149 | mCurrentAgendaView = 3 ; |
150 | } | 150 | } |
151 | } else | 151 | } else |
152 | showWeekView(); | 152 | showWeekView(); |
153 | } else if (view == 10) { | 153 | } else if (view == 10) { |
154 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); | 154 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); |
155 | } | 155 | } |
156 | lastMode = view; | 156 | lastMode = view; |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | 160 | ||
161 | void KOViewManager::writeSettings(KConfig *config) | 161 | void KOViewManager::writeSettings(KConfig *config) |
162 | { | 162 | { |
163 | config->setGroup("General"); | 163 | config->setGroup("General"); |
164 | 164 | ||
165 | QString view; | 165 | QString view; |
166 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 166 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
167 | else if (mCurrentView == mMonthView) view = "Month"; | 167 | else if (mCurrentView == mMonthView) view = "Month"; |
168 | else if (mCurrentView == mListView) view = "List"; | 168 | else if (mCurrentView == mListView) view = "List"; |
169 | else if (mCurrentView == mJournalView) view = "Journal"; | 169 | else if (mCurrentView == mJournalView) view = "Journal"; |
170 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 170 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
171 | else if (mCurrentView == mTodoView) view = "Todo"; | 171 | else if (mCurrentView == mTodoView) view = "Todo"; |
172 | else view = "Agenda"; | 172 | else view = "Agenda"; |
173 | 173 | ||
174 | config->writeEntry("Current View",view); | 174 | config->writeEntry("Current View",view); |
175 | 175 | ||
176 | if (mAgendaView) { | 176 | if (mAgendaView) { |
177 | mAgendaView->writeSettings(config); | 177 | mAgendaView->writeSettings(config); |
178 | } | 178 | } |
179 | if (mTimeSpanView) { | 179 | if (mTimeSpanView) { |
180 | mTimeSpanView->writeSettings(config); | 180 | mTimeSpanView->writeSettings(config); |
181 | } | 181 | } |
182 | if (mListView) { | 182 | if (mListView) { |
183 | mListView->writeSettings(config); | 183 | mListView->writeSettings(config); |
184 | } | 184 | } |
185 | if (mTodoView) { | 185 | if (mTodoView) { |
186 | mTodoView->saveLayout(config,"Todo View"); | 186 | mTodoView->saveLayout(config,"Todo View"); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 190 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
191 | { | 191 | { |
192 | 192 | ||
193 | //mFlagShowNextxDays = false; | 193 | //mFlagShowNextxDays = false; |
194 | //if(view == mCurrentView) return; | 194 | //if(view == mCurrentView) return; |
195 | if ( view == 0 ) { | 195 | if ( view == 0 ) { |
196 | view = mCurrentView; | 196 | view = mCurrentView; |
197 | if ( view == 0 ) | 197 | if ( view == 0 ) |
198 | return; | 198 | return; |
199 | } | 199 | } |
200 | bool full = fullScreen; | 200 | bool full = fullScreen; |
201 | if(view == mCurrentView && view != mWhatsNextView ) { | 201 | if(view == mCurrentView && view != mWhatsNextView ) { |
202 | if ( mCurrentAgendaView < 0 ) | 202 | if ( mCurrentAgendaView < 0 ) |
203 | return; | 203 | return; |
204 | full = mMainView->leftFrame()->isVisible(); | 204 | full = mMainView->leftFrame()->isVisible(); |
205 | } else { | 205 | } else { |
206 | mCurrentView = view; | 206 | mCurrentView = view; |
207 | // bool full = fullScreen; | 207 | // bool full = fullScreen; |
208 | bool isFull = !mMainView->leftFrame()->isVisible(); | 208 | bool isFull = !mMainView->leftFrame()->isVisible(); |
209 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 209 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
210 | full = true; | 210 | full = true; |
211 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 211 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
212 | full = false; | 212 | full = false; |
213 | } | 213 | } |
214 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 214 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
215 | //raiseCurrentView( full ); | 215 | //raiseCurrentView( full ); |
216 | mMainView->processIncidenceSelection( 0 ); | 216 | mMainView->processIncidenceSelection( 0 ); |
217 | //mMainView->updateView(); | 217 | //mMainView->updateView(); |
218 | raiseCurrentView( full, true ); | 218 | raiseCurrentView( full, true ); |
219 | mMainView->adaptNavigationUnits(); | 219 | mMainView->adaptNavigationUnits(); |
220 | } | 220 | } |
221 | 221 | ||
222 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) | 222 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) |
223 | { | 223 | { |
224 | mCurrentAgendaView = 0; | 224 | mCurrentAgendaView = 0; |
225 | int wid = mMainView->width() ; | 225 | int wid = mMainView->width() ; |
226 | int hei = mMainView->height(); | 226 | int hei = mMainView->height(); |
227 | if ( mCurrentView == mMonthView ) { | 227 | if ( mCurrentView == mMonthView ) { |
228 | mMainView->navigatorBar()->show(); | 228 | if ( !KOPrefs::instance()->mMonthViewWeek ) { |
229 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 229 | mMainView->navigatorBar()->show(); |
230 | hei -= mMainView->navigatorBar()->sizeHint().height(); | ||
231 | } | ||
230 | //mMainView->navigatorBar()->hide(); | 232 | //mMainView->navigatorBar()->hide(); |
231 | } else { | 233 | } else { |
232 | mMainView->navigatorBar()->hide(); | 234 | mMainView->navigatorBar()->hide(); |
233 | } | 235 | } |
234 | if ( fullScreen ) { | 236 | if ( fullScreen ) { |
235 | mMainView->leftFrame()->hide(); | 237 | mMainView->leftFrame()->hide(); |
236 | } else { | 238 | } else { |
237 | mMainView->leftFrame()->show(); | 239 | mMainView->leftFrame()->show(); |
238 | if ( KOPrefs::instance()->mVerticalScreen ) | 240 | if ( KOPrefs::instance()->mVerticalScreen ) |
239 | hei -= mMainView->leftFrame()->height(); | 241 | hei -= mMainView->leftFrame()->height(); |
240 | else | 242 | else |
241 | wid -= mMainView->leftFrame()->width(); | 243 | wid -= mMainView->leftFrame()->width(); |
242 | } | 244 | } |
243 | emit signalFullScreen( !fullScreen ); | 245 | emit signalFullScreen( !fullScreen ); |
244 | if ( callUpdateView ) | 246 | if ( callUpdateView ) |
245 | mMainView->updateView(); | 247 | mMainView->updateView(); |
246 | 248 | ||
247 | if ( globalFlagBlockAgenda == 5 ) { | 249 | if ( globalFlagBlockAgenda == 5 ) { |
248 | globalFlagBlockAgenda = 4; | 250 | globalFlagBlockAgenda = 4; |
249 | globalFlagBlockAgendaItemPaint = 1; | 251 | globalFlagBlockAgendaItemPaint = 1; |
250 | } | 252 | } |
251 | mMainView->viewStack()->raiseWidget(mCurrentView); | 253 | mMainView->viewStack()->raiseWidget(mCurrentView); |
252 | if ( globalFlagBlockAgenda == 4 ) { | 254 | if ( globalFlagBlockAgenda == 4 ) { |
253 | if ( mCurrentView == mAgendaView ) { | 255 | if ( mCurrentView == mAgendaView ) { |
254 | //globalFlagBlockAgenda =1 ; | 256 | //globalFlagBlockAgenda =1 ; |
255 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 257 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
256 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 258 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
257 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 259 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
258 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 260 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
259 | qApp->processEvents(); | 261 | qApp->processEvents(); |
260 | //qDebug("qApp->processEvents() "); | 262 | //qDebug("qApp->processEvents() "); |
261 | globalFlagBlockAgenda = 0; | 263 | globalFlagBlockAgenda = 0; |
262 | mAgendaView->repaintAgenda(); | 264 | mAgendaView->repaintAgenda(); |
263 | 265 | ||
264 | } | 266 | } |
265 | globalFlagBlockAgenda = 0; | 267 | globalFlagBlockAgenda = 0; |
266 | } | 268 | } |
267 | emit signalAgendaView( mCurrentView == mAgendaView ); | 269 | emit signalAgendaView( mCurrentView == mAgendaView ); |
268 | //qDebug("raiseCurrentView ende "); | 270 | //qDebug("raiseCurrentView ende "); |
269 | 271 | ||
270 | } | 272 | } |
271 | 273 | ||
272 | void KOViewManager::updateView() | 274 | void KOViewManager::updateView() |
273 | { | 275 | { |
274 | // qDebug("KOViewManager::updateView() "); | 276 | // qDebug("KOViewManager::updateView() "); |
275 | // if we are updating mTodoView, we get endless recursion | 277 | // if we are updating mTodoView, we get endless recursion |
276 | if ( mTodoView == mCurrentView ) | 278 | if ( mTodoView == mCurrentView ) |
277 | return; | 279 | return; |
278 | if ( mCurrentView ) mCurrentView->updateView(); | 280 | if ( mCurrentView ) mCurrentView->updateView(); |
279 | 281 | ||
280 | } | 282 | } |
281 | 283 | ||
282 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 284 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
283 | { | 285 | { |
284 | // kdDebug() << "KOViewManager::updateView()" << endl; | 286 | // kdDebug() << "KOViewManager::updateView()" << endl; |
285 | 287 | ||
286 | if (mCurrentView) mCurrentView->showDates(start, end); | 288 | if (mCurrentView) mCurrentView->showDates(start, end); |
287 | 289 | ||
288 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); | 290 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); |
289 | } | 291 | } |
290 | 292 | ||
291 | 293 | ||
292 | void KOViewManager::updateWNview() | 294 | void KOViewManager::updateWNview() |
293 | { | 295 | { |
294 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 296 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
295 | mWhatsNextView->updateView(); | 297 | mWhatsNextView->updateView(); |
296 | 298 | ||
297 | } | 299 | } |
298 | void KOViewManager::showWhatsNextView() | 300 | void KOViewManager::showWhatsNextView() |
299 | { | 301 | { |
300 | if (!mWhatsNextView) { | 302 | if (!mWhatsNextView) { |
301 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 303 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
302 | "KOViewManager::WhatsNextView"); | 304 | "KOViewManager::WhatsNextView"); |
303 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 305 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
304 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 306 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
305 | addView(mWhatsNextView); | 307 | addView(mWhatsNextView); |
306 | connect(this, SIGNAL( printWNV() ), | 308 | connect(this, SIGNAL( printWNV() ), |
307 | mWhatsNextView, SLOT( printMe() ) ); | 309 | mWhatsNextView, SLOT( printMe() ) ); |
308 | } | 310 | } |
309 | globalFlagBlockAgenda = 1; | 311 | globalFlagBlockAgenda = 1; |
310 | showView(mWhatsNextView, true ); | 312 | showView(mWhatsNextView, true ); |
311 | //mWhatsNextView->updateView(); | 313 | //mWhatsNextView->updateView(); |
312 | 314 | ||
313 | } | 315 | } |
314 | 316 | ||
315 | void KOViewManager::showListView() | 317 | void KOViewManager::showListView() |
316 | { | 318 | { |
317 | if (!mListView) { | 319 | if (!mListView) { |
318 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 320 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
319 | addView(mListView); | 321 | addView(mListView); |
320 | 322 | ||
321 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 323 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
322 | mMainView, SLOT(showIncidence(Incidence *))); | 324 | mMainView, SLOT(showIncidence(Incidence *))); |
323 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 325 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
324 | mMainView, SLOT(editIncidence(Incidence *))); | 326 | mMainView, SLOT(editIncidence(Incidence *))); |
325 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 327 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
326 | mMainView, SLOT(deleteIncidence(Incidence *))); | 328 | mMainView, SLOT(deleteIncidence(Incidence *))); |
327 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 329 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
328 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 330 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
329 | connect( mListView, SIGNAL( signalNewEvent() ), | 331 | connect( mListView, SIGNAL( signalNewEvent() ), |
330 | mMainView, SLOT( newEvent() ) ); | 332 | mMainView, SLOT( newEvent() ) ); |
331 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 333 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
332 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 334 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
333 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 335 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
334 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 336 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
335 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 337 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
336 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 338 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
337 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 339 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
338 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 340 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
339 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 341 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
340 | } | 342 | } |
341 | // bool temp = mFlagShowNextxDays; | 343 | // bool temp = mFlagShowNextxDays; |
342 | //globalFlagBlockPainting = true; | 344 | //globalFlagBlockPainting = true; |
343 | globalFlagBlockAgenda = 1; | 345 | globalFlagBlockAgenda = 1; |
344 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 346 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
345 | mMainView->setBlockShowDates( true ); | 347 | mMainView->setBlockShowDates( true ); |
346 | mMainView->dateNavigator()->selectMonth(); | 348 | mMainView->dateNavigator()->selectMonth(); |
347 | mMainView->setBlockShowDates( false ); | 349 | mMainView->setBlockShowDates( false ); |
348 | } | 350 | } |
349 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 351 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
350 | //mFlagShowNextxDays = temp; | 352 | //mFlagShowNextxDays = temp; |
351 | } | 353 | } |
352 | 354 | ||
353 | void KOViewManager::showAgendaView( bool fullScreen ) | 355 | void KOViewManager::showAgendaView( bool fullScreen ) |
354 | { | 356 | { |
355 | 357 | ||
356 | mMainView->dialogManager()->hideSearchDialog(); | 358 | mMainView->dialogManager()->hideSearchDialog(); |
357 | // qDebug("KOViewManager::showAgendaView "); | 359 | // qDebug("KOViewManager::showAgendaView "); |
358 | bool full; | 360 | bool full; |
359 | full = fullScreen; | 361 | full = fullScreen; |
360 | if (!mAgendaView) { | 362 | if (!mAgendaView) { |
361 | full = false; | 363 | full = false; |
362 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 364 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
363 | addView(mAgendaView); | 365 | addView(mAgendaView); |
364 | #ifndef DESKTOP_VERSION | 366 | #ifndef DESKTOP_VERSION |
365 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 367 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
366 | #endif | 368 | #endif |
367 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 369 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
368 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 370 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
369 | 371 | ||
370 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 372 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
371 | 373 | ||
372 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 374 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
373 | 375 | ||
374 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 376 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
375 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 377 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
376 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 378 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
377 | mMainView, SLOT(newEvent(QDateTime))); | 379 | mMainView, SLOT(newEvent(QDateTime))); |
378 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 380 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
379 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 381 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
380 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 382 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
381 | mMainView, SLOT(newEvent(QDate))); | 383 | mMainView, SLOT(newEvent(QDate))); |
382 | 384 | ||
383 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 385 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
384 | mMainView, SLOT(editIncidence(Incidence *))); | 386 | mMainView, SLOT(editIncidence(Incidence *))); |
385 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 387 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
386 | mMainView, SLOT(showIncidence(Incidence *))); | 388 | mMainView, SLOT(showIncidence(Incidence *))); |
387 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 389 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
388 | mMainView, SLOT(deleteIncidence(Incidence *))); | 390 | mMainView, SLOT(deleteIncidence(Incidence *))); |
389 | 391 | ||
390 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 392 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
391 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 393 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
392 | 394 | ||
393 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 395 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
394 | mMainView, SLOT( toggleExpand() ) ); | 396 | mMainView, SLOT( toggleExpand() ) ); |
395 | 397 | ||
396 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 398 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
397 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 399 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
398 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 400 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
399 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 401 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
400 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 402 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
401 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 403 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
402 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 404 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
403 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 405 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
404 | SLOT( updateTodo( Todo *, int ) ) ); | 406 | SLOT( updateTodo( Todo *, int ) ) ); |
405 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 407 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
406 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 408 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
407 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 409 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
408 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 410 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
409 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 411 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
410 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 412 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
411 | mAgendaView->readSettings(); | 413 | mAgendaView->readSettings(); |
412 | mAgendaView->updateConfig(); | 414 | mAgendaView->updateConfig(); |
413 | } | 415 | } |
414 | 416 | ||
415 | showView( mAgendaView, full); | 417 | showView( mAgendaView, full); |
416 | 418 | ||
417 | } | 419 | } |
418 | 420 | ||
419 | void KOViewManager::showDayView() | 421 | void KOViewManager::showDayView() |
420 | { | 422 | { |
421 | mFlagShowNextxDays = false; | 423 | mFlagShowNextxDays = false; |
422 | globalFlagBlockLabel = 1; | 424 | globalFlagBlockLabel = 1; |
423 | globalFlagBlockAgenda = 1; | 425 | globalFlagBlockAgenda = 1; |
424 | if ( mCurrentAgendaView != 1 ) | 426 | if ( mCurrentAgendaView != 1 ) |
425 | mCurrentAgendaView = -1; | 427 | mCurrentAgendaView = -1; |
426 | showAgendaView(); | 428 | showAgendaView(); |
427 | qApp->processEvents(); | 429 | qApp->processEvents(); |
428 | globalFlagBlockAgenda = 2; | 430 | globalFlagBlockAgenda = 2; |
429 | globalFlagBlockLabel = 0; | 431 | globalFlagBlockLabel = 0; |
430 | mMainView->dateNavigator()->selectDates( 1 ); | 432 | mMainView->dateNavigator()->selectDates( 1 ); |
431 | mCurrentAgendaView = 1 ; | 433 | mCurrentAgendaView = 1 ; |
432 | 434 | ||
433 | } | 435 | } |
434 | 436 | ||
435 | void KOViewManager::showWorkWeekView() | 437 | void KOViewManager::showWorkWeekView() |
436 | { | 438 | { |
437 | mFlagShowNextxDays = false; | 439 | mFlagShowNextxDays = false; |
438 | globalFlagBlockAgenda = 1; | 440 | globalFlagBlockAgenda = 1; |
439 | globalFlagBlockLabel = 1; | 441 | globalFlagBlockLabel = 1; |
440 | if ( mCurrentAgendaView != 5 ) | 442 | if ( mCurrentAgendaView != 5 ) |
441 | mCurrentAgendaView = -1; | 443 | mCurrentAgendaView = -1; |
442 | showAgendaView(); | 444 | showAgendaView(); |
443 | qApp->processEvents(); | 445 | qApp->processEvents(); |
444 | globalFlagBlockAgenda = 2; | 446 | globalFlagBlockAgenda = 2; |
445 | globalFlagBlockLabel = 0; | 447 | globalFlagBlockLabel = 0; |
446 | mMainView->dateNavigator()->selectWorkWeek(); | 448 | mMainView->dateNavigator()->selectWorkWeek(); |
447 | mCurrentAgendaView = 5 ; | 449 | mCurrentAgendaView = 5 ; |
448 | 450 | ||
449 | } | 451 | } |
450 | 452 | ||
451 | void KOViewManager::showWeekView() | 453 | void KOViewManager::showWeekView() |
452 | { | 454 | { |
453 | /* | 455 | /* |
454 | globalFlagBlockAgenda = 2; | 456 | globalFlagBlockAgenda = 2; |
455 | qDebug("4globalFlagBlockAgenda = 2; "); | 457 | qDebug("4globalFlagBlockAgenda = 2; "); |
456 | //globalFlagBlockPainting = true; | 458 | //globalFlagBlockPainting = true; |
457 | mMainView->dateNavigator()->selectWeek(); | 459 | mMainView->dateNavigator()->selectWeek(); |
458 | showAgendaView(); | 460 | showAgendaView(); |
459 | */ | 461 | */ |
460 | 462 | ||
461 | 463 | ||
462 | mFlagShowNextxDays = false; | 464 | mFlagShowNextxDays = false; |
463 | globalFlagBlockAgenda = 1; | 465 | globalFlagBlockAgenda = 1; |
464 | globalFlagBlockLabel = 1; | 466 | globalFlagBlockLabel = 1; |
465 | if ( mCurrentAgendaView != 7 ) | 467 | if ( mCurrentAgendaView != 7 ) |
466 | mCurrentAgendaView = -1; | 468 | mCurrentAgendaView = -1; |
467 | showAgendaView(); | 469 | showAgendaView(); |
468 | qApp->processEvents(); | 470 | qApp->processEvents(); |
469 | globalFlagBlockAgenda = 2; | 471 | globalFlagBlockAgenda = 2; |
470 | globalFlagBlockLabel = 0; | 472 | globalFlagBlockLabel = 0; |
471 | mMainView->dateNavigator()->selectWeek(); | 473 | mMainView->dateNavigator()->selectWeek(); |
472 | mCurrentAgendaView = 7 ; | 474 | mCurrentAgendaView = 7 ; |
473 | } | 475 | } |
474 | 476 | ||
475 | void KOViewManager::showNextXView() | 477 | void KOViewManager::showNextXView() |
476 | { | 478 | { |
477 | 479 | ||
478 | globalFlagBlockAgenda = 1; | 480 | globalFlagBlockAgenda = 1; |
479 | if ( mCurrentAgendaView != 3 ) | 481 | if ( mCurrentAgendaView != 3 ) |
480 | mCurrentAgendaView = -1; | 482 | mCurrentAgendaView = -1; |
481 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 483 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
482 | globalFlagBlockAgenda = 2; | 484 | globalFlagBlockAgenda = 2; |
483 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 485 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
484 | KOPrefs::instance()->mNextXDays ); | 486 | KOPrefs::instance()->mNextXDays ); |
485 | mFlagShowNextxDays = true; | 487 | mFlagShowNextxDays = true; |
486 | mCurrentAgendaView = 3 ; | 488 | mCurrentAgendaView = 3 ; |
487 | } | 489 | } |
488 | bool KOViewManager::showsNextDays() | 490 | bool KOViewManager::showsNextDays() |
489 | { | 491 | { |
490 | return mFlagShowNextxDays; | 492 | return mFlagShowNextxDays; |
491 | } | 493 | } |
492 | void KOViewManager::showMonthView() | 494 | void KOViewManager::showMonthView() |
493 | { | 495 | { |
494 | if (!mMonthView) { | 496 | if (!mMonthView) { |
495 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 497 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
496 | 498 | ||
497 | addView(mMonthView); | 499 | addView(mMonthView); |
498 | // mMonthView->show(); | 500 | // mMonthView->show(); |
499 | // SIGNALS/SLOTS FOR MONTH VIEW | 501 | // SIGNALS/SLOTS FOR MONTH VIEW |
500 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 502 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
501 | mMainView, SLOT(newEvent(QDateTime))); | 503 | mMainView, SLOT(newEvent(QDateTime))); |
502 | 504 | ||
503 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 505 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
504 | mMainView, SLOT(showIncidence(Incidence *))); | 506 | mMainView, SLOT(showIncidence(Incidence *))); |
505 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 507 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
506 | mMainView, SLOT(editIncidence(Incidence *))); | 508 | mMainView, SLOT(editIncidence(Incidence *))); |
507 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 509 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
508 | mMainView, SLOT(deleteIncidence(Incidence *))); | 510 | mMainView, SLOT(deleteIncidence(Incidence *))); |
509 | 511 | ||
510 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 512 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
511 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 513 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
512 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 514 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
513 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 515 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
514 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 516 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
515 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 517 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
516 | 518 | ||
517 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 519 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
518 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 520 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
519 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 521 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
520 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 522 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
521 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 523 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
522 | mMainView, SLOT ( selectWeekNum( int ) ) ); | 524 | mMainView, SLOT ( selectWeekNum( int ) ) ); |
523 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | 525 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), |
524 | mMainView, SLOT ( showDay( QDate ) ) ); | 526 | mMainView, SLOT ( showDay( QDate ) ) ); |
525 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 527 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
526 | connect( mMonthView, SIGNAL(nextMonth() ), | 528 | connect( mMonthView, SIGNAL(nextMonth() ), |
527 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); | 529 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); |
528 | connect( mMonthView, SIGNAL(prevMonth() ), | 530 | connect( mMonthView, SIGNAL(prevMonth() ), |
529 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | 531 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); |
530 | mMonthView->updateConfig(); | 532 | connect( mMonthView, SIGNAL( showNavigator(bool) ), |
533 | mMainView, SLOT ( showNavigatorBar(bool) ) ); | ||
531 | } | 534 | } |
532 | 535 | ||
533 | globalFlagBlockAgenda = 1; | 536 | globalFlagBlockAgenda = 1; |
534 | //mFlagShowNextxDays = false; | 537 | //mFlagShowNextxDays = false; |
535 | // if(mMonthView == mCurrentView) return; | 538 | // if(mMonthView == mCurrentView) return; |
536 | mMainView->dateNavigator()->selectMonth(); | 539 | if ( KOPrefs::instance()->mMonthViewWeek ) |
540 | mMainView->dateNavigator()->selectWeek(); | ||
541 | else | ||
542 | mMainView->dateNavigator()->selectMonth(); | ||
537 | 543 | ||
538 | showView(mMonthView, true ); | 544 | showView(mMonthView, true ); |
539 | 545 | ||
540 | } | 546 | } |
541 | 547 | ||
542 | void KOViewManager::showTodoView() | 548 | void KOViewManager::showTodoView() |
543 | { | 549 | { |
544 | //mFlagShowNextxDays = false; | 550 | //mFlagShowNextxDays = false; |
545 | if ( !mTodoView ) { | 551 | if ( !mTodoView ) { |
546 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 552 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
547 | "KOViewManager::TodoView" ); | 553 | "KOViewManager::TodoView" ); |
548 | 554 | ||
549 | addView( mTodoView ); | 555 | addView( mTodoView ); |
550 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 556 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
551 | 557 | ||
552 | // SIGNALS/SLOTS FOR TODO VIEW | 558 | // SIGNALS/SLOTS FOR TODO VIEW |
553 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 559 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
554 | mMainView, SLOT( newTodo() ) ); | 560 | mMainView, SLOT( newTodo() ) ); |
555 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 561 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
556 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 562 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
557 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 563 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
558 | mMainView, SLOT( showTodo( Todo * ) ) ); | 564 | mMainView, SLOT( showTodo( Todo * ) ) ); |
559 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 565 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
560 | mMainView, SLOT( editTodo( Todo * ) ) ); | 566 | mMainView, SLOT( editTodo( Todo * ) ) ); |
561 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 567 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
562 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 568 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
563 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 569 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
564 | mMainView, SLOT( purgeCompleted() ) ); | 570 | mMainView, SLOT( purgeCompleted() ) ); |
565 | 571 | ||
566 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 572 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
567 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 573 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
568 | 574 | ||
569 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 575 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
570 | SLOT( updateConfig() ) ); | 576 | SLOT( updateConfig() ) ); |
571 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 577 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
572 | SLOT( updateTodo( Todo *, int ) ) ); | 578 | SLOT( updateTodo( Todo *, int ) ) ); |
573 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 579 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
574 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 580 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
575 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 581 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
576 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 582 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
577 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 583 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
578 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 584 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
579 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 585 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
580 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 586 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
581 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 587 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
582 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); | 588 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); |
583 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | 589 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), |
584 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 590 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
585 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | 591 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), |
586 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 592 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
587 | KConfig *config = KOGlobals::config(); | 593 | KConfig *config = KOGlobals::config(); |
588 | mTodoView->restoreLayout(config,"Todo View"); | 594 | mTodoView->restoreLayout(config,"Todo View"); |
589 | mTodoView->setNavigator( mMainView->dateNavigator() ); | 595 | mTodoView->setNavigator( mMainView->dateNavigator() ); |
590 | } | 596 | } |
591 | 597 | ||
592 | globalFlagBlockAgenda = 1; | 598 | globalFlagBlockAgenda = 1; |
593 | showView( mTodoView, true ); | 599 | showView( mTodoView, true ); |
594 | 600 | ||
595 | } | 601 | } |
596 | 602 | ||
597 | void KOViewManager::showJournalView() | 603 | void KOViewManager::showJournalView() |
598 | { | 604 | { |
599 | //mFlagShowNextxDays = false; | 605 | //mFlagShowNextxDays = false; |
600 | if (!mJournalView) { | 606 | if (!mJournalView) { |
601 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | 607 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), |
602 | "KOViewManager::JournalView"); | 608 | "KOViewManager::JournalView"); |
603 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | 609 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, |
604 | SLOT( updateConfig() ) ); | 610 | SLOT( updateConfig() ) ); |
605 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | 611 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); |
606 | addView(mJournalView); | 612 | addView(mJournalView); |
607 | } | 613 | } |
608 | 614 | ||
609 | showView(mJournalView); | 615 | showView(mJournalView); |
610 | mMainView->dateNavigator()->selectDates( 1 ); | 616 | mMainView->dateNavigator()->selectDates( 1 ); |
611 | } | 617 | } |
612 | 618 | ||
613 | void KOViewManager::showTimeSpanView() | 619 | void KOViewManager::showTimeSpanView() |
614 | { | 620 | { |
615 | //mFlagShowNextxDays = false; | 621 | //mFlagShowNextxDays = false; |
616 | if (!mTimeSpanView) { | 622 | if (!mTimeSpanView) { |
617 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | 623 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), |
618 | "KOViewManager::TimeSpanView"); | 624 | "KOViewManager::TimeSpanView"); |
619 | addView(mTimeSpanView); | 625 | addView(mTimeSpanView); |
620 | 626 | ||
621 | mTimeSpanView->readSettings(); | 627 | mTimeSpanView->readSettings(); |
622 | } | 628 | } |
623 | 629 | ||
624 | showView(mTimeSpanView); | 630 | showView(mTimeSpanView); |
625 | } | 631 | } |
626 | 632 | ||
627 | Incidence *KOViewManager::currentSelection() | 633 | Incidence *KOViewManager::currentSelection() |
628 | { | 634 | { |
629 | if (!mCurrentView) return 0; | 635 | if (!mCurrentView) return 0; |
630 | if ( mCurrentView == mListView ) { | 636 | if ( mCurrentView == mListView ) { |
631 | if ( mListView->currentItem() ) | 637 | if ( mListView->currentItem() ) |
632 | return mListView->currentItem(); | 638 | return mListView->currentItem(); |
633 | } | 639 | } |
634 | return mCurrentView->selectedIncidences().first(); | 640 | return mCurrentView->selectedIncidences().first(); |
635 | } | 641 | } |
636 | 642 | ||
637 | QDate KOViewManager::currentSelectionDate() | 643 | QDate KOViewManager::currentSelectionDate() |
638 | { | 644 | { |
639 | QDate qd; | 645 | QDate qd; |
640 | if (mCurrentView) { | 646 | if (mCurrentView) { |
641 | DateList qvl = mCurrentView->selectedDates(); | 647 | DateList qvl = mCurrentView->selectedDates(); |
642 | if (!qvl.isEmpty()) qd = qvl.first(); | 648 | if (!qvl.isEmpty()) qd = qvl.first(); |
643 | } | 649 | } |
644 | return qd; | 650 | return qd; |
645 | } | 651 | } |
646 | 652 | ||
647 | void KOViewManager::addView(KOrg::BaseView *view) | 653 | void KOViewManager::addView(KOrg::BaseView *view) |
648 | { | 654 | { |
649 | #if QT_VERSION >= 0x030000 | 655 | #if QT_VERSION >= 0x030000 |
650 | mMainView->viewStack()->addWidget( view ); | 656 | mMainView->viewStack()->addWidget( view ); |
651 | #else | 657 | #else |
652 | mMainView->viewStack()->addWidget( view, 1 ); | 658 | mMainView->viewStack()->addWidget( view, 1 ); |
653 | #endif | 659 | #endif |
654 | } | 660 | } |
655 | 661 | ||
656 | void KOViewManager::setDocumentId( const QString &id ) | 662 | void KOViewManager::setDocumentId( const QString &id ) |
657 | { | 663 | { |
658 | if (mTodoView) mTodoView->setDocumentId( id ); | 664 | if (mTodoView) mTodoView->setDocumentId( id ); |
659 | } | 665 | } |