author | zautrix <zautrix> | 2004-09-22 06:39:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-22 06:39:51 (UTC) |
commit | c640aaff31f298b4aff7a61cbdfa9c8a95269479 (patch) (unidiff) | |
tree | 3fe1c1d16c63d03e7b1faec540df30b7a8e5c506 | |
parent | bbeffa56ee51d30b84bcadaf22234b8227958f31 (diff) | |
download | kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.zip kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.tar.gz kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.tar.bz2 |
modified file warning fix
-rw-r--r-- | korganizer/calendarview.cpp | 17 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 3 |
3 files changed, 18 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3635cfa..eaea040 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -749,1578 +749,1591 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
749 | } else { | 749 | } else { |
750 | //qDebug(" not loc changed "); | 750 | //qDebug(" not loc changed "); |
751 | lastSync = localMod.addDays( 1 ); | 751 | lastSync = localMod.addDays( 1 ); |
752 | if ( remCh ) | 752 | if ( remCh ) |
753 | remoteMod =( lastSync.addDays( 1 ) ); | 753 | remoteMod =( lastSync.addDays( 1 ) ); |
754 | 754 | ||
755 | } | 755 | } |
756 | } | 756 | } |
757 | full = true; | 757 | full = true; |
758 | if ( mode < SYNC_PREF_ASK ) | 758 | if ( mode < SYNC_PREF_ASK ) |
759 | mode = SYNC_PREF_ASK; | 759 | mode = SYNC_PREF_ASK; |
760 | } else { | 760 | } else { |
761 | if ( localMod == remoteMod ) | 761 | if ( localMod == remoteMod ) |
762 | if ( local->revision() == remote->revision() ) | 762 | if ( local->revision() == remote->revision() ) |
763 | return 0; | 763 | return 0; |
764 | 764 | ||
765 | } | 765 | } |
766 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 766 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
767 | 767 | ||
768 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 768 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
769 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 769 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
770 | //full = true; //debug only | 770 | //full = true; //debug only |
771 | if ( full ) { | 771 | if ( full ) { |
772 | bool equ = false; | 772 | bool equ = false; |
773 | if ( local->type() == "Event" ) { | 773 | if ( local->type() == "Event" ) { |
774 | equ = (*((Event*) local) == *((Event*) remote)); | 774 | equ = (*((Event*) local) == *((Event*) remote)); |
775 | } | 775 | } |
776 | else if ( local->type() =="Todo" ) | 776 | else if ( local->type() =="Todo" ) |
777 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 777 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
778 | else if ( local->type() =="Journal" ) | 778 | else if ( local->type() =="Journal" ) |
779 | equ = (*((Journal*) local) == *((Journal*) remote)); | 779 | equ = (*((Journal*) local) == *((Journal*) remote)); |
780 | if ( equ ) { | 780 | if ( equ ) { |
781 | //qDebug("equal "); | 781 | //qDebug("equal "); |
782 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 782 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
783 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 783 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
784 | } | 784 | } |
785 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 785 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
786 | return 0; | 786 | return 0; |
787 | 787 | ||
788 | }//else //debug only | 788 | }//else //debug only |
789 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 789 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
790 | } | 790 | } |
791 | int result; | 791 | int result; |
792 | bool localIsNew; | 792 | bool localIsNew; |
793 | //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() ); | 793 | //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() ); |
794 | 794 | ||
795 | if ( full && mode < SYNC_PREF_NEWEST ) | 795 | if ( full && mode < SYNC_PREF_NEWEST ) |
796 | mode = SYNC_PREF_ASK; | 796 | mode = SYNC_PREF_ASK; |
797 | 797 | ||
798 | switch( mode ) { | 798 | switch( mode ) { |
799 | case SYNC_PREF_LOCAL: | 799 | case SYNC_PREF_LOCAL: |
800 | if ( lastSync > remoteMod ) | 800 | if ( lastSync > remoteMod ) |
801 | return 1; | 801 | return 1; |
802 | if ( lastSync > localMod ) | 802 | if ( lastSync > localMod ) |
803 | return 2; | 803 | return 2; |
804 | return 1; | 804 | return 1; |
805 | break; | 805 | break; |
806 | case SYNC_PREF_REMOTE: | 806 | case SYNC_PREF_REMOTE: |
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 2; | 811 | return 2; |
812 | break; | 812 | break; |
813 | case SYNC_PREF_NEWEST: | 813 | case SYNC_PREF_NEWEST: |
814 | if ( localMod > remoteMod ) | 814 | if ( localMod > remoteMod ) |
815 | return 1; | 815 | return 1; |
816 | else | 816 | else |
817 | return 2; | 817 | return 2; |
818 | break; | 818 | break; |
819 | case SYNC_PREF_ASK: | 819 | case SYNC_PREF_ASK: |
820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
821 | if ( lastSync > remoteMod ) | 821 | if ( lastSync > remoteMod ) |
822 | return 1; | 822 | return 1; |
823 | if ( lastSync > localMod ) | 823 | if ( lastSync > localMod ) |
824 | return 2; | 824 | return 2; |
825 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 825 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
826 | localIsNew = localMod >= remoteMod; | 826 | localIsNew = localMod >= remoteMod; |
827 | if ( localIsNew ) | 827 | if ( localIsNew ) |
828 | getEventViewerDialog()->setColorMode( 1 ); | 828 | getEventViewerDialog()->setColorMode( 1 ); |
829 | else | 829 | else |
830 | getEventViewerDialog()->setColorMode( 2 ); | 830 | getEventViewerDialog()->setColorMode( 2 ); |
831 | getEventViewerDialog()->setIncidence(local); | 831 | getEventViewerDialog()->setIncidence(local); |
832 | if ( localIsNew ) | 832 | if ( localIsNew ) |
833 | getEventViewerDialog()->setColorMode( 2 ); | 833 | getEventViewerDialog()->setColorMode( 2 ); |
834 | else | 834 | else |
835 | getEventViewerDialog()->setColorMode( 1 ); | 835 | getEventViewerDialog()->setColorMode( 1 ); |
836 | getEventViewerDialog()->addIncidence(remote); | 836 | getEventViewerDialog()->addIncidence(remote); |
837 | getEventViewerDialog()->setColorMode( 0 ); | 837 | getEventViewerDialog()->setColorMode( 0 ); |
838 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 838 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
839 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 839 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
840 | getEventViewerDialog()->showMe(); | 840 | getEventViewerDialog()->showMe(); |
841 | result = getEventViewerDialog()->executeS( localIsNew ); | 841 | result = getEventViewerDialog()->executeS( localIsNew ); |
842 | return result; | 842 | return result; |
843 | 843 | ||
844 | break; | 844 | break; |
845 | case SYNC_PREF_FORCE_LOCAL: | 845 | case SYNC_PREF_FORCE_LOCAL: |
846 | return 1; | 846 | return 1; |
847 | break; | 847 | break; |
848 | case SYNC_PREF_FORCE_REMOTE: | 848 | case SYNC_PREF_FORCE_REMOTE: |
849 | return 2; | 849 | return 2; |
850 | break; | 850 | break; |
851 | 851 | ||
852 | default: | 852 | default: |
853 | // SYNC_PREF_TAKE_BOTH not implemented | 853 | // SYNC_PREF_TAKE_BOTH not implemented |
854 | break; | 854 | break; |
855 | } | 855 | } |
856 | return 0; | 856 | return 0; |
857 | } | 857 | } |
858 | Event* CalendarView::getLastSyncEvent() | 858 | Event* CalendarView::getLastSyncEvent() |
859 | { | 859 | { |
860 | Event* lse; | 860 | Event* lse; |
861 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 861 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
862 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 862 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
863 | if (!lse) { | 863 | if (!lse) { |
864 | lse = new Event(); | 864 | lse = new Event(); |
865 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 865 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
866 | QString sum = ""; | 866 | QString sum = ""; |
867 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 867 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
868 | sum = "E: "; | 868 | sum = "E: "; |
869 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 869 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
870 | lse->setDtStart( mLastCalendarSync ); | 870 | lse->setDtStart( mLastCalendarSync ); |
871 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 871 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
872 | lse->setCategories( i18n("SyncEvent") ); | 872 | lse->setCategories( i18n("SyncEvent") ); |
873 | lse->setReadOnly( true ); | 873 | lse->setReadOnly( true ); |
874 | mCalendar->addEvent( lse ); | 874 | mCalendar->addEvent( lse ); |
875 | } | 875 | } |
876 | 876 | ||
877 | return lse; | 877 | return lse; |
878 | 878 | ||
879 | } | 879 | } |
880 | // probaly useless | 880 | // probaly useless |
881 | void CalendarView::setupExternSyncProfiles() | 881 | void CalendarView::setupExternSyncProfiles() |
882 | { | 882 | { |
883 | Event* lse; | 883 | Event* lse; |
884 | mExternLastSyncEvent.clear(); | 884 | mExternLastSyncEvent.clear(); |
885 | int i; | 885 | int i; |
886 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 886 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
887 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 887 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
888 | if ( lse ) | 888 | if ( lse ) |
889 | mExternLastSyncEvent.append( lse ); | 889 | mExternLastSyncEvent.append( lse ); |
890 | else | 890 | else |
891 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 891 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
892 | } | 892 | } |
893 | 893 | ||
894 | } | 894 | } |
895 | // we check, if the to delete event has a id for a profile | 895 | // we check, if the to delete event has a id for a profile |
896 | // if yes, we set this id in the profile to delete | 896 | // if yes, we set this id in the profile to delete |
897 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 897 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
898 | { | 898 | { |
899 | if ( lastSync.count() == 0 ) { | 899 | if ( lastSync.count() == 0 ) { |
900 | //qDebug(" lastSync.count() == 0"); | 900 | //qDebug(" lastSync.count() == 0"); |
901 | return; | 901 | return; |
902 | } | 902 | } |
903 | if ( toDelete->type() == "Journal" ) | 903 | if ( toDelete->type() == "Journal" ) |
904 | return; | 904 | return; |
905 | 905 | ||
906 | Event* eve = lastSync.first(); | 906 | Event* eve = lastSync.first(); |
907 | 907 | ||
908 | while ( eve ) { | 908 | while ( eve ) { |
909 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 909 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
910 | if ( !id.isEmpty() ) { | 910 | if ( !id.isEmpty() ) { |
911 | QString des = eve->description(); | 911 | QString des = eve->description(); |
912 | QString pref = "e"; | 912 | QString pref = "e"; |
913 | if ( toDelete->type() == "Todo" ) | 913 | if ( toDelete->type() == "Todo" ) |
914 | pref = "t"; | 914 | pref = "t"; |
915 | des += pref+ id + ","; | 915 | des += pref+ id + ","; |
916 | eve->setReadOnly( false ); | 916 | eve->setReadOnly( false ); |
917 | eve->setDescription( des ); | 917 | eve->setDescription( des ); |
918 | //qDebug("setdes %s ", des.latin1()); | 918 | //qDebug("setdes %s ", des.latin1()); |
919 | eve->setReadOnly( true ); | 919 | eve->setReadOnly( true ); |
920 | } | 920 | } |
921 | eve = lastSync.next(); | 921 | eve = lastSync.next(); |
922 | } | 922 | } |
923 | 923 | ||
924 | } | 924 | } |
925 | void CalendarView::checkExternalId( Incidence * inc ) | 925 | void CalendarView::checkExternalId( Incidence * inc ) |
926 | { | 926 | { |
927 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 927 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
928 | checkExternSyncEvent( lastSync, inc ); | 928 | checkExternSyncEvent( lastSync, inc ); |
929 | 929 | ||
930 | } | 930 | } |
931 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 931 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
932 | { | 932 | { |
933 | bool syncOK = true; | 933 | bool syncOK = true; |
934 | int addedEvent = 0; | 934 | int addedEvent = 0; |
935 | int addedEventR = 0; | 935 | int addedEventR = 0; |
936 | int deletedEventR = 0; | 936 | int deletedEventR = 0; |
937 | int deletedEventL = 0; | 937 | int deletedEventL = 0; |
938 | int changedLocal = 0; | 938 | int changedLocal = 0; |
939 | int changedRemote = 0; | 939 | int changedRemote = 0; |
940 | //QPtrList<Event> el = local->rawEvents(); | 940 | //QPtrList<Event> el = local->rawEvents(); |
941 | Event* eventR; | 941 | Event* eventR; |
942 | QString uid; | 942 | QString uid; |
943 | int take; | 943 | int take; |
944 | Event* eventL; | 944 | Event* eventL; |
945 | Event* eventRSync; | 945 | Event* eventRSync; |
946 | Event* eventLSync; | 946 | Event* eventLSync; |
947 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 947 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
948 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 948 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
949 | bool fullDateRange = false; | 949 | bool fullDateRange = false; |
950 | local->resetTempSyncStat(); | 950 | local->resetTempSyncStat(); |
951 | mLastCalendarSync = QDateTime::currentDateTime(); | 951 | mLastCalendarSync = QDateTime::currentDateTime(); |
952 | QDateTime modifiedCalendar = mLastCalendarSync;; | 952 | QDateTime modifiedCalendar = mLastCalendarSync;; |
953 | eventLSync = getLastSyncEvent(); | 953 | eventLSync = getLastSyncEvent(); |
954 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 954 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
955 | if ( eventR ) { | 955 | if ( eventR ) { |
956 | eventRSync = (Event*) eventR->clone(); | 956 | eventRSync = (Event*) eventR->clone(); |
957 | remote->deleteEvent(eventR ); | 957 | remote->deleteEvent(eventR ); |
958 | 958 | ||
959 | } else { | 959 | } else { |
960 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 960 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
961 | eventRSync = (Event*)eventLSync->clone(); | 961 | eventRSync = (Event*)eventLSync->clone(); |
962 | } else { | 962 | } else { |
963 | fullDateRange = true; | 963 | fullDateRange = true; |
964 | eventRSync = new Event(); | 964 | eventRSync = new Event(); |
965 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 965 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
966 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 966 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
967 | eventRSync->setDtStart( mLastCalendarSync ); | 967 | eventRSync->setDtStart( mLastCalendarSync ); |
968 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 968 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
969 | eventRSync->setCategories( i18n("SyncEvent") ); | 969 | eventRSync->setCategories( i18n("SyncEvent") ); |
970 | } | 970 | } |
971 | } | 971 | } |
972 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 972 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
973 | fullDateRange = true; | 973 | fullDateRange = true; |
974 | 974 | ||
975 | if ( ! fullDateRange ) { | 975 | if ( ! fullDateRange ) { |
976 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 976 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
977 | 977 | ||
978 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 978 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
979 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 979 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
980 | fullDateRange = true; | 980 | fullDateRange = true; |
981 | } | 981 | } |
982 | } | 982 | } |
983 | if ( fullDateRange ) | 983 | if ( fullDateRange ) |
984 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 984 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
985 | else | 985 | else |
986 | mLastCalendarSync = eventLSync->dtStart(); | 986 | mLastCalendarSync = eventLSync->dtStart(); |
987 | // for resyncing if own file has changed | 987 | // for resyncing if own file has changed |
988 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 988 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
989 | mLastCalendarSync = loadedFileVersion; | 989 | mLastCalendarSync = loadedFileVersion; |
990 | qDebug("setting mLastCalendarSync "); | 990 | qDebug("setting mLastCalendarSync "); |
991 | } | 991 | } |
992 | //qDebug("*************************** "); | 992 | //qDebug("*************************** "); |
993 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 993 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
994 | QPtrList<Incidence> er = remote->rawIncidences(); | 994 | QPtrList<Incidence> er = remote->rawIncidences(); |
995 | Incidence* inR = er.first(); | 995 | Incidence* inR = er.first(); |
996 | Incidence* inL; | 996 | Incidence* inL; |
997 | QProgressBar bar( er.count(),0 ); | 997 | QProgressBar bar( er.count(),0 ); |
998 | bar.setCaption (i18n("Syncing - close to abort!") ); | 998 | bar.setCaption (i18n("Syncing - close to abort!") ); |
999 | 999 | ||
1000 | int w = 300; | 1000 | int w = 300; |
1001 | if ( QApplication::desktop()->width() < 320 ) | 1001 | if ( QApplication::desktop()->width() < 320 ) |
1002 | w = 220; | 1002 | w = 220; |
1003 | int h = bar.sizeHint().height() ; | 1003 | int h = bar.sizeHint().height() ; |
1004 | int dw = QApplication::desktop()->width(); | 1004 | int dw = QApplication::desktop()->width(); |
1005 | int dh = QApplication::desktop()->height(); | 1005 | int dh = QApplication::desktop()->height(); |
1006 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1006 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1007 | bar.show(); | 1007 | bar.show(); |
1008 | int modulo = (er.count()/10)+1; | 1008 | int modulo = (er.count()/10)+1; |
1009 | int incCounter = 0; | 1009 | int incCounter = 0; |
1010 | while ( inR ) { | 1010 | while ( inR ) { |
1011 | if ( ! bar.isVisible() ) | 1011 | if ( ! bar.isVisible() ) |
1012 | return false; | 1012 | return false; |
1013 | if ( incCounter % modulo == 0 ) | 1013 | if ( incCounter % modulo == 0 ) |
1014 | bar.setProgress( incCounter ); | 1014 | bar.setProgress( incCounter ); |
1015 | ++incCounter; | 1015 | ++incCounter; |
1016 | uid = inR->uid(); | 1016 | uid = inR->uid(); |
1017 | bool skipIncidence = false; | 1017 | bool skipIncidence = false; |
1018 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1018 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1019 | skipIncidence = true; | 1019 | skipIncidence = true; |
1020 | QString idS; | 1020 | QString idS; |
1021 | qApp->processEvents(); | 1021 | qApp->processEvents(); |
1022 | if ( !skipIncidence ) { | 1022 | if ( !skipIncidence ) { |
1023 | inL = local->incidence( uid ); | 1023 | inL = local->incidence( uid ); |
1024 | if ( inL ) { // maybe conflict - same uid in both calendars | 1024 | if ( inL ) { // maybe conflict - same uid in both calendars |
1025 | int maxrev = inL->revision(); | 1025 | int maxrev = inL->revision(); |
1026 | if ( maxrev < inR->revision() ) | 1026 | if ( maxrev < inR->revision() ) |
1027 | maxrev = inR->revision(); | 1027 | maxrev = inR->revision(); |
1028 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1028 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1029 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1029 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1030 | if ( take == 3 ) | 1030 | if ( take == 3 ) |
1031 | return false; | 1031 | return false; |
1032 | if ( take == 1 ) {// take local | 1032 | if ( take == 1 ) {// take local |
1033 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1033 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1034 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1034 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1035 | else | 1035 | else |
1036 | idS = inR->IDStr(); | 1036 | idS = inR->IDStr(); |
1037 | remote->deleteIncidence( inR ); | 1037 | remote->deleteIncidence( inR ); |
1038 | if ( inL->revision() < maxrev ) | 1038 | if ( inL->revision() < maxrev ) |
1039 | inL->setRevision( maxrev ); | 1039 | inL->setRevision( maxrev ); |
1040 | inR = inL->clone(); | 1040 | inR = inL->clone(); |
1041 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1041 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1042 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1042 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1043 | inR->setIDStr( idS ); | 1043 | inR->setIDStr( idS ); |
1044 | remote->addIncidence( inR ); | 1044 | remote->addIncidence( inR ); |
1045 | ++changedRemote; | 1045 | ++changedRemote; |
1046 | } else { | 1046 | } else { |
1047 | if ( inR->revision() < maxrev ) | 1047 | if ( inR->revision() < maxrev ) |
1048 | inR->setRevision( maxrev ); | 1048 | inR->setRevision( maxrev ); |
1049 | idS = inL->IDStr(); | 1049 | idS = inL->IDStr(); |
1050 | local->deleteIncidence( inL ); | 1050 | local->deleteIncidence( inL ); |
1051 | inL = inR->clone(); | 1051 | inL = inR->clone(); |
1052 | inL->setIDStr( idS ); | 1052 | inL->setIDStr( idS ); |
1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1054 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1054 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1055 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1055 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1056 | } | 1056 | } |
1057 | local->addIncidence( inL ); | 1057 | local->addIncidence( inL ); |
1058 | ++changedLocal; | 1058 | ++changedLocal; |
1059 | } | 1059 | } |
1060 | } | 1060 | } |
1061 | } else { // no conflict | 1061 | } else { // no conflict |
1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1063 | QString des = eventLSync->description(); | 1063 | QString des = eventLSync->description(); |
1064 | QString pref = "e"; | 1064 | QString pref = "e"; |
1065 | if ( inR->type() == "Todo" ) | 1065 | if ( inR->type() == "Todo" ) |
1066 | pref = "t"; | 1066 | pref = "t"; |
1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1069 | //remote->deleteIncidence( inR ); | 1069 | //remote->deleteIncidence( inR ); |
1070 | ++deletedEventR; | 1070 | ++deletedEventR; |
1071 | } else { | 1071 | } else { |
1072 | inR->setLastModified( modifiedCalendar ); | 1072 | inR->setLastModified( modifiedCalendar ); |
1073 | inL = inR->clone(); | 1073 | inL = inR->clone(); |
1074 | local->addIncidence( inL ); | 1074 | local->addIncidence( inL ); |
1075 | ++addedEvent; | 1075 | ++addedEvent; |
1076 | } | 1076 | } |
1077 | } else { | 1077 | } else { |
1078 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1078 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1079 | inR->setLastModified( modifiedCalendar ); | 1079 | inR->setLastModified( modifiedCalendar ); |
1080 | local->addIncidence( inR->clone() ); | 1080 | local->addIncidence( inR->clone() ); |
1081 | ++addedEvent; | 1081 | ++addedEvent; |
1082 | } else { | 1082 | } else { |
1083 | checkExternSyncEvent(eventRSyncSharp, inR); | 1083 | checkExternSyncEvent(eventRSyncSharp, inR); |
1084 | remote->deleteIncidence( inR ); | 1084 | remote->deleteIncidence( inR ); |
1085 | ++deletedEventR; | 1085 | ++deletedEventR; |
1086 | } | 1086 | } |
1087 | } | 1087 | } |
1088 | } | 1088 | } |
1089 | } | 1089 | } |
1090 | inR = er.next(); | 1090 | inR = er.next(); |
1091 | } | 1091 | } |
1092 | QPtrList<Incidence> el = local->rawIncidences(); | 1092 | QPtrList<Incidence> el = local->rawIncidences(); |
1093 | inL = el.first(); | 1093 | inL = el.first(); |
1094 | modulo = (el.count()/10)+1; | 1094 | modulo = (el.count()/10)+1; |
1095 | bar.setCaption (i18n("Add / remove events") ); | 1095 | bar.setCaption (i18n("Add / remove events") ); |
1096 | bar.setTotalSteps ( el.count() ) ; | 1096 | bar.setTotalSteps ( el.count() ) ; |
1097 | bar.show(); | 1097 | bar.show(); |
1098 | incCounter = 0; | 1098 | incCounter = 0; |
1099 | 1099 | ||
1100 | while ( inL ) { | 1100 | while ( inL ) { |
1101 | 1101 | ||
1102 | qApp->processEvents(); | 1102 | qApp->processEvents(); |
1103 | if ( ! bar.isVisible() ) | 1103 | if ( ! bar.isVisible() ) |
1104 | return false; | 1104 | return false; |
1105 | if ( incCounter % modulo == 0 ) | 1105 | if ( incCounter % modulo == 0 ) |
1106 | bar.setProgress( incCounter ); | 1106 | bar.setProgress( incCounter ); |
1107 | ++incCounter; | 1107 | ++incCounter; |
1108 | uid = inL->uid(); | 1108 | uid = inL->uid(); |
1109 | bool skipIncidence = false; | 1109 | bool skipIncidence = false; |
1110 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1110 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1111 | skipIncidence = true; | 1111 | skipIncidence = true; |
1112 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1112 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1113 | skipIncidence = true; | 1113 | skipIncidence = true; |
1114 | if ( !skipIncidence ) { | 1114 | if ( !skipIncidence ) { |
1115 | inR = remote->incidence( uid ); | 1115 | inR = remote->incidence( uid ); |
1116 | if ( ! inR ) { | 1116 | if ( ! inR ) { |
1117 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1117 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1118 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1118 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1119 | checkExternSyncEvent(eventLSyncSharp, inL); | 1119 | checkExternSyncEvent(eventLSyncSharp, inL); |
1120 | local->deleteIncidence( inL ); | 1120 | local->deleteIncidence( inL ); |
1121 | ++deletedEventL; | 1121 | ++deletedEventL; |
1122 | } else { | 1122 | } else { |
1123 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1123 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1124 | inL->removeID(mCurrentSyncDevice ); | 1124 | inL->removeID(mCurrentSyncDevice ); |
1125 | ++addedEventR; | 1125 | ++addedEventR; |
1126 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1126 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1127 | inL->setLastModified( modifiedCalendar ); | 1127 | inL->setLastModified( modifiedCalendar ); |
1128 | inR = inL->clone(); | 1128 | inR = inL->clone(); |
1129 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1129 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1130 | remote->addIncidence( inR ); | 1130 | remote->addIncidence( inR ); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | } else { | 1133 | } else { |
1134 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1134 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1135 | checkExternSyncEvent(eventLSyncSharp, inL); | 1135 | checkExternSyncEvent(eventLSyncSharp, inL); |
1136 | local->deleteIncidence( inL ); | 1136 | local->deleteIncidence( inL ); |
1137 | ++deletedEventL; | 1137 | ++deletedEventL; |
1138 | } else { | 1138 | } else { |
1139 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1139 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1140 | ++addedEventR; | 1140 | ++addedEventR; |
1141 | inL->setLastModified( modifiedCalendar ); | 1141 | inL->setLastModified( modifiedCalendar ); |
1142 | remote->addIncidence( inL->clone() ); | 1142 | remote->addIncidence( inL->clone() ); |
1143 | } | 1143 | } |
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | inL = el.next(); | 1148 | inL = el.next(); |
1149 | } | 1149 | } |
1150 | int delFut = 0; | 1150 | int delFut = 0; |
1151 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1151 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1152 | er = remote->rawIncidences(); | 1152 | er = remote->rawIncidences(); |
1153 | inR = er.first(); | 1153 | inR = er.first(); |
1154 | QDateTime dt; | 1154 | QDateTime dt; |
1155 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1155 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1156 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); | 1156 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); |
1157 | while ( inR ) { | 1157 | while ( inR ) { |
1158 | if ( inR->type() == "Todo" ) { | 1158 | if ( inR->type() == "Todo" ) { |
1159 | Todo * t = (Todo*)inR; | 1159 | Todo * t = (Todo*)inR; |
1160 | if ( t->hasDueDate() ) | 1160 | if ( t->hasDueDate() ) |
1161 | dt = t->dtDue(); | 1161 | dt = t->dtDue(); |
1162 | else | 1162 | else |
1163 | dt = cur.addSecs( 62 ); | 1163 | dt = cur.addSecs( 62 ); |
1164 | } | 1164 | } |
1165 | else if (inR->type() == "Event" ) { | 1165 | else if (inR->type() == "Event" ) { |
1166 | bool ok; | 1166 | bool ok; |
1167 | dt = inR->getNextOccurence( cur, &ok ); | 1167 | dt = inR->getNextOccurence( cur, &ok ); |
1168 | if ( !ok ) | 1168 | if ( !ok ) |
1169 | dt = cur.addSecs( -62 ); | 1169 | dt = cur.addSecs( -62 ); |
1170 | } | 1170 | } |
1171 | else | 1171 | else |
1172 | dt = inR->dtStart(); | 1172 | dt = inR->dtStart(); |
1173 | if ( dt < cur || dt > end ) { | 1173 | if ( dt < cur || dt > end ) { |
1174 | remote->deleteIncidence( inR ); | 1174 | remote->deleteIncidence( inR ); |
1175 | ++delFut; | 1175 | ++delFut; |
1176 | } | 1176 | } |
1177 | inR = er.next(); | 1177 | inR = er.next(); |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | bar.hide(); | 1180 | bar.hide(); |
1181 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1181 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1182 | eventLSync->setReadOnly( false ); | 1182 | eventLSync->setReadOnly( false ); |
1183 | eventLSync->setDtStart( mLastCalendarSync ); | 1183 | eventLSync->setDtStart( mLastCalendarSync ); |
1184 | eventRSync->setDtStart( mLastCalendarSync ); | 1184 | eventRSync->setDtStart( mLastCalendarSync ); |
1185 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1185 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1186 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1186 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1187 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1187 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1188 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1188 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1189 | eventLSync->setReadOnly( true ); | 1189 | eventLSync->setReadOnly( true ); |
1190 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1190 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1191 | remote->addEvent( eventRSync ); | 1191 | remote->addEvent( eventRSync ); |
1192 | QString mes; | 1192 | QString mes; |
1193 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1193 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1194 | QString delmess; | 1194 | QString delmess; |
1195 | if ( delFut ) { | 1195 | if ( delFut ) { |
1196 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 1196 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); |
1197 | mes += delmess; | 1197 | mes += delmess; |
1198 | } | 1198 | } |
1199 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1199 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1200 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1200 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1201 | } | 1201 | } |
1202 | qDebug( mes ); | 1202 | qDebug( mes ); |
1203 | mCalendar->checkAlarmForIncidence( 0, true ); | 1203 | mCalendar->checkAlarmForIncidence( 0, true ); |
1204 | return syncOK; | 1204 | return syncOK; |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | void CalendarView::setSyncDevice( QString s ) | 1207 | void CalendarView::setSyncDevice( QString s ) |
1208 | { | 1208 | { |
1209 | mCurrentSyncDevice= s; | 1209 | mCurrentSyncDevice= s; |
1210 | } | 1210 | } |
1211 | void CalendarView::setSyncName( QString s ) | 1211 | void CalendarView::setSyncName( QString s ) |
1212 | { | 1212 | { |
1213 | mCurrentSyncName= s; | 1213 | mCurrentSyncName= s; |
1214 | } | 1214 | } |
1215 | bool CalendarView::syncCalendar(QString filename, int mode) | 1215 | bool CalendarView::syncCalendar(QString filename, int mode) |
1216 | { | 1216 | { |
1217 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1217 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1218 | CalendarLocal* calendar = new CalendarLocal(); | 1218 | CalendarLocal* calendar = new CalendarLocal(); |
1219 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1219 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1220 | FileStorage* storage = new FileStorage( calendar ); | 1220 | FileStorage* storage = new FileStorage( calendar ); |
1221 | bool syncOK = false; | 1221 | bool syncOK = false; |
1222 | storage->setFileName( filename ); | 1222 | storage->setFileName( filename ); |
1223 | // qDebug("loading ... "); | 1223 | // qDebug("loading ... "); |
1224 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1224 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1225 | getEventViewerDialog()->setSyncMode( true ); | 1225 | getEventViewerDialog()->setSyncMode( true ); |
1226 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1226 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1227 | getEventViewerDialog()->setSyncMode( false ); | 1227 | getEventViewerDialog()->setSyncMode( false ); |
1228 | if ( syncOK ) { | 1228 | if ( syncOK ) { |
1229 | if ( KOPrefs::instance()->mWriteBackFile ) | 1229 | if ( KOPrefs::instance()->mWriteBackFile ) |
1230 | { | 1230 | { |
1231 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1231 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1232 | storage->save(); | 1232 | storage->save(); |
1233 | } | 1233 | } |
1234 | } | 1234 | } |
1235 | setModified( true ); | 1235 | setModified( true ); |
1236 | } | 1236 | } |
1237 | delete storage; | 1237 | delete storage; |
1238 | delete calendar; | 1238 | delete calendar; |
1239 | if ( syncOK ) | 1239 | if ( syncOK ) |
1240 | updateView(); | 1240 | updateView(); |
1241 | return syncOK; | 1241 | return syncOK; |
1242 | } | 1242 | } |
1243 | void CalendarView::syncPhone() | 1243 | void CalendarView::syncPhone() |
1244 | { | 1244 | { |
1245 | syncExternal( 1 ); | 1245 | syncExternal( 1 ); |
1246 | } | 1246 | } |
1247 | void CalendarView::syncExternal( int mode ) | 1247 | void CalendarView::syncExternal( int mode ) |
1248 | { | 1248 | { |
1249 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1249 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1250 | //mCurrentSyncDevice = "sharp-DTM"; | 1250 | //mCurrentSyncDevice = "sharp-DTM"; |
1251 | if ( KOPrefs::instance()->mAskForPreferences ) | 1251 | if ( KOPrefs::instance()->mAskForPreferences ) |
1252 | edit_sync_options(); | 1252 | edit_sync_options(); |
1253 | qApp->processEvents(); | 1253 | qApp->processEvents(); |
1254 | CalendarLocal* calendar = new CalendarLocal(); | 1254 | CalendarLocal* calendar = new CalendarLocal(); |
1255 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1255 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1256 | bool syncOK = false; | 1256 | bool syncOK = false; |
1257 | bool loadSuccess = false; | 1257 | bool loadSuccess = false; |
1258 | PhoneFormat* phoneFormat = 0; | 1258 | PhoneFormat* phoneFormat = 0; |
1259 | #ifndef DESKTOP_VERSION | 1259 | #ifndef DESKTOP_VERSION |
1260 | SharpFormat* sharpFormat = 0; | 1260 | SharpFormat* sharpFormat = 0; |
1261 | if ( mode == 0 ) { // sharp | 1261 | if ( mode == 0 ) { // sharp |
1262 | sharpFormat = new SharpFormat () ; | 1262 | sharpFormat = new SharpFormat () ; |
1263 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1263 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1264 | 1264 | ||
1265 | } else | 1265 | } else |
1266 | #endif | 1266 | #endif |
1267 | if ( mode == 1 ) { // phone | 1267 | if ( mode == 1 ) { // phone |
1268 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1268 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1269 | KOPrefs::instance()->mPhoneDevice, | 1269 | KOPrefs::instance()->mPhoneDevice, |
1270 | KOPrefs::instance()->mPhoneConnection, | 1270 | KOPrefs::instance()->mPhoneConnection, |
1271 | KOPrefs::instance()->mPhoneModel); | 1271 | KOPrefs::instance()->mPhoneModel); |
1272 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1272 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1273 | 1273 | ||
1274 | } else | 1274 | } else |
1275 | return; | 1275 | return; |
1276 | if ( loadSuccess ) { | 1276 | if ( loadSuccess ) { |
1277 | getEventViewerDialog()->setSyncMode( true ); | 1277 | getEventViewerDialog()->setSyncMode( true ); |
1278 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1278 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1279 | getEventViewerDialog()->setSyncMode( false ); | 1279 | getEventViewerDialog()->setSyncMode( false ); |
1280 | qApp->processEvents(); | 1280 | qApp->processEvents(); |
1281 | if ( syncOK ) { | 1281 | if ( syncOK ) { |
1282 | if ( KOPrefs::instance()->mWriteBackFile ) | 1282 | if ( KOPrefs::instance()->mWriteBackFile ) |
1283 | { | 1283 | { |
1284 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1284 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1285 | Incidence* inc = iL.first(); | 1285 | Incidence* inc = iL.first(); |
1286 | if ( phoneFormat ) { | 1286 | if ( phoneFormat ) { |
1287 | while ( inc ) { | 1287 | while ( inc ) { |
1288 | inc->removeID(mCurrentSyncDevice); | 1288 | inc->removeID(mCurrentSyncDevice); |
1289 | inc = iL.next(); | 1289 | inc = iL.next(); |
1290 | } | 1290 | } |
1291 | } | 1291 | } |
1292 | #ifndef DESKTOP_VERSION | 1292 | #ifndef DESKTOP_VERSION |
1293 | if ( sharpFormat ) | 1293 | if ( sharpFormat ) |
1294 | sharpFormat->save(calendar); | 1294 | sharpFormat->save(calendar); |
1295 | #endif | 1295 | #endif |
1296 | if ( phoneFormat ) | 1296 | if ( phoneFormat ) |
1297 | phoneFormat->save(calendar); | 1297 | phoneFormat->save(calendar); |
1298 | iL = calendar->rawIncidences(); | 1298 | iL = calendar->rawIncidences(); |
1299 | inc = iL.first(); | 1299 | inc = iL.first(); |
1300 | Incidence* loc; | 1300 | Incidence* loc; |
1301 | while ( inc ) { | 1301 | while ( inc ) { |
1302 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1302 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1303 | loc = mCalendar->incidence(inc->uid() ); | 1303 | loc = mCalendar->incidence(inc->uid() ); |
1304 | if ( loc ) { | 1304 | if ( loc ) { |
1305 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1305 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1306 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1306 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | inc = iL.next(); | 1309 | inc = iL.next(); |
1310 | } | 1310 | } |
1311 | Incidence* lse = getLastSyncEvent(); | 1311 | Incidence* lse = getLastSyncEvent(); |
1312 | if ( lse ) { | 1312 | if ( lse ) { |
1313 | lse->setReadOnly( false ); | 1313 | lse->setReadOnly( false ); |
1314 | lse->setDescription( "" ); | 1314 | lse->setDescription( "" ); |
1315 | lse->setReadOnly( true ); | 1315 | lse->setReadOnly( true ); |
1316 | } | 1316 | } |
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | setModified( true ); | 1319 | setModified( true ); |
1320 | } else { | 1320 | } else { |
1321 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1321 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1322 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1322 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1323 | question, i18n("Ok")) ; | 1323 | question, i18n("Ok")) ; |
1324 | 1324 | ||
1325 | } | 1325 | } |
1326 | delete calendar; | 1326 | delete calendar; |
1327 | updateView(); | 1327 | updateView(); |
1328 | return ;//syncOK; | 1328 | return ;//syncOK; |
1329 | 1329 | ||
1330 | } | 1330 | } |
1331 | void CalendarView::syncSharp() | 1331 | void CalendarView::syncSharp() |
1332 | { | 1332 | { |
1333 | syncExternal( 0 ); | 1333 | syncExternal( 0 ); |
1334 | 1334 | ||
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | 1337 | ||
1338 | //#include <kabc/stdaddressbook.h> | 1338 | //#include <kabc/stdaddressbook.h> |
1339 | bool CalendarView::importBday() | 1339 | bool CalendarView::importBday() |
1340 | { | 1340 | { |
1341 | #if 0 | 1341 | #if 0 |
1342 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1342 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1343 | KABC::AddressBook::Iterator it; | 1343 | KABC::AddressBook::Iterator it; |
1344 | int count = 0; | 1344 | int count = 0; |
1345 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1345 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1346 | ++count; | 1346 | ++count; |
1347 | } | 1347 | } |
1348 | QProgressBar bar(count,0 ); | 1348 | QProgressBar bar(count,0 ); |
1349 | int w = 300; | 1349 | int w = 300; |
1350 | if ( QApplication::desktop()->width() < 320 ) | 1350 | if ( QApplication::desktop()->width() < 320 ) |
1351 | w = 220; | 1351 | w = 220; |
1352 | int h = bar.sizeHint().height() ; | 1352 | int h = bar.sizeHint().height() ; |
1353 | int dw = QApplication::desktop()->width(); | 1353 | int dw = QApplication::desktop()->width(); |
1354 | int dh = QApplication::desktop()->height(); | 1354 | int dh = QApplication::desktop()->height(); |
1355 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1355 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1356 | bar.show(); | 1356 | bar.show(); |
1357 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1357 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1358 | qApp->processEvents(); | 1358 | qApp->processEvents(); |
1359 | count = 0; | 1359 | count = 0; |
1360 | int addCount = 0; | 1360 | int addCount = 0; |
1361 | KCal::Attendee* a = 0; | 1361 | KCal::Attendee* a = 0; |
1362 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1362 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1363 | if ( ! bar.isVisible() ) | 1363 | if ( ! bar.isVisible() ) |
1364 | return false; | 1364 | return false; |
1365 | bar.setProgress( count++ ); | 1365 | bar.setProgress( count++ ); |
1366 | qApp->processEvents(); | 1366 | qApp->processEvents(); |
1367 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1367 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1368 | if ( (*it).birthday().date().isValid() ){ | 1368 | if ( (*it).birthday().date().isValid() ){ |
1369 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1369 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1370 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1370 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1371 | ++addCount; | 1371 | ++addCount; |
1372 | } | 1372 | } |
1373 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1373 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1374 | if ( anni.isValid() ){ | 1374 | if ( anni.isValid() ){ |
1375 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1375 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1376 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1376 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1377 | ++addCount; | 1377 | ++addCount; |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | updateView(); | 1380 | updateView(); |
1381 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1381 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1382 | #endif | 1382 | #endif |
1383 | return true; | 1383 | return true; |
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1386 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1387 | { | 1387 | { |
1388 | //qDebug("addAnni "); | 1388 | //qDebug("addAnni "); |
1389 | Event * ev = new Event(); | 1389 | Event * ev = new Event(); |
1390 | if ( a ) { | 1390 | if ( a ) { |
1391 | ev->addAttendee( a ); | 1391 | ev->addAttendee( a ); |
1392 | } | 1392 | } |
1393 | QString kind; | 1393 | QString kind; |
1394 | if ( birthday ) | 1394 | if ( birthday ) |
1395 | kind = i18n( "Birthday" ); | 1395 | kind = i18n( "Birthday" ); |
1396 | else | 1396 | else |
1397 | kind = i18n( "Anniversary" ); | 1397 | kind = i18n( "Anniversary" ); |
1398 | ev->setSummary( name + " - " + kind ); | 1398 | ev->setSummary( name + " - " + kind ); |
1399 | ev->setOrganizer( "nobody@nowhere" ); | 1399 | ev->setOrganizer( "nobody@nowhere" ); |
1400 | ev->setCategories( kind ); | 1400 | ev->setCategories( kind ); |
1401 | ev->setDtStart( QDateTime(date) ); | 1401 | ev->setDtStart( QDateTime(date) ); |
1402 | ev->setDtEnd( QDateTime(date) ); | 1402 | ev->setDtEnd( QDateTime(date) ); |
1403 | ev->setFloats( true ); | 1403 | ev->setFloats( true ); |
1404 | Recurrence * rec = ev->recurrence(); | 1404 | Recurrence * rec = ev->recurrence(); |
1405 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1405 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1406 | rec->addYearlyNum( date.month() ); | 1406 | rec->addYearlyNum( date.month() ); |
1407 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1407 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1408 | delete ev; | 1408 | delete ev; |
1409 | return false; | 1409 | return false; |
1410 | } | 1410 | } |
1411 | return true; | 1411 | return true; |
1412 | 1412 | ||
1413 | } | 1413 | } |
1414 | bool CalendarView::importQtopia( const QString &categories, | 1414 | bool CalendarView::importQtopia( const QString &categories, |
1415 | const QString &datebook, | 1415 | const QString &datebook, |
1416 | const QString &todolist ) | 1416 | const QString &todolist ) |
1417 | { | 1417 | { |
1418 | 1418 | ||
1419 | QtopiaFormat qtopiaFormat; | 1419 | QtopiaFormat qtopiaFormat; |
1420 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1420 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1421 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1421 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1422 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1422 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1423 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1423 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1424 | 1424 | ||
1425 | updateView(); | 1425 | updateView(); |
1426 | return true; | 1426 | return true; |
1427 | 1427 | ||
1428 | #if 0 | 1428 | #if 0 |
1429 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1429 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1430 | mCurrentSyncDevice = "qtopia-XML"; | 1430 | mCurrentSyncDevice = "qtopia-XML"; |
1431 | if ( KOPrefs::instance()->mAskForPreferences ) | 1431 | if ( KOPrefs::instance()->mAskForPreferences ) |
1432 | edit_sync_options(); | 1432 | edit_sync_options(); |
1433 | qApp->processEvents(); | 1433 | qApp->processEvents(); |
1434 | CalendarLocal* calendar = new CalendarLocal(); | 1434 | CalendarLocal* calendar = new CalendarLocal(); |
1435 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1435 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1436 | bool syncOK = false; | 1436 | bool syncOK = false; |
1437 | QtopiaFormat qtopiaFormat; | 1437 | QtopiaFormat qtopiaFormat; |
1438 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1438 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1439 | bool loadOk = true; | 1439 | bool loadOk = true; |
1440 | if ( !categories.isEmpty() ) | 1440 | if ( !categories.isEmpty() ) |
1441 | loadOk = qtopiaFormat.load( calendar, categories ); | 1441 | loadOk = qtopiaFormat.load( calendar, categories ); |
1442 | if ( loadOk && !datebook.isEmpty() ) | 1442 | if ( loadOk && !datebook.isEmpty() ) |
1443 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1443 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1444 | if ( loadOk && !todolist.isEmpty() ) | 1444 | if ( loadOk && !todolist.isEmpty() ) |
1445 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1445 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1446 | 1446 | ||
1447 | if ( loadOk ) { | 1447 | if ( loadOk ) { |
1448 | getEventViewerDialog()->setSyncMode( true ); | 1448 | getEventViewerDialog()->setSyncMode( true ); |
1449 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1449 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1450 | getEventViewerDialog()->setSyncMode( false ); | 1450 | getEventViewerDialog()->setSyncMode( false ); |
1451 | qApp->processEvents(); | 1451 | qApp->processEvents(); |
1452 | if ( syncOK ) { | 1452 | if ( syncOK ) { |
1453 | if ( KOPrefs::instance()->mWriteBackFile ) | 1453 | if ( KOPrefs::instance()->mWriteBackFile ) |
1454 | { | 1454 | { |
1455 | // write back XML file | 1455 | // write back XML file |
1456 | 1456 | ||
1457 | } | 1457 | } |
1458 | setModified( true ); | 1458 | setModified( true ); |
1459 | } | 1459 | } |
1460 | } else { | 1460 | } else { |
1461 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1461 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1462 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1462 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1463 | question, i18n("Ok")) ; | 1463 | question, i18n("Ok")) ; |
1464 | } | 1464 | } |
1465 | delete calendar; | 1465 | delete calendar; |
1466 | updateView(); | 1466 | updateView(); |
1467 | return syncOK; | 1467 | return syncOK; |
1468 | 1468 | ||
1469 | 1469 | ||
1470 | #endif | 1470 | #endif |
1471 | 1471 | ||
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void CalendarView::setSyncEventsReadOnly() | 1474 | void CalendarView::setSyncEventsReadOnly() |
1475 | { | 1475 | { |
1476 | Event * ev; | 1476 | Event * ev; |
1477 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1477 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1478 | ev = eL.first(); | 1478 | ev = eL.first(); |
1479 | while ( ev ) { | 1479 | while ( ev ) { |
1480 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1480 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1481 | ev->setReadOnly( true ); | 1481 | ev->setReadOnly( true ); |
1482 | ev = eL.next(); | 1482 | ev = eL.next(); |
1483 | } | 1483 | } |
1484 | } | 1484 | } |
1485 | bool CalendarView::openCalendar(QString filename, bool merge) | 1485 | bool CalendarView::openCalendar(QString filename, bool merge) |
1486 | { | 1486 | { |
1487 | 1487 | ||
1488 | if (filename.isEmpty()) { | 1488 | if (filename.isEmpty()) { |
1489 | return false; | 1489 | return false; |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | if (!QFile::exists(filename)) { | 1492 | if (!QFile::exists(filename)) { |
1493 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1493 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1494 | return false; | 1494 | return false; |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | globalFlagBlockAgenda = 1; | 1497 | globalFlagBlockAgenda = 1; |
1498 | if (!merge) mCalendar->close(); | 1498 | if (!merge) mCalendar->close(); |
1499 | 1499 | ||
1500 | mStorage->setFileName( filename ); | 1500 | mStorage->setFileName( filename ); |
1501 | 1501 | ||
1502 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1502 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1503 | if ( merge ) ;//setModified( true ); | 1503 | if ( merge ) ;//setModified( true ); |
1504 | else { | 1504 | else { |
1505 | //setModified( true ); | 1505 | //setModified( true ); |
1506 | mViewManager->setDocumentId( filename ); | 1506 | mViewManager->setDocumentId( filename ); |
1507 | mDialogManager->setDocumentId( filename ); | 1507 | mDialogManager->setDocumentId( filename ); |
1508 | mTodoList->setDocumentId( filename ); | 1508 | mTodoList->setDocumentId( filename ); |
1509 | } | 1509 | } |
1510 | globalFlagBlockAgenda = 2; | 1510 | globalFlagBlockAgenda = 2; |
1511 | // if ( getLastSyncEvent() ) | 1511 | // if ( getLastSyncEvent() ) |
1512 | // getLastSyncEvent()->setReadOnly( true ); | 1512 | // getLastSyncEvent()->setReadOnly( true ); |
1513 | mCalendar->reInitAlarmSettings(); | 1513 | mCalendar->reInitAlarmSettings(); |
1514 | setSyncEventsReadOnly(); | 1514 | setSyncEventsReadOnly(); |
1515 | updateUnmanagedViews(); | 1515 | updateUnmanagedViews(); |
1516 | updateView(); | 1516 | updateView(); |
1517 | if ( filename != MainWindow::defaultFileName() ) | 1517 | if ( filename != MainWindow::defaultFileName() ) |
1518 | saveCalendar( MainWindow::defaultFileName() ); | 1518 | saveCalendar( MainWindow::defaultFileName() ); |
1519 | loadedFileVersion = QDateTime::currentDateTime(); | 1519 | loadedFileVersion = QDateTime::currentDateTime(); |
1520 | return true; | 1520 | return true; |
1521 | } else { | 1521 | } else { |
1522 | // while failing to load, the calendar object could | 1522 | // while failing to load, the calendar object could |
1523 | // have become partially populated. Clear it out. | 1523 | // have become partially populated. Clear it out. |
1524 | if ( !merge ) mCalendar->close(); | 1524 | if ( !merge ) mCalendar->close(); |
1525 | 1525 | ||
1526 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1526 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1527 | 1527 | ||
1528 | globalFlagBlockAgenda = 2; | 1528 | globalFlagBlockAgenda = 2; |
1529 | updateView(); | 1529 | updateView(); |
1530 | } | 1530 | } |
1531 | return false; | 1531 | return false; |
1532 | } | 1532 | } |
1533 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1533 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1534 | { | 1534 | { |
1535 | loadedFileVersion = dt; | 1535 | loadedFileVersion = dt; |
1536 | } | 1536 | } |
1537 | bool CalendarView::checkFileChanged(QString fn) | 1537 | bool CalendarView::checkFileChanged(QString fn) |
1538 | { | 1538 | { |
1539 | QFileInfo finf ( fn ); | 1539 | QFileInfo finf ( fn ); |
1540 | if ( !finf.exists() ) | 1540 | if ( !finf.exists() ) |
1541 | return true; | 1541 | return true; |
1542 | QDateTime dt = finf.lastModified (); | 1542 | QDateTime dt = finf.lastModified (); |
1543 | if ( dt <= loadedFileVersion ) | 1543 | if ( dt <= loadedFileVersion ) |
1544 | return false; | 1544 | return false; |
1545 | return true; | 1545 | return true; |
1546 | 1546 | ||
1547 | } | 1547 | } |
1548 | void CalendarView::watchSavedFile() | ||
1549 | { | ||
1550 | QFileInfo finf ( MainWindow::defaultFileName()); | ||
1551 | if ( !finf.exists() ) | ||
1552 | return; | ||
1553 | QDateTime dt = finf.lastModified (); | ||
1554 | if ( dt < loadedFileVersion ) { | ||
1555 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | ||
1556 | return; | ||
1557 | } | ||
1558 | loadedFileVersion = dt; | ||
1559 | } | ||
1560 | |||
1548 | bool CalendarView::checkFileVersion(QString fn) | 1561 | bool CalendarView::checkFileVersion(QString fn) |
1549 | { | 1562 | { |
1550 | QFileInfo finf ( fn ); | 1563 | QFileInfo finf ( fn ); |
1551 | if ( !finf.exists() ) | 1564 | if ( !finf.exists() ) |
1552 | return true; | 1565 | return true; |
1553 | QDateTime dt = finf.lastModified (); | 1566 | QDateTime dt = finf.lastModified (); |
1554 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1567 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1555 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1568 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1556 | if ( dt <= loadedFileVersion ) | 1569 | if ( dt <= loadedFileVersion ) |
1557 | return true; | 1570 | return true; |
1558 | 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, false)) , | 1571 | 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)) , |
1559 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1572 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1560 | i18n("Sync+save")); | 1573 | i18n("Sync+save")); |
1561 | 1574 | ||
1562 | if ( km == KMessageBox::Cancel ) | 1575 | if ( km == KMessageBox::Cancel ) |
1563 | return false; | 1576 | return false; |
1564 | if ( km == KMessageBox::Yes ) | 1577 | if ( km == KMessageBox::Yes ) |
1565 | return true; | 1578 | return true; |
1566 | 1579 | ||
1567 | setSyncDevice("deleteaftersync" ); | 1580 | setSyncDevice("deleteaftersync" ); |
1568 | KOPrefs::instance()->mAskForPreferences = true; | 1581 | KOPrefs::instance()->mAskForPreferences = true; |
1569 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1582 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1570 | KOPrefs::instance()->mWriteBackFile = false; | 1583 | KOPrefs::instance()->mWriteBackFile = false; |
1571 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1584 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1572 | KOPrefs::instance()->mShowSyncSummary = false; | 1585 | KOPrefs::instance()->mShowSyncSummary = false; |
1573 | syncCalendar( fn, 3 ); | 1586 | syncCalendar( fn, 3 ); |
1574 | Event * e = getLastSyncEvent(); | 1587 | Event * e = getLastSyncEvent(); |
1575 | mCalendar->deleteEvent ( e ); | 1588 | mCalendar->deleteEvent ( e ); |
1576 | updateView(); | 1589 | updateView(); |
1577 | return true; | 1590 | return true; |
1578 | } | 1591 | } |
1579 | 1592 | ||
1580 | bool CalendarView::saveCalendar( QString filename ) | 1593 | bool CalendarView::saveCalendar( QString filename ) |
1581 | { | 1594 | { |
1582 | 1595 | ||
1583 | // Store back all unsaved data into calendar object | 1596 | // Store back all unsaved data into calendar object |
1584 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1597 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1585 | if ( mViewManager->currentView() ) | 1598 | if ( mViewManager->currentView() ) |
1586 | mViewManager->currentView()->flushView(); | 1599 | mViewManager->currentView()->flushView(); |
1587 | 1600 | ||
1588 | //mStorage->setFileName( filename ); | 1601 | //mStorage->setFileName( filename ); |
1589 | 1602 | ||
1590 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1603 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1591 | mStorage->setFileName( filename ); | 1604 | mStorage->setFileName( filename ); |
1592 | bool success; | 1605 | bool success; |
1593 | success = mStorage->save(); | 1606 | success = mStorage->save(); |
1594 | if ( !success ) { | 1607 | if ( !success ) { |
1595 | return false; | 1608 | return false; |
1596 | } | 1609 | } |
1597 | 1610 | ||
1598 | return true; | 1611 | return true; |
1599 | } | 1612 | } |
1600 | 1613 | ||
1601 | void CalendarView::closeCalendar() | 1614 | void CalendarView::closeCalendar() |
1602 | { | 1615 | { |
1603 | 1616 | ||
1604 | // child windows no longer valid | 1617 | // child windows no longer valid |
1605 | emit closingDown(); | 1618 | emit closingDown(); |
1606 | 1619 | ||
1607 | mCalendar->close(); | 1620 | mCalendar->close(); |
1608 | setModified(false); | 1621 | setModified(false); |
1609 | updateView(); | 1622 | updateView(); |
1610 | } | 1623 | } |
1611 | 1624 | ||
1612 | void CalendarView::archiveCalendar() | 1625 | void CalendarView::archiveCalendar() |
1613 | { | 1626 | { |
1614 | mDialogManager->showArchiveDialog(); | 1627 | mDialogManager->showArchiveDialog(); |
1615 | } | 1628 | } |
1616 | 1629 | ||
1617 | 1630 | ||
1618 | void CalendarView::readSettings() | 1631 | void CalendarView::readSettings() |
1619 | { | 1632 | { |
1620 | 1633 | ||
1621 | 1634 | ||
1622 | // mViewManager->showAgendaView(); | 1635 | // mViewManager->showAgendaView(); |
1623 | QString str; | 1636 | QString str; |
1624 | //qDebug("CalendarView::readSettings() "); | 1637 | //qDebug("CalendarView::readSettings() "); |
1625 | // read settings from the KConfig, supplying reasonable | 1638 | // read settings from the KConfig, supplying reasonable |
1626 | // defaults where none are to be found | 1639 | // defaults where none are to be found |
1627 | KConfig *config = KOGlobals::config(); | 1640 | KConfig *config = KOGlobals::config(); |
1628 | #ifndef KORG_NOSPLITTER | 1641 | #ifndef KORG_NOSPLITTER |
1629 | config->setGroup("KOrganizer Geometry"); | 1642 | config->setGroup("KOrganizer Geometry"); |
1630 | 1643 | ||
1631 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1644 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1632 | if (sizes.count() != 2) { | 1645 | if (sizes.count() != 2) { |
1633 | sizes << mDateNavigator->minimumSizeHint().width(); | 1646 | sizes << mDateNavigator->minimumSizeHint().width(); |
1634 | sizes << 300; | 1647 | sizes << 300; |
1635 | } | 1648 | } |
1636 | mPanner->setSizes(sizes); | 1649 | mPanner->setSizes(sizes); |
1637 | 1650 | ||
1638 | sizes = config->readIntListEntry("Separator2"); | 1651 | sizes = config->readIntListEntry("Separator2"); |
1639 | if ( ( mResourceView && sizes.count() == 4 ) || | 1652 | if ( ( mResourceView && sizes.count() == 4 ) || |
1640 | ( !mResourceView && sizes.count() == 3 ) ) { | 1653 | ( !mResourceView && sizes.count() == 3 ) ) { |
1641 | mLeftSplitter->setSizes(sizes); | 1654 | mLeftSplitter->setSizes(sizes); |
1642 | } | 1655 | } |
1643 | #endif | 1656 | #endif |
1644 | globalFlagBlockAgenda = 1; | 1657 | globalFlagBlockAgenda = 1; |
1645 | mViewManager->showAgendaView(); | 1658 | mViewManager->showAgendaView(); |
1646 | //mViewManager->readSettings( config ); | 1659 | //mViewManager->readSettings( config ); |
1647 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1660 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1648 | readFilterSettings(config); | 1661 | readFilterSettings(config); |
1649 | config->setGroup( "Views" ); | 1662 | config->setGroup( "Views" ); |
1650 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1663 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1651 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1664 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1652 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1665 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1653 | else mNavigator->selectDates( dateCount ); | 1666 | else mNavigator->selectDates( dateCount ); |
1654 | // mViewManager->readSettings( config ); | 1667 | // mViewManager->readSettings( config ); |
1655 | updateConfig(); | 1668 | updateConfig(); |
1656 | globalFlagBlockAgenda = 2; | 1669 | globalFlagBlockAgenda = 2; |
1657 | mViewManager->readSettings( config ); | 1670 | mViewManager->readSettings( config ); |
1658 | #ifdef DESKTOP_VERSION | 1671 | #ifdef DESKTOP_VERSION |
1659 | config->setGroup("WidgetLayout"); | 1672 | config->setGroup("WidgetLayout"); |
1660 | QStringList list; | 1673 | QStringList list; |
1661 | list = config->readListEntry("MainLayout"); | 1674 | list = config->readListEntry("MainLayout"); |
1662 | int x,y,w,h; | 1675 | int x,y,w,h; |
1663 | if ( ! list.isEmpty() ) { | 1676 | if ( ! list.isEmpty() ) { |
1664 | x = list[0].toInt(); | 1677 | x = list[0].toInt(); |
1665 | y = list[1].toInt(); | 1678 | y = list[1].toInt(); |
1666 | w = list[2].toInt(); | 1679 | w = list[2].toInt(); |
1667 | h = list[3].toInt(); | 1680 | h = list[3].toInt(); |
1668 | topLevelWidget()->setGeometry(x,y,w,h); | 1681 | topLevelWidget()->setGeometry(x,y,w,h); |
1669 | 1682 | ||
1670 | } else { | 1683 | } else { |
1671 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1684 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1672 | } | 1685 | } |
1673 | list = config->readListEntry("EditEventLayout"); | 1686 | list = config->readListEntry("EditEventLayout"); |
1674 | if ( ! list.isEmpty() ) { | 1687 | if ( ! list.isEmpty() ) { |
1675 | x = list[0].toInt(); | 1688 | x = list[0].toInt(); |
1676 | y = list[1].toInt(); | 1689 | y = list[1].toInt(); |
1677 | w = list[2].toInt(); | 1690 | w = list[2].toInt(); |
1678 | h = list[3].toInt(); | 1691 | h = list[3].toInt(); |
1679 | mEventEditor->setGeometry(x,y,w,h); | 1692 | mEventEditor->setGeometry(x,y,w,h); |
1680 | 1693 | ||
1681 | } | 1694 | } |
1682 | list = config->readListEntry("EditTodoLayout"); | 1695 | list = config->readListEntry("EditTodoLayout"); |
1683 | if ( ! list.isEmpty() ) { | 1696 | if ( ! list.isEmpty() ) { |
1684 | x = list[0].toInt(); | 1697 | x = list[0].toInt(); |
1685 | y = list[1].toInt(); | 1698 | y = list[1].toInt(); |
1686 | w = list[2].toInt(); | 1699 | w = list[2].toInt(); |
1687 | h = list[3].toInt(); | 1700 | h = list[3].toInt(); |
1688 | mTodoEditor->setGeometry(x,y,w,h); | 1701 | mTodoEditor->setGeometry(x,y,w,h); |
1689 | 1702 | ||
1690 | } | 1703 | } |
1691 | list = config->readListEntry("ViewerLayout"); | 1704 | list = config->readListEntry("ViewerLayout"); |
1692 | if ( ! list.isEmpty() ) { | 1705 | if ( ! list.isEmpty() ) { |
1693 | x = list[0].toInt(); | 1706 | x = list[0].toInt(); |
1694 | y = list[1].toInt(); | 1707 | y = list[1].toInt(); |
1695 | w = list[2].toInt(); | 1708 | w = list[2].toInt(); |
1696 | h = list[3].toInt(); | 1709 | h = list[3].toInt(); |
1697 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1710 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1698 | } | 1711 | } |
1699 | #endif | 1712 | #endif |
1700 | 1713 | ||
1701 | } | 1714 | } |
1702 | 1715 | ||
1703 | 1716 | ||
1704 | void CalendarView::writeSettings() | 1717 | void CalendarView::writeSettings() |
1705 | { | 1718 | { |
1706 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1719 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1707 | 1720 | ||
1708 | KConfig *config = KOGlobals::config(); | 1721 | KConfig *config = KOGlobals::config(); |
1709 | 1722 | ||
1710 | #ifndef KORG_NOSPLITTER | 1723 | #ifndef KORG_NOSPLITTER |
1711 | config->setGroup("KOrganizer Geometry"); | 1724 | config->setGroup("KOrganizer Geometry"); |
1712 | 1725 | ||
1713 | QValueList<int> list = mPanner->sizes(); | 1726 | QValueList<int> list = mPanner->sizes(); |
1714 | config->writeEntry("Separator1",list); | 1727 | config->writeEntry("Separator1",list); |
1715 | 1728 | ||
1716 | list = mLeftSplitter->sizes(); | 1729 | list = mLeftSplitter->sizes(); |
1717 | config->writeEntry("Separator2",list); | 1730 | config->writeEntry("Separator2",list); |
1718 | #endif | 1731 | #endif |
1719 | 1732 | ||
1720 | mViewManager->writeSettings( config ); | 1733 | mViewManager->writeSettings( config ); |
1721 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1734 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1722 | mDialogManager->writeSettings( config ); | 1735 | mDialogManager->writeSettings( config ); |
1723 | //KOPrefs::instance()->usrWriteConfig(); | 1736 | //KOPrefs::instance()->usrWriteConfig(); |
1724 | KOPrefs::instance()->writeConfig(); | 1737 | KOPrefs::instance()->writeConfig(); |
1725 | 1738 | ||
1726 | writeFilterSettings(config); | 1739 | writeFilterSettings(config); |
1727 | 1740 | ||
1728 | config->setGroup( "Views" ); | 1741 | config->setGroup( "Views" ); |
1729 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1742 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1730 | 1743 | ||
1731 | #ifdef DESKTOP_VERSION | 1744 | #ifdef DESKTOP_VERSION |
1732 | config->setGroup("WidgetLayout"); | 1745 | config->setGroup("WidgetLayout"); |
1733 | QStringList list ;//= config->readListEntry("MainLayout"); | 1746 | QStringList list ;//= config->readListEntry("MainLayout"); |
1734 | int x,y,w,h; | 1747 | int x,y,w,h; |
1735 | QWidget* wid; | 1748 | QWidget* wid; |
1736 | wid = topLevelWidget(); | 1749 | wid = topLevelWidget(); |
1737 | x = wid->geometry().x(); | 1750 | x = wid->geometry().x(); |
1738 | y = wid->geometry().y(); | 1751 | y = wid->geometry().y(); |
1739 | w = wid->width(); | 1752 | w = wid->width(); |
1740 | h = wid->height(); | 1753 | h = wid->height(); |
1741 | list.clear(); | 1754 | list.clear(); |
1742 | list << QString::number( x ); | 1755 | list << QString::number( x ); |
1743 | list << QString::number( y ); | 1756 | list << QString::number( y ); |
1744 | list << QString::number( w ); | 1757 | list << QString::number( w ); |
1745 | list << QString::number( h ); | 1758 | list << QString::number( h ); |
1746 | config->writeEntry("MainLayout",list ); | 1759 | config->writeEntry("MainLayout",list ); |
1747 | 1760 | ||
1748 | wid = mEventEditor; | 1761 | wid = mEventEditor; |
1749 | x = wid->geometry().x(); | 1762 | x = wid->geometry().x(); |
1750 | y = wid->geometry().y(); | 1763 | y = wid->geometry().y(); |
1751 | w = wid->width(); | 1764 | w = wid->width(); |
1752 | h = wid->height(); | 1765 | h = wid->height(); |
1753 | list.clear(); | 1766 | list.clear(); |
1754 | list << QString::number( x ); | 1767 | list << QString::number( x ); |
1755 | list << QString::number( y ); | 1768 | list << QString::number( y ); |
1756 | list << QString::number( w ); | 1769 | list << QString::number( w ); |
1757 | list << QString::number( h ); | 1770 | list << QString::number( h ); |
1758 | config->writeEntry("EditEventLayout",list ); | 1771 | config->writeEntry("EditEventLayout",list ); |
1759 | 1772 | ||
1760 | wid = mTodoEditor; | 1773 | wid = mTodoEditor; |
1761 | x = wid->geometry().x(); | 1774 | x = wid->geometry().x(); |
1762 | y = wid->geometry().y(); | 1775 | y = wid->geometry().y(); |
1763 | w = wid->width(); | 1776 | w = wid->width(); |
1764 | h = wid->height(); | 1777 | h = wid->height(); |
1765 | list.clear(); | 1778 | list.clear(); |
1766 | list << QString::number( x ); | 1779 | list << QString::number( x ); |
1767 | list << QString::number( y ); | 1780 | list << QString::number( y ); |
1768 | list << QString::number( w ); | 1781 | list << QString::number( w ); |
1769 | list << QString::number( h ); | 1782 | list << QString::number( h ); |
1770 | config->writeEntry("EditTodoLayout",list ); | 1783 | config->writeEntry("EditTodoLayout",list ); |
1771 | wid = getEventViewerDialog(); | 1784 | wid = getEventViewerDialog(); |
1772 | x = wid->geometry().x(); | 1785 | x = wid->geometry().x(); |
1773 | y = wid->geometry().y(); | 1786 | y = wid->geometry().y(); |
1774 | w = wid->width(); | 1787 | w = wid->width(); |
1775 | h = wid->height(); | 1788 | h = wid->height(); |
1776 | list.clear(); | 1789 | list.clear(); |
1777 | list << QString::number( x ); | 1790 | list << QString::number( x ); |
1778 | list << QString::number( y ); | 1791 | list << QString::number( y ); |
1779 | list << QString::number( w ); | 1792 | list << QString::number( w ); |
1780 | list << QString::number( h ); | 1793 | list << QString::number( h ); |
1781 | config->writeEntry("ViewerLayout",list ); | 1794 | config->writeEntry("ViewerLayout",list ); |
1782 | wid = mDialogManager->getSearchDialog(); | 1795 | wid = mDialogManager->getSearchDialog(); |
1783 | if ( wid ) { | 1796 | if ( wid ) { |
1784 | x = wid->geometry().x(); | 1797 | x = wid->geometry().x(); |
1785 | y = wid->geometry().y(); | 1798 | y = wid->geometry().y(); |
1786 | w = wid->width(); | 1799 | w = wid->width(); |
1787 | h = wid->height(); | 1800 | h = wid->height(); |
1788 | list.clear(); | 1801 | list.clear(); |
1789 | list << QString::number( x ); | 1802 | list << QString::number( x ); |
1790 | list << QString::number( y ); | 1803 | list << QString::number( y ); |
1791 | list << QString::number( w ); | 1804 | list << QString::number( w ); |
1792 | list << QString::number( h ); | 1805 | list << QString::number( h ); |
1793 | config->writeEntry("SearchLayout",list ); | 1806 | config->writeEntry("SearchLayout",list ); |
1794 | } | 1807 | } |
1795 | #endif | 1808 | #endif |
1796 | 1809 | ||
1797 | 1810 | ||
1798 | config->sync(); | 1811 | config->sync(); |
1799 | } | 1812 | } |
1800 | 1813 | ||
1801 | void CalendarView::readFilterSettings(KConfig *config) | 1814 | void CalendarView::readFilterSettings(KConfig *config) |
1802 | { | 1815 | { |
1803 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1816 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1804 | 1817 | ||
1805 | mFilters.clear(); | 1818 | mFilters.clear(); |
1806 | 1819 | ||
1807 | config->setGroup("General"); | 1820 | config->setGroup("General"); |
1808 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1821 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1809 | 1822 | ||
1810 | QStringList::ConstIterator it = filterList.begin(); | 1823 | QStringList::ConstIterator it = filterList.begin(); |
1811 | QStringList::ConstIterator end = filterList.end(); | 1824 | QStringList::ConstIterator end = filterList.end(); |
1812 | while(it != end) { | 1825 | while(it != end) { |
1813 | // kdDebug() << " filter: " << (*it) << endl; | 1826 | // kdDebug() << " filter: " << (*it) << endl; |
1814 | 1827 | ||
1815 | CalFilter *filter; | 1828 | CalFilter *filter; |
1816 | filter = new CalFilter(*it); | 1829 | filter = new CalFilter(*it); |
1817 | config->setGroup("Filter_" + (*it)); | 1830 | config->setGroup("Filter_" + (*it)); |
1818 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1831 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1819 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1832 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1820 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1833 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1821 | mFilters.append(filter); | 1834 | mFilters.append(filter); |
1822 | 1835 | ||
1823 | ++it; | 1836 | ++it; |
1824 | } | 1837 | } |
1825 | 1838 | ||
1826 | if (mFilters.count() == 0) { | 1839 | if (mFilters.count() == 0) { |
1827 | CalFilter *filter = new CalFilter(i18n("Default")); | 1840 | CalFilter *filter = new CalFilter(i18n("Default")); |
1828 | mFilters.append(filter); | 1841 | mFilters.append(filter); |
1829 | } | 1842 | } |
1830 | mFilterView->updateFilters(); | 1843 | mFilterView->updateFilters(); |
1831 | config->setGroup("FilterView"); | 1844 | config->setGroup("FilterView"); |
1832 | 1845 | ||
1833 | mFilterView->blockSignals(true); | 1846 | mFilterView->blockSignals(true); |
1834 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1847 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1835 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1848 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1836 | mFilterView->blockSignals(false); | 1849 | mFilterView->blockSignals(false); |
1837 | // We do it manually to avoid it being done twice by the above calls | 1850 | // We do it manually to avoid it being done twice by the above calls |
1838 | updateFilter(); | 1851 | updateFilter(); |
1839 | } | 1852 | } |
1840 | 1853 | ||
1841 | void CalendarView::writeFilterSettings(KConfig *config) | 1854 | void CalendarView::writeFilterSettings(KConfig *config) |
1842 | { | 1855 | { |
1843 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1856 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1844 | 1857 | ||
1845 | QStringList filterList; | 1858 | QStringList filterList; |
1846 | 1859 | ||
1847 | CalFilter *filter = mFilters.first(); | 1860 | CalFilter *filter = mFilters.first(); |
1848 | while(filter) { | 1861 | while(filter) { |
1849 | // kdDebug() << " fn: " << filter->name() << endl; | 1862 | // kdDebug() << " fn: " << filter->name() << endl; |
1850 | filterList << filter->name(); | 1863 | filterList << filter->name(); |
1851 | config->setGroup("Filter_" + filter->name()); | 1864 | config->setGroup("Filter_" + filter->name()); |
1852 | config->writeEntry("Criteria",filter->criteria()); | 1865 | config->writeEntry("Criteria",filter->criteria()); |
1853 | config->writeEntry("CategoryList",filter->categoryList()); | 1866 | config->writeEntry("CategoryList",filter->categoryList()); |
1854 | filter = mFilters.next(); | 1867 | filter = mFilters.next(); |
1855 | } | 1868 | } |
1856 | config->setGroup("General"); | 1869 | config->setGroup("General"); |
1857 | config->writeEntry("CalendarFilters",filterList); | 1870 | config->writeEntry("CalendarFilters",filterList); |
1858 | 1871 | ||
1859 | config->setGroup("FilterView"); | 1872 | config->setGroup("FilterView"); |
1860 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1873 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1861 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1874 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1862 | } | 1875 | } |
1863 | 1876 | ||
1864 | 1877 | ||
1865 | void CalendarView::goToday() | 1878 | void CalendarView::goToday() |
1866 | { | 1879 | { |
1867 | mNavigator->selectToday(); | 1880 | mNavigator->selectToday(); |
1868 | } | 1881 | } |
1869 | 1882 | ||
1870 | void CalendarView::goNext() | 1883 | void CalendarView::goNext() |
1871 | { | 1884 | { |
1872 | mNavigator->selectNext(); | 1885 | mNavigator->selectNext(); |
1873 | } | 1886 | } |
1874 | 1887 | ||
1875 | void CalendarView::goPrevious() | 1888 | void CalendarView::goPrevious() |
1876 | { | 1889 | { |
1877 | mNavigator->selectPrevious(); | 1890 | mNavigator->selectPrevious(); |
1878 | } | 1891 | } |
1879 | void CalendarView::goNextMonth() | 1892 | void CalendarView::goNextMonth() |
1880 | { | 1893 | { |
1881 | mNavigator->selectNextMonth(); | 1894 | mNavigator->selectNextMonth(); |
1882 | } | 1895 | } |
1883 | 1896 | ||
1884 | void CalendarView::goPreviousMonth() | 1897 | void CalendarView::goPreviousMonth() |
1885 | { | 1898 | { |
1886 | mNavigator->selectPreviousMonth(); | 1899 | mNavigator->selectPreviousMonth(); |
1887 | } | 1900 | } |
1888 | void CalendarView::writeLocale() | 1901 | void CalendarView::writeLocale() |
1889 | { | 1902 | { |
1890 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1903 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1891 | #if 0 | 1904 | #if 0 |
1892 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1905 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1893 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1906 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1894 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1907 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1895 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1908 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1896 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1909 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1897 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1910 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1898 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1911 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1899 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1912 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1900 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1913 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1901 | KOPrefs::instance()->mDaylightsavingStart, | 1914 | KOPrefs::instance()->mDaylightsavingStart, |
1902 | KOPrefs::instance()->mDaylightsavingEnd ); | 1915 | KOPrefs::instance()->mDaylightsavingEnd ); |
1903 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1916 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1904 | #endif | 1917 | #endif |
1905 | } | 1918 | } |
1906 | void CalendarView::updateConfig() | 1919 | void CalendarView::updateConfig() |
1907 | { | 1920 | { |
1908 | writeLocale(); | 1921 | writeLocale(); |
1909 | if ( KOPrefs::instance()->mUseAppColors ) | 1922 | if ( KOPrefs::instance()->mUseAppColors ) |
1910 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1923 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1911 | emit configChanged(); | 1924 | emit configChanged(); |
1912 | mTodoList->updateConfig(); | 1925 | mTodoList->updateConfig(); |
1913 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1926 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1914 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1927 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1915 | // To make the "fill window" configurations work | 1928 | // To make the "fill window" configurations work |
1916 | //mViewManager->raiseCurrentView(); | 1929 | //mViewManager->raiseCurrentView(); |
1917 | } | 1930 | } |
1918 | 1931 | ||
1919 | 1932 | ||
1920 | void CalendarView::eventChanged(Event *event) | 1933 | void CalendarView::eventChanged(Event *event) |
1921 | { | 1934 | { |
1922 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1935 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1923 | //updateUnmanagedViews(); | 1936 | //updateUnmanagedViews(); |
1924 | } | 1937 | } |
1925 | 1938 | ||
1926 | void CalendarView::eventAdded(Event *event) | 1939 | void CalendarView::eventAdded(Event *event) |
1927 | { | 1940 | { |
1928 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1941 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1929 | } | 1942 | } |
1930 | 1943 | ||
1931 | void CalendarView::eventToBeDeleted(Event *) | 1944 | void CalendarView::eventToBeDeleted(Event *) |
1932 | { | 1945 | { |
1933 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1946 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1934 | } | 1947 | } |
1935 | 1948 | ||
1936 | void CalendarView::eventDeleted() | 1949 | void CalendarView::eventDeleted() |
1937 | { | 1950 | { |
1938 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1951 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1939 | } | 1952 | } |
1940 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1953 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1941 | { | 1954 | { |
1942 | changeIncidenceDisplay((Incidence *)which, action); | 1955 | changeIncidenceDisplay((Incidence *)which, action); |
1943 | mDateNavigator->updateView(); //LR | 1956 | mDateNavigator->updateView(); //LR |
1944 | //mDialogManager->updateSearchDialog(); | 1957 | //mDialogManager->updateSearchDialog(); |
1945 | 1958 | ||
1946 | if (which) { | 1959 | if (which) { |
1947 | mViewManager->updateWNview(); | 1960 | mViewManager->updateWNview(); |
1948 | //mTodoList->updateView(); | 1961 | //mTodoList->updateView(); |
1949 | } | 1962 | } |
1950 | 1963 | ||
1951 | } | 1964 | } |
1952 | 1965 | ||
1953 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1966 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1954 | { | 1967 | { |
1955 | updateUnmanagedViews(); | 1968 | updateUnmanagedViews(); |
1956 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1969 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1957 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1970 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1958 | mCalendar->checkAlarmForIncidence( 0, true ); | 1971 | mCalendar->checkAlarmForIncidence( 0, true ); |
1959 | if ( mEventViewerDialog ) | 1972 | if ( mEventViewerDialog ) |
1960 | mEventViewerDialog->hide(); | 1973 | mEventViewerDialog->hide(); |
1961 | } | 1974 | } |
1962 | else | 1975 | else |
1963 | mCalendar->checkAlarmForIncidence( which , false ); | 1976 | mCalendar->checkAlarmForIncidence( which , false ); |
1964 | } | 1977 | } |
1965 | 1978 | ||
1966 | // most of the changeEventDisplays() right now just call the view's | 1979 | // most of the changeEventDisplays() right now just call the view's |
1967 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1980 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1968 | void CalendarView::changeEventDisplay(Event *which, int action) | 1981 | void CalendarView::changeEventDisplay(Event *which, int action) |
1969 | { | 1982 | { |
1970 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1983 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
1971 | changeIncidenceDisplay((Incidence *)which, action); | 1984 | changeIncidenceDisplay((Incidence *)which, action); |
1972 | mDateNavigator->updateView(); | 1985 | mDateNavigator->updateView(); |
1973 | //mDialogManager->updateSearchDialog(); | 1986 | //mDialogManager->updateSearchDialog(); |
1974 | 1987 | ||
1975 | if (which) { | 1988 | if (which) { |
1976 | // If there is an event view visible update the display | 1989 | // If there is an event view visible update the display |
1977 | mViewManager->currentView()->changeEventDisplay(which,action); | 1990 | mViewManager->currentView()->changeEventDisplay(which,action); |
1978 | // TODO: check, if update needed | 1991 | // TODO: check, if update needed |
1979 | // if (which->getTodoStatus()) { | 1992 | // if (which->getTodoStatus()) { |
1980 | mTodoList->updateView(); | 1993 | mTodoList->updateView(); |
1981 | // } | 1994 | // } |
1982 | } else { | 1995 | } else { |
1983 | mViewManager->currentView()->updateView(); | 1996 | mViewManager->currentView()->updateView(); |
1984 | } | 1997 | } |
1985 | } | 1998 | } |
1986 | 1999 | ||
1987 | 2000 | ||
1988 | void CalendarView::updateTodoViews() | 2001 | void CalendarView::updateTodoViews() |
1989 | { | 2002 | { |
1990 | 2003 | ||
1991 | mTodoList->updateView(); | 2004 | mTodoList->updateView(); |
1992 | mViewManager->currentView()->updateView(); | 2005 | mViewManager->currentView()->updateView(); |
1993 | 2006 | ||
1994 | } | 2007 | } |
1995 | 2008 | ||
1996 | 2009 | ||
1997 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2010 | void CalendarView::updateView(const QDate &start, const QDate &end) |
1998 | { | 2011 | { |
1999 | mTodoList->updateView(); | 2012 | mTodoList->updateView(); |
2000 | mViewManager->updateView(start, end); | 2013 | mViewManager->updateView(start, end); |
2001 | //mDateNavigator->updateView(); | 2014 | //mDateNavigator->updateView(); |
2002 | } | 2015 | } |
2003 | 2016 | ||
2004 | void CalendarView::updateView() | 2017 | void CalendarView::updateView() |
2005 | { | 2018 | { |
2006 | DateList tmpList = mNavigator->selectedDates(); | 2019 | DateList tmpList = mNavigator->selectedDates(); |
2007 | 2020 | ||
2008 | // We assume that the navigator only selects consecutive days. | 2021 | // We assume that the navigator only selects consecutive days. |
2009 | updateView( tmpList.first(), tmpList.last() ); | 2022 | updateView( tmpList.first(), tmpList.last() ); |
2010 | } | 2023 | } |
2011 | 2024 | ||
2012 | void CalendarView::updateUnmanagedViews() | 2025 | void CalendarView::updateUnmanagedViews() |
2013 | { | 2026 | { |
2014 | mDateNavigator->updateDayMatrix(); | 2027 | mDateNavigator->updateDayMatrix(); |
2015 | } | 2028 | } |
2016 | 2029 | ||
2017 | int CalendarView::msgItemDelete() | 2030 | int CalendarView::msgItemDelete() |
2018 | { | 2031 | { |
2019 | return KMessageBox::warningContinueCancel(this, | 2032 | return KMessageBox::warningContinueCancel(this, |
2020 | i18n("This item will be\npermanently deleted."), | 2033 | i18n("This item will be\npermanently deleted."), |
2021 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2034 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2022 | } | 2035 | } |
2023 | 2036 | ||
2024 | 2037 | ||
2025 | void CalendarView::edit_cut() | 2038 | void CalendarView::edit_cut() |
2026 | { | 2039 | { |
2027 | Event *anEvent=0; | 2040 | Event *anEvent=0; |
2028 | 2041 | ||
2029 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2042 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2030 | 2043 | ||
2031 | if (mViewManager->currentView()->isEventView()) { | 2044 | if (mViewManager->currentView()->isEventView()) { |
2032 | if ( incidence && incidence->type() == "Event" ) { | 2045 | if ( incidence && incidence->type() == "Event" ) { |
2033 | anEvent = static_cast<Event *>(incidence); | 2046 | anEvent = static_cast<Event *>(incidence); |
2034 | } | 2047 | } |
2035 | } | 2048 | } |
2036 | 2049 | ||
2037 | if (!anEvent) { | 2050 | if (!anEvent) { |
2038 | KNotifyClient::beep(); | 2051 | KNotifyClient::beep(); |
2039 | return; | 2052 | return; |
2040 | } | 2053 | } |
2041 | DndFactory factory( mCalendar ); | 2054 | DndFactory factory( mCalendar ); |
2042 | factory.cutEvent(anEvent); | 2055 | factory.cutEvent(anEvent); |
2043 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2056 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2044 | } | 2057 | } |
2045 | 2058 | ||
2046 | void CalendarView::edit_copy() | 2059 | void CalendarView::edit_copy() |
2047 | { | 2060 | { |
2048 | Event *anEvent=0; | 2061 | Event *anEvent=0; |
2049 | 2062 | ||
2050 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2063 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2051 | 2064 | ||
2052 | if (mViewManager->currentView()->isEventView()) { | 2065 | if (mViewManager->currentView()->isEventView()) { |
2053 | if ( incidence && incidence->type() == "Event" ) { | 2066 | if ( incidence && incidence->type() == "Event" ) { |
2054 | anEvent = static_cast<Event *>(incidence); | 2067 | anEvent = static_cast<Event *>(incidence); |
2055 | } | 2068 | } |
2056 | } | 2069 | } |
2057 | 2070 | ||
2058 | if (!anEvent) { | 2071 | if (!anEvent) { |
2059 | KNotifyClient::beep(); | 2072 | KNotifyClient::beep(); |
2060 | return; | 2073 | return; |
2061 | } | 2074 | } |
2062 | DndFactory factory( mCalendar ); | 2075 | DndFactory factory( mCalendar ); |
2063 | factory.copyEvent(anEvent); | 2076 | factory.copyEvent(anEvent); |
2064 | } | 2077 | } |
2065 | 2078 | ||
2066 | void CalendarView::edit_paste() | 2079 | void CalendarView::edit_paste() |
2067 | { | 2080 | { |
2068 | QDate date = mNavigator->selectedDates().first(); | 2081 | QDate date = mNavigator->selectedDates().first(); |
2069 | 2082 | ||
2070 | DndFactory factory( mCalendar ); | 2083 | DndFactory factory( mCalendar ); |
2071 | Event *pastedEvent = factory.pasteEvent( date ); | 2084 | Event *pastedEvent = factory.pasteEvent( date ); |
2072 | 2085 | ||
2073 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2086 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2074 | } | 2087 | } |
2075 | 2088 | ||
2076 | void CalendarView::edit_options() | 2089 | void CalendarView::edit_options() |
2077 | { | 2090 | { |
2078 | mDialogManager->showOptionsDialog(); | 2091 | mDialogManager->showOptionsDialog(); |
2079 | //writeSettings(); | 2092 | //writeSettings(); |
2080 | } | 2093 | } |
2081 | void CalendarView::edit_sync_options() | 2094 | void CalendarView::edit_sync_options() |
2082 | { | 2095 | { |
2083 | //mDialogManager->showSyncOptions(); | 2096 | //mDialogManager->showSyncOptions(); |
2084 | //KOPrefs::instance()->mSyncAlgoPrefs | 2097 | //KOPrefs::instance()->mSyncAlgoPrefs |
2085 | QDialog dia( this, "dia", true ); | 2098 | QDialog dia( this, "dia", true ); |
2086 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2099 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2087 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2100 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2088 | QVBoxLayout lay ( &dia ); | 2101 | QVBoxLayout lay ( &dia ); |
2089 | lay.setSpacing( 2 ); | 2102 | lay.setSpacing( 2 ); |
2090 | lay.setMargin( 3 ); | 2103 | lay.setMargin( 3 ); |
2091 | lay.addWidget(&gr); | 2104 | lay.addWidget(&gr); |
2092 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2105 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2093 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2106 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2094 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2107 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2095 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2108 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2096 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2109 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2097 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2110 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2098 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2111 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2099 | QPushButton pb ( "OK", &dia); | 2112 | QPushButton pb ( "OK", &dia); |
2100 | lay.addWidget( &pb ); | 2113 | lay.addWidget( &pb ); |
2101 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2114 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2102 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 2115 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
2103 | case 0: | 2116 | case 0: |
2104 | loc.setChecked( true); | 2117 | loc.setChecked( true); |
2105 | break; | 2118 | break; |
2106 | case 1: | 2119 | case 1: |
2107 | rem.setChecked( true ); | 2120 | rem.setChecked( true ); |
2108 | break; | 2121 | break; |
2109 | case 2: | 2122 | case 2: |
2110 | newest.setChecked( true); | 2123 | newest.setChecked( true); |
2111 | break; | 2124 | break; |
2112 | case 3: | 2125 | case 3: |
2113 | ask.setChecked( true); | 2126 | ask.setChecked( true); |
2114 | break; | 2127 | break; |
2115 | case 4: | 2128 | case 4: |
2116 | f_loc.setChecked( true); | 2129 | f_loc.setChecked( true); |
2117 | break; | 2130 | break; |
2118 | case 5: | 2131 | case 5: |
2119 | f_rem.setChecked( true); | 2132 | f_rem.setChecked( true); |
2120 | break; | 2133 | break; |
2121 | case 6: | 2134 | case 6: |
2122 | // both.setChecked( true); | 2135 | // both.setChecked( true); |
2123 | break; | 2136 | break; |
2124 | default: | 2137 | default: |
2125 | break; | 2138 | break; |
2126 | } | 2139 | } |
2127 | if ( dia.exec() ) { | 2140 | if ( dia.exec() ) { |
2128 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2141 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2129 | } | 2142 | } |
2130 | 2143 | ||
2131 | } | 2144 | } |
2132 | 2145 | ||
2133 | void CalendarView::slotSelectPickerDate( QDate d) | 2146 | void CalendarView::slotSelectPickerDate( QDate d) |
2134 | { | 2147 | { |
2135 | mDateFrame->hide(); | 2148 | mDateFrame->hide(); |
2136 | if ( mDatePickerMode == 1 ) { | 2149 | if ( mDatePickerMode == 1 ) { |
2137 | mNavigator->slotDaySelect( d ); | 2150 | mNavigator->slotDaySelect( d ); |
2138 | } else if ( mDatePickerMode == 2 ) { | 2151 | } else if ( mDatePickerMode == 2 ) { |
2139 | if ( mMoveIncidence->type() == "Todo" ) { | 2152 | if ( mMoveIncidence->type() == "Todo" ) { |
2140 | Todo * to = (Todo *) mMoveIncidence; | 2153 | Todo * to = (Todo *) mMoveIncidence; |
2141 | QTime tim; | 2154 | QTime tim; |
2142 | if ( to->hasDueDate() ) | 2155 | if ( to->hasDueDate() ) |
2143 | tim = to->dtDue().time(); | 2156 | tim = to->dtDue().time(); |
2144 | else { | 2157 | else { |
2145 | tim = QTime ( 0,0,0 ); | 2158 | tim = QTime ( 0,0,0 ); |
2146 | to->setFloats( true ); | 2159 | to->setFloats( true ); |
2147 | to->setHasDueDate( true ); | 2160 | to->setHasDueDate( true ); |
2148 | } | 2161 | } |
2149 | QDateTime dt ( d,tim ); | 2162 | QDateTime dt ( d,tim ); |
2150 | to->setDtDue( dt ); | 2163 | to->setDtDue( dt ); |
2151 | todoChanged( to ); | 2164 | todoChanged( to ); |
2152 | } else { | 2165 | } else { |
2153 | QTime tim = mMoveIncidence->dtStart().time(); | 2166 | QTime tim = mMoveIncidence->dtStart().time(); |
2154 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2167 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2155 | QDateTime dt ( d,tim ); | 2168 | QDateTime dt ( d,tim ); |
2156 | mMoveIncidence->setDtStart( dt ); | 2169 | mMoveIncidence->setDtStart( dt ); |
2157 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2170 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2158 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2171 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2159 | } | 2172 | } |
2160 | 2173 | ||
2161 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2174 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2162 | } | 2175 | } |
2163 | } | 2176 | } |
2164 | 2177 | ||
2165 | void CalendarView::removeCategories() | 2178 | void CalendarView::removeCategories() |
2166 | { | 2179 | { |
2167 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2180 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2168 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2181 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2169 | QStringList catIncList; | 2182 | QStringList catIncList; |
2170 | QStringList newCatList; | 2183 | QStringList newCatList; |
2171 | Incidence* inc = incList.first(); | 2184 | Incidence* inc = incList.first(); |
2172 | int i; | 2185 | int i; |
2173 | int count = 0; | 2186 | int count = 0; |
2174 | while ( inc ) { | 2187 | while ( inc ) { |
2175 | newCatList.clear(); | 2188 | newCatList.clear(); |
2176 | catIncList = inc->categories() ; | 2189 | catIncList = inc->categories() ; |
2177 | for( i = 0; i< catIncList.count(); ++i ) { | 2190 | for( i = 0; i< catIncList.count(); ++i ) { |
2178 | if ( catList.contains (catIncList[i])) | 2191 | if ( catList.contains (catIncList[i])) |
2179 | newCatList.append( catIncList[i] ); | 2192 | newCatList.append( catIncList[i] ); |
2180 | } | 2193 | } |
2181 | newCatList.sort(); | 2194 | newCatList.sort(); |
2182 | inc->setCategories( newCatList.join(",") ); | 2195 | inc->setCategories( newCatList.join(",") ); |
2183 | inc = incList.next(); | 2196 | inc = incList.next(); |
2184 | } | 2197 | } |
2185 | } | 2198 | } |
2186 | 2199 | ||
2187 | int CalendarView::addCategories() | 2200 | int CalendarView::addCategories() |
2188 | { | 2201 | { |
2189 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2202 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2190 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2203 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2191 | QStringList catIncList; | 2204 | QStringList catIncList; |
2192 | Incidence* inc = incList.first(); | 2205 | Incidence* inc = incList.first(); |
2193 | int i; | 2206 | int i; |
2194 | int count = 0; | 2207 | int count = 0; |
2195 | while ( inc ) { | 2208 | while ( inc ) { |
2196 | catIncList = inc->categories() ; | 2209 | catIncList = inc->categories() ; |
2197 | for( i = 0; i< catIncList.count(); ++i ) { | 2210 | for( i = 0; i< catIncList.count(); ++i ) { |
2198 | if ( !catList.contains (catIncList[i])) { | 2211 | if ( !catList.contains (catIncList[i])) { |
2199 | catList.append( catIncList[i] ); | 2212 | catList.append( catIncList[i] ); |
2200 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2213 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2201 | ++count; | 2214 | ++count; |
2202 | } | 2215 | } |
2203 | } | 2216 | } |
2204 | inc = incList.next(); | 2217 | inc = incList.next(); |
2205 | } | 2218 | } |
2206 | catList.sort(); | 2219 | catList.sort(); |
2207 | KOPrefs::instance()->mCustomCategories = catList; | 2220 | KOPrefs::instance()->mCustomCategories = catList; |
2208 | return count; | 2221 | return count; |
2209 | } | 2222 | } |
2210 | 2223 | ||
2211 | void CalendarView::manageCategories() | 2224 | void CalendarView::manageCategories() |
2212 | { | 2225 | { |
2213 | KOCatPrefs* cp = new KOCatPrefs(); | 2226 | KOCatPrefs* cp = new KOCatPrefs(); |
2214 | cp->show(); | 2227 | cp->show(); |
2215 | int w =cp->sizeHint().width() ; | 2228 | int w =cp->sizeHint().width() ; |
2216 | int h = cp->sizeHint().height() ; | 2229 | int h = cp->sizeHint().height() ; |
2217 | int dw = QApplication::desktop()->width(); | 2230 | int dw = QApplication::desktop()->width(); |
2218 | int dh = QApplication::desktop()->height(); | 2231 | int dh = QApplication::desktop()->height(); |
2219 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2232 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2220 | if ( !cp->exec() ) { | 2233 | if ( !cp->exec() ) { |
2221 | delete cp; | 2234 | delete cp; |
2222 | return; | 2235 | return; |
2223 | } | 2236 | } |
2224 | int count = 0; | 2237 | int count = 0; |
2225 | if ( cp->addCat() ) { | 2238 | if ( cp->addCat() ) { |
2226 | count = addCategories(); | 2239 | count = addCategories(); |
2227 | if ( count ) { | 2240 | if ( count ) { |
2228 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2241 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2229 | writeSettings(); | 2242 | writeSettings(); |
2230 | } | 2243 | } |
2231 | } else { | 2244 | } else { |
2232 | removeCategories(); | 2245 | removeCategories(); |
2233 | updateView(); | 2246 | updateView(); |
2234 | } | 2247 | } |
2235 | delete cp; | 2248 | delete cp; |
2236 | } | 2249 | } |
2237 | 2250 | ||
2238 | void CalendarView::beamIncidence(Incidence * Inc) | 2251 | void CalendarView::beamIncidence(Incidence * Inc) |
2239 | { | 2252 | { |
2240 | QPtrList<Incidence> delSel ; | 2253 | QPtrList<Incidence> delSel ; |
2241 | delSel.append(Inc); | 2254 | delSel.append(Inc); |
2242 | beamIncidenceList( delSel ); | 2255 | beamIncidenceList( delSel ); |
2243 | } | 2256 | } |
2244 | void CalendarView::beamCalendar() | 2257 | void CalendarView::beamCalendar() |
2245 | { | 2258 | { |
2246 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2259 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2247 | //qDebug("beamCalendar() "); | 2260 | //qDebug("beamCalendar() "); |
2248 | beamIncidenceList( delSel ); | 2261 | beamIncidenceList( delSel ); |
2249 | } | 2262 | } |
2250 | void CalendarView::beamFilteredCalendar() | 2263 | void CalendarView::beamFilteredCalendar() |
2251 | { | 2264 | { |
2252 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2265 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2253 | //qDebug("beamFilteredCalendar() "); | 2266 | //qDebug("beamFilteredCalendar() "); |
2254 | beamIncidenceList( delSel ); | 2267 | beamIncidenceList( delSel ); |
2255 | } | 2268 | } |
2256 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2269 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2257 | { | 2270 | { |
2258 | if ( beamDialog->exec () == QDialog::Rejected ) | 2271 | if ( beamDialog->exec () == QDialog::Rejected ) |
2259 | return; | 2272 | return; |
2260 | 2273 | ||
2261 | QString fn = "/tmp/kopibeamfile"; | 2274 | QString fn = "/tmp/kopibeamfile"; |
2262 | QString mes; | 2275 | QString mes; |
2263 | bool createbup = true; | 2276 | bool createbup = true; |
2264 | if ( createbup ) { | 2277 | if ( createbup ) { |
2265 | QString description = "\n"; | 2278 | QString description = "\n"; |
2266 | CalendarLocal* cal = new CalendarLocal(); | 2279 | CalendarLocal* cal = new CalendarLocal(); |
2267 | if ( beamDialog->beamLocal() ) | 2280 | if ( beamDialog->beamLocal() ) |
2268 | cal->setLocalTime(); | 2281 | cal->setLocalTime(); |
2269 | else | 2282 | else |
2270 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2283 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2271 | Incidence *incidence = delSel.first(); | 2284 | Incidence *incidence = delSel.first(); |
2272 | bool addText = false; | 2285 | bool addText = false; |
2273 | if ( delSel.count() < 10 ) | 2286 | if ( delSel.count() < 10 ) |
2274 | addText = true; | 2287 | addText = true; |
2275 | else { | 2288 | else { |
2276 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2289 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2277 | } | 2290 | } |
2278 | while ( incidence ) { | 2291 | while ( incidence ) { |
2279 | Incidence *in = incidence->clone(); | 2292 | Incidence *in = incidence->clone(); |
2280 | if ( addText ) | 2293 | if ( addText ) |
2281 | description += in->summary() + "\n"; | 2294 | description += in->summary() + "\n"; |
2282 | cal->addIncidence( in ); | 2295 | cal->addIncidence( in ); |
2283 | incidence = delSel.next(); | 2296 | incidence = delSel.next(); |
2284 | } | 2297 | } |
2285 | if ( beamDialog->beamVcal() ) { | 2298 | if ( beamDialog->beamVcal() ) { |
2286 | fn += ".vcs"; | 2299 | fn += ".vcs"; |
2287 | FileStorage storage( cal, fn, new VCalFormat ); | 2300 | FileStorage storage( cal, fn, new VCalFormat ); |
2288 | storage.save(); | 2301 | storage.save(); |
2289 | } else { | 2302 | } else { |
2290 | fn += ".ics"; | 2303 | fn += ".ics"; |
2291 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2304 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2292 | storage.save(); | 2305 | storage.save(); |
2293 | } | 2306 | } |
2294 | delete cal; | 2307 | delete cal; |
2295 | mes = i18n("KO/Pi: Ready for beaming"); | 2308 | mes = i18n("KO/Pi: Ready for beaming"); |
2296 | setCaption(mes); | 2309 | setCaption(mes); |
2297 | 2310 | ||
2298 | #ifndef DESKTOP_VERSION | 2311 | #ifndef DESKTOP_VERSION |
2299 | Ir *ir = new Ir( this ); | 2312 | Ir *ir = new Ir( this ); |
2300 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2313 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2301 | ir->send( fn, description, "text/x-vCalendar" ); | 2314 | ir->send( fn, description, "text/x-vCalendar" ); |
2302 | #endif | 2315 | #endif |
2303 | } | 2316 | } |
2304 | } | 2317 | } |
2305 | void CalendarView::beamDone( Ir *ir ) | 2318 | void CalendarView::beamDone( Ir *ir ) |
2306 | { | 2319 | { |
2307 | #ifndef DESKTOP_VERSION | 2320 | #ifndef DESKTOP_VERSION |
2308 | delete ir; | 2321 | delete ir; |
2309 | #endif | 2322 | #endif |
2310 | } | 2323 | } |
2311 | 2324 | ||
2312 | void CalendarView::moveIncidence(Incidence * inc ) | 2325 | void CalendarView::moveIncidence(Incidence * inc ) |
2313 | { | 2326 | { |
2314 | if ( !inc ) return; | 2327 | if ( !inc ) return; |
2315 | // qDebug("showDatePickerForIncidence( ) "); | 2328 | // qDebug("showDatePickerForIncidence( ) "); |
2316 | if ( mDateFrame->isVisible() ) | 2329 | if ( mDateFrame->isVisible() ) |
2317 | mDateFrame->hide(); | 2330 | mDateFrame->hide(); |
2318 | else { | 2331 | else { |
2319 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2332 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2320 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2333 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2321 | int dw = QApplication::desktop()->width(); | 2334 | int dw = QApplication::desktop()->width(); |
2322 | int dh = QApplication::desktop()->height(); | 2335 | int dh = QApplication::desktop()->height(); |
2323 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2336 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2324 | mDateFrame->show(); | 2337 | mDateFrame->show(); |
2325 | } | 2338 | } |
2326 | mDatePickerMode = 2; | 2339 | mDatePickerMode = 2; |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index a3315ad..355bb84 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,590 +1,591 @@ | |||
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 | class QWidgetStack; | 45 | class QWidgetStack; |
46 | class QSplitter; | 46 | class QSplitter; |
47 | 47 | ||
48 | class CalPrinter; | 48 | class CalPrinter; |
49 | class KOFilterView; | 49 | class KOFilterView; |
50 | class KOViewManager; | 50 | class KOViewManager; |
51 | class KODialogManager; | 51 | class KODialogManager; |
52 | class KOTodoView; | 52 | class KOTodoView; |
53 | class KDateNavigator; | 53 | class KDateNavigator; |
54 | class DateNavigator; | 54 | class DateNavigator; |
55 | class KOIncidenceEditor; | 55 | class KOIncidenceEditor; |
56 | class KDatePicker; | 56 | class KDatePicker; |
57 | class ResourceView; | 57 | class ResourceView; |
58 | class NavigatorBar; | 58 | class NavigatorBar; |
59 | class KOEventEditor; | 59 | class KOEventEditor; |
60 | class KOTodoEditor ; | 60 | class KOTodoEditor ; |
61 | class KOEventViewerDialog; | 61 | class KOEventViewerDialog; |
62 | class KOBeamPrefs; | 62 | class KOBeamPrefs; |
63 | class KSyncProfile; | 63 | class KSyncProfile; |
64 | class AlarmDialog; | 64 | class AlarmDialog; |
65 | class KCal::Attendee; | 65 | class KCal::Attendee; |
66 | 66 | ||
67 | namespace KCal { class FileStorage; } | 67 | namespace KCal { class FileStorage; } |
68 | 68 | ||
69 | using namespace KCal; | 69 | using namespace KCal; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | This is the main calendar widget. It provides the different vies on t he | 72 | This is the main calendar widget. It provides the different vies on t he |
73 | calendar data as well as the date navigator. It also handles synchronisation | 73 | calendar data as well as the date navigator. It also handles synchronisation |
74 | of the different views and controls the different dialogs like preferences, | 74 | of the different views and controls the different dialogs like preferences, |
75 | event editor, search dialog etc. | 75 | event editor, search dialog etc. |
76 | 76 | ||
77 | @short main calendar view widget | 77 | @short main calendar view widget |
78 | @author Cornelius Schumacher | 78 | @author Cornelius Schumacher |
79 | */ | 79 | */ |
80 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer | 80 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer |
81 | { | 81 | { |
82 | Q_OBJECT | 82 | Q_OBJECT |
83 | public: | 83 | public: |
84 | /** | 84 | /** |
85 | Constructs a new calendar view widget. | 85 | Constructs a new calendar view widget. |
86 | 86 | ||
87 | @param calendar calendar document | 87 | @param calendar calendar document |
88 | @param parent parent window | 88 | @param parent parent window |
89 | @param name Qt internal widget object name | 89 | @param name Qt internal widget object name |
90 | */ | 90 | */ |
91 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 91 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
92 | const char *name = 0 ); | 92 | const char *name = 0 ); |
93 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 93 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 94 | const char *name = 0 ); |
95 | virtual ~CalendarView(); | 95 | virtual ~CalendarView(); |
96 | 96 | ||
97 | Calendar *calendar() { return mCalendar; } | 97 | Calendar *calendar() { return mCalendar; } |
98 | 98 | ||
99 | KOViewManager *viewManager(); | 99 | KOViewManager *viewManager(); |
100 | KODialogManager *dialogManager(); | 100 | KODialogManager *dialogManager(); |
101 | 101 | ||
102 | QDate startDate(); | 102 | QDate startDate(); |
103 | QDate endDate(); | 103 | QDate endDate(); |
104 | 104 | ||
105 | QWidgetStack *viewStack(); | 105 | QWidgetStack *viewStack(); |
106 | QWidget *leftFrame(); | 106 | QWidget *leftFrame(); |
107 | NavigatorBar *navigatorBar(); | 107 | NavigatorBar *navigatorBar(); |
108 | 108 | ||
109 | DateNavigator *dateNavigator(); | 109 | DateNavigator *dateNavigator(); |
110 | KDateNavigator *dateNavigatorWidget(); | 110 | KDateNavigator *dateNavigatorWidget(); |
111 | 111 | ||
112 | void addView(KOrg::BaseView *); | 112 | void addView(KOrg::BaseView *); |
113 | void showView(KOrg::BaseView *); | 113 | void showView(KOrg::BaseView *); |
114 | KOEventViewerDialog* getEventViewerDialog(); | 114 | KOEventViewerDialog* getEventViewerDialog(); |
115 | Incidence *currentSelection(); | 115 | Incidence *currentSelection(); |
116 | void setupExternSyncProfiles(); | 116 | void setupExternSyncProfiles(); |
117 | 117 | ||
118 | signals: | 118 | signals: |
119 | /** This todo has been modified */ | 119 | /** This todo has been modified */ |
120 | void todoModified(Todo *, int); | 120 | void todoModified(Todo *, int); |
121 | 121 | ||
122 | /** when change is made to options dialog, the topwidget will catch this | 122 | /** when change is made to options dialog, the topwidget will catch this |
123 | * and emit this signal which notifies all widgets which have registered | 123 | * and emit this signal which notifies all widgets which have registered |
124 | * for notification to update their settings. */ | 124 | * for notification to update their settings. */ |
125 | void configChanged(); | 125 | void configChanged(); |
126 | /** emitted when the topwidget is closing down, so that any attached | 126 | /** emitted when the topwidget is closing down, so that any attached |
127 | child windows can also close. */ | 127 | child windows can also close. */ |
128 | void closingDown(); | 128 | void closingDown(); |
129 | /** emitted right before we die */ | 129 | /** emitted right before we die */ |
130 | void closed(QWidget *); | 130 | void closed(QWidget *); |
131 | 131 | ||
132 | /** Emitted when state of modified flag changes */ | 132 | /** Emitted when state of modified flag changes */ |
133 | void modifiedChanged(bool); | 133 | void modifiedChanged(bool); |
134 | void signalmodified(); | 134 | void signalmodified(); |
135 | 135 | ||
136 | /** Emitted when state of read-only flag changes */ | 136 | /** Emitted when state of read-only flag changes */ |
137 | void readOnlyChanged(bool); | 137 | void readOnlyChanged(bool); |
138 | 138 | ||
139 | /** Emitted when the unit of navigation changes */ | 139 | /** Emitted when the unit of navigation changes */ |
140 | void changeNavStringPrev(const QString &); | 140 | void changeNavStringPrev(const QString &); |
141 | void changeNavStringNext(const QString &); | 141 | void changeNavStringNext(const QString &); |
142 | 142 | ||
143 | /** Emitted when state of events selection has changed and user is organizer*/ | 143 | /** Emitted when state of events selection has changed and user is organizer*/ |
144 | void organizerEventsSelected(bool); | 144 | void organizerEventsSelected(bool); |
145 | /** Emitted when state of events selection has changed and user is attendee*/ | 145 | /** Emitted when state of events selection has changed and user is attendee*/ |
146 | void groupEventsSelected(bool); | 146 | void groupEventsSelected(bool); |
147 | /** | 147 | /** |
148 | Emitted when an incidence gets selected. If the selection is cleared the | 148 | Emitted when an incidence gets selected. If the selection is cleared the |
149 | signal is emitted with 0 as argument. | 149 | signal is emitted with 0 as argument. |
150 | */ | 150 | */ |
151 | void incidenceSelected( Incidence * ); | 151 | void incidenceSelected( Incidence * ); |
152 | /** Emitted, when a todoitem is selected or deselected. */ | 152 | /** Emitted, when a todoitem is selected or deselected. */ |
153 | void todoSelected( bool ); | 153 | void todoSelected( bool ); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | Emitted, when clipboard content changes. Parameter indicates if paste | 156 | Emitted, when clipboard content changes. Parameter indicates if paste |
157 | is possible or not. | 157 | is possible or not. |
158 | */ | 158 | */ |
159 | void pasteEnabled(bool); | 159 | void pasteEnabled(bool); |
160 | 160 | ||
161 | /** Emitted, when the number of incoming messages has changed. */ | 161 | /** Emitted, when the number of incoming messages has changed. */ |
162 | void numIncomingChanged(int); | 162 | void numIncomingChanged(int); |
163 | 163 | ||
164 | /** Emitted, when the number of outgoing messages has changed. */ | 164 | /** Emitted, when the number of outgoing messages has changed. */ |
165 | void numOutgoingChanged(int); | 165 | void numOutgoingChanged(int); |
166 | 166 | ||
167 | /** Send status message, which can e.g. be displayed in the status bar. */ | 167 | /** Send status message, which can e.g. be displayed in the status bar. */ |
168 | void statusMessage(const QString &); | 168 | void statusMessage(const QString &); |
169 | 169 | ||
170 | void calendarViewExpanded( bool ); | 170 | void calendarViewExpanded( bool ); |
171 | void updateSearchDialog(); | 171 | void updateSearchDialog(); |
172 | 172 | ||
173 | 173 | ||
174 | public slots: | 174 | public slots: |
175 | void watchSavedFile(); | ||
175 | void recheckTimerAlarm(); | 176 | void recheckTimerAlarm(); |
176 | void checkNextTimerAlarm(); | 177 | void checkNextTimerAlarm(); |
177 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 178 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
178 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 179 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
179 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 180 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
180 | 181 | ||
181 | /** options dialog made a changed to the configuration. we catch this | 182 | /** options dialog made a changed to the configuration. we catch this |
182 | * and notify all widgets which need to update their configuration. */ | 183 | * and notify all widgets which need to update their configuration. */ |
183 | void updateConfig(); | 184 | void updateConfig(); |
184 | 185 | ||
185 | /** | 186 | /** |
186 | Load calendar from file \a filename. If \a merge is true, load | 187 | Load calendar from file \a filename. If \a merge is true, load |
187 | calendar into existing one, if it is false, clear calendar, before | 188 | calendar into existing one, if it is false, clear calendar, before |
188 | loading. Return true, if calendar could be successfully loaded. | 189 | loading. Return true, if calendar could be successfully loaded. |
189 | */ | 190 | */ |
190 | bool openCalendar(QString filename, bool merge=false); | 191 | bool openCalendar(QString filename, bool merge=false); |
191 | bool syncCalendar(QString filename,int mode = 0 ); | 192 | bool syncCalendar(QString filename,int mode = 0 ); |
192 | 193 | ||
193 | /** | 194 | /** |
194 | Save calendar data to file. Return true if calendar could be | 195 | Save calendar data to file. Return true if calendar could be |
195 | successfully saved. | 196 | successfully saved. |
196 | */ | 197 | */ |
197 | bool saveCalendar(QString filename); | 198 | bool saveCalendar(QString filename); |
198 | 199 | ||
199 | /** | 200 | /** |
200 | Close calendar. Clear calendar data and reset views to display an empty | 201 | Close calendar. Clear calendar data and reset views to display an empty |
201 | calendar. | 202 | calendar. |
202 | */ | 203 | */ |
203 | void closeCalendar(); | 204 | void closeCalendar(); |
204 | 205 | ||
205 | /** Archive old events of calendar */ | 206 | /** Archive old events of calendar */ |
206 | void archiveCalendar(); | 207 | void archiveCalendar(); |
207 | 208 | ||
208 | void showIncidence(); | 209 | void showIncidence(); |
209 | void editIncidence(); | 210 | void editIncidence(); |
210 | void editIncidenceDescription(); | 211 | void editIncidenceDescription(); |
211 | void deleteIncidence(); | 212 | void deleteIncidence(); |
212 | 213 | ||
213 | /** create an editeventwin with supplied date/time, and if bool is true, | 214 | /** create an editeventwin with supplied date/time, and if bool is true, |
214 | * make the event take all day. */ | 215 | * make the event take all day. */ |
215 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 216 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
216 | void newEvent(QDateTime fh); | 217 | void newEvent(QDateTime fh); |
217 | void newEvent(QDate dt); | 218 | void newEvent(QDate dt); |
218 | /** create new event without having a date hint. Takes current date as | 219 | /** create new event without having a date hint. Takes current date as |
219 | default hint. */ | 220 | default hint. */ |
220 | void newEvent(); | 221 | void newEvent(); |
221 | void newFloatingEvent(); | 222 | void newFloatingEvent(); |
222 | 223 | ||
223 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 224 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
224 | void showIncidence(Incidence *); | 225 | void showIncidence(Incidence *); |
225 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 226 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
226 | void editIncidence(Incidence *); | 227 | void editIncidence(Incidence *); |
227 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 228 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
228 | void deleteIncidence(Incidence *); | 229 | void deleteIncidence(Incidence *); |
229 | void cloneIncidence(Incidence *); | 230 | void cloneIncidence(Incidence *); |
230 | void cancelIncidence(Incidence *); | 231 | void cancelIncidence(Incidence *); |
231 | /** Create an editor for the supplied event. */ | 232 | /** Create an editor for the supplied event. */ |
232 | void editEvent(Event *); | 233 | void editEvent(Event *); |
233 | /** Delete the supplied event. */ | 234 | /** Delete the supplied event. */ |
234 | void deleteEvent(Event *); | 235 | void deleteEvent(Event *); |
235 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 236 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
236 | found. */ | 237 | found. */ |
237 | bool deleteEvent(const QString &uid); | 238 | bool deleteEvent(const QString &uid); |
238 | /** Create a read-only viewer dialog for the supplied event. */ | 239 | /** Create a read-only viewer dialog for the supplied event. */ |
239 | void showEvent(Event *); | 240 | void showEvent(Event *); |
240 | 241 | ||
241 | void editJournal(Journal *); | 242 | void editJournal(Journal *); |
242 | void showJournal(Journal *); | 243 | void showJournal(Journal *); |
243 | void deleteJournal(Journal *); | 244 | void deleteJournal(Journal *); |
244 | /** Create an editor dialog for a todo */ | 245 | /** Create an editor dialog for a todo */ |
245 | void editTodo(Todo *); | 246 | void editTodo(Todo *); |
246 | /** Create a read-only viewer dialog for the supplied todo */ | 247 | /** Create a read-only viewer dialog for the supplied todo */ |
247 | void showTodo(Todo *); | 248 | void showTodo(Todo *); |
248 | /** create new todo */ | 249 | /** create new todo */ |
249 | void newTodo(); | 250 | void newTodo(); |
250 | /** create new todo with a parent todo */ | 251 | /** create new todo with a parent todo */ |
251 | void newSubTodo(); | 252 | void newSubTodo(); |
252 | /** create new todo with a parent todo */ | 253 | /** create new todo with a parent todo */ |
253 | void newSubTodo(Todo *); | 254 | void newSubTodo(Todo *); |
254 | /** Delete todo */ | 255 | /** Delete todo */ |
255 | void deleteTodo(Todo *); | 256 | void deleteTodo(Todo *); |
256 | 257 | ||
257 | 258 | ||
258 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 259 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
259 | * emitted as result. */ | 260 | * emitted as result. */ |
260 | void checkClipboard(); | 261 | void checkClipboard(); |
261 | 262 | ||
262 | /** using the KConfig associated with the kapp variable, read in the | 263 | /** using the KConfig associated with the kapp variable, read in the |
263 | * settings from the config file. | 264 | * settings from the config file. |
264 | */ | 265 | */ |
265 | void readSettings(); | 266 | void readSettings(); |
266 | 267 | ||
267 | /** write current state to config file. */ | 268 | /** write current state to config file. */ |
268 | void writeSettings(); | 269 | void writeSettings(); |
269 | 270 | ||
270 | /** read settings for calendar filters */ | 271 | /** read settings for calendar filters */ |
271 | void readFilterSettings(KConfig *config); | 272 | void readFilterSettings(KConfig *config); |
272 | 273 | ||
273 | /** write settings for calendar filters */ | 274 | /** write settings for calendar filters */ |
274 | void writeFilterSettings(KConfig *config); | 275 | void writeFilterSettings(KConfig *config); |
275 | 276 | ||
276 | /** passes on the message that an event has changed to the currently | 277 | /** passes on the message that an event has changed to the currently |
277 | * activated view so that it can make appropriate display changes. */ | 278 | * activated view so that it can make appropriate display changes. */ |
278 | void changeEventDisplay(Event *, int); | 279 | void changeEventDisplay(Event *, int); |
279 | void changeIncidenceDisplay(Incidence *, int); | 280 | void changeIncidenceDisplay(Incidence *, int); |
280 | void changeTodoDisplay(Todo *, int); | 281 | void changeTodoDisplay(Todo *, int); |
281 | 282 | ||
282 | void eventAdded(Event *); | 283 | void eventAdded(Event *); |
283 | void eventChanged(Event *); | 284 | void eventChanged(Event *); |
284 | void eventToBeDeleted(Event *); | 285 | void eventToBeDeleted(Event *); |
285 | void eventDeleted(); | 286 | void eventDeleted(); |
286 | 287 | ||
287 | void todoAdded(Todo *); | 288 | void todoAdded(Todo *); |
288 | void todoChanged(Todo *); | 289 | void todoChanged(Todo *); |
289 | void todoToBeDeleted(Todo *); | 290 | void todoToBeDeleted(Todo *); |
290 | void todoDeleted(); | 291 | void todoDeleted(); |
291 | 292 | ||
292 | void updateView(const QDate &start, const QDate &end); | 293 | void updateView(const QDate &start, const QDate &end); |
293 | void updateView(); | 294 | void updateView(); |
294 | 295 | ||
295 | /** Full update of visible todo views */ | 296 | /** Full update of visible todo views */ |
296 | void updateTodoViews(); | 297 | void updateTodoViews(); |
297 | 298 | ||
298 | void updateUnmanagedViews(); | 299 | void updateUnmanagedViews(); |
299 | 300 | ||
300 | /** cut the current appointment to the clipboard */ | 301 | /** cut the current appointment to the clipboard */ |
301 | void edit_cut(); | 302 | void edit_cut(); |
302 | 303 | ||
303 | /** copy the current appointment(s) to the clipboard */ | 304 | /** copy the current appointment(s) to the clipboard */ |
304 | void edit_copy(); | 305 | void edit_copy(); |
305 | 306 | ||
306 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 307 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
307 | void edit_paste(); | 308 | void edit_paste(); |
308 | 309 | ||
309 | /** edit viewing and configuration options. */ | 310 | /** edit viewing and configuration options. */ |
310 | void edit_options(); | 311 | void edit_options(); |
311 | void edit_sync_options(); | 312 | void edit_sync_options(); |
312 | /** | 313 | /** |
313 | Functions for printing, previewing a print, and setting up printing | 314 | Functions for printing, previewing a print, and setting up printing |
314 | parameters. | 315 | parameters. |
315 | */ | 316 | */ |
316 | void print(); | 317 | void print(); |
317 | void printSetup(); | 318 | void printSetup(); |
318 | void printPreview(); | 319 | void printPreview(); |
319 | 320 | ||
320 | /** Export as iCalendar file */ | 321 | /** Export as iCalendar file */ |
321 | void exportICalendar(); | 322 | void exportICalendar(); |
322 | 323 | ||
323 | /** Export as vCalendar file */ | 324 | /** Export as vCalendar file */ |
324 | bool exportVCalendar( QString fn); | 325 | bool exportVCalendar( QString fn); |
325 | 326 | ||
326 | /** pop up a dialog to show an existing appointment. */ | 327 | /** pop up a dialog to show an existing appointment. */ |
327 | void appointment_show(); | 328 | void appointment_show(); |
328 | /** | 329 | /** |
329 | * pop up an Appointment Dialog to edit an existing appointment.Get | 330 | * pop up an Appointment Dialog to edit an existing appointment.Get |
330 | * information on the appointment from the list of unique IDs that is | 331 | * information on the appointment from the list of unique IDs that is |
331 | * currently in the View, called currIds. | 332 | * currently in the View, called currIds. |
332 | */ | 333 | */ |
333 | void appointment_edit(); | 334 | void appointment_edit(); |
334 | /** | 335 | /** |
335 | * pop up dialog confirming deletion of currently selected event in the | 336 | * pop up dialog confirming deletion of currently selected event in the |
336 | * View. | 337 | * View. |
337 | */ | 338 | */ |
338 | void appointment_delete(); | 339 | void appointment_delete(); |
339 | 340 | ||
340 | /** mails the currently selected event to a particular user as a vCalendar | 341 | /** mails the currently selected event to a particular user as a vCalendar |
341 | attachment. */ | 342 | attachment. */ |
342 | void action_mail(); | 343 | void action_mail(); |
343 | 344 | ||
344 | /* frees a subtodo from it's relation */ | 345 | /* frees a subtodo from it's relation */ |
345 | void todo_unsub( Todo * ); | 346 | void todo_unsub( Todo * ); |
346 | 347 | ||
347 | /** Take ownership of selected event. */ | 348 | /** Take ownership of selected event. */ |
348 | void takeOverEvent(); | 349 | void takeOverEvent(); |
349 | 350 | ||
350 | /** Take ownership of all events in calendar. */ | 351 | /** Take ownership of all events in calendar. */ |
351 | void takeOverCalendar(); | 352 | void takeOverCalendar(); |
352 | 353 | ||
353 | /** query whether or not the calendar is "dirty". */ | 354 | /** query whether or not the calendar is "dirty". */ |
354 | bool isModified(); | 355 | bool isModified(); |
355 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 356 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
356 | void setModified(bool modified=true); | 357 | void setModified(bool modified=true); |
357 | 358 | ||
358 | /** query if the calendar is read-only. */ | 359 | /** query if the calendar is read-only. */ |
359 | bool isReadOnly(); | 360 | bool isReadOnly(); |
360 | /** set state of calendar to read-only */ | 361 | /** set state of calendar to read-only */ |
361 | void setReadOnly(bool readOnly=true); | 362 | void setReadOnly(bool readOnly=true); |
362 | 363 | ||
363 | void eventUpdated(Incidence *); | 364 | void eventUpdated(Incidence *); |
364 | 365 | ||
365 | /* iTIP scheduling actions */ | 366 | /* iTIP scheduling actions */ |
366 | void schedule_publish(Incidence *incidence = 0); | 367 | void schedule_publish(Incidence *incidence = 0); |
367 | void schedule_request(Incidence *incidence = 0); | 368 | void schedule_request(Incidence *incidence = 0); |
368 | void schedule_refresh(Incidence *incidence = 0); | 369 | void schedule_refresh(Incidence *incidence = 0); |
369 | void schedule_cancel(Incidence *incidence = 0); | 370 | void schedule_cancel(Incidence *incidence = 0); |
370 | void schedule_add(Incidence *incidence = 0); | 371 | void schedule_add(Incidence *incidence = 0); |
371 | void schedule_reply(Incidence *incidence = 0); | 372 | void schedule_reply(Incidence *incidence = 0); |
372 | void schedule_counter(Incidence *incidence = 0); | 373 | void schedule_counter(Incidence *incidence = 0); |
373 | void schedule_declinecounter(Incidence *incidence = 0); | 374 | void schedule_declinecounter(Incidence *incidence = 0); |
374 | void schedule_publish_freebusy(int daysToPublish = 30); | 375 | void schedule_publish_freebusy(int daysToPublish = 30); |
375 | 376 | ||
376 | void openAddressbook(); | 377 | void openAddressbook(); |
377 | 378 | ||
378 | void editFilters(); | 379 | void editFilters(); |
379 | void toggleFilerEnabled(); | 380 | void toggleFilerEnabled(); |
380 | QPtrList<CalFilter> filters(); | 381 | QPtrList<CalFilter> filters(); |
381 | void toggleFilter(); | 382 | void toggleFilter(); |
382 | void showFilter(bool visible); | 383 | void showFilter(bool visible); |
383 | void updateFilter(); | 384 | void updateFilter(); |
384 | void filterEdited(); | 385 | void filterEdited(); |
385 | void selectFilter( int ); | 386 | void selectFilter( int ); |
386 | KOFilterView *filterView(); | 387 | KOFilterView *filterView(); |
387 | 388 | ||
388 | void showIntro(); | 389 | void showIntro(); |
389 | 390 | ||
390 | /** Move the curdatepient view date to today */ | 391 | /** Move the curdatepient view date to today */ |
391 | void goToday(); | 392 | void goToday(); |
392 | 393 | ||
393 | /** Move to the next date(s) in the current view */ | 394 | /** Move to the next date(s) in the current view */ |
394 | void goNext(); | 395 | void goNext(); |
395 | 396 | ||
396 | /** Move to the previous date(s) in the current view */ | 397 | /** Move to the previous date(s) in the current view */ |
397 | void goPrevious(); | 398 | void goPrevious(); |
398 | /** Move to the next date(s) in the current view */ | 399 | /** Move to the next date(s) in the current view */ |
399 | void goNextMonth(); | 400 | void goNextMonth(); |
400 | 401 | ||
401 | /** Move to the previous date(s) in the current view */ | 402 | /** Move to the previous date(s) in the current view */ |
402 | void goPreviousMonth(); | 403 | void goPreviousMonth(); |
403 | 404 | ||
404 | void toggleExpand(); | 405 | void toggleExpand(); |
405 | void toggleDateNavigatorWidget(); | 406 | void toggleDateNavigatorWidget(); |
406 | void toggleAllDaySize(); | 407 | void toggleAllDaySize(); |
407 | void dialogClosing(Incidence *); | 408 | void dialogClosing(Incidence *); |
408 | 409 | ||
409 | /** Look for new messages in the inbox */ | 410 | /** Look for new messages in the inbox */ |
410 | void lookForIncomingMessages(); | 411 | void lookForIncomingMessages(); |
411 | /** Look for new messages in the outbox */ | 412 | /** Look for new messages in the outbox */ |
412 | void lookForOutgoingMessages(); | 413 | void lookForOutgoingMessages(); |
413 | 414 | ||
414 | void processMainViewSelection( Incidence * ); | 415 | void processMainViewSelection( Incidence * ); |
415 | void processTodoListSelection( Incidence * ); | 416 | void processTodoListSelection( Incidence * ); |
416 | 417 | ||
417 | void processIncidenceSelection( Incidence * ); | 418 | void processIncidenceSelection( Incidence * ); |
418 | 419 | ||
419 | void purgeCompleted(); | 420 | void purgeCompleted(); |
420 | bool removeCompletedSubTodos( Todo* ); | 421 | bool removeCompletedSubTodos( Todo* ); |
421 | void slotCalendarChanged(); | 422 | void slotCalendarChanged(); |
422 | bool importBday(); | 423 | bool importBday(); |
423 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 424 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
424 | bool importQtopia( const QString &categoriesFile, | 425 | bool importQtopia( const QString &categoriesFile, |
425 | const QString &datebookFile, | 426 | const QString &datebookFile, |
426 | const QString &tasklistFile ); | 427 | const QString &tasklistFile ); |
427 | void syncSharp( ); | 428 | void syncSharp( ); |
428 | void syncPhone( ); | 429 | void syncPhone( ); |
429 | void syncExternal( int mode ); | 430 | void syncExternal( int mode ); |
430 | void slotSelectPickerDate( QDate ) ; | 431 | void slotSelectPickerDate( QDate ) ; |
431 | void showDatePicker( ) ; | 432 | void showDatePicker( ) ; |
432 | void moveIncidence(Incidence *) ; | 433 | void moveIncidence(Incidence *) ; |
433 | void beamIncidence(Incidence *) ; | 434 | void beamIncidence(Incidence *) ; |
434 | void beamCalendar() ; | 435 | void beamCalendar() ; |
435 | void beamFilteredCalendar() ; | 436 | void beamFilteredCalendar() ; |
436 | void beamIncidenceList(QPtrList<Incidence>) ; | 437 | void beamIncidenceList(QPtrList<Incidence>) ; |
437 | void manageCategories(); | 438 | void manageCategories(); |
438 | int addCategories(); | 439 | int addCategories(); |
439 | void removeCategories(); | 440 | void removeCategories(); |
440 | void setSyncDevice( QString ); | 441 | void setSyncDevice( QString ); |
441 | void setSyncName( QString ); | 442 | void setSyncName( QString ); |
442 | protected slots: | 443 | protected slots: |
443 | void timerAlarm(); | 444 | void timerAlarm(); |
444 | void suspendAlarm(); | 445 | void suspendAlarm(); |
445 | void beamDone( Ir *ir ); | 446 | void beamDone( Ir *ir ); |
446 | /** Select a view or adapt the current view to display the specified dates. */ | 447 | /** Select a view or adapt the current view to display the specified dates. */ |
447 | void showDates( const KCal::DateList & ); | 448 | void showDates( const KCal::DateList & ); |
448 | void selectWeekNum ( int ); | 449 | void selectWeekNum ( int ); |
449 | 450 | ||
450 | public: | 451 | public: |
451 | // show a standard warning | 452 | // show a standard warning |
452 | // returns KMsgBox::yesNoCancel() | 453 | // returns KMsgBox::yesNoCancel() |
453 | int msgCalModified(); | 454 | int msgCalModified(); |
454 | void confSync(); | 455 | void confSync(); |
455 | void setLoadedFileVersion(QDateTime); | 456 | void setLoadedFileVersion(QDateTime); |
456 | bool checkFileVersion(QString fn); | 457 | bool checkFileVersion(QString fn); |
457 | bool checkFileChanged(QString fn); | 458 | bool checkFileChanged(QString fn); |
458 | Event* getLastSyncEvent(); | 459 | Event* getLastSyncEvent(); |
459 | /** Adapt navigation units correpsonding to step size of navigation of the | 460 | /** Adapt navigation units correpsonding to step size of navigation of the |
460 | * current view. | 461 | * current view. |
461 | */ | 462 | */ |
462 | void adaptNavigationUnits(); | 463 | void adaptNavigationUnits(); |
463 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 464 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
464 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 465 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
465 | //Attendee* getYourAttendee(Event *event); | 466 | //Attendee* getYourAttendee(Event *event); |
466 | protected: | 467 | protected: |
467 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 468 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
468 | 469 | ||
469 | // returns KMsgBox::OKCandel() | 470 | // returns KMsgBox::OKCandel() |
470 | int msgItemDelete(); | 471 | int msgItemDelete(); |
471 | void showEventEditor(); | 472 | void showEventEditor(); |
472 | void showTodoEditor(); | 473 | void showTodoEditor(); |
473 | void writeLocale(); | 474 | void writeLocale(); |
474 | Todo *selectedTodo(); | 475 | Todo *selectedTodo(); |
475 | 476 | ||
476 | private: | 477 | private: |
477 | AlarmDialog * mAlarmDialog; | 478 | AlarmDialog * mAlarmDialog; |
478 | QString mAlarmNotification; | 479 | QString mAlarmNotification; |
479 | QString mSuspendAlarmNotification; | 480 | QString mSuspendAlarmNotification; |
480 | QTimer* mSuspendTimer; | 481 | QTimer* mSuspendTimer; |
481 | QTimer* mAlarmTimer; | 482 | QTimer* mAlarmTimer; |
482 | QTimer* mRecheckAlarmTimer; | 483 | QTimer* mRecheckAlarmTimer; |
483 | void computeAlarm( QString ); | 484 | void computeAlarm( QString ); |
484 | void startAlarm( QString, QString ); | 485 | void startAlarm( QString, QString ); |
485 | void setSyncEventsReadOnly(); | 486 | void setSyncEventsReadOnly(); |
486 | 487 | ||
487 | QDateTime loadedFileVersion; | 488 | QDateTime loadedFileVersion; |
488 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 489 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
489 | void checkExternalId( Incidence * inc ); | 490 | void checkExternalId( Incidence * inc ); |
490 | int mGlobalSyncMode; | 491 | int mGlobalSyncMode; |
491 | QString mCurrentSyncDevice; | 492 | QString mCurrentSyncDevice; |
492 | QString mCurrentSyncName; | 493 | QString mCurrentSyncName; |
493 | KOBeamPrefs* beamDialog; | 494 | KOBeamPrefs* beamDialog; |
494 | void init(); | 495 | void init(); |
495 | int mDatePickerMode; | 496 | int mDatePickerMode; |
496 | bool mFlagEditDescription; | 497 | bool mFlagEditDescription; |
497 | QDateTime mLastCalendarSync; | 498 | QDateTime mLastCalendarSync; |
498 | void createPrinter(); | 499 | void createPrinter(); |
499 | 500 | ||
500 | void calendarModified( bool, Calendar * ); | 501 | void calendarModified( bool, Calendar * ); |
501 | 502 | ||
502 | CalPrinter *mCalPrinter; | 503 | CalPrinter *mCalPrinter; |
503 | 504 | ||
504 | QSplitter *mPanner; | 505 | QSplitter *mPanner; |
505 | QSplitter *mLeftSplitter; | 506 | QSplitter *mLeftSplitter; |
506 | QWidget *mLeftFrame; | 507 | QWidget *mLeftFrame; |
507 | QWidgetStack *mRightFrame; | 508 | QWidgetStack *mRightFrame; |
508 | 509 | ||
509 | KDatePicker* mDatePicker; | 510 | KDatePicker* mDatePicker; |
510 | QVBox* mDateFrame; | 511 | QVBox* mDateFrame; |
511 | NavigatorBar *mNavigatorBar; | 512 | NavigatorBar *mNavigatorBar; |
512 | 513 | ||
513 | KDateNavigator *mDateNavigator; // widget showing small month view. | 514 | KDateNavigator *mDateNavigator; // widget showing small month view. |
514 | 515 | ||
515 | KOFilterView *mFilterView; | 516 | KOFilterView *mFilterView; |
516 | 517 | ||
517 | ResourceView *mResourceView; | 518 | ResourceView *mResourceView; |
518 | 519 | ||
519 | // calendar object for this viewing instance | 520 | // calendar object for this viewing instance |
520 | Calendar *mCalendar; | 521 | Calendar *mCalendar; |
521 | 522 | ||
522 | CalendarResourceManager *mResourceManager; | 523 | CalendarResourceManager *mResourceManager; |
523 | 524 | ||
524 | FileStorage *mStorage; | 525 | FileStorage *mStorage; |
525 | 526 | ||
526 | DateNavigator *mNavigator; | 527 | DateNavigator *mNavigator; |
527 | 528 | ||
528 | KOViewManager *mViewManager; | 529 | KOViewManager *mViewManager; |
529 | KODialogManager *mDialogManager; | 530 | KODialogManager *mDialogManager; |
530 | 531 | ||
531 | // Calendar filters | 532 | // Calendar filters |
532 | QPtrList<CalFilter> mFilters; | 533 | QPtrList<CalFilter> mFilters; |
533 | 534 | ||
534 | // various housekeeping variables. | 535 | // various housekeeping variables. |
535 | bool mModified; // flag indicating if calendar is modified | 536 | bool mModified; // flag indicating if calendar is modified |
536 | bool mReadOnly; // flag indicating if calendar is read-only | 537 | bool mReadOnly; // flag indicating if calendar is read-only |
537 | QDate mSaveSingleDate; | 538 | QDate mSaveSingleDate; |
538 | 539 | ||
539 | Incidence *mSelectedIncidence; | 540 | Incidence *mSelectedIncidence; |
540 | Incidence *mMoveIncidence; | 541 | Incidence *mMoveIncidence; |
541 | QPtrList<Event> mExternLastSyncEvent; | 542 | QPtrList<Event> mExternLastSyncEvent; |
542 | KOTodoView *mTodoList; | 543 | KOTodoView *mTodoList; |
543 | KOEventEditor * mEventEditor; | 544 | KOEventEditor * mEventEditor; |
544 | KOTodoEditor * mTodoEditor; | 545 | KOTodoEditor * mTodoEditor; |
545 | KOEventViewerDialog * mEventViewerDialog; | 546 | KOEventViewerDialog * mEventViewerDialog; |
546 | void keyPressEvent ( QKeyEvent *e) ; | 547 | void keyPressEvent ( QKeyEvent *e) ; |
547 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 548 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
548 | }; | 549 | }; |
549 | 550 | ||
550 | 551 | ||
551 | class CalendarViewVisitor : public Incidence::Visitor | 552 | class CalendarViewVisitor : public Incidence::Visitor |
552 | { | 553 | { |
553 | public: | 554 | public: |
554 | CalendarViewVisitor() : mView( 0 ) {} | 555 | CalendarViewVisitor() : mView( 0 ) {} |
555 | 556 | ||
556 | bool act( Incidence *incidence, CalendarView *view ) | 557 | bool act( Incidence *incidence, CalendarView *view ) |
557 | { | 558 | { |
558 | mView = view; | 559 | mView = view; |
559 | return incidence->accept( *this ); | 560 | return incidence->accept( *this ); |
560 | } | 561 | } |
561 | 562 | ||
562 | protected: | 563 | protected: |
563 | CalendarView *mView; | 564 | CalendarView *mView; |
564 | }; | 565 | }; |
565 | 566 | ||
566 | class ShowIncidenceVisitor : public CalendarViewVisitor | 567 | class ShowIncidenceVisitor : public CalendarViewVisitor |
567 | { | 568 | { |
568 | protected: | 569 | protected: |
569 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 570 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
570 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 571 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
571 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 572 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
572 | }; | 573 | }; |
573 | 574 | ||
574 | class EditIncidenceVisitor : public CalendarViewVisitor | 575 | class EditIncidenceVisitor : public CalendarViewVisitor |
575 | { | 576 | { |
576 | protected: | 577 | protected: |
577 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 578 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
578 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 579 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
579 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 580 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
580 | }; | 581 | }; |
581 | 582 | ||
582 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 583 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
583 | { | 584 | { |
584 | protected: | 585 | protected: |
585 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 586 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
586 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 587 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
587 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 588 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
588 | }; | 589 | }; |
589 | 590 | ||
590 | #endif | 591 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 1c4a186..6315c64 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -643,1494 +643,1495 @@ void MainWindow::initActions() | |||
643 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 643 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
644 | 644 | ||
645 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 645 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
646 | this ); | 646 | this ); |
647 | action->addTo( importMenu ); | 647 | action->addTo( importMenu ); |
648 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 648 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
649 | 649 | ||
650 | importMenu->insertSeparator(); | 650 | importMenu->insertSeparator(); |
651 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 651 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
652 | this ); | 652 | this ); |
653 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 653 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
654 | importMenu->insertSeparator(); | 654 | importMenu->insertSeparator(); |
655 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 655 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
656 | this ); | 656 | this ); |
657 | action->addTo( importMenu ); | 657 | action->addTo( importMenu ); |
658 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 658 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
659 | #ifndef DESKTOP_VERSION | 659 | #ifndef DESKTOP_VERSION |
660 | importMenu->insertSeparator(); | 660 | importMenu->insertSeparator(); |
661 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 661 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
662 | this ); | 662 | this ); |
663 | action->addTo( importMenu ); | 663 | action->addTo( importMenu ); |
664 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 664 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
665 | 665 | ||
666 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 666 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
667 | this ); | 667 | this ); |
668 | action->addTo( importMenu ); | 668 | action->addTo( importMenu ); |
669 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 669 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
670 | #else | 670 | #else |
671 | importMenu->insertSeparator(); | 671 | importMenu->insertSeparator(); |
672 | icon = loadPixmap( pathString + "print" ); | 672 | icon = loadPixmap( pathString + "print" ); |
673 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 673 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
674 | action->addTo( importMenu ); | 674 | action->addTo( importMenu ); |
675 | connect( action, SIGNAL( activated() ), | 675 | connect( action, SIGNAL( activated() ), |
676 | this, SLOT( printCal() ) ); | 676 | this, SLOT( printCal() ) ); |
677 | 677 | ||
678 | icon = loadPixmap( pathString + "print" ); | 678 | icon = loadPixmap( pathString + "print" ); |
679 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 679 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
680 | action->addTo( importMenu ); | 680 | action->addTo( importMenu ); |
681 | connect( action, SIGNAL( activated() ), | 681 | connect( action, SIGNAL( activated() ), |
682 | this, SLOT( printSel() ) ); | 682 | this, SLOT( printSel() ) ); |
683 | #endif | 683 | #endif |
684 | importMenu->insertSeparator(); | 684 | importMenu->insertSeparator(); |
685 | action = new QAction( "beam all", i18n("Save"), 0, | 685 | action = new QAction( "beam all", i18n("Save"), 0, |
686 | this ); | 686 | this ); |
687 | action->addTo( importMenu ); | 687 | action->addTo( importMenu ); |
688 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 688 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
689 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 689 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
690 | this ); | 690 | this ); |
691 | action->addTo( importMenu ); | 691 | action->addTo( importMenu ); |
692 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 692 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
693 | 693 | ||
694 | //menuBar->insertItem( "Configure",configureMenu ); | 694 | //menuBar->insertItem( "Configure",configureMenu ); |
695 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 695 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
696 | icon = loadPixmap( "korganizer/korganizer" ); | 696 | icon = loadPixmap( "korganizer/korganizer" ); |
697 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 697 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
698 | action->addTo( helpMenu ); | 698 | action->addTo( helpMenu ); |
699 | connect( action, SIGNAL( activated() ), | 699 | connect( action, SIGNAL( activated() ), |
700 | SLOT( keyBindings() ) ); | 700 | SLOT( keyBindings() ) ); |
701 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 701 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
702 | action->addTo( helpMenu ); | 702 | action->addTo( helpMenu ); |
703 | connect( action, SIGNAL( activated() ), | 703 | connect( action, SIGNAL( activated() ), |
704 | SLOT( features() ) ); | 704 | SLOT( features() ) ); |
705 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 705 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
706 | action->addTo( helpMenu ); | 706 | action->addTo( helpMenu ); |
707 | connect( action, SIGNAL( activated() ), | 707 | connect( action, SIGNAL( activated() ), |
708 | SLOT( aboutAutoSaving() ) ); | 708 | SLOT( aboutAutoSaving() ) ); |
709 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 709 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
710 | action->addTo( helpMenu ); | 710 | action->addTo( helpMenu ); |
711 | connect( action, SIGNAL( activated() ), | 711 | connect( action, SIGNAL( activated() ), |
712 | SLOT( aboutKnownBugs() ) ); | 712 | SLOT( aboutKnownBugs() ) ); |
713 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 713 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
714 | action->addTo( helpMenu ); | 714 | action->addTo( helpMenu ); |
715 | connect( action, SIGNAL( activated() ), | 715 | connect( action, SIGNAL( activated() ), |
716 | SLOT( usertrans() ) ); | 716 | SLOT( usertrans() ) ); |
717 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 717 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
718 | action->addTo( helpMenu ); | 718 | action->addTo( helpMenu ); |
719 | connect( action, SIGNAL( activated() ), | 719 | connect( action, SIGNAL( activated() ), |
720 | SLOT( synchowto() ) ); | 720 | SLOT( synchowto() ) ); |
721 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 721 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
722 | action->addTo( helpMenu ); | 722 | action->addTo( helpMenu ); |
723 | connect( action, SIGNAL( activated() ), | 723 | connect( action, SIGNAL( activated() ), |
724 | SLOT( whatsNew() ) ); | 724 | SLOT( whatsNew() ) ); |
725 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 725 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
726 | action->addTo( helpMenu ); | 726 | action->addTo( helpMenu ); |
727 | connect( action, SIGNAL( activated() ), | 727 | connect( action, SIGNAL( activated() ), |
728 | SLOT( faq() ) ); | 728 | SLOT( faq() ) ); |
729 | 729 | ||
730 | 730 | ||
731 | action = new QAction( "about", i18n("About..."), 0, this ); | 731 | action = new QAction( "about", i18n("About..."), 0, this ); |
732 | action->addTo( helpMenu ); | 732 | action->addTo( helpMenu ); |
733 | connect( action, SIGNAL( activated() ), | 733 | connect( action, SIGNAL( activated() ), |
734 | SLOT( about() ) ); | 734 | SLOT( about() ) ); |
735 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 735 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
736 | action->addTo( helpMenu ); | 736 | action->addTo( helpMenu ); |
737 | connect( action, SIGNAL( activated() ), | 737 | connect( action, SIGNAL( activated() ), |
738 | SLOT( licence() ) ); | 738 | SLOT( licence() ) ); |
739 | //menuBar->insertSeparator(); | 739 | //menuBar->insertSeparator(); |
740 | 740 | ||
741 | // ****************************************************** | 741 | // ****************************************************** |
742 | // menubar icons | 742 | // menubar icons |
743 | 743 | ||
744 | 744 | ||
745 | iconToolBar->setHorizontalStretchable (true ); | 745 | iconToolBar->setHorizontalStretchable (true ); |
746 | //menuBar->insertItem( iconToolBar ); | 746 | //menuBar->insertItem( iconToolBar ); |
747 | //xdays_action | 747 | //xdays_action |
748 | if (p-> mShowIconNewEvent) | 748 | if (p-> mShowIconNewEvent) |
749 | ne_action->addTo( iconToolBar ); | 749 | ne_action->addTo( iconToolBar ); |
750 | if (p->mShowIconNewTodo ) | 750 | if (p->mShowIconNewTodo ) |
751 | nt_action->addTo( iconToolBar ); | 751 | nt_action->addTo( iconToolBar ); |
752 | if (p-> mShowIconSearch) | 752 | if (p-> mShowIconSearch) |
753 | search_action->addTo( iconToolBar ); | 753 | search_action->addTo( iconToolBar ); |
754 | if (p-> mShowIconNext) | 754 | if (p-> mShowIconNext) |
755 | whatsnext_action->addTo( iconToolBar ); | 755 | whatsnext_action->addTo( iconToolBar ); |
756 | if (p-> mShowIconNextDays) | 756 | if (p-> mShowIconNextDays) |
757 | xdays_action->addTo( iconToolBar ); | 757 | xdays_action->addTo( iconToolBar ); |
758 | if (p-> mShowIconList) | 758 | if (p-> mShowIconList) |
759 | showlist_action->addTo( iconToolBar ); | 759 | showlist_action->addTo( iconToolBar ); |
760 | if (p-> mShowIconDay1) | 760 | if (p-> mShowIconDay1) |
761 | day1_action->addTo( iconToolBar ); | 761 | day1_action->addTo( iconToolBar ); |
762 | if (p-> mShowIconDay5) | 762 | if (p-> mShowIconDay5) |
763 | day5_action->addTo( iconToolBar ); | 763 | day5_action->addTo( iconToolBar ); |
764 | if (p-> mShowIconDay7) | 764 | if (p-> mShowIconDay7) |
765 | day7_action->addTo( iconToolBar ); | 765 | day7_action->addTo( iconToolBar ); |
766 | if (p-> mShowIconMonth) | 766 | if (p-> mShowIconMonth) |
767 | month_action->addTo( iconToolBar ); | 767 | month_action->addTo( iconToolBar ); |
768 | if (p-> mShowIconTodoview) | 768 | if (p-> mShowIconTodoview) |
769 | todoview_action->addTo( iconToolBar ); | 769 | todoview_action->addTo( iconToolBar ); |
770 | if (p-> mShowIconJournal) | 770 | if (p-> mShowIconJournal) |
771 | viewjournal_action->addTo( iconToolBar ); | 771 | viewjournal_action->addTo( iconToolBar ); |
772 | icon = loadPixmap( pathString + "2leftarrowB" ); | 772 | icon = loadPixmap( pathString + "2leftarrowB" ); |
773 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 773 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
774 | if (p-> mShowIconBackFast) { | 774 | if (p-> mShowIconBackFast) { |
775 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 775 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
776 | connect( action, SIGNAL( activated() ), | 776 | connect( action, SIGNAL( activated() ), |
777 | mView, SLOT( goPreviousMonth() ) ); | 777 | mView, SLOT( goPreviousMonth() ) ); |
778 | action->addTo( iconToolBar ); | 778 | action->addTo( iconToolBar ); |
779 | } | 779 | } |
780 | icon = loadPixmap( pathString + "1leftarrowB" ); | 780 | icon = loadPixmap( pathString + "1leftarrowB" ); |
781 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 781 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
782 | if (p-> mShowIconBack) { | 782 | if (p-> mShowIconBack) { |
783 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 783 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
784 | connect( action, SIGNAL( activated() ), | 784 | connect( action, SIGNAL( activated() ), |
785 | mView, SLOT( goPrevious() ) ); | 785 | mView, SLOT( goPrevious() ) ); |
786 | action->addTo( iconToolBar ); | 786 | action->addTo( iconToolBar ); |
787 | } | 787 | } |
788 | if (p-> mShowIconToday) | 788 | if (p-> mShowIconToday) |
789 | today_action->addTo( iconToolBar ); | 789 | today_action->addTo( iconToolBar ); |
790 | icon = loadPixmap( pathString + "1rightarrowB" ); | 790 | icon = loadPixmap( pathString + "1rightarrowB" ); |
791 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 791 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
792 | if (p-> mShowIconForward) { | 792 | if (p-> mShowIconForward) { |
793 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 793 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
794 | connect( action, SIGNAL( activated() ), | 794 | connect( action, SIGNAL( activated() ), |
795 | mView, SLOT( goNext() ) ); | 795 | mView, SLOT( goNext() ) ); |
796 | action->addTo( iconToolBar ); | 796 | action->addTo( iconToolBar ); |
797 | } | 797 | } |
798 | icon = loadPixmap( pathString + "2rightarrowB" ); | 798 | icon = loadPixmap( pathString + "2rightarrowB" ); |
799 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 799 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
800 | if (p-> mShowIconForwardFast) { | 800 | if (p-> mShowIconForwardFast) { |
801 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 801 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
802 | connect( action, SIGNAL( activated() ), | 802 | connect( action, SIGNAL( activated() ), |
803 | mView, SLOT( goNextMonth() ) ); | 803 | mView, SLOT( goNextMonth() ) ); |
804 | action->addTo( iconToolBar ); | 804 | action->addTo( iconToolBar ); |
805 | } | 805 | } |
806 | 806 | ||
807 | 807 | ||
808 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 808 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
809 | 809 | ||
810 | if (p-> mShowIconNewEvent) | 810 | if (p-> mShowIconNewEvent) |
811 | configureToolBarMenu->setItemChecked( 10, true ); | 811 | configureToolBarMenu->setItemChecked( 10, true ); |
812 | if (p->mShowIconNewTodo ) | 812 | if (p->mShowIconNewTodo ) |
813 | configureToolBarMenu->setItemChecked( 20, true ); | 813 | configureToolBarMenu->setItemChecked( 20, true ); |
814 | if (p-> mShowIconSearch) | 814 | if (p-> mShowIconSearch) |
815 | configureToolBarMenu->setItemChecked( 120, true ); | 815 | configureToolBarMenu->setItemChecked( 120, true ); |
816 | if (p-> mShowIconList) | 816 | if (p-> mShowIconList) |
817 | configureToolBarMenu->setItemChecked( 30, true ); | 817 | configureToolBarMenu->setItemChecked( 30, true ); |
818 | if (p-> mShowIconDay1) | 818 | if (p-> mShowIconDay1) |
819 | configureToolBarMenu->setItemChecked( 40, true ); | 819 | configureToolBarMenu->setItemChecked( 40, true ); |
820 | if (p-> mShowIconDay5) | 820 | if (p-> mShowIconDay5) |
821 | configureToolBarMenu->setItemChecked( 50, true ); | 821 | configureToolBarMenu->setItemChecked( 50, true ); |
822 | if (p-> mShowIconDay7) | 822 | if (p-> mShowIconDay7) |
823 | configureToolBarMenu->setItemChecked( 60, true ); | 823 | configureToolBarMenu->setItemChecked( 60, true ); |
824 | if (p-> mShowIconMonth) | 824 | if (p-> mShowIconMonth) |
825 | configureToolBarMenu->setItemChecked( 70, true ); | 825 | configureToolBarMenu->setItemChecked( 70, true ); |
826 | if (p-> mShowIconTodoview) | 826 | if (p-> mShowIconTodoview) |
827 | configureToolBarMenu->setItemChecked( 80, true ); | 827 | configureToolBarMenu->setItemChecked( 80, true ); |
828 | if (p-> mShowIconBackFast) | 828 | if (p-> mShowIconBackFast) |
829 | configureToolBarMenu->setItemChecked( 200, true ); | 829 | configureToolBarMenu->setItemChecked( 200, true ); |
830 | if (p-> mShowIconBack) | 830 | if (p-> mShowIconBack) |
831 | configureToolBarMenu->setItemChecked( 210, true ); | 831 | configureToolBarMenu->setItemChecked( 210, true ); |
832 | if (p-> mShowIconToday) | 832 | if (p-> mShowIconToday) |
833 | configureToolBarMenu->setItemChecked( 130, true ); | 833 | configureToolBarMenu->setItemChecked( 130, true ); |
834 | if (p-> mShowIconForward) | 834 | if (p-> mShowIconForward) |
835 | configureToolBarMenu->setItemChecked( 220, true ); | 835 | configureToolBarMenu->setItemChecked( 220, true ); |
836 | if (p-> mShowIconForwardFast) | 836 | if (p-> mShowIconForwardFast) |
837 | configureToolBarMenu->setItemChecked( 230, true ); | 837 | configureToolBarMenu->setItemChecked( 230, true ); |
838 | if (p-> mShowIconNextDays) | 838 | if (p-> mShowIconNextDays) |
839 | configureToolBarMenu->setItemChecked( 100, true ); | 839 | configureToolBarMenu->setItemChecked( 100, true ); |
840 | if (p-> mShowIconNext) | 840 | if (p-> mShowIconNext) |
841 | configureToolBarMenu->setItemChecked( 110, true ); | 841 | configureToolBarMenu->setItemChecked( 110, true ); |
842 | if (p-> mShowIconJournal) | 842 | if (p-> mShowIconJournal) |
843 | configureToolBarMenu->setItemChecked( 90, true ); | 843 | configureToolBarMenu->setItemChecked( 90, true ); |
844 | if (p-> mShowIconWhatsThis) | 844 | if (p-> mShowIconWhatsThis) |
845 | configureToolBarMenu->setItemChecked( 300, true ); | 845 | configureToolBarMenu->setItemChecked( 300, true ); |
846 | 846 | ||
847 | QLabel* dummy = new QLabel( iconToolBar ); | 847 | QLabel* dummy = new QLabel( iconToolBar ); |
848 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 848 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
849 | if (!p-> mShowIconStretch) | 849 | if (!p-> mShowIconStretch) |
850 | iconToolBar->setStretchableWidget ( dummy ) ; | 850 | iconToolBar->setStretchableWidget ( dummy ) ; |
851 | else | 851 | else |
852 | configureToolBarMenu->setItemChecked( 5, true ); | 852 | configureToolBarMenu->setItemChecked( 5, true ); |
853 | if (p-> mShowIconWhatsThis) | 853 | if (p-> mShowIconWhatsThis) |
854 | QWhatsThis::whatsThisButton ( iconToolBar ); | 854 | QWhatsThis::whatsThisButton ( iconToolBar ); |
855 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 855 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
856 | configureAgenda( p->mHourSize ); | 856 | configureAgenda( p->mHourSize ); |
857 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 857 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
858 | } | 858 | } |
859 | void MainWindow::fillSyncMenu() | 859 | void MainWindow::fillSyncMenu() |
860 | { | 860 | { |
861 | if ( syncMenu->count() ) | 861 | if ( syncMenu->count() ) |
862 | syncMenu->clear(); | 862 | syncMenu->clear(); |
863 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 863 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
864 | syncMenu->insertSeparator(); | 864 | syncMenu->insertSeparator(); |
865 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 865 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
866 | syncMenu->insertSeparator(); | 866 | syncMenu->insertSeparator(); |
867 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 867 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
868 | config.setGroup("General"); | 868 | config.setGroup("General"); |
869 | QStringList prof = config.readListEntry("SyncProfileNames"); | 869 | QStringList prof = config.readListEntry("SyncProfileNames"); |
870 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 870 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
871 | if ( prof.count() < 3 ) { | 871 | if ( prof.count() < 3 ) { |
872 | prof.clear(); | 872 | prof.clear(); |
873 | prof << i18n("Sharp_DTM"); | 873 | prof << i18n("Sharp_DTM"); |
874 | prof << i18n("Local_file"); | 874 | prof << i18n("Local_file"); |
875 | prof << i18n("Last_file"); | 875 | prof << i18n("Last_file"); |
876 | KSyncProfile* temp = new KSyncProfile (); | 876 | KSyncProfile* temp = new KSyncProfile (); |
877 | temp->setName( prof[0] ); | 877 | temp->setName( prof[0] ); |
878 | temp->writeConfig(&config); | 878 | temp->writeConfig(&config); |
879 | temp->setName( prof[1] ); | 879 | temp->setName( prof[1] ); |
880 | temp->writeConfig(&config); | 880 | temp->writeConfig(&config); |
881 | temp->setName( prof[2] ); | 881 | temp->setName( prof[2] ); |
882 | temp->writeConfig(&config); | 882 | temp->writeConfig(&config); |
883 | config.setGroup("General"); | 883 | config.setGroup("General"); |
884 | config.writeEntry("SyncProfileNames",prof); | 884 | config.writeEntry("SyncProfileNames",prof); |
885 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 885 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
886 | config.sync(); | 886 | config.sync(); |
887 | delete temp; | 887 | delete temp; |
888 | } | 888 | } |
889 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 889 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
890 | KOPrefs::instance()->mSyncProfileNames = prof; | 890 | KOPrefs::instance()->mSyncProfileNames = prof; |
891 | int i; | 891 | int i; |
892 | for ( i = 0; i < prof.count(); ++i ) { | 892 | for ( i = 0; i < prof.count(); ++i ) { |
893 | 893 | ||
894 | syncMenu->insertItem( prof[i], 1000+i ); | 894 | syncMenu->insertItem( prof[i], 1000+i ); |
895 | if ( i == 2 ) | 895 | if ( i == 2 ) |
896 | syncMenu->insertSeparator(); | 896 | syncMenu->insertSeparator(); |
897 | } | 897 | } |
898 | QDir app_dir; | 898 | QDir app_dir; |
899 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 899 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
900 | syncMenu->setItemEnabled( false , 1000 ); | 900 | syncMenu->setItemEnabled( false , 1000 ); |
901 | } | 901 | } |
902 | mView->setupExternSyncProfiles(); | 902 | mView->setupExternSyncProfiles(); |
903 | } | 903 | } |
904 | 904 | ||
905 | int MainWindow::ringSync() | 905 | int MainWindow::ringSync() |
906 | { | 906 | { |
907 | int syncedProfiles = 0; | 907 | int syncedProfiles = 0; |
908 | int i; | 908 | int i; |
909 | QTime timer; | 909 | QTime timer; |
910 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 910 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
911 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 911 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
912 | KSyncProfile* temp = new KSyncProfile (); | 912 | KSyncProfile* temp = new KSyncProfile (); |
913 | KOPrefs::instance()->mAskForPreferences = false; | 913 | KOPrefs::instance()->mAskForPreferences = false; |
914 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 914 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
915 | mCurrentSyncProfile = i; | 915 | mCurrentSyncProfile = i; |
916 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 916 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
917 | temp->readConfig(&config); | 917 | temp->readConfig(&config); |
918 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 918 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
919 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 919 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
920 | ++syncedProfiles; | 920 | ++syncedProfiles; |
921 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 921 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
922 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 922 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
923 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 923 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
924 | KOPrefs::instance()->mWriteBackInFuture = 0; | 924 | KOPrefs::instance()->mWriteBackInFuture = 0; |
925 | if ( temp->getWriteBackFuture() ) | 925 | if ( temp->getWriteBackFuture() ) |
926 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 926 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
927 | KOPrefs::instance()->mShowSyncSummary = false; | 927 | KOPrefs::instance()->mShowSyncSummary = false; |
928 | mView->setSyncDevice(syncProfileNames[i] ); | 928 | mView->setSyncDevice(syncProfileNames[i] ); |
929 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 929 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
930 | if ( i == 0 ) { | 930 | if ( i == 0 ) { |
931 | syncSharp(); | 931 | syncSharp(); |
932 | } else { | 932 | } else { |
933 | if ( temp->getIsLocalFileSync() ) { | 933 | if ( temp->getIsLocalFileSync() ) { |
934 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 934 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
935 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 935 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
936 | } else { | 936 | } else { |
937 | if ( temp->getIsPhoneSync() ) { | 937 | if ( temp->getIsPhoneSync() ) { |
938 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 938 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
939 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 939 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
940 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 940 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
941 | syncPhone(); | 941 | syncPhone(); |
942 | } else | 942 | } else |
943 | syncRemote( temp, false ); | 943 | syncRemote( temp, false ); |
944 | 944 | ||
945 | } | 945 | } |
946 | } | 946 | } |
947 | timer.start(); | 947 | timer.start(); |
948 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 948 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
949 | while ( timer.elapsed () < 2000 ) { | 949 | while ( timer.elapsed () < 2000 ) { |
950 | qApp->processEvents(); | 950 | qApp->processEvents(); |
951 | #ifndef _WIN32_ | 951 | #ifndef _WIN32_ |
952 | sleep (1); | 952 | sleep (1); |
953 | #endif | 953 | #endif |
954 | } | 954 | } |
955 | 955 | ||
956 | } | 956 | } |
957 | 957 | ||
958 | } | 958 | } |
959 | delete temp; | 959 | delete temp; |
960 | return syncedProfiles; | 960 | return syncedProfiles; |
961 | } | 961 | } |
962 | 962 | ||
963 | void MainWindow::multiSync( bool askforPrefs ) | 963 | void MainWindow::multiSync( bool askforPrefs ) |
964 | { | 964 | { |
965 | if (mBlockSaveFlag) | 965 | if (mBlockSaveFlag) |
966 | return; | 966 | return; |
967 | mBlockSaveFlag = true; | 967 | mBlockSaveFlag = true; |
968 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 968 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
969 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 969 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
970 | question, | 970 | question, |
971 | i18n("Yes"), i18n("No"), | 971 | i18n("Yes"), i18n("No"), |
972 | 0, 0 ) != 0 ) { | 972 | 0, 0 ) != 0 ) { |
973 | mBlockSaveFlag = false; | 973 | mBlockSaveFlag = false; |
974 | setCaption(i18n("Aborted! Nothing synced!")); | 974 | setCaption(i18n("Aborted! Nothing synced!")); |
975 | return; | 975 | return; |
976 | } | 976 | } |
977 | mView->setSyncDevice(i18n("Multiple profiles") ); | 977 | mView->setSyncDevice(i18n("Multiple profiles") ); |
978 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | 978 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; |
979 | if ( askforPrefs ) { | 979 | if ( askforPrefs ) { |
980 | mView->edit_sync_options(); | 980 | mView->edit_sync_options(); |
981 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | 981 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; |
982 | } | 982 | } |
983 | setCaption(i18n("Multiple sync started.") ); | 983 | setCaption(i18n("Multiple sync started.") ); |
984 | qApp->processEvents(); | 984 | qApp->processEvents(); |
985 | int num = ringSync() ; | 985 | int num = ringSync() ; |
986 | if ( num > 1 ) | 986 | if ( num > 1 ) |
987 | ringSync(); | 987 | ringSync(); |
988 | mBlockSaveFlag = false; | 988 | mBlockSaveFlag = false; |
989 | if ( num ) | 989 | if ( num ) |
990 | save(); | 990 | save(); |
991 | if ( num ) | 991 | if ( num ) |
992 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 992 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
993 | else | 993 | else |
994 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 994 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
995 | return; | 995 | return; |
996 | } | 996 | } |
997 | void MainWindow::slotSyncMenu( int action ) | 997 | void MainWindow::slotSyncMenu( int action ) |
998 | { | 998 | { |
999 | //qDebug("syncaction %d ", action); | 999 | //qDebug("syncaction %d ", action); |
1000 | if ( action == 0 ) { | 1000 | if ( action == 0 ) { |
1001 | 1001 | ||
1002 | // seems to be a Qt2 event handling bug | 1002 | // seems to be a Qt2 event handling bug |
1003 | // syncmenu.clear causes a segfault at first time | 1003 | // syncmenu.clear causes a segfault at first time |
1004 | // when we call it after the main event loop, it is ok | 1004 | // when we call it after the main event loop, it is ok |
1005 | // same behaviour when calling OM/Pi via QCOP for the first time | 1005 | // same behaviour when calling OM/Pi via QCOP for the first time |
1006 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 1006 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
1007 | //confSync(); | 1007 | //confSync(); |
1008 | 1008 | ||
1009 | return; | 1009 | return; |
1010 | } | 1010 | } |
1011 | if ( action == 1 ) { | 1011 | if ( action == 1 ) { |
1012 | multiSync( true ); | 1012 | multiSync( true ); |
1013 | return; | 1013 | return; |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | if (mBlockSaveFlag) | 1016 | if (mBlockSaveFlag) |
1017 | return; | 1017 | return; |
1018 | mBlockSaveFlag = true; | 1018 | mBlockSaveFlag = true; |
1019 | mCurrentSyncProfile = action - 1000 ; | 1019 | mCurrentSyncProfile = action - 1000 ; |
1020 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 1020 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
1021 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1021 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1022 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1022 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1023 | KSyncProfile* temp = new KSyncProfile (); | 1023 | KSyncProfile* temp = new KSyncProfile (); |
1024 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1024 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1025 | temp->readConfig(&config); | 1025 | temp->readConfig(&config); |
1026 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1026 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1027 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 1027 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
1028 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1028 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1029 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1029 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1030 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1030 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1031 | if ( temp->getWriteBackFuture() ) | 1031 | if ( temp->getWriteBackFuture() ) |
1032 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1032 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1033 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1033 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1034 | if ( action == 1000 ) { | 1034 | if ( action == 1000 ) { |
1035 | syncSharp(); | 1035 | syncSharp(); |
1036 | 1036 | ||
1037 | } else if ( action == 1001 ) { | 1037 | } else if ( action == 1001 ) { |
1038 | syncLocalFile(); | 1038 | syncLocalFile(); |
1039 | 1039 | ||
1040 | } else if ( action == 1002 ) { | 1040 | } else if ( action == 1002 ) { |
1041 | quickSyncLocalFile(); | 1041 | quickSyncLocalFile(); |
1042 | 1042 | ||
1043 | } else if ( action >= 1003 ) { | 1043 | } else if ( action >= 1003 ) { |
1044 | if ( temp->getIsLocalFileSync() ) { | 1044 | if ( temp->getIsLocalFileSync() ) { |
1045 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1045 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1046 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1046 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1047 | } else { | 1047 | } else { |
1048 | if ( temp->getIsPhoneSync() ) { | 1048 | if ( temp->getIsPhoneSync() ) { |
1049 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1049 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1050 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1050 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1051 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1051 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1052 | syncPhone(); | 1052 | syncPhone(); |
1053 | } else | 1053 | } else |
1054 | syncRemote( temp ); | 1054 | syncRemote( temp ); |
1055 | 1055 | ||
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | delete temp; | 1058 | delete temp; |
1059 | mBlockSaveFlag = false; | 1059 | mBlockSaveFlag = false; |
1060 | } | 1060 | } |
1061 | void MainWindow::setDefaultPreferences() | 1061 | void MainWindow::setDefaultPreferences() |
1062 | { | 1062 | { |
1063 | KOPrefs *p = KOPrefs::instance(); | 1063 | KOPrefs *p = KOPrefs::instance(); |
1064 | 1064 | ||
1065 | p->mCompactDialogs = true; | 1065 | p->mCompactDialogs = true; |
1066 | p->mConfirm = true; | 1066 | p->mConfirm = true; |
1067 | // p->mEnableQuickTodo = false; | 1067 | // p->mEnableQuickTodo = false; |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | QString MainWindow::resourcePath() | 1070 | QString MainWindow::resourcePath() |
1071 | { | 1071 | { |
1072 | return KGlobal::iconLoader()->iconPath(); | 1072 | return KGlobal::iconLoader()->iconPath(); |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | void MainWindow::displayText( QString text ,QString cap ) | 1075 | void MainWindow::displayText( QString text ,QString cap ) |
1076 | { | 1076 | { |
1077 | QDialog dia( this, "name", true ); ; | 1077 | QDialog dia( this, "name", true ); ; |
1078 | dia.setCaption( cap ); | 1078 | dia.setCaption( cap ); |
1079 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1079 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1080 | lay->setSpacing( 3 ); | 1080 | lay->setSpacing( 3 ); |
1081 | lay->setMargin( 3 ); | 1081 | lay->setMargin( 3 ); |
1082 | QTextBrowser tb ( &dia ); | 1082 | QTextBrowser tb ( &dia ); |
1083 | lay->addWidget( &tb ); | 1083 | lay->addWidget( &tb ); |
1084 | tb.setText( text ); | 1084 | tb.setText( text ); |
1085 | #ifdef DESKTOP_VERSION | 1085 | #ifdef DESKTOP_VERSION |
1086 | dia.resize( 640, 480); | 1086 | dia.resize( 640, 480); |
1087 | #else | 1087 | #else |
1088 | dia.showMaximized(); | 1088 | dia.showMaximized(); |
1089 | #endif | 1089 | #endif |
1090 | dia.exec(); | 1090 | dia.exec(); |
1091 | } | 1091 | } |
1092 | void MainWindow::displayFile( QString fn, QString cap ) | 1092 | void MainWindow::displayFile( QString fn, QString cap ) |
1093 | { | 1093 | { |
1094 | QString fileName = resourcePath() + fn; | 1094 | QString fileName = resourcePath() + fn; |
1095 | QString text; | 1095 | QString text; |
1096 | QFile file( fileName ); | 1096 | QFile file( fileName ); |
1097 | if (!file.open( IO_ReadOnly ) ) { | 1097 | if (!file.open( IO_ReadOnly ) ) { |
1098 | return ; | 1098 | return ; |
1099 | 1099 | ||
1100 | } | 1100 | } |
1101 | QTextStream ts( &file ); | 1101 | QTextStream ts( &file ); |
1102 | text = ts.read(); | 1102 | text = ts.read(); |
1103 | file.close(); | 1103 | file.close(); |
1104 | displayText( text, cap); | 1104 | displayText( text, cap); |
1105 | } | 1105 | } |
1106 | void MainWindow::features() | 1106 | void MainWindow::features() |
1107 | { | 1107 | { |
1108 | 1108 | ||
1109 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1109 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | void MainWindow::usertrans() | 1112 | void MainWindow::usertrans() |
1113 | { | 1113 | { |
1114 | 1114 | ||
1115 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1115 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1116 | } | 1116 | } |
1117 | #if 0 | 1117 | #if 0 |
1118 | #include <libkcal/vcalformat.h> | 1118 | #include <libkcal/vcalformat.h> |
1119 | #include <libkcal/event.h> | 1119 | #include <libkcal/event.h> |
1120 | #include <libkcal/todo.h> | 1120 | #include <libkcal/todo.h> |
1121 | #include <libkcal/incidence.h> | 1121 | #include <libkcal/incidence.h> |
1122 | #endif | 1122 | #endif |
1123 | void MainWindow::synchowto() | 1123 | void MainWindow::synchowto() |
1124 | { | 1124 | { |
1125 | #if 0 | 1125 | #if 0 |
1126 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1126 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1127 | Incidence* inR = er.first(); | 1127 | Incidence* inR = er.first(); |
1128 | VCalFormat vf; | 1128 | VCalFormat vf; |
1129 | QString strout; | 1129 | QString strout; |
1130 | while ( inR ) { | 1130 | while ( inR ) { |
1131 | if ( inR->type() == "Todo" ) | 1131 | if ( inR->type() == "Todo" ) |
1132 | strout = vf.todoToString( (Todo *) inR ); | 1132 | strout = vf.todoToString( (Todo *) inR ); |
1133 | if ( inR->type() == "Event" ) | 1133 | if ( inR->type() == "Event" ) |
1134 | strout = vf.eventToString( (Event *) inR ); | 1134 | strout = vf.eventToString( (Event *) inR ); |
1135 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1135 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1136 | inR = er.next(); | 1136 | inR = er.next(); |
1137 | } | 1137 | } |
1138 | #endif | 1138 | #endif |
1139 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1139 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1140 | } | 1140 | } |
1141 | void MainWindow::faq() | 1141 | void MainWindow::faq() |
1142 | { | 1142 | { |
1143 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1143 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1144 | 1144 | ||
1145 | } | 1145 | } |
1146 | void MainWindow::whatsNew() | 1146 | void MainWindow::whatsNew() |
1147 | { | 1147 | { |
1148 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1148 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1149 | 1149 | ||
1150 | } | 1150 | } |
1151 | void MainWindow::licence() | 1151 | void MainWindow::licence() |
1152 | { | 1152 | { |
1153 | KApplication::showLicence(); | 1153 | KApplication::showLicence(); |
1154 | 1154 | ||
1155 | } | 1155 | } |
1156 | void MainWindow::about() | 1156 | void MainWindow::about() |
1157 | { | 1157 | { |
1158 | QString version; | 1158 | QString version; |
1159 | #include <../version> | 1159 | #include <../version> |
1160 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1160 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1161 | i18n("KOrganizer/Platform-independent\n") + | 1161 | i18n("KOrganizer/Platform-independent\n") + |
1162 | "(KO/Pi) " + version + " - " + | 1162 | "(KO/Pi) " + version + " - " + |
1163 | 1163 | ||
1164 | #ifdef DESKTOP_VERSION | 1164 | #ifdef DESKTOP_VERSION |
1165 | i18n("Desktop Edition\n") + | 1165 | i18n("Desktop Edition\n") + |
1166 | #else | 1166 | #else |
1167 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1167 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1168 | #endif | 1168 | #endif |
1169 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1169 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1170 | } | 1170 | } |
1171 | void MainWindow::keyBindings() | 1171 | void MainWindow::keyBindings() |
1172 | { | 1172 | { |
1173 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1173 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1174 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1174 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1175 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1175 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1176 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1176 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1177 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1177 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1178 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1178 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1179 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1179 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1180 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1180 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1181 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1181 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1182 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1182 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1183 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1183 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1184 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1184 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1185 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1185 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1186 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1186 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1187 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1187 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1188 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1188 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1189 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1189 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1190 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1190 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1191 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1191 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1192 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1192 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1193 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1193 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1194 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1194 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1195 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1195 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1196 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1196 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1197 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1197 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1198 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1198 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1199 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1199 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1200 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1200 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1201 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1201 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1202 | i18n("<p><h3>In list view:</h3></p>\n") + | 1202 | i18n("<p><h3>In list view:</h3></p>\n") + |
1203 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1203 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1204 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1204 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1205 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1205 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1206 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1206 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1207 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1207 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1208 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1208 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1209 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1209 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1210 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1210 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1211 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1211 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1212 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1212 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1213 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1213 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1214 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1214 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1215 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1215 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1216 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1216 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1217 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1217 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1218 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1218 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1219 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1219 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1220 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1220 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1221 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1221 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1222 | displayText( text, cap); | 1222 | displayText( text, cap); |
1223 | 1223 | ||
1224 | } | 1224 | } |
1225 | void MainWindow::aboutAutoSaving() | 1225 | void MainWindow::aboutAutoSaving() |
1226 | { | 1226 | { |
1227 | QMessageBox* msg; | 1227 | QMessageBox* msg; |
1228 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1228 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1229 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1229 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1230 | QMessageBox::Ok, | 1230 | QMessageBox::Ok, |
1231 | QMessageBox::NoButton, | 1231 | QMessageBox::NoButton, |
1232 | QMessageBox::NoButton); | 1232 | QMessageBox::NoButton); |
1233 | msg->exec(); | 1233 | msg->exec(); |
1234 | delete msg; | 1234 | delete msg; |
1235 | 1235 | ||
1236 | 1236 | ||
1237 | } | 1237 | } |
1238 | void MainWindow::aboutKnownBugs() | 1238 | void MainWindow::aboutKnownBugs() |
1239 | { | 1239 | { |
1240 | QMessageBox* msg; | 1240 | QMessageBox* msg; |
1241 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1241 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1242 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1242 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1243 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1243 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1244 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1244 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1245 | i18n("\nor report them in the bugtracker on\n") + | 1245 | i18n("\nor report them in the bugtracker on\n") + |
1246 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1246 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1247 | QMessageBox::NoIcon, | 1247 | QMessageBox::NoIcon, |
1248 | QMessageBox::Ok, | 1248 | QMessageBox::Ok, |
1249 | QMessageBox::NoButton, | 1249 | QMessageBox::NoButton, |
1250 | QMessageBox::NoButton); | 1250 | QMessageBox::NoButton); |
1251 | msg->exec(); | 1251 | msg->exec(); |
1252 | delete msg; | 1252 | delete msg; |
1253 | 1253 | ||
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | QString MainWindow::defaultFileName() | 1256 | QString MainWindow::defaultFileName() |
1257 | { | 1257 | { |
1258 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1258 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1261 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1262 | { | 1262 | { |
1263 | if ( !incidence ) { | 1263 | if ( !incidence ) { |
1264 | enableIncidenceActions( false ); | 1264 | enableIncidenceActions( false ); |
1265 | 1265 | ||
1266 | mNewSubTodoAction->setEnabled( false ); | 1266 | mNewSubTodoAction->setEnabled( false ); |
1267 | setCaptionToDates(); | 1267 | setCaptionToDates(); |
1268 | return; | 1268 | return; |
1269 | 1269 | ||
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | //KGlobal::locale()->formatDateTime(nextA, true); | 1272 | //KGlobal::locale()->formatDateTime(nextA, true); |
1273 | QString startString = ""; | 1273 | QString startString = ""; |
1274 | if ( incidence->type() != "Todo" ) { | 1274 | if ( incidence->type() != "Todo" ) { |
1275 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1275 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1276 | if ( incidence->doesFloat() ) { | 1276 | if ( incidence->doesFloat() ) { |
1277 | startString += ": "+incidence->dtStartDateStr( true ); | 1277 | startString += ": "+incidence->dtStartDateStr( true ); |
1278 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1278 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1279 | 1279 | ||
1280 | } else { | 1280 | } else { |
1281 | startString = ": "+incidence->dtStartStr(true); | 1281 | startString = ": "+incidence->dtStartStr(true); |
1282 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1282 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1283 | 1283 | ||
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | } else { | 1286 | } else { |
1287 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1287 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1288 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1288 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1289 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1289 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1290 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1290 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1291 | } | 1291 | } |
1292 | 1292 | ||
1293 | } | 1293 | } |
1294 | else | 1294 | else |
1295 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1295 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1296 | if ( !incidence->location().isEmpty() ) | 1296 | if ( !incidence->location().isEmpty() ) |
1297 | startString += " (" +incidence->location()+")"; | 1297 | startString += " (" +incidence->location()+")"; |
1298 | setCaption( incidence->summary()+startString); | 1298 | setCaption( incidence->summary()+startString); |
1299 | 1299 | ||
1300 | enableIncidenceActions( true ); | 1300 | enableIncidenceActions( true ); |
1301 | 1301 | ||
1302 | if ( incidence->type() == "Event" ) { | 1302 | if ( incidence->type() == "Event" ) { |
1303 | mShowAction->setText( i18n("Show Event...") ); | 1303 | mShowAction->setText( i18n("Show Event...") ); |
1304 | mEditAction->setText( i18n("Edit Event...") ); | 1304 | mEditAction->setText( i18n("Edit Event...") ); |
1305 | mDeleteAction->setText( i18n("Delete Event...") ); | 1305 | mDeleteAction->setText( i18n("Delete Event...") ); |
1306 | 1306 | ||
1307 | mNewSubTodoAction->setEnabled( false ); | 1307 | mNewSubTodoAction->setEnabled( false ); |
1308 | } else if ( incidence->type() == "Todo" ) { | 1308 | } else if ( incidence->type() == "Todo" ) { |
1309 | mShowAction->setText( i18n("Show Todo...") ); | 1309 | mShowAction->setText( i18n("Show Todo...") ); |
1310 | mEditAction->setText( i18n("Edit Todo...") ); | 1310 | mEditAction->setText( i18n("Edit Todo...") ); |
1311 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1311 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1312 | 1312 | ||
1313 | mNewSubTodoAction->setEnabled( true ); | 1313 | mNewSubTodoAction->setEnabled( true ); |
1314 | } else { | 1314 | } else { |
1315 | mShowAction->setText( i18n("Show...") ); | 1315 | mShowAction->setText( i18n("Show...") ); |
1316 | mShowAction->setText( i18n("Edit...") ); | 1316 | mShowAction->setText( i18n("Edit...") ); |
1317 | mShowAction->setText( i18n("Delete...") ); | 1317 | mShowAction->setText( i18n("Delete...") ); |
1318 | 1318 | ||
1319 | mNewSubTodoAction->setEnabled( false ); | 1319 | mNewSubTodoAction->setEnabled( false ); |
1320 | } | 1320 | } |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | void MainWindow::enableIncidenceActions( bool enabled ) | 1323 | void MainWindow::enableIncidenceActions( bool enabled ) |
1324 | { | 1324 | { |
1325 | mShowAction->setEnabled( enabled ); | 1325 | mShowAction->setEnabled( enabled ); |
1326 | mEditAction->setEnabled( enabled ); | 1326 | mEditAction->setEnabled( enabled ); |
1327 | mDeleteAction->setEnabled( enabled ); | 1327 | mDeleteAction->setEnabled( enabled ); |
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | void MainWindow::importOL() | 1330 | void MainWindow::importOL() |
1331 | { | 1331 | { |
1332 | #ifdef _WIN32_ | 1332 | #ifdef _WIN32_ |
1333 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1333 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1334 | id->exec(); | 1334 | id->exec(); |
1335 | delete id; | 1335 | delete id; |
1336 | mView->updateView(); | 1336 | mView->updateView(); |
1337 | #endif | 1337 | #endif |
1338 | } | 1338 | } |
1339 | void MainWindow::importBday() | 1339 | void MainWindow::importBday() |
1340 | { | 1340 | { |
1341 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1341 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1342 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1342 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1343 | i18n("Import!"), i18n("Cancel"), 0, | 1343 | i18n("Import!"), i18n("Cancel"), 0, |
1344 | 0, 1 ); | 1344 | 0, 1 ); |
1345 | if ( result == 0 ) { | 1345 | if ( result == 0 ) { |
1346 | mView->importBday(); | 1346 | mView->importBday(); |
1347 | 1347 | ||
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | 1350 | ||
1351 | } | 1351 | } |
1352 | void MainWindow::importQtopia() | 1352 | void MainWindow::importQtopia() |
1353 | { | 1353 | { |
1354 | #ifndef DESKTOP_VERSION | 1354 | #ifndef DESKTOP_VERSION |
1355 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1355 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1356 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1356 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1357 | i18n("Import!"), i18n("Cancel"), 0, | 1357 | i18n("Import!"), i18n("Cancel"), 0, |
1358 | 0, 1 ); | 1358 | 0, 1 ); |
1359 | if ( result == 0 ) { | 1359 | if ( result == 0 ) { |
1360 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1360 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1361 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1361 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1362 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1362 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1363 | mView->importQtopia( categories, datebook, todolist ); | 1363 | mView->importQtopia( categories, datebook, todolist ); |
1364 | } | 1364 | } |
1365 | #else | 1365 | #else |
1366 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1366 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1367 | i18n("Not supported \non desktop!\n"), | 1367 | i18n("Not supported \non desktop!\n"), |
1368 | i18n("Ok"), i18n("Cancel"), 0, | 1368 | i18n("Ok"), i18n("Cancel"), 0, |
1369 | 0, 1 ); | 1369 | 0, 1 ); |
1370 | 1370 | ||
1371 | #endif | 1371 | #endif |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | void MainWindow::saveOnClose() | 1374 | void MainWindow::saveOnClose() |
1375 | { | 1375 | { |
1376 | KOPrefs *p = KOPrefs::instance(); | 1376 | KOPrefs *p = KOPrefs::instance(); |
1377 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1377 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1378 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1378 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1379 | iconToolBar->y() > height()/2; | 1379 | iconToolBar->y() > height()/2; |
1380 | mView->writeSettings(); | 1380 | mView->writeSettings(); |
1381 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1381 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1382 | save(); | 1382 | save(); |
1383 | } | 1383 | } |
1384 | void MainWindow::slotModifiedChanged( bool changed ) | 1384 | void MainWindow::slotModifiedChanged( bool changed ) |
1385 | { | 1385 | { |
1386 | if ( mBlockAtStartup ) | 1386 | if ( mBlockAtStartup ) |
1387 | return; | 1387 | return; |
1388 | int msec; | 1388 | int msec; |
1389 | // we store the changes after 1 minute, | 1389 | // we store the changes after 1 minute, |
1390 | // and for safety reasons after 10 minutes again | 1390 | // and for safety reasons after 10 minutes again |
1391 | if ( !mBlockSaveFlag ) | 1391 | if ( !mBlockSaveFlag ) |
1392 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1392 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1393 | else | 1393 | else |
1394 | msec = 1000 * 600; | 1394 | msec = 1000 * 600; |
1395 | mSaveTimer.start( msec, true ); // 1 minute | 1395 | mSaveTimer.start( msec, true ); // 1 minute |
1396 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1396 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1397 | mCalendarModifiedFlag = true; | 1397 | mCalendarModifiedFlag = true; |
1398 | } | 1398 | } |
1399 | #include <qfileinfo.h> | 1399 | #include <qfileinfo.h> |
1400 | void MainWindow::save() | 1400 | void MainWindow::save() |
1401 | { | 1401 | { |
1402 | if ( mBlockSaveFlag ) | 1402 | if ( mBlockSaveFlag ) |
1403 | return; | 1403 | return; |
1404 | bool store = mBlockSaveFlag; | 1404 | bool store = mBlockSaveFlag; |
1405 | mBlockSaveFlag = true; | 1405 | mBlockSaveFlag = true; |
1406 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1406 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1407 | 1407 | ||
1408 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1408 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1409 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1409 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1410 | qDebug("KO: Start saving data to file!"); | 1410 | qDebug("KO: Start saving data to file!"); |
1411 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | ||
1411 | mView->saveCalendar( defaultFileName() ); | 1412 | mView->saveCalendar( defaultFileName() ); |
1412 | 1413 | ||
1413 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1414 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1414 | mView->setLoadedFileVersion(QDateTime::currentDateTime()); | 1415 | mView->watchSavedFile(); |
1415 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1416 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1416 | QString savemes; | 1417 | QString savemes; |
1417 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1418 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1418 | setCaption(savemes); | 1419 | setCaption(savemes); |
1419 | } else | 1420 | } else |
1420 | setCaption(i18n("Saving cancelled!")); | 1421 | setCaption(i18n("Saving cancelled!")); |
1421 | mCalendarModifiedFlag = false; | 1422 | mCalendarModifiedFlag = false; |
1422 | mBlockSaveFlag = store; | 1423 | mBlockSaveFlag = store; |
1423 | } | 1424 | } |
1424 | 1425 | ||
1425 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1426 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1426 | { | 1427 | { |
1427 | if ( !e->isAutoRepeat() ) { | 1428 | if ( !e->isAutoRepeat() ) { |
1428 | mFlagKeyPressed = false; | 1429 | mFlagKeyPressed = false; |
1429 | } | 1430 | } |
1430 | } | 1431 | } |
1431 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1432 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1432 | { | 1433 | { |
1433 | qApp->processEvents(); | 1434 | qApp->processEvents(); |
1434 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1435 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1435 | e->ignore(); | 1436 | e->ignore(); |
1436 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1437 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1437 | return; | 1438 | return; |
1438 | } | 1439 | } |
1439 | if (! e->isAutoRepeat() ) | 1440 | if (! e->isAutoRepeat() ) |
1440 | mFlagKeyPressed = true; | 1441 | mFlagKeyPressed = true; |
1441 | KOPrefs *p = KOPrefs::instance(); | 1442 | KOPrefs *p = KOPrefs::instance(); |
1442 | bool showSelectedDates = false; | 1443 | bool showSelectedDates = false; |
1443 | int size; | 1444 | int size; |
1444 | int pro = 0; | 1445 | int pro = 0; |
1445 | //qDebug("MainWindow::keyPressEvent "); | 1446 | //qDebug("MainWindow::keyPressEvent "); |
1446 | switch ( e->key() ) { | 1447 | switch ( e->key() ) { |
1447 | case Qt::Key_Right: | 1448 | case Qt::Key_Right: |
1448 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1449 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1449 | mView->goNextMonth(); | 1450 | mView->goNextMonth(); |
1450 | else | 1451 | else |
1451 | mView->goNext(); | 1452 | mView->goNext(); |
1452 | showSelectedDates = true; | 1453 | showSelectedDates = true; |
1453 | break; | 1454 | break; |
1454 | case Qt::Key_Left: | 1455 | case Qt::Key_Left: |
1455 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1456 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1456 | mView->goPreviousMonth(); | 1457 | mView->goPreviousMonth(); |
1457 | else | 1458 | else |
1458 | mView->goPrevious(); | 1459 | mView->goPrevious(); |
1459 | showSelectedDates = true; | 1460 | showSelectedDates = true; |
1460 | break; | 1461 | break; |
1461 | case Qt::Key_Down: | 1462 | case Qt::Key_Down: |
1462 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1463 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1463 | break; | 1464 | break; |
1464 | case Qt::Key_Up: | 1465 | case Qt::Key_Up: |
1465 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1466 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1466 | break; | 1467 | break; |
1467 | case Qt::Key_I: | 1468 | case Qt::Key_I: |
1468 | mView->showIncidence(); | 1469 | mView->showIncidence(); |
1469 | break; | 1470 | break; |
1470 | case Qt::Key_Delete: | 1471 | case Qt::Key_Delete: |
1471 | case Qt::Key_Backspace: | 1472 | case Qt::Key_Backspace: |
1472 | mView->deleteIncidence(); | 1473 | mView->deleteIncidence(); |
1473 | break; | 1474 | break; |
1474 | case Qt::Key_D: | 1475 | case Qt::Key_D: |
1475 | mView->viewManager()->showDayView(); | 1476 | mView->viewManager()->showDayView(); |
1476 | showSelectedDates = true; | 1477 | showSelectedDates = true; |
1477 | break; | 1478 | break; |
1478 | case Qt::Key_O: | 1479 | case Qt::Key_O: |
1479 | mView->toggleFilerEnabled( ); | 1480 | mView->toggleFilerEnabled( ); |
1480 | break; | 1481 | break; |
1481 | case Qt::Key_0: | 1482 | case Qt::Key_0: |
1482 | case Qt::Key_1: | 1483 | case Qt::Key_1: |
1483 | case Qt::Key_2: | 1484 | case Qt::Key_2: |
1484 | case Qt::Key_3: | 1485 | case Qt::Key_3: |
1485 | case Qt::Key_4: | 1486 | case Qt::Key_4: |
1486 | case Qt::Key_5: | 1487 | case Qt::Key_5: |
1487 | case Qt::Key_6: | 1488 | case Qt::Key_6: |
1488 | case Qt::Key_7: | 1489 | case Qt::Key_7: |
1489 | case Qt::Key_8: | 1490 | case Qt::Key_8: |
1490 | case Qt::Key_9: | 1491 | case Qt::Key_9: |
1491 | pro = e->key()-48; | 1492 | pro = e->key()-48; |
1492 | if ( pro == 0 ) | 1493 | if ( pro == 0 ) |
1493 | pro = 10; | 1494 | pro = 10; |
1494 | if ( e->state() == Qt::ControlButton) | 1495 | if ( e->state() == Qt::ControlButton) |
1495 | pro += 10; | 1496 | pro += 10; |
1496 | break; | 1497 | break; |
1497 | case Qt::Key_M: | 1498 | case Qt::Key_M: |
1498 | mView->viewManager()->showMonthView(); | 1499 | mView->viewManager()->showMonthView(); |
1499 | showSelectedDates = true; | 1500 | showSelectedDates = true; |
1500 | break; | 1501 | break; |
1501 | case Qt::Key_Insert: | 1502 | case Qt::Key_Insert: |
1502 | mView->newEvent(); | 1503 | mView->newEvent(); |
1503 | break; | 1504 | break; |
1504 | case Qt::Key_S : | 1505 | case Qt::Key_S : |
1505 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1506 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1506 | mView->newSubTodo(); | 1507 | mView->newSubTodo(); |
1507 | else | 1508 | else |
1508 | mView->dialogManager()->showSearchDialog(); | 1509 | mView->dialogManager()->showSearchDialog(); |
1509 | break; | 1510 | break; |
1510 | case Qt::Key_Y : | 1511 | case Qt::Key_Y : |
1511 | case Qt::Key_Z : | 1512 | case Qt::Key_Z : |
1512 | mView->viewManager()->showWorkWeekView(); | 1513 | mView->viewManager()->showWorkWeekView(); |
1513 | showSelectedDates = true; | 1514 | showSelectedDates = true; |
1514 | break; | 1515 | break; |
1515 | case Qt::Key_U : | 1516 | case Qt::Key_U : |
1516 | mView->viewManager()->showWeekView(); | 1517 | mView->viewManager()->showWeekView(); |
1517 | showSelectedDates = true; | 1518 | showSelectedDates = true; |
1518 | break; | 1519 | break; |
1519 | case Qt::Key_H : | 1520 | case Qt::Key_H : |
1520 | keyBindings(); | 1521 | keyBindings(); |
1521 | break; | 1522 | break; |
1522 | case Qt::Key_W: | 1523 | case Qt::Key_W: |
1523 | mView->viewManager()->showWhatsNextView(); | 1524 | mView->viewManager()->showWhatsNextView(); |
1524 | break; | 1525 | break; |
1525 | case Qt::Key_L: | 1526 | case Qt::Key_L: |
1526 | mView->viewManager()->showListView(); | 1527 | mView->viewManager()->showListView(); |
1527 | break; | 1528 | break; |
1528 | case Qt::Key_N: | 1529 | case Qt::Key_N: |
1529 | mView->viewManager()->showNextXView(); | 1530 | mView->viewManager()->showNextXView(); |
1530 | showSelectedDates = true; | 1531 | showSelectedDates = true; |
1531 | break; | 1532 | break; |
1532 | case Qt::Key_V: | 1533 | case Qt::Key_V: |
1533 | mView->viewManager()->showTodoView(); | 1534 | mView->viewManager()->showTodoView(); |
1534 | break; | 1535 | break; |
1535 | case Qt::Key_C: | 1536 | case Qt::Key_C: |
1536 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1537 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1537 | break; | 1538 | break; |
1538 | case Qt::Key_P: | 1539 | case Qt::Key_P: |
1539 | mView->showDatePicker( ); | 1540 | mView->showDatePicker( ); |
1540 | break; | 1541 | break; |
1541 | case Qt::Key_F: | 1542 | case Qt::Key_F: |
1542 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1543 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1543 | mView->editFilters(); | 1544 | mView->editFilters(); |
1544 | else | 1545 | else |
1545 | mView->toggleFilter(); | 1546 | mView->toggleFilter(); |
1546 | break; | 1547 | break; |
1547 | case Qt::Key_X: | 1548 | case Qt::Key_X: |
1548 | mView->toggleDateNavigatorWidget(); | 1549 | mView->toggleDateNavigatorWidget(); |
1549 | break; | 1550 | break; |
1550 | case Qt::Key_Space: | 1551 | case Qt::Key_Space: |
1551 | mView->toggleExpand(); | 1552 | mView->toggleExpand(); |
1552 | break; | 1553 | break; |
1553 | case Qt::Key_A: | 1554 | case Qt::Key_A: |
1554 | mView->toggleAllDaySize(); | 1555 | mView->toggleAllDaySize(); |
1555 | break; | 1556 | break; |
1556 | case Qt::Key_T: | 1557 | case Qt::Key_T: |
1557 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1558 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1558 | mView->newTodo(); | 1559 | mView->newTodo(); |
1559 | else { | 1560 | else { |
1560 | mView->goToday(); | 1561 | mView->goToday(); |
1561 | showSelectedDates = true; | 1562 | showSelectedDates = true; |
1562 | } | 1563 | } |
1563 | break; | 1564 | break; |
1564 | case Qt::Key_J: | 1565 | case Qt::Key_J: |
1565 | mView->viewManager()->showJournalView(); | 1566 | mView->viewManager()->showJournalView(); |
1566 | break; | 1567 | break; |
1567 | case Qt::Key_B: | 1568 | case Qt::Key_B: |
1568 | mView->editIncidenceDescription();; | 1569 | mView->editIncidenceDescription();; |
1569 | break; | 1570 | break; |
1570 | // case Qt::Key_Return: | 1571 | // case Qt::Key_Return: |
1571 | case Qt::Key_E: | 1572 | case Qt::Key_E: |
1572 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1573 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1573 | mView->newEvent(); | 1574 | mView->newEvent(); |
1574 | else | 1575 | else |
1575 | mView->editIncidence(); | 1576 | mView->editIncidence(); |
1576 | break; | 1577 | break; |
1577 | case Qt::Key_Plus: | 1578 | case Qt::Key_Plus: |
1578 | size = p->mHourSize +2; | 1579 | size = p->mHourSize +2; |
1579 | if ( size <= 18 ) | 1580 | if ( size <= 18 ) |
1580 | configureAgenda( size ); | 1581 | configureAgenda( size ); |
1581 | break; | 1582 | break; |
1582 | case Qt::Key_Minus: | 1583 | case Qt::Key_Minus: |
1583 | size = p->mHourSize - 2; | 1584 | size = p->mHourSize - 2; |
1584 | if ( size >= 4 ) | 1585 | if ( size >= 4 ) |
1585 | configureAgenda( size ); | 1586 | configureAgenda( size ); |
1586 | break; | 1587 | break; |
1587 | 1588 | ||
1588 | 1589 | ||
1589 | default: | 1590 | default: |
1590 | e->ignore(); | 1591 | e->ignore(); |
1591 | } | 1592 | } |
1592 | if ( pro > 0 ) { | 1593 | if ( pro > 0 ) { |
1593 | mView->selectFilter( pro-1 ); | 1594 | mView->selectFilter( pro-1 ); |
1594 | } | 1595 | } |
1595 | if ( showSelectedDates ) { | 1596 | if ( showSelectedDates ) { |
1596 | ;// setCaptionToDates(); | 1597 | ;// setCaptionToDates(); |
1597 | } | 1598 | } |
1598 | 1599 | ||
1599 | } | 1600 | } |
1600 | 1601 | ||
1601 | void MainWindow::fillFilterMenu() | 1602 | void MainWindow::fillFilterMenu() |
1602 | { | 1603 | { |
1603 | selectFilterMenu->clear(); | 1604 | selectFilterMenu->clear(); |
1604 | bool disable = false; | 1605 | bool disable = false; |
1605 | if ( mView->filterView()->filtersEnabled() ) { | 1606 | if ( mView->filterView()->filtersEnabled() ) { |
1606 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1607 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1607 | } | 1608 | } |
1608 | else { | 1609 | else { |
1609 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1610 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1610 | disable = true; | 1611 | disable = true; |
1611 | } | 1612 | } |
1612 | selectFilterMenu->insertSeparator(); | 1613 | selectFilterMenu->insertSeparator(); |
1613 | QPtrList<CalFilter> fili = mView->filters(); | 1614 | QPtrList<CalFilter> fili = mView->filters(); |
1614 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1615 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1615 | CalFilter *filter = fili.first(); | 1616 | CalFilter *filter = fili.first(); |
1616 | int iii = 1; | 1617 | int iii = 1; |
1617 | while(filter) { | 1618 | while(filter) { |
1618 | selectFilterMenu->insertItem( filter->name(), iii ); | 1619 | selectFilterMenu->insertItem( filter->name(), iii ); |
1619 | if ( filter == curfilter) | 1620 | if ( filter == curfilter) |
1620 | selectFilterMenu->setItemChecked( iii, true ); | 1621 | selectFilterMenu->setItemChecked( iii, true ); |
1621 | if ( disable ) | 1622 | if ( disable ) |
1622 | selectFilterMenu->setItemEnabled( iii, false ); | 1623 | selectFilterMenu->setItemEnabled( iii, false ); |
1623 | filter = fili.next(); | 1624 | filter = fili.next(); |
1624 | ++iii; | 1625 | ++iii; |
1625 | } | 1626 | } |
1626 | } | 1627 | } |
1627 | void MainWindow::selectFilter( int fil ) | 1628 | void MainWindow::selectFilter( int fil ) |
1628 | { | 1629 | { |
1629 | if ( fil == 0 ) { | 1630 | if ( fil == 0 ) { |
1630 | mView->toggleFilerEnabled( ); | 1631 | mView->toggleFilerEnabled( ); |
1631 | } else { | 1632 | } else { |
1632 | mView->selectFilter( fil-1 ); | 1633 | mView->selectFilter( fil-1 ); |
1633 | } | 1634 | } |
1634 | } | 1635 | } |
1635 | void MainWindow::configureToolBar( int item ) | 1636 | void MainWindow::configureToolBar( int item ) |
1636 | { | 1637 | { |
1637 | 1638 | ||
1638 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1639 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1639 | KOPrefs *p = KOPrefs::instance(); | 1640 | KOPrefs *p = KOPrefs::instance(); |
1640 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1641 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1641 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1642 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1642 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1643 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1643 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1644 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1644 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1645 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1645 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1646 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1646 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1647 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1647 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1648 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1648 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1649 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1649 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1650 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1650 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1651 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1651 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1652 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1652 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1653 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1653 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1654 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1654 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1655 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1655 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1656 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1656 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1657 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1657 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1658 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1658 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1659 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1659 | // initActions(); | 1660 | // initActions(); |
1660 | } | 1661 | } |
1661 | 1662 | ||
1662 | void MainWindow::setCaptionToDates() | 1663 | void MainWindow::setCaptionToDates() |
1663 | { | 1664 | { |
1664 | QString selDates; | 1665 | QString selDates; |
1665 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1666 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1666 | if (mView->startDate() < mView->endDate() ) | 1667 | if (mView->startDate() < mView->endDate() ) |
1667 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1668 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1668 | setCaption( i18n("Dates: ") + selDates ); | 1669 | setCaption( i18n("Dates: ") + selDates ); |
1669 | 1670 | ||
1670 | } | 1671 | } |
1671 | // parameter item == 0: reinit | 1672 | // parameter item == 0: reinit |
1672 | void MainWindow::configureAgenda( int item ) | 1673 | void MainWindow::configureAgenda( int item ) |
1673 | { | 1674 | { |
1674 | 1675 | ||
1675 | KOPrefs *p = KOPrefs::instance(); | 1676 | KOPrefs *p = KOPrefs::instance(); |
1676 | 1677 | ||
1677 | int i; | 1678 | int i; |
1678 | if ( item == 1 ) { | 1679 | if ( item == 1 ) { |
1679 | mView->toggleAllDaySize(); | 1680 | mView->toggleAllDaySize(); |
1680 | return; | 1681 | return; |
1681 | } | 1682 | } |
1682 | // do not allow 4 for widgets higher than 480 | 1683 | // do not allow 4 for widgets higher than 480 |
1683 | // if ( QApplication::desktop()->height() > 480 ) { | 1684 | // if ( QApplication::desktop()->height() > 480 ) { |
1684 | // if ( item == 4 ) | 1685 | // if ( item == 4 ) |
1685 | // item = 6; | 1686 | // item = 6; |
1686 | // } | 1687 | // } |
1687 | for ( i = 4; i <= 18; i= i+2 ) | 1688 | for ( i = 4; i <= 18; i= i+2 ) |
1688 | configureAgendaMenu->setItemChecked( i, false ); | 1689 | configureAgendaMenu->setItemChecked( i, false ); |
1689 | configureAgendaMenu->setItemChecked( item, true ); | 1690 | configureAgendaMenu->setItemChecked( item, true ); |
1690 | if ( p->mHourSize == item ) | 1691 | if ( p->mHourSize == item ) |
1691 | return; | 1692 | return; |
1692 | p->mHourSize=item; | 1693 | p->mHourSize=item; |
1693 | mView->viewManager()->agendaView()->updateConfig(); | 1694 | mView->viewManager()->agendaView()->updateConfig(); |
1694 | } | 1695 | } |
1695 | 1696 | ||
1696 | void MainWindow::saveCalendar() | 1697 | void MainWindow::saveCalendar() |
1697 | { | 1698 | { |
1698 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1699 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1699 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1700 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1700 | 1701 | ||
1701 | if ( fn == "" ) | 1702 | if ( fn == "" ) |
1702 | return; | 1703 | return; |
1703 | QFileInfo info; | 1704 | QFileInfo info; |
1704 | info.setFile( fn ); | 1705 | info.setFile( fn ); |
1705 | QString mes; | 1706 | QString mes; |
1706 | bool createbup = true; | 1707 | bool createbup = true; |
1707 | if ( info. exists() ) { | 1708 | if ( info. exists() ) { |
1708 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1709 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1709 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1710 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1710 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1711 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1711 | 0, 1 ); | 1712 | 0, 1 ); |
1712 | if ( result != 0 ) { | 1713 | if ( result != 0 ) { |
1713 | createbup = false; | 1714 | createbup = false; |
1714 | } | 1715 | } |
1715 | } | 1716 | } |
1716 | if ( createbup ) { | 1717 | if ( createbup ) { |
1717 | mView->saveCalendar( fn ); | 1718 | mView->saveCalendar( fn ); |
1718 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1719 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1719 | KOPrefs::instance()->mLastSaveFile = fn; | 1720 | KOPrefs::instance()->mLastSaveFile = fn; |
1720 | setCaption(mes); | 1721 | setCaption(mes); |
1721 | } | 1722 | } |
1722 | } | 1723 | } |
1723 | void MainWindow::loadCalendar() | 1724 | void MainWindow::loadCalendar() |
1724 | { | 1725 | { |
1725 | 1726 | ||
1726 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1727 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1727 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1728 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1728 | 1729 | ||
1729 | if ( fn == "" ) | 1730 | if ( fn == "" ) |
1730 | return; | 1731 | return; |
1731 | QFileInfo info; | 1732 | QFileInfo info; |
1732 | info.setFile( fn ); | 1733 | info.setFile( fn ); |
1733 | QString mess; | 1734 | QString mess; |
1734 | bool loadbup = true; | 1735 | bool loadbup = true; |
1735 | if ( info. exists() ) { | 1736 | if ( info. exists() ) { |
1736 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1737 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1737 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1738 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1738 | mess, | 1739 | mess, |
1739 | i18n("Load!"), i18n("Cancel"), 0, | 1740 | i18n("Load!"), i18n("Cancel"), 0, |
1740 | 0, 1 ); | 1741 | 0, 1 ); |
1741 | if ( result != 0 ) { | 1742 | if ( result != 0 ) { |
1742 | loadbup = false; | 1743 | loadbup = false; |
1743 | } | 1744 | } |
1744 | } else { | 1745 | } else { |
1745 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1746 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1746 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1747 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1747 | 0, 1 ); | 1748 | 0, 1 ); |
1748 | 1749 | ||
1749 | return; | 1750 | return; |
1750 | } | 1751 | } |
1751 | if ( loadbup ) { | 1752 | if ( loadbup ) { |
1752 | mView->openCalendar( fn ); | 1753 | mView->openCalendar( fn ); |
1753 | KOPrefs::instance()->mLastLoadFile = fn; | 1754 | KOPrefs::instance()->mLastLoadFile = fn; |
1754 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1755 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1755 | setCaption(mess); | 1756 | setCaption(mess); |
1756 | } | 1757 | } |
1757 | 1758 | ||
1758 | } | 1759 | } |
1759 | void MainWindow::quickImportIcal() | 1760 | void MainWindow::quickImportIcal() |
1760 | { | 1761 | { |
1761 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1762 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1762 | } | 1763 | } |
1763 | void MainWindow::importFile( QString fn, bool quick ) | 1764 | void MainWindow::importFile( QString fn, bool quick ) |
1764 | { | 1765 | { |
1765 | QFileInfo info; | 1766 | QFileInfo info; |
1766 | info.setFile( fn ); | 1767 | info.setFile( fn ); |
1767 | QString mess; | 1768 | QString mess; |
1768 | bool loadbup = true; | 1769 | bool loadbup = true; |
1769 | if ( !info. exists() ) { | 1770 | if ( !info. exists() ) { |
1770 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1771 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1771 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1772 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1772 | mess ); | 1773 | mess ); |
1773 | return; | 1774 | return; |
1774 | } | 1775 | } |
1775 | int result = 0; | 1776 | int result = 0; |
1776 | if ( !quick ) { | 1777 | if ( !quick ) { |
1777 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1778 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1778 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1779 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1779 | mess, | 1780 | mess, |
1780 | "Import", "Cancel", 0, | 1781 | "Import", "Cancel", 0, |
1781 | 0, 1 ); | 1782 | 0, 1 ); |
1782 | } | 1783 | } |
1783 | if ( result == 0 ) { | 1784 | if ( result == 0 ) { |
1784 | if ( mView->openCalendar( fn, true )) { | 1785 | if ( mView->openCalendar( fn, true )) { |
1785 | KOPrefs::instance()->mLastImportFile = fn; | 1786 | KOPrefs::instance()->mLastImportFile = fn; |
1786 | setCaption(i18n("Imported file successfully")); | 1787 | setCaption(i18n("Imported file successfully")); |
1787 | } else { | 1788 | } else { |
1788 | setCaption(i18n("Error importing file")); | 1789 | setCaption(i18n("Error importing file")); |
1789 | } | 1790 | } |
1790 | } | 1791 | } |
1791 | } | 1792 | } |
1792 | 1793 | ||
1793 | void MainWindow::importIcal() | 1794 | void MainWindow::importIcal() |
1794 | { | 1795 | { |
1795 | 1796 | ||
1796 | QString fn =KOPrefs::instance()->mLastImportFile; | 1797 | QString fn =KOPrefs::instance()->mLastImportFile; |
1797 | 1798 | ||
1798 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1799 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1799 | if ( fn == "" ) | 1800 | if ( fn == "" ) |
1800 | return; | 1801 | return; |
1801 | importFile( fn, true ); | 1802 | importFile( fn, true ); |
1802 | 1803 | ||
1803 | } | 1804 | } |
1804 | 1805 | ||
1805 | void MainWindow::exportVCalendar() | 1806 | void MainWindow::exportVCalendar() |
1806 | { | 1807 | { |
1807 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1808 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1808 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1809 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1809 | if ( fn == "" ) | 1810 | if ( fn == "" ) |
1810 | return; | 1811 | return; |
1811 | QFileInfo info; | 1812 | QFileInfo info; |
1812 | info.setFile( fn ); | 1813 | info.setFile( fn ); |
1813 | QString mes; | 1814 | QString mes; |
1814 | bool createbup = true; | 1815 | bool createbup = true; |
1815 | if ( info. exists() ) { | 1816 | if ( info. exists() ) { |
1816 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1817 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1817 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1818 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1818 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1819 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1819 | 0, 1 ); | 1820 | 0, 1 ); |
1820 | if ( result != 0 ) { | 1821 | if ( result != 0 ) { |
1821 | createbup = false; | 1822 | createbup = false; |
1822 | } | 1823 | } |
1823 | } | 1824 | } |
1824 | if ( createbup ) { | 1825 | if ( createbup ) { |
1825 | if ( mView->exportVCalendar( fn ) ) { | 1826 | if ( mView->exportVCalendar( fn ) ) { |
1826 | KOPrefs::instance()->mLastVcalFile = fn; | 1827 | KOPrefs::instance()->mLastVcalFile = fn; |
1827 | if ( fn.length() > 20 ) | 1828 | if ( fn.length() > 20 ) |
1828 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1829 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1829 | else | 1830 | else |
1830 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1831 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1831 | setCaption(mes); | 1832 | setCaption(mes); |
1832 | } | 1833 | } |
1833 | } | 1834 | } |
1834 | 1835 | ||
1835 | } | 1836 | } |
1836 | #include <qpushbutton.h> | 1837 | #include <qpushbutton.h> |
1837 | QString MainWindow::getPassword( ) | 1838 | QString MainWindow::getPassword( ) |
1838 | { | 1839 | { |
1839 | QString retfile = ""; | 1840 | QString retfile = ""; |
1840 | QDialog dia ( this, "input-dialog", true ); | 1841 | QDialog dia ( this, "input-dialog", true ); |
1841 | QLineEdit lab ( &dia ); | 1842 | QLineEdit lab ( &dia ); |
1842 | lab.setEchoMode( QLineEdit::Password ); | 1843 | lab.setEchoMode( QLineEdit::Password ); |
1843 | QVBoxLayout lay( &dia ); | 1844 | QVBoxLayout lay( &dia ); |
1844 | lay.setMargin(7); | 1845 | lay.setMargin(7); |
1845 | lay.setSpacing(7); | 1846 | lay.setSpacing(7); |
1846 | lay.addWidget( &lab); | 1847 | lay.addWidget( &lab); |
1847 | dia.setFixedSize( 230,50 ); | 1848 | dia.setFixedSize( 230,50 ); |
1848 | dia.setCaption( i18n("Enter password") ); | 1849 | dia.setCaption( i18n("Enter password") ); |
1849 | QPushButton pb ( "OK", &dia); | 1850 | QPushButton pb ( "OK", &dia); |
1850 | lay.addWidget( &pb ); | 1851 | lay.addWidget( &pb ); |
1851 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1852 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1852 | dia.show(); | 1853 | dia.show(); |
1853 | int res = dia.exec(); | 1854 | int res = dia.exec(); |
1854 | if ( res ) | 1855 | if ( res ) |
1855 | retfile = lab.text(); | 1856 | retfile = lab.text(); |
1856 | dia.hide(); | 1857 | dia.hide(); |
1857 | qApp->processEvents(); | 1858 | qApp->processEvents(); |
1858 | return retfile; | 1859 | return retfile; |
1859 | 1860 | ||
1860 | } | 1861 | } |
1861 | 1862 | ||
1862 | void MainWindow::syncLocalFile() | 1863 | void MainWindow::syncLocalFile() |
1863 | { | 1864 | { |
1864 | 1865 | ||
1865 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 1866 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
1866 | 1867 | ||
1867 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 1868 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
1868 | if ( fn == "" ) | 1869 | if ( fn == "" ) |
1869 | return; | 1870 | return; |
1870 | //mView->setSyncDevice("local-file" ); | 1871 | //mView->setSyncDevice("local-file" ); |
1871 | if ( syncWithFile( fn, false ) ) { | 1872 | if ( syncWithFile( fn, false ) ) { |
1872 | // Event* e = mView->getLastSyncEvent(); | 1873 | // Event* e = mView->getLastSyncEvent(); |
1873 | // e->setReadOnly( false ); | 1874 | // e->setReadOnly( false ); |
1874 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 1875 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
1875 | // e->setReadOnly( true ); | 1876 | // e->setReadOnly( true ); |
1876 | } | 1877 | } |
1877 | 1878 | ||
1878 | } | 1879 | } |
1879 | 1880 | ||
1880 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 1881 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
1881 | { | 1882 | { |
1882 | bool ret = false; | 1883 | bool ret = false; |
1883 | QFileInfo info; | 1884 | QFileInfo info; |
1884 | info.setFile( fn ); | 1885 | info.setFile( fn ); |
1885 | QString mess; | 1886 | QString mess; |
1886 | bool loadbup = true; | 1887 | bool loadbup = true; |
1887 | if ( !info. exists() ) { | 1888 | if ( !info. exists() ) { |
1888 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 1889 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
1889 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1890 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1890 | mess ); | 1891 | mess ); |
1891 | return ret; | 1892 | return ret; |
1892 | } | 1893 | } |
1893 | int result = 0; | 1894 | int result = 0; |
1894 | if ( !quick ) { | 1895 | if ( !quick ) { |
1895 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1896 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1896 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1897 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1897 | mess, | 1898 | mess, |
1898 | i18n("Sync"), i18n("Cancel"), 0, | 1899 | i18n("Sync"), i18n("Cancel"), 0, |
1899 | 0, 1 ); | 1900 | 0, 1 ); |
1900 | if ( result ) | 1901 | if ( result ) |
1901 | return false; | 1902 | return false; |
1902 | } | 1903 | } |
1903 | if ( KOPrefs::instance()->mAskForPreferences ) | 1904 | if ( KOPrefs::instance()->mAskForPreferences ) |
1904 | mView->edit_sync_options(); | 1905 | mView->edit_sync_options(); |
1905 | if ( result == 0 ) { | 1906 | if ( result == 0 ) { |
1906 | //qDebug("Now sycing ... "); | 1907 | //qDebug("Now sycing ... "); |
1907 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | 1908 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) |
1908 | setCaption( i18n("Synchronization successful") ); | 1909 | setCaption( i18n("Synchronization successful") ); |
1909 | else | 1910 | else |
1910 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 1911 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
1911 | if ( ! quick ) | 1912 | if ( ! quick ) |
1912 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | 1913 | KOPrefs::instance()->mLastSyncedLocalFile = fn; |
1913 | slotModifiedChanged( true ); | 1914 | slotModifiedChanged( true ); |
1914 | } | 1915 | } |
1915 | return ret; | 1916 | return ret; |
1916 | } | 1917 | } |
1917 | void MainWindow::quickSyncLocalFile() | 1918 | void MainWindow::quickSyncLocalFile() |
1918 | { | 1919 | { |
1919 | //mView->setSyncDevice("local-file" ); | 1920 | //mView->setSyncDevice("local-file" ); |
1920 | //qDebug("quickSyncLocalFile() "); | 1921 | //qDebug("quickSyncLocalFile() "); |
1921 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 1922 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
1922 | // Event* e = mView->getLastSyncEvent(); | 1923 | // Event* e = mView->getLastSyncEvent(); |
1923 | // e->setReadOnly( false ); | 1924 | // e->setReadOnly( false ); |
1924 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 1925 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
1925 | // e->setReadOnly( true ); | 1926 | // e->setReadOnly( true ); |
1926 | 1927 | ||
1927 | } | 1928 | } |
1928 | } | 1929 | } |
1929 | 1930 | ||
1930 | void MainWindow::confSync() | 1931 | void MainWindow::confSync() |
1931 | { | 1932 | { |
1932 | mView->confSync(); | 1933 | mView->confSync(); |
1933 | fillSyncMenu(); | 1934 | fillSyncMenu(); |
1934 | } | 1935 | } |
1935 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) | 1936 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) |
1936 | { | 1937 | { |
1937 | QString question; | 1938 | QString question; |
1938 | if ( ask ) { | 1939 | if ( ask ) { |
1939 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 1940 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
1940 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 1941 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
1941 | question, | 1942 | question, |
1942 | i18n("Yes"), i18n("No"), | 1943 | i18n("Yes"), i18n("No"), |
1943 | 0, 0 ) != 0 ) | 1944 | 0, 0 ) != 0 ) |
1944 | return; | 1945 | return; |
1945 | } | 1946 | } |
1946 | QString command = prof->getPreSyncCommand(); | 1947 | QString command = prof->getPreSyncCommand(); |
1947 | int fi; | 1948 | int fi; |
1948 | if ( (fi = command.find("$PWD$")) > 0 ) { | 1949 | if ( (fi = command.find("$PWD$")) > 0 ) { |
1949 | QString pwd = getPassword(); | 1950 | QString pwd = getPassword(); |
1950 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 1951 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
1951 | 1952 | ||
1952 | } | 1953 | } |
1953 | int maxlen = 30; | 1954 | int maxlen = 30; |
1954 | if ( QApplication::desktop()->width() > 320 ) | 1955 | if ( QApplication::desktop()->width() > 320 ) |
1955 | maxlen += 25; | 1956 | maxlen += 25; |
1956 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 1957 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
1957 | int fileSize = 0; | 1958 | int fileSize = 0; |
1958 | int result = system ( command ); | 1959 | int result = system ( command ); |
1959 | // 0 : okay | 1960 | // 0 : okay |
1960 | // 256: no such file or dir | 1961 | // 256: no such file or dir |
1961 | // | 1962 | // |
1962 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 1963 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
1963 | if ( result != 0 ) { | 1964 | if ( result != 0 ) { |
1964 | int len = maxlen; | 1965 | int len = maxlen; |
1965 | while ( len < command.length() ) { | 1966 | while ( len < command.length() ) { |
1966 | command.insert( len , "\n" ); | 1967 | command.insert( len , "\n" ); |
1967 | len += maxlen +2; | 1968 | len += maxlen +2; |
1968 | } | 1969 | } |
1969 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 1970 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
1970 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 1971 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
1971 | question, | 1972 | question, |
1972 | i18n("Okay!")) ; | 1973 | i18n("Okay!")) ; |
1973 | setCaption ("KO/Pi"); | 1974 | setCaption ("KO/Pi"); |
1974 | return; | 1975 | return; |
1975 | } | 1976 | } |
1976 | setCaption ( i18n( "Copying succeed." ) ); | 1977 | setCaption ( i18n( "Copying succeed." ) ); |
1977 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 1978 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
1978 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | 1979 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { |
1979 | // Event* e = mView->getLastSyncEvent(); | 1980 | // Event* e = mView->getLastSyncEvent(); |
1980 | // e->setReadOnly( false ); | 1981 | // e->setReadOnly( false ); |
1981 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1982 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1982 | // e->setReadOnly( true ); | 1983 | // e->setReadOnly( true ); |
1983 | if ( KOPrefs::instance()->mWriteBackFile ) { | 1984 | if ( KOPrefs::instance()->mWriteBackFile ) { |
1984 | command = prof->getPostSyncCommand(); | 1985 | command = prof->getPostSyncCommand(); |
1985 | int fi; | 1986 | int fi; |
1986 | if ( (fi = command.find("$PWD$")) > 0 ) { | 1987 | if ( (fi = command.find("$PWD$")) > 0 ) { |
1987 | QString pwd = getPassword(); | 1988 | QString pwd = getPassword(); |
1988 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 1989 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
1989 | 1990 | ||
1990 | } | 1991 | } |
1991 | setCaption ( i18n( "Writing back file ..." ) ); | 1992 | setCaption ( i18n( "Writing back file ..." ) ); |
1992 | result = system ( command ); | 1993 | result = system ( command ); |
1993 | qDebug("KO: Writing back file result: %d ", result); | 1994 | qDebug("KO: Writing back file result: %d ", result); |
1994 | if ( result != 0 ) { | 1995 | if ( result != 0 ) { |
1995 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 1996 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
1996 | return; | 1997 | return; |
1997 | } else { | 1998 | } else { |
1998 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 1999 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
1999 | } | 2000 | } |
2000 | } | 2001 | } |
2001 | } | 2002 | } |
2002 | return; | 2003 | return; |
2003 | } | 2004 | } |
2004 | void MainWindow::syncSSH() | 2005 | void MainWindow::syncSSH() |
2005 | { | 2006 | { |
2006 | // not used anymore | 2007 | // not used anymore |
2007 | QTime timer; | 2008 | QTime timer; |
2008 | timer.start(); | 2009 | timer.start(); |
2009 | //qDebug("MainWindow::syncssh() "); | 2010 | //qDebug("MainWindow::syncssh() "); |
2010 | KOPrefs *p = KOPrefs::instance(); | 2011 | KOPrefs *p = KOPrefs::instance(); |
2011 | QString localFile = p->mLocalTempFile; | 2012 | QString localFile = p->mLocalTempFile; |
2012 | QString remoteIP = p->mRemoteIP; | 2013 | QString remoteIP = p->mRemoteIP; |
2013 | QString remoteUser = p->mRemoteUser; | 2014 | QString remoteUser = p->mRemoteUser; |
2014 | QString remoteFile = p->mRemoteFile; | 2015 | QString remoteFile = p->mRemoteFile; |
2015 | if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) | 2016 | if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) |
2016 | remoteUser += ":" + p->mRemotePassWd; | 2017 | remoteUser += ":" + p->mRemotePassWd; |
2017 | 2018 | ||
2018 | QString question = i18n("Do you really want\nto remote sync?\n \n") + | 2019 | QString question = i18n("Do you really want\nto remote sync?\n \n") + |
2019 | i18n("IP: " ) +remoteIP +"\n" + | 2020 | i18n("IP: " ) +remoteIP +"\n" + |
2020 | i18n("User: " ) + remoteUser +"\n" ; | 2021 | i18n("User: " ) + remoteUser +"\n" ; |
2021 | int maxlen = 30; | 2022 | int maxlen = 30; |
2022 | if ( QApplication::desktop()->width() > 320 ) | 2023 | if ( QApplication::desktop()->width() > 320 ) |
2023 | maxlen += 25; | 2024 | maxlen += 25; |
2024 | if ( remoteFile.length() > maxlen ) | 2025 | if ( remoteFile.length() > maxlen ) |
2025 | question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; | 2026 | question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; |
2026 | else | 2027 | else |
2027 | question += i18n("Remote file:\n " ) + remoteFile +"\n"; | 2028 | question += i18n("Remote file:\n " ) + remoteFile +"\n"; |
2028 | if ( localFile.length() > maxlen ) | 2029 | if ( localFile.length() > maxlen ) |
2029 | question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; | 2030 | question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; |
2030 | else | 2031 | else |
2031 | question += i18n("Local temp file:\n " ) + localFile +"\n"; | 2032 | question += i18n("Local temp file:\n " ) + localFile +"\n"; |
2032 | 2033 | ||
2033 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2034 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2034 | question, | 2035 | question, |
2035 | i18n("Yes"), i18n("No"), | 2036 | i18n("Yes"), i18n("No"), |
2036 | 0, 0 ) != 0 ) | 2037 | 0, 0 ) != 0 ) |
2037 | return; | 2038 | return; |
2038 | // if ( !p->mUsePassWd ) { | 2039 | // if ( !p->mUsePassWd ) { |
2039 | // QString pass = getPassword(); | 2040 | // QString pass = getPassword(); |
2040 | // if ( pass.length() > 0 ) | 2041 | // if ( pass.length() > 0 ) |
2041 | // remoteUser += ":" + pass; | 2042 | // remoteUser += ":" + pass; |
2042 | // } | 2043 | // } |
2043 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; | 2044 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; |
2044 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2045 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2045 | int fileSize = 0; | 2046 | int fileSize = 0; |
2046 | int result = system ( command ); | 2047 | int result = system ( command ); |
2047 | // 0 : okay | 2048 | // 0 : okay |
2048 | // 256: no such file or dir | 2049 | // 256: no such file or dir |
2049 | // | 2050 | // |
2050 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2051 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2051 | if ( result != 0 ) { | 2052 | if ( result != 0 ) { |
2052 | int len = maxlen; | 2053 | int len = maxlen; |
2053 | while ( len < command.length() ) { | 2054 | while ( len < command.length() ) { |
2054 | command.insert( len , "\n" ); | 2055 | command.insert( len , "\n" ); |
2055 | len += maxlen +2; | 2056 | len += maxlen +2; |
2056 | } | 2057 | } |
2057 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2058 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2058 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2059 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2059 | question, | 2060 | question, |
2060 | i18n("Okay!")) ; | 2061 | i18n("Okay!")) ; |
2061 | setCaption ("KO/Pi"); | 2062 | setCaption ("KO/Pi"); |
2062 | return; | 2063 | return; |
2063 | } | 2064 | } |
2064 | 2065 | ||
2065 | 2066 | ||
2066 | setCaption ( i18n( "Copying succeed." ) ); | 2067 | setCaption ( i18n( "Copying succeed." ) ); |
2067 | //mView->setSyncDevice("ssh-scp" ); | 2068 | //mView->setSyncDevice("ssh-scp" ); |
2068 | if ( syncWithFile(localFile , true ) ) { | 2069 | if ( syncWithFile(localFile , true ) ) { |
2069 | // Event* e = mView->getLastSyncEvent(); | 2070 | // Event* e = mView->getLastSyncEvent(); |
2070 | // e->setReadOnly( false ); | 2071 | // e->setReadOnly( false ); |
2071 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2072 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2072 | // e->setReadOnly( true ); | 2073 | // e->setReadOnly( true ); |
2073 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2074 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2074 | command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; | 2075 | command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; |
2075 | setCaption ( i18n( "Writing back file ..." ) ); | 2076 | setCaption ( i18n( "Writing back file ..." ) ); |
2076 | result = system ( command ); | 2077 | result = system ( command ); |
2077 | if ( result != 0 ) { | 2078 | if ( result != 0 ) { |
2078 | int len = maxlen; | 2079 | int len = maxlen; |
2079 | while ( len < command.length() ) { | 2080 | while ( len < command.length() ) { |
2080 | command.insert( len , "\n" ); | 2081 | command.insert( len , "\n" ); |
2081 | len += maxlen +2; | 2082 | len += maxlen +2; |
2082 | } | 2083 | } |
2083 | question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2084 | question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2084 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2085 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2085 | question, | 2086 | question, |
2086 | i18n("Okay!")) ; | 2087 | i18n("Okay!")) ; |
2087 | setCaption ("KO/Pi"); | 2088 | setCaption ("KO/Pi"); |
2088 | return; | 2089 | return; |
2089 | } else { | 2090 | } else { |
2090 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2091 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2091 | } | 2092 | } |
2092 | } | 2093 | } |
2093 | } | 2094 | } |
2094 | return; | 2095 | return; |
2095 | #if 0 | 2096 | #if 0 |
2096 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); | 2097 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); |
2097 | while ( timer.elapsed() < 5000 ) | 2098 | while ( timer.elapsed() < 5000 ) |
2098 | qApp->processEvents(); | 2099 | qApp->processEvents(); |
2099 | 2100 | ||
2100 | qDebug("MainWindow::merging) "); | 2101 | qDebug("MainWindow::merging) "); |
2101 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); | 2102 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); |
2102 | while ( mBlockSaveFlag ) | 2103 | while ( mBlockSaveFlag ) |
2103 | qApp->processEvents(); | 2104 | qApp->processEvents(); |
2104 | save(); | 2105 | save(); |
2105 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); | 2106 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); |
2106 | #endif | 2107 | #endif |
2107 | 2108 | ||
2108 | } | 2109 | } |
2109 | 2110 | ||
2110 | 2111 | ||
2111 | void MainWindow::syncSharp() | 2112 | void MainWindow::syncSharp() |
2112 | { | 2113 | { |
2113 | if ( mCalendarModifiedFlag ) | 2114 | if ( mCalendarModifiedFlag ) |
2114 | save(); | 2115 | save(); |
2115 | mView->syncSharp(); | 2116 | mView->syncSharp(); |
2116 | slotModifiedChanged( true ); | 2117 | slotModifiedChanged( true ); |
2117 | 2118 | ||
2118 | } | 2119 | } |
2119 | void MainWindow::syncPhone() | 2120 | void MainWindow::syncPhone() |
2120 | { | 2121 | { |
2121 | if ( mCalendarModifiedFlag ) | 2122 | if ( mCalendarModifiedFlag ) |
2122 | save(); | 2123 | save(); |
2123 | mView->syncPhone(); | 2124 | mView->syncPhone(); |
2124 | slotModifiedChanged( true ); | 2125 | slotModifiedChanged( true ); |
2125 | 2126 | ||
2126 | } | 2127 | } |
2127 | 2128 | ||
2128 | void MainWindow::printSel( ) | 2129 | void MainWindow::printSel( ) |
2129 | { | 2130 | { |
2130 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2131 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2131 | } | 2132 | } |
2132 | 2133 | ||
2133 | void MainWindow::printCal() | 2134 | void MainWindow::printCal() |
2134 | { | 2135 | { |
2135 | mView->print();//mCp->showDialog(); | 2136 | mView->print();//mCp->showDialog(); |
2136 | } | 2137 | } |