author | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
commit | 6385f303bef3cbcd19d097a7b05c30e144d5dd6e (patch) (unidiff) | |
tree | 770795d94ea6ec1dc8bcaa67cc174a9c0add564a /korganizer | |
parent | 13e996beddabc5e88f4f2fe49b2ce6cb8408eb30 (diff) | |
download | kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.zip kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.tar.gz kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.tar.bz2 |
implemented remove sync info for kopi and kapi
-rw-r--r-- | korganizer/calendarview.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index af01625..a08f243 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -699,3074 +699,3075 @@ void CalendarView::createPrinter() | |||
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | // 0 equal | 717 | // 0 equal |
718 | // 1 take local | 718 | // 1 take local |
719 | // 2 take remote | 719 | // 2 take remote |
720 | // 3 cancel | 720 | // 3 cancel |
721 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
722 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
723 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
725 | bool remCh, locCh; | 725 | bool remCh, locCh; |
726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
727 | //if ( remCh ) | 727 | //if ( remCh ) |
728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
729 | locCh = ( localMod > mLastCalendarSync ); | 729 | locCh = ( localMod > mLastCalendarSync ); |
730 | if ( !remCh && ! locCh ) { | 730 | if ( !remCh && ! locCh ) { |
731 | //qDebug("both not changed "); | 731 | //qDebug("both not changed "); |
732 | lastSync = localMod.addDays(1); | 732 | lastSync = localMod.addDays(1); |
733 | if ( mode <= SYNC_PREF_ASK ) | 733 | if ( mode <= SYNC_PREF_ASK ) |
734 | return 0; | 734 | return 0; |
735 | } else { | 735 | } else { |
736 | if ( locCh ) { | 736 | if ( locCh ) { |
737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
738 | lastSync = localMod.addDays( -1 ); | 738 | lastSync = localMod.addDays( -1 ); |
739 | if ( !remCh ) | 739 | if ( !remCh ) |
740 | remoteMod = ( lastSync.addDays( -1 ) ); | 740 | remoteMod = ( lastSync.addDays( -1 ) ); |
741 | } else { | 741 | } else { |
742 | //qDebug(" not loc changed "); | 742 | //qDebug(" not loc changed "); |
743 | lastSync = localMod.addDays( 1 ); | 743 | lastSync = localMod.addDays( 1 ); |
744 | if ( remCh ) | 744 | if ( remCh ) |
745 | remoteMod =( lastSync.addDays( 1 ) ); | 745 | remoteMod =( lastSync.addDays( 1 ) ); |
746 | 746 | ||
747 | } | 747 | } |
748 | } | 748 | } |
749 | full = true; | 749 | full = true; |
750 | if ( mode < SYNC_PREF_ASK ) | 750 | if ( mode < SYNC_PREF_ASK ) |
751 | mode = SYNC_PREF_ASK; | 751 | mode = SYNC_PREF_ASK; |
752 | } else { | 752 | } else { |
753 | if ( localMod == remoteMod ) | 753 | if ( localMod == remoteMod ) |
754 | // if ( local->revision() == remote->revision() ) | 754 | // if ( local->revision() == remote->revision() ) |
755 | return 0; | 755 | return 0; |
756 | 756 | ||
757 | } | 757 | } |
758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
759 | 759 | ||
760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
762 | //full = true; //debug only | 762 | //full = true; //debug only |
763 | if ( full ) { | 763 | if ( full ) { |
764 | bool equ = false; | 764 | bool equ = false; |
765 | if ( local->type() == "Event" ) { | 765 | if ( local->type() == "Event" ) { |
766 | equ = (*((Event*) local) == *((Event*) remote)); | 766 | equ = (*((Event*) local) == *((Event*) remote)); |
767 | } | 767 | } |
768 | else if ( local->type() =="Todo" ) | 768 | else if ( local->type() =="Todo" ) |
769 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 769 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
770 | else if ( local->type() =="Journal" ) | 770 | else if ( local->type() =="Journal" ) |
771 | equ = (*((Journal*) local) == *((Journal*) remote)); | 771 | equ = (*((Journal*) local) == *((Journal*) remote)); |
772 | if ( equ ) { | 772 | if ( equ ) { |
773 | //qDebug("equal "); | 773 | //qDebug("equal "); |
774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
776 | } | 776 | } |
777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
778 | return 0; | 778 | return 0; |
779 | 779 | ||
780 | }//else //debug only | 780 | }//else //debug only |
781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
782 | } | 782 | } |
783 | int result; | 783 | int result; |
784 | bool localIsNew; | 784 | bool localIsNew; |
785 | //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() ); | 785 | //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() ); |
786 | 786 | ||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
789 | 789 | ||
790 | switch( mode ) { | 790 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remoteMod ) | 792 | if ( lastSync > remoteMod ) |
793 | return 1; | 793 | return 1; |
794 | if ( lastSync > localMod ) | 794 | if ( lastSync > localMod ) |
795 | return 2; | 795 | return 2; |
796 | return 1; | 796 | return 1; |
797 | break; | 797 | break; |
798 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remoteMod ) | 799 | if ( lastSync > remoteMod ) |
800 | return 1; | 800 | return 1; |
801 | if ( lastSync > localMod ) | 801 | if ( lastSync > localMod ) |
802 | return 2; | 802 | return 2; |
803 | return 2; | 803 | return 2; |
804 | break; | 804 | break; |
805 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
806 | if ( localMod > remoteMod ) | 806 | if ( localMod > remoteMod ) |
807 | return 1; | 807 | return 1; |
808 | else | 808 | else |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
813 | if ( lastSync > remoteMod ) | 813 | if ( lastSync > remoteMod ) |
814 | return 1; | 814 | return 1; |
815 | if ( lastSync > localMod ) | 815 | if ( lastSync > localMod ) |
816 | return 2; | 816 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | localIsNew = localMod >= remoteMod; | 818 | localIsNew = localMod >= remoteMod; |
819 | if ( localIsNew ) | 819 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 821 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 824 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 826 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 834 | return result; |
835 | 835 | ||
836 | break; | 836 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 838 | return 1; |
839 | break; | 839 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 858 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 860 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
867 | } | 867 | } |
868 | 868 | ||
869 | return lse; | 869 | return lse; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | // we check, if the to delete event has a id for a profile | 873 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 874 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 876 | { |
877 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | if ( mSyncKDE ) | 929 | if ( mSyncKDE ) |
930 | remote->resetPilotStat(1); | 930 | remote->resetPilotStat(1); |
931 | mLastCalendarSync = QDateTime::currentDateTime(); | 931 | mLastCalendarSync = QDateTime::currentDateTime(); |
932 | QDateTime modifiedCalendar = mLastCalendarSync;; | 932 | QDateTime modifiedCalendar = mLastCalendarSync;; |
933 | eventLSync = getLastSyncEvent(); | 933 | eventLSync = getLastSyncEvent(); |
934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
935 | if ( eventR ) { | 935 | if ( eventR ) { |
936 | eventRSync = (Event*) eventR->clone(); | 936 | eventRSync = (Event*) eventR->clone(); |
937 | remote->deleteEvent(eventR ); | 937 | remote->deleteEvent(eventR ); |
938 | 938 | ||
939 | } else { | 939 | } else { |
940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { | 940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { |
941 | eventRSync = (Event*)eventLSync->clone(); | 941 | eventRSync = (Event*)eventLSync->clone(); |
942 | } else { | 942 | } else { |
943 | fullDateRange = true; | 943 | fullDateRange = true; |
944 | eventRSync = new Event(); | 944 | eventRSync = new Event(); |
945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
947 | eventRSync->setDtStart( mLastCalendarSync ); | 947 | eventRSync->setDtStart( mLastCalendarSync ); |
948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
949 | eventRSync->setCategories( i18n("SyncEvent") ); | 949 | eventRSync->setCategories( i18n("SyncEvent") ); |
950 | } | 950 | } |
951 | } | 951 | } |
952 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 952 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
953 | fullDateRange = true; | 953 | fullDateRange = true; |
954 | 954 | ||
955 | if ( ! fullDateRange ) { | 955 | if ( ! fullDateRange ) { |
956 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 956 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
957 | 957 | ||
958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | } | 961 | } |
962 | } | 962 | } |
963 | if ( mSyncKDE ) { | 963 | if ( mSyncKDE ) { |
964 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | 964 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); |
965 | } | 965 | } |
966 | if ( fullDateRange ) | 966 | if ( fullDateRange ) |
967 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 967 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
968 | else | 968 | else |
969 | mLastCalendarSync = eventLSync->dtStart(); | 969 | mLastCalendarSync = eventLSync->dtStart(); |
970 | // for resyncing if own file has changed | 970 | // for resyncing if own file has changed |
971 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 971 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
972 | mLastCalendarSync = loadedFileVersion; | 972 | mLastCalendarSync = loadedFileVersion; |
973 | //qDebug("setting mLastCalendarSync "); | 973 | //qDebug("setting mLastCalendarSync "); |
974 | } | 974 | } |
975 | //qDebug("*************************** "); | 975 | //qDebug("*************************** "); |
976 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 976 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
977 | QPtrList<Incidence> er = remote->rawIncidences(); | 977 | QPtrList<Incidence> er = remote->rawIncidences(); |
978 | Incidence* inR = er.first(); | 978 | Incidence* inR = er.first(); |
979 | Incidence* inL; | 979 | Incidence* inL; |
980 | QProgressBar bar( er.count(),0 ); | 980 | QProgressBar bar( er.count(),0 ); |
981 | bar.setCaption (i18n("Syncing - close to abort!") ); | 981 | bar.setCaption (i18n("Syncing - close to abort!") ); |
982 | 982 | ||
983 | int w = 300; | 983 | int w = 300; |
984 | if ( QApplication::desktop()->width() < 320 ) | 984 | if ( QApplication::desktop()->width() < 320 ) |
985 | w = 220; | 985 | w = 220; |
986 | int h = bar.sizeHint().height() ; | 986 | int h = bar.sizeHint().height() ; |
987 | int dw = QApplication::desktop()->width(); | 987 | int dw = QApplication::desktop()->width(); |
988 | int dh = QApplication::desktop()->height(); | 988 | int dh = QApplication::desktop()->height(); |
989 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 989 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
990 | bar.show(); | 990 | bar.show(); |
991 | int modulo = (er.count()/10)+1; | 991 | int modulo = (er.count()/10)+1; |
992 | int incCounter = 0; | 992 | int incCounter = 0; |
993 | while ( inR ) { | 993 | while ( inR ) { |
994 | if ( ! bar.isVisible() ) | 994 | if ( ! bar.isVisible() ) |
995 | return false; | 995 | return false; |
996 | if ( incCounter % modulo == 0 ) | 996 | if ( incCounter % modulo == 0 ) |
997 | bar.setProgress( incCounter ); | 997 | bar.setProgress( incCounter ); |
998 | ++incCounter; | 998 | ++incCounter; |
999 | uid = inR->uid(); | 999 | uid = inR->uid(); |
1000 | bool skipIncidence = false; | 1000 | bool skipIncidence = false; |
1001 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1001 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1002 | skipIncidence = true; | 1002 | skipIncidence = true; |
1003 | QString idS; | 1003 | QString idS; |
1004 | qApp->processEvents(); | 1004 | qApp->processEvents(); |
1005 | if ( !skipIncidence ) { | 1005 | if ( !skipIncidence ) { |
1006 | inL = local->incidence( uid ); | 1006 | inL = local->incidence( uid ); |
1007 | if ( inL ) { // maybe conflict - same uid in both calendars | 1007 | if ( inL ) { // maybe conflict - same uid in both calendars |
1008 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1008 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1009 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1009 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1010 | if ( take == 3 ) | 1010 | if ( take == 3 ) |
1011 | return false; | 1011 | return false; |
1012 | if ( take == 1 ) {// take local | 1012 | if ( take == 1 ) {// take local |
1013 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1013 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1014 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1014 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1015 | else | 1015 | else |
1016 | idS = inR->IDStr(); | 1016 | idS = inR->IDStr(); |
1017 | remote->deleteIncidence( inR ); | 1017 | remote->deleteIncidence( inR ); |
1018 | inR = inL->clone(); | 1018 | inR = inL->clone(); |
1019 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1019 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1020 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1021 | inR->setIDStr( idS ); | 1021 | inR->setIDStr( idS ); |
1022 | remote->addIncidence( inR ); | 1022 | remote->addIncidence( inR ); |
1023 | if ( mSyncKDE ) | 1023 | if ( mSyncKDE ) |
1024 | inR->setPilotId( 2 ); | 1024 | inR->setPilotId( 2 ); |
1025 | ++changedRemote; | 1025 | ++changedRemote; |
1026 | } else { | 1026 | } else { |
1027 | idS = inL->IDStr(); | 1027 | idS = inL->IDStr(); |
1028 | int pid = inL->pilotId(); | 1028 | int pid = inL->pilotId(); |
1029 | local->deleteIncidence( inL ); | 1029 | local->deleteIncidence( inL ); |
1030 | inL = inR->clone(); | 1030 | inL = inR->clone(); |
1031 | if ( mSyncKDE ) | 1031 | if ( mSyncKDE ) |
1032 | inL->setPilotId( pid ); | 1032 | inL->setPilotId( pid ); |
1033 | inL->setIDStr( idS ); | 1033 | inL->setIDStr( idS ); |
1034 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1034 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1035 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1035 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1036 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1036 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1037 | } | 1037 | } |
1038 | local->addIncidence( inL ); | 1038 | local->addIncidence( inL ); |
1039 | ++changedLocal; | 1039 | ++changedLocal; |
1040 | } | 1040 | } |
1041 | } | 1041 | } |
1042 | } else { // no conflict | 1042 | } else { // no conflict |
1043 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1043 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1044 | QString des = eventLSync->description(); | 1044 | QString des = eventLSync->description(); |
1045 | QString pref = "e"; | 1045 | QString pref = "e"; |
1046 | if ( inR->type() == "Todo" ) | 1046 | if ( inR->type() == "Todo" ) |
1047 | pref = "t"; | 1047 | pref = "t"; |
1048 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1048 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1049 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1049 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1050 | //remote->deleteIncidence( inR ); | 1050 | //remote->deleteIncidence( inR ); |
1051 | ++deletedEventR; | 1051 | ++deletedEventR; |
1052 | } else { | 1052 | } else { |
1053 | inR->setLastModified( modifiedCalendar ); | 1053 | inR->setLastModified( modifiedCalendar ); |
1054 | inL = inR->clone(); | 1054 | inL = inR->clone(); |
1055 | inL->setIDStr( ":" ); | 1055 | inL->setIDStr( ":" ); |
1056 | local->addIncidence( inL ); | 1056 | local->addIncidence( inL ); |
1057 | ++addedEvent; | 1057 | ++addedEvent; |
1058 | } | 1058 | } |
1059 | } else { | 1059 | } else { |
1060 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1060 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1061 | inR->setLastModified( modifiedCalendar ); | 1061 | inR->setLastModified( modifiedCalendar ); |
1062 | inL = inR->clone(); | 1062 | inL = inR->clone(); |
1063 | inL->setIDStr( ":" ); | 1063 | inL->setIDStr( ":" ); |
1064 | local->addIncidence( inL ); | 1064 | local->addIncidence( inL ); |
1065 | ++addedEvent; | 1065 | ++addedEvent; |
1066 | } else { | 1066 | } else { |
1067 | checkExternSyncEvent(eventRSyncSharp, inR); | 1067 | checkExternSyncEvent(eventRSyncSharp, inR); |
1068 | remote->deleteIncidence( inR ); | 1068 | remote->deleteIncidence( inR ); |
1069 | ++deletedEventR; | 1069 | ++deletedEventR; |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | } | 1072 | } |
1073 | } | 1073 | } |
1074 | inR = er.next(); | 1074 | inR = er.next(); |
1075 | } | 1075 | } |
1076 | QPtrList<Incidence> el = local->rawIncidences(); | 1076 | QPtrList<Incidence> el = local->rawIncidences(); |
1077 | inL = el.first(); | 1077 | inL = el.first(); |
1078 | modulo = (el.count()/10)+1; | 1078 | modulo = (el.count()/10)+1; |
1079 | bar.setCaption (i18n("Add / remove events") ); | 1079 | bar.setCaption (i18n("Add / remove events") ); |
1080 | bar.setTotalSteps ( el.count() ) ; | 1080 | bar.setTotalSteps ( el.count() ) ; |
1081 | bar.show(); | 1081 | bar.show(); |
1082 | incCounter = 0; | 1082 | incCounter = 0; |
1083 | 1083 | ||
1084 | while ( inL ) { | 1084 | while ( inL ) { |
1085 | 1085 | ||
1086 | qApp->processEvents(); | 1086 | qApp->processEvents(); |
1087 | if ( ! bar.isVisible() ) | 1087 | if ( ! bar.isVisible() ) |
1088 | return false; | 1088 | return false; |
1089 | if ( incCounter % modulo == 0 ) | 1089 | if ( incCounter % modulo == 0 ) |
1090 | bar.setProgress( incCounter ); | 1090 | bar.setProgress( incCounter ); |
1091 | ++incCounter; | 1091 | ++incCounter; |
1092 | uid = inL->uid(); | 1092 | uid = inL->uid(); |
1093 | bool skipIncidence = false; | 1093 | bool skipIncidence = false; |
1094 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1094 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1095 | skipIncidence = true; | 1095 | skipIncidence = true; |
1096 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1096 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1097 | skipIncidence = true; | 1097 | skipIncidence = true; |
1098 | if ( !skipIncidence ) { | 1098 | if ( !skipIncidence ) { |
1099 | inR = remote->incidence( uid ); | 1099 | inR = remote->incidence( uid ); |
1100 | if ( ! inR ) { | 1100 | if ( ! inR ) { |
1101 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1101 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1102 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1102 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1103 | checkExternSyncEvent(eventLSyncSharp, inL); | 1103 | checkExternSyncEvent(eventLSyncSharp, inL); |
1104 | local->deleteIncidence( inL ); | 1104 | local->deleteIncidence( inL ); |
1105 | ++deletedEventL; | 1105 | ++deletedEventL; |
1106 | } else { | 1106 | } else { |
1107 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1107 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1108 | inL->removeID(mCurrentSyncDevice ); | 1108 | inL->removeID(mCurrentSyncDevice ); |
1109 | ++addedEventR; | 1109 | ++addedEventR; |
1110 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1110 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1111 | inL->setLastModified( modifiedCalendar ); | 1111 | inL->setLastModified( modifiedCalendar ); |
1112 | inR = inL->clone(); | 1112 | inR = inL->clone(); |
1113 | inR->setIDStr( ":" ); | 1113 | inR->setIDStr( ":" ); |
1114 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1114 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1115 | remote->addIncidence( inR ); | 1115 | remote->addIncidence( inR ); |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | } else { | 1118 | } else { |
1119 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1119 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1120 | checkExternSyncEvent(eventLSyncSharp, inL); | 1120 | checkExternSyncEvent(eventLSyncSharp, inL); |
1121 | local->deleteIncidence( inL ); | 1121 | local->deleteIncidence( inL ); |
1122 | ++deletedEventL; | 1122 | ++deletedEventL; |
1123 | } else { | 1123 | } else { |
1124 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1124 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1125 | ++addedEventR; | 1125 | ++addedEventR; |
1126 | inL->setLastModified( modifiedCalendar ); | 1126 | inL->setLastModified( modifiedCalendar ); |
1127 | inR = inL->clone(); | 1127 | inR = inL->clone(); |
1128 | inR->setIDStr( ":" ); | 1128 | inR->setIDStr( ":" ); |
1129 | remote->addIncidence( inR ); | 1129 | remote->addIncidence( inR ); |
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | } | 1133 | } |
1134 | } | 1134 | } |
1135 | inL = el.next(); | 1135 | inL = el.next(); |
1136 | } | 1136 | } |
1137 | int delFut = 0; | 1137 | int delFut = 0; |
1138 | int remRem = 0; | 1138 | int remRem = 0; |
1139 | if ( mSyncManager->mWriteBackInFuture ) { | 1139 | if ( mSyncManager->mWriteBackInFuture ) { |
1140 | er = remote->rawIncidences(); | 1140 | er = remote->rawIncidences(); |
1141 | remRem = er.count(); | 1141 | remRem = er.count(); |
1142 | inR = er.first(); | 1142 | inR = er.first(); |
1143 | QDateTime dt; | 1143 | QDateTime dt; |
1144 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1144 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1145 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1145 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1146 | while ( inR ) { | 1146 | while ( inR ) { |
1147 | if ( inR->type() == "Todo" ) { | 1147 | if ( inR->type() == "Todo" ) { |
1148 | Todo * t = (Todo*)inR; | 1148 | Todo * t = (Todo*)inR; |
1149 | if ( t->hasDueDate() ) | 1149 | if ( t->hasDueDate() ) |
1150 | dt = t->dtDue(); | 1150 | dt = t->dtDue(); |
1151 | else | 1151 | else |
1152 | dt = cur.addSecs( 62 ); | 1152 | dt = cur.addSecs( 62 ); |
1153 | } | 1153 | } |
1154 | else if (inR->type() == "Event" ) { | 1154 | else if (inR->type() == "Event" ) { |
1155 | bool ok; | 1155 | bool ok; |
1156 | dt = inR->getNextOccurence( cur, &ok ); | 1156 | dt = inR->getNextOccurence( cur, &ok ); |
1157 | if ( !ok ) | 1157 | if ( !ok ) |
1158 | dt = cur.addSecs( -62 ); | 1158 | dt = cur.addSecs( -62 ); |
1159 | } | 1159 | } |
1160 | else | 1160 | else |
1161 | dt = inR->dtStart(); | 1161 | dt = inR->dtStart(); |
1162 | if ( dt < cur || dt > end ) { | 1162 | if ( dt < cur || dt > end ) { |
1163 | remote->deleteIncidence( inR ); | 1163 | remote->deleteIncidence( inR ); |
1164 | ++delFut; | 1164 | ++delFut; |
1165 | } | 1165 | } |
1166 | inR = er.next(); | 1166 | inR = er.next(); |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | bar.hide(); | 1169 | bar.hide(); |
1170 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1170 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1171 | eventLSync->setReadOnly( false ); | 1171 | eventLSync->setReadOnly( false ); |
1172 | eventLSync->setDtStart( mLastCalendarSync ); | 1172 | eventLSync->setDtStart( mLastCalendarSync ); |
1173 | eventRSync->setDtStart( mLastCalendarSync ); | 1173 | eventRSync->setDtStart( mLastCalendarSync ); |
1174 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1174 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1175 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1175 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1176 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1176 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1177 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1177 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1178 | eventLSync->setReadOnly( true ); | 1178 | eventLSync->setReadOnly( true ); |
1179 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... | 1179 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... |
1180 | remote->addEvent( eventRSync ); | 1180 | remote->addEvent( eventRSync ); |
1181 | else | 1181 | else |
1182 | delete eventRSync; | 1182 | delete eventRSync; |
1183 | QString mes; | 1183 | QString mes; |
1184 | 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 ); | 1184 | 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 ); |
1185 | QString delmess; | 1185 | QString delmess; |
1186 | if ( delFut ) { | 1186 | if ( delFut ) { |
1187 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1187 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1188 | mes += delmess; | 1188 | mes += delmess; |
1189 | } | 1189 | } |
1190 | if ( mSyncManager->mShowSyncSummary ) { | 1190 | if ( mSyncManager->mShowSyncSummary ) { |
1191 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1191 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1192 | } | 1192 | } |
1193 | qDebug( mes ); | 1193 | qDebug( mes ); |
1194 | mCalendar->checkAlarmForIncidence( 0, true ); | 1194 | mCalendar->checkAlarmForIncidence( 0, true ); |
1195 | return syncOK; | 1195 | return syncOK; |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | void CalendarView::setSyncDevice( QString s ) | 1198 | void CalendarView::setSyncDevice( QString s ) |
1199 | { | 1199 | { |
1200 | mCurrentSyncDevice= s; | 1200 | mCurrentSyncDevice= s; |
1201 | } | 1201 | } |
1202 | void CalendarView::setSyncName( QString s ) | 1202 | void CalendarView::setSyncName( QString s ) |
1203 | { | 1203 | { |
1204 | mCurrentSyncName= s; | 1204 | mCurrentSyncName= s; |
1205 | } | 1205 | } |
1206 | bool CalendarView::syncCalendar(QString filename, int mode) | 1206 | bool CalendarView::syncCalendar(QString filename, int mode) |
1207 | { | 1207 | { |
1208 | //qDebug("syncCalendar %s ", filename.latin1()); | 1208 | //qDebug("syncCalendar %s ", filename.latin1()); |
1209 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1209 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1210 | CalendarLocal* calendar = new CalendarLocal(); | 1210 | CalendarLocal* calendar = new CalendarLocal(); |
1211 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1211 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1212 | FileStorage* storage = new FileStorage( calendar ); | 1212 | FileStorage* storage = new FileStorage( calendar ); |
1213 | bool syncOK = false; | 1213 | bool syncOK = false; |
1214 | storage->setFileName( filename ); | 1214 | storage->setFileName( filename ); |
1215 | // qDebug("loading ... "); | 1215 | // qDebug("loading ... "); |
1216 | if ( storage->load() ) { | 1216 | if ( storage->load() ) { |
1217 | getEventViewerDialog()->setSyncMode( true ); | 1217 | getEventViewerDialog()->setSyncMode( true ); |
1218 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1218 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1219 | getEventViewerDialog()->setSyncMode( false ); | 1219 | getEventViewerDialog()->setSyncMode( false ); |
1220 | if ( syncOK ) { | 1220 | if ( syncOK ) { |
1221 | if ( mSyncManager->mWriteBackFile ) | 1221 | if ( mSyncManager->mWriteBackFile ) |
1222 | { | 1222 | { |
1223 | storage->setSaveFormat( new ICalFormat() ); | 1223 | storage->setSaveFormat( new ICalFormat() ); |
1224 | storage->save(); | 1224 | storage->save(); |
1225 | } | 1225 | } |
1226 | } | 1226 | } |
1227 | setModified( true ); | 1227 | setModified( true ); |
1228 | } | 1228 | } |
1229 | delete storage; | 1229 | delete storage; |
1230 | delete calendar; | 1230 | delete calendar; |
1231 | if ( syncOK ) | 1231 | if ( syncOK ) |
1232 | updateView(); | 1232 | updateView(); |
1233 | return syncOK; | 1233 | return syncOK; |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | void CalendarView::syncExternal( int mode ) | 1236 | void CalendarView::syncExternal( int mode ) |
1237 | { | 1237 | { |
1238 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1238 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1239 | 1239 | ||
1240 | qApp->processEvents(); | 1240 | qApp->processEvents(); |
1241 | CalendarLocal* calendar = new CalendarLocal(); | 1241 | CalendarLocal* calendar = new CalendarLocal(); |
1242 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1242 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1243 | bool syncOK = false; | 1243 | bool syncOK = false; |
1244 | bool loadSuccess = false; | 1244 | bool loadSuccess = false; |
1245 | PhoneFormat* phoneFormat = 0; | 1245 | PhoneFormat* phoneFormat = 0; |
1246 | emit tempDisableBR(true); | 1246 | emit tempDisableBR(true); |
1247 | #ifndef DESKTOP_VERSION | 1247 | #ifndef DESKTOP_VERSION |
1248 | SharpFormat* sharpFormat = 0; | 1248 | SharpFormat* sharpFormat = 0; |
1249 | if ( mode == 0 ) { // sharp | 1249 | if ( mode == 0 ) { // sharp |
1250 | sharpFormat = new SharpFormat () ; | 1250 | sharpFormat = new SharpFormat () ; |
1251 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1251 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1252 | 1252 | ||
1253 | } else | 1253 | } else |
1254 | #endif | 1254 | #endif |
1255 | if ( mode == 1 ) { // phone | 1255 | if ( mode == 1 ) { // phone |
1256 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1256 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1257 | mSyncManager->mPhoneDevice, | 1257 | mSyncManager->mPhoneDevice, |
1258 | mSyncManager->mPhoneConnection, | 1258 | mSyncManager->mPhoneConnection, |
1259 | mSyncManager->mPhoneModel); | 1259 | mSyncManager->mPhoneModel); |
1260 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1260 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1261 | 1261 | ||
1262 | } else { | 1262 | } else { |
1263 | emit tempDisableBR(false); | 1263 | emit tempDisableBR(false); |
1264 | return; | 1264 | return; |
1265 | } | 1265 | } |
1266 | if ( loadSuccess ) { | 1266 | if ( loadSuccess ) { |
1267 | getEventViewerDialog()->setSyncMode( true ); | 1267 | getEventViewerDialog()->setSyncMode( true ); |
1268 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1268 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1269 | getEventViewerDialog()->setSyncMode( false ); | 1269 | getEventViewerDialog()->setSyncMode( false ); |
1270 | qApp->processEvents(); | 1270 | qApp->processEvents(); |
1271 | if ( syncOK ) { | 1271 | if ( syncOK ) { |
1272 | if ( mSyncManager->mWriteBackFile ) | 1272 | if ( mSyncManager->mWriteBackFile ) |
1273 | { | 1273 | { |
1274 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1274 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1275 | Incidence* inc = iL.first(); | 1275 | Incidence* inc = iL.first(); |
1276 | if ( phoneFormat ) { | 1276 | if ( phoneFormat ) { |
1277 | while ( inc ) { | 1277 | while ( inc ) { |
1278 | inc->removeID(mCurrentSyncDevice); | 1278 | inc->removeID(mCurrentSyncDevice); |
1279 | inc = iL.next(); | 1279 | inc = iL.next(); |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | #ifndef DESKTOP_VERSION | 1282 | #ifndef DESKTOP_VERSION |
1283 | if ( sharpFormat ) | 1283 | if ( sharpFormat ) |
1284 | sharpFormat->save(calendar); | 1284 | sharpFormat->save(calendar); |
1285 | #endif | 1285 | #endif |
1286 | if ( phoneFormat ) | 1286 | if ( phoneFormat ) |
1287 | phoneFormat->save(calendar); | 1287 | phoneFormat->save(calendar); |
1288 | iL = calendar->rawIncidences(); | 1288 | iL = calendar->rawIncidences(); |
1289 | inc = iL.first(); | 1289 | inc = iL.first(); |
1290 | Incidence* loc; | 1290 | Incidence* loc; |
1291 | while ( inc ) { | 1291 | while ( inc ) { |
1292 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1292 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1293 | loc = mCalendar->incidence(inc->uid() ); | 1293 | loc = mCalendar->incidence(inc->uid() ); |
1294 | if ( loc ) { | 1294 | if ( loc ) { |
1295 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1295 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1296 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1296 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1297 | } | 1297 | } |
1298 | } | 1298 | } |
1299 | inc = iL.next(); | 1299 | inc = iL.next(); |
1300 | } | 1300 | } |
1301 | Incidence* lse = getLastSyncEvent(); | 1301 | Incidence* lse = getLastSyncEvent(); |
1302 | if ( lse ) { | 1302 | if ( lse ) { |
1303 | lse->setReadOnly( false ); | 1303 | lse->setReadOnly( false ); |
1304 | lse->setDescription( "" ); | 1304 | lse->setDescription( "" ); |
1305 | lse->setReadOnly( true ); | 1305 | lse->setReadOnly( true ); |
1306 | } | 1306 | } |
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | setModified( true ); | 1309 | setModified( true ); |
1310 | } else { | 1310 | } else { |
1311 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1311 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1312 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1312 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1313 | question, i18n("Ok")) ; | 1313 | question, i18n("Ok")) ; |
1314 | 1314 | ||
1315 | } | 1315 | } |
1316 | delete calendar; | 1316 | delete calendar; |
1317 | updateView(); | 1317 | updateView(); |
1318 | emit tempDisableBR(false); | 1318 | emit tempDisableBR(false); |
1319 | return ;//syncOK; | 1319 | return ;//syncOK; |
1320 | 1320 | ||
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | bool CalendarView::importBday() | 1323 | bool CalendarView::importBday() |
1324 | { | 1324 | { |
1325 | #ifndef KORG_NOKABC | 1325 | #ifndef KORG_NOKABC |
1326 | 1326 | ||
1327 | #ifdef DESKTOP_VERSION | 1327 | #ifdef DESKTOP_VERSION |
1328 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1328 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1329 | KABC::AddressBook::Iterator it; | 1329 | KABC::AddressBook::Iterator it; |
1330 | int count = 0; | 1330 | int count = 0; |
1331 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1331 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1332 | ++count; | 1332 | ++count; |
1333 | } | 1333 | } |
1334 | QProgressBar bar(count,0 ); | 1334 | QProgressBar bar(count,0 ); |
1335 | int w = 300; | 1335 | int w = 300; |
1336 | if ( QApplication::desktop()->width() < 320 ) | 1336 | if ( QApplication::desktop()->width() < 320 ) |
1337 | w = 220; | 1337 | w = 220; |
1338 | int h = bar.sizeHint().height() ; | 1338 | int h = bar.sizeHint().height() ; |
1339 | int dw = QApplication::desktop()->width(); | 1339 | int dw = QApplication::desktop()->width(); |
1340 | int dh = QApplication::desktop()->height(); | 1340 | int dh = QApplication::desktop()->height(); |
1341 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1341 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1342 | bar.show(); | 1342 | bar.show(); |
1343 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1343 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1344 | qApp->processEvents(); | 1344 | qApp->processEvents(); |
1345 | count = 0; | 1345 | count = 0; |
1346 | int addCount = 0; | 1346 | int addCount = 0; |
1347 | KCal::Attendee* a = 0; | 1347 | KCal::Attendee* a = 0; |
1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1349 | if ( ! bar.isVisible() ) | 1349 | if ( ! bar.isVisible() ) |
1350 | return false; | 1350 | return false; |
1351 | bar.setProgress( count++ ); | 1351 | bar.setProgress( count++ ); |
1352 | qApp->processEvents(); | 1352 | qApp->processEvents(); |
1353 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1353 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1354 | if ( (*it).birthday().date().isValid() ){ | 1354 | if ( (*it).birthday().date().isValid() ){ |
1355 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1355 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1356 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1356 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1357 | ++addCount; | 1357 | ++addCount; |
1358 | } | 1358 | } |
1359 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1359 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1360 | if ( anni.isValid() ){ | 1360 | if ( anni.isValid() ){ |
1361 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1361 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1362 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1362 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1363 | ++addCount; | 1363 | ++addCount; |
1364 | } | 1364 | } |
1365 | } | 1365 | } |
1366 | updateView(); | 1366 | updateView(); |
1367 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1367 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1368 | #else //DESKTOP_VERSION | 1368 | #else //DESKTOP_VERSION |
1369 | 1369 | ||
1370 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1370 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1371 | // the result should now arrive through method insertBirthdays | 1371 | // the result should now arrive through method insertBirthdays |
1372 | 1372 | ||
1373 | #endif //DESKTOP_VERSION | 1373 | #endif //DESKTOP_VERSION |
1374 | 1374 | ||
1375 | #endif //KORG_NOKABC | 1375 | #endif //KORG_NOKABC |
1376 | 1376 | ||
1377 | 1377 | ||
1378 | return true; | 1378 | return true; |
1379 | } | 1379 | } |
1380 | 1380 | ||
1381 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1381 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1382 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1382 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1383 | const QStringList& anniversaryList, const QStringList& realNameList, | 1383 | const QStringList& anniversaryList, const QStringList& realNameList, |
1384 | const QStringList& emailList, const QStringList& assembledNameList, | 1384 | const QStringList& emailList, const QStringList& assembledNameList, |
1385 | const QStringList& uidList) | 1385 | const QStringList& uidList) |
1386 | { | 1386 | { |
1387 | qDebug("CalendarView::insertBirthdays"); | 1387 | qDebug("CalendarView::insertBirthdays"); |
1388 | if (uid == this->name()) | 1388 | if (uid == this->name()) |
1389 | { | 1389 | { |
1390 | int count = birthdayList.count(); | 1390 | int count = birthdayList.count(); |
1391 | int addCount = 0; | 1391 | int addCount = 0; |
1392 | KCal::Attendee* a = 0; | 1392 | KCal::Attendee* a = 0; |
1393 | 1393 | ||
1394 | qDebug("CalView 1 %i", count); | 1394 | qDebug("CalView 1 %i", count); |
1395 | 1395 | ||
1396 | QProgressBar bar(count,0 ); | 1396 | QProgressBar bar(count,0 ); |
1397 | int w = 300; | 1397 | int w = 300; |
1398 | if ( QApplication::desktop()->width() < 320 ) | 1398 | if ( QApplication::desktop()->width() < 320 ) |
1399 | w = 220; | 1399 | w = 220; |
1400 | int h = bar.sizeHint().height() ; | 1400 | int h = bar.sizeHint().height() ; |
1401 | int dw = QApplication::desktop()->width(); | 1401 | int dw = QApplication::desktop()->width(); |
1402 | int dh = QApplication::desktop()->height(); | 1402 | int dh = QApplication::desktop()->height(); |
1403 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1403 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1404 | bar.show(); | 1404 | bar.show(); |
1405 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1405 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1406 | qApp->processEvents(); | 1406 | qApp->processEvents(); |
1407 | 1407 | ||
1408 | QDate birthday; | 1408 | QDate birthday; |
1409 | QDate anniversary; | 1409 | QDate anniversary; |
1410 | QString realName; | 1410 | QString realName; |
1411 | QString email; | 1411 | QString email; |
1412 | QString assembledName; | 1412 | QString assembledName; |
1413 | QString uid; | 1413 | QString uid; |
1414 | bool ok = true; | 1414 | bool ok = true; |
1415 | for ( int i = 0; i < count; i++) | 1415 | for ( int i = 0; i < count; i++) |
1416 | { | 1416 | { |
1417 | if ( ! bar.isVisible() ) | 1417 | if ( ! bar.isVisible() ) |
1418 | return; | 1418 | return; |
1419 | bar.setProgress( i ); | 1419 | bar.setProgress( i ); |
1420 | qApp->processEvents(); | 1420 | qApp->processEvents(); |
1421 | 1421 | ||
1422 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1422 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1423 | if (!ok) { | 1423 | if (!ok) { |
1424 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1424 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1425 | } | 1425 | } |
1426 | 1426 | ||
1427 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1427 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1428 | if (!ok) { | 1428 | if (!ok) { |
1429 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1429 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1430 | } | 1430 | } |
1431 | realName = realNameList[i]; | 1431 | realName = realNameList[i]; |
1432 | email = emailList[i]; | 1432 | email = emailList[i]; |
1433 | assembledName = assembledNameList[i]; | 1433 | assembledName = assembledNameList[i]; |
1434 | uid = uidList[i]; | 1434 | uid = uidList[i]; |
1435 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1435 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1436 | 1436 | ||
1437 | if ( birthday.isValid() ){ | 1437 | if ( birthday.isValid() ){ |
1438 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1438 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1439 | KCal::Attendee::ReqParticipant,uid) ; | 1439 | KCal::Attendee::ReqParticipant,uid) ; |
1440 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1440 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1441 | ++addCount; | 1441 | ++addCount; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | if ( anniversary.isValid() ){ | 1444 | if ( anniversary.isValid() ){ |
1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1446 | KCal::Attendee::ReqParticipant,uid) ; | 1446 | KCal::Attendee::ReqParticipant,uid) ; |
1447 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1447 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1448 | ++addCount; | 1448 | ++addCount; |
1449 | } | 1449 | } |
1450 | } | 1450 | } |
1451 | 1451 | ||
1452 | updateView(); | 1452 | updateView(); |
1453 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1453 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1454 | 1454 | ||
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | } | 1457 | } |
1458 | 1458 | ||
1459 | 1459 | ||
1460 | 1460 | ||
1461 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1461 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1462 | { | 1462 | { |
1463 | //qDebug("addAnni "); | 1463 | //qDebug("addAnni "); |
1464 | Event * ev = new Event(); | 1464 | Event * ev = new Event(); |
1465 | if ( a ) { | 1465 | if ( a ) { |
1466 | ev->addAttendee( a ); | 1466 | ev->addAttendee( a ); |
1467 | } | 1467 | } |
1468 | QString kind; | 1468 | QString kind; |
1469 | if ( birthday ) | 1469 | if ( birthday ) |
1470 | kind = i18n( "Birthday" ); | 1470 | kind = i18n( "Birthday" ); |
1471 | else | 1471 | else |
1472 | kind = i18n( "Anniversary" ); | 1472 | kind = i18n( "Anniversary" ); |
1473 | ev->setSummary( name + " - " + kind ); | 1473 | ev->setSummary( name + " - " + kind ); |
1474 | ev->setOrganizer(a->email()); | 1474 | ev->setOrganizer(a->email()); |
1475 | ev->setCategories( kind ); | 1475 | ev->setCategories( kind ); |
1476 | ev->setDtStart( QDateTime(date) ); | 1476 | ev->setDtStart( QDateTime(date) ); |
1477 | ev->setDtEnd( QDateTime(date) ); | 1477 | ev->setDtEnd( QDateTime(date) ); |
1478 | ev->setFloats( true ); | 1478 | ev->setFloats( true ); |
1479 | Recurrence * rec = ev->recurrence(); | 1479 | Recurrence * rec = ev->recurrence(); |
1480 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1480 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1481 | rec->addYearlyNum( date.month() ); | 1481 | rec->addYearlyNum( date.month() ); |
1482 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1482 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1483 | delete ev; | 1483 | delete ev; |
1484 | return false; | 1484 | return false; |
1485 | } | 1485 | } |
1486 | return true; | 1486 | return true; |
1487 | 1487 | ||
1488 | } | 1488 | } |
1489 | bool CalendarView::importQtopia( const QString &categories, | 1489 | bool CalendarView::importQtopia( const QString &categories, |
1490 | const QString &datebook, | 1490 | const QString &datebook, |
1491 | const QString &todolist ) | 1491 | const QString &todolist ) |
1492 | { | 1492 | { |
1493 | 1493 | ||
1494 | QtopiaFormat qtopiaFormat; | 1494 | QtopiaFormat qtopiaFormat; |
1495 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1495 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1496 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1496 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1497 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1497 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1498 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1498 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1499 | 1499 | ||
1500 | updateView(); | 1500 | updateView(); |
1501 | return true; | 1501 | return true; |
1502 | 1502 | ||
1503 | #if 0 | 1503 | #if 0 |
1504 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1504 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1505 | mCurrentSyncDevice = "qtopia-XML"; | 1505 | mCurrentSyncDevice = "qtopia-XML"; |
1506 | if ( mSyncManager->mAskForPreferences ) | 1506 | if ( mSyncManager->mAskForPreferences ) |
1507 | edit_sync_options(); | 1507 | edit_sync_options(); |
1508 | qApp->processEvents(); | 1508 | qApp->processEvents(); |
1509 | CalendarLocal* calendar = new CalendarLocal(); | 1509 | CalendarLocal* calendar = new CalendarLocal(); |
1510 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1510 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1511 | bool syncOK = false; | 1511 | bool syncOK = false; |
1512 | QtopiaFormat qtopiaFormat; | 1512 | QtopiaFormat qtopiaFormat; |
1513 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1513 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1514 | bool loadOk = true; | 1514 | bool loadOk = true; |
1515 | if ( !categories.isEmpty() ) | 1515 | if ( !categories.isEmpty() ) |
1516 | loadOk = qtopiaFormat.load( calendar, categories ); | 1516 | loadOk = qtopiaFormat.load( calendar, categories ); |
1517 | if ( loadOk && !datebook.isEmpty() ) | 1517 | if ( loadOk && !datebook.isEmpty() ) |
1518 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1518 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1519 | if ( loadOk && !todolist.isEmpty() ) | 1519 | if ( loadOk && !todolist.isEmpty() ) |
1520 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1520 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1521 | 1521 | ||
1522 | if ( loadOk ) { | 1522 | if ( loadOk ) { |
1523 | getEventViewerDialog()->setSyncMode( true ); | 1523 | getEventViewerDialog()->setSyncMode( true ); |
1524 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1524 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1525 | getEventViewerDialog()->setSyncMode( false ); | 1525 | getEventViewerDialog()->setSyncMode( false ); |
1526 | qApp->processEvents(); | 1526 | qApp->processEvents(); |
1527 | if ( syncOK ) { | 1527 | if ( syncOK ) { |
1528 | if ( mSyncManager->mWriteBackFile ) | 1528 | if ( mSyncManager->mWriteBackFile ) |
1529 | { | 1529 | { |
1530 | // write back XML file | 1530 | // write back XML file |
1531 | 1531 | ||
1532 | } | 1532 | } |
1533 | setModified( true ); | 1533 | setModified( true ); |
1534 | } | 1534 | } |
1535 | } else { | 1535 | } else { |
1536 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1536 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1537 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1537 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1538 | question, i18n("Ok")) ; | 1538 | question, i18n("Ok")) ; |
1539 | } | 1539 | } |
1540 | delete calendar; | 1540 | delete calendar; |
1541 | updateView(); | 1541 | updateView(); |
1542 | return syncOK; | 1542 | return syncOK; |
1543 | 1543 | ||
1544 | 1544 | ||
1545 | #endif | 1545 | #endif |
1546 | 1546 | ||
1547 | } | 1547 | } |
1548 | 1548 | ||
1549 | void CalendarView::setSyncEventsReadOnly() | 1549 | void CalendarView::setSyncEventsReadOnly() |
1550 | { | 1550 | { |
1551 | Event * ev; | 1551 | Event * ev; |
1552 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1552 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1553 | ev = eL.first(); | 1553 | ev = eL.first(); |
1554 | while ( ev ) { | 1554 | while ( ev ) { |
1555 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1555 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1556 | ev->setReadOnly( true ); | 1556 | ev->setReadOnly( true ); |
1557 | ev = eL.next(); | 1557 | ev = eL.next(); |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | bool CalendarView::openCalendar(QString filename, bool merge) | 1560 | bool CalendarView::openCalendar(QString filename, bool merge) |
1561 | { | 1561 | { |
1562 | 1562 | ||
1563 | if (filename.isEmpty()) { | 1563 | if (filename.isEmpty()) { |
1564 | return false; | 1564 | return false; |
1565 | } | 1565 | } |
1566 | 1566 | ||
1567 | if (!QFile::exists(filename)) { | 1567 | if (!QFile::exists(filename)) { |
1568 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1568 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1569 | return false; | 1569 | return false; |
1570 | } | 1570 | } |
1571 | 1571 | ||
1572 | globalFlagBlockAgenda = 1; | 1572 | globalFlagBlockAgenda = 1; |
1573 | if (!merge) mCalendar->close(); | 1573 | if (!merge) mCalendar->close(); |
1574 | 1574 | ||
1575 | mStorage->setFileName( filename ); | 1575 | mStorage->setFileName( filename ); |
1576 | 1576 | ||
1577 | if ( mStorage->load() ) { | 1577 | if ( mStorage->load() ) { |
1578 | if ( merge ) ;//setModified( true ); | 1578 | if ( merge ) ;//setModified( true ); |
1579 | else { | 1579 | else { |
1580 | //setModified( true ); | 1580 | //setModified( true ); |
1581 | mViewManager->setDocumentId( filename ); | 1581 | mViewManager->setDocumentId( filename ); |
1582 | mDialogManager->setDocumentId( filename ); | 1582 | mDialogManager->setDocumentId( filename ); |
1583 | mTodoList->setDocumentId( filename ); | 1583 | mTodoList->setDocumentId( filename ); |
1584 | } | 1584 | } |
1585 | globalFlagBlockAgenda = 2; | 1585 | globalFlagBlockAgenda = 2; |
1586 | // if ( getLastSyncEvent() ) | 1586 | // if ( getLastSyncEvent() ) |
1587 | // getLastSyncEvent()->setReadOnly( true ); | 1587 | // getLastSyncEvent()->setReadOnly( true ); |
1588 | mCalendar->reInitAlarmSettings(); | 1588 | mCalendar->reInitAlarmSettings(); |
1589 | setSyncEventsReadOnly(); | 1589 | setSyncEventsReadOnly(); |
1590 | updateUnmanagedViews(); | 1590 | updateUnmanagedViews(); |
1591 | updateView(); | 1591 | updateView(); |
1592 | if ( filename != MainWindow::defaultFileName() ) { | 1592 | if ( filename != MainWindow::defaultFileName() ) { |
1593 | saveCalendar( MainWindow::defaultFileName() ); | 1593 | saveCalendar( MainWindow::defaultFileName() ); |
1594 | } else { | 1594 | } else { |
1595 | QFileInfo finf ( MainWindow::defaultFileName()); | 1595 | QFileInfo finf ( MainWindow::defaultFileName()); |
1596 | if ( finf.exists() ) { | 1596 | if ( finf.exists() ) { |
1597 | setLoadedFileVersion( finf.lastModified () ); | 1597 | setLoadedFileVersion( finf.lastModified () ); |
1598 | } | 1598 | } |
1599 | } | 1599 | } |
1600 | return true; | 1600 | return true; |
1601 | } else { | 1601 | } else { |
1602 | // while failing to load, the calendar object could | 1602 | // while failing to load, the calendar object could |
1603 | // have become partially populated. Clear it out. | 1603 | // have become partially populated. Clear it out. |
1604 | if ( !merge ) { | 1604 | if ( !merge ) { |
1605 | mCalendar->close(); | 1605 | mCalendar->close(); |
1606 | mViewManager->setDocumentId( filename ); | 1606 | mViewManager->setDocumentId( filename ); |
1607 | mDialogManager->setDocumentId( filename ); | 1607 | mDialogManager->setDocumentId( filename ); |
1608 | mTodoList->setDocumentId( filename ); | 1608 | mTodoList->setDocumentId( filename ); |
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1611 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1612 | 1612 | ||
1613 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1613 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1614 | globalFlagBlockAgenda = 2; | 1614 | globalFlagBlockAgenda = 2; |
1615 | mCalendar->reInitAlarmSettings(); | 1615 | mCalendar->reInitAlarmSettings(); |
1616 | setSyncEventsReadOnly(); | 1616 | setSyncEventsReadOnly(); |
1617 | updateUnmanagedViews(); | 1617 | updateUnmanagedViews(); |
1618 | updateView(); | 1618 | updateView(); |
1619 | } | 1619 | } |
1620 | return false; | 1620 | return false; |
1621 | } | 1621 | } |
1622 | void CalendarView::showOpenError() | 1622 | void CalendarView::showOpenError() |
1623 | { | 1623 | { |
1624 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1624 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1625 | } | 1625 | } |
1626 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1626 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1627 | { | 1627 | { |
1628 | loadedFileVersion = dt; | 1628 | loadedFileVersion = dt; |
1629 | } | 1629 | } |
1630 | bool CalendarView::checkFileChanged(QString fn) | 1630 | bool CalendarView::checkFileChanged(QString fn) |
1631 | { | 1631 | { |
1632 | QFileInfo finf ( fn ); | 1632 | QFileInfo finf ( fn ); |
1633 | if ( !finf.exists() ) | 1633 | if ( !finf.exists() ) |
1634 | return true; | 1634 | return true; |
1635 | QDateTime dt = finf.lastModified (); | 1635 | QDateTime dt = finf.lastModified (); |
1636 | if ( dt <= loadedFileVersion ) | 1636 | if ( dt <= loadedFileVersion ) |
1637 | return false; | 1637 | return false; |
1638 | return true; | 1638 | return true; |
1639 | 1639 | ||
1640 | } | 1640 | } |
1641 | void CalendarView::watchSavedFile() | 1641 | void CalendarView::watchSavedFile() |
1642 | { | 1642 | { |
1643 | QFileInfo finf ( MainWindow::defaultFileName()); | 1643 | QFileInfo finf ( MainWindow::defaultFileName()); |
1644 | if ( !finf.exists() ) | 1644 | if ( !finf.exists() ) |
1645 | return; | 1645 | return; |
1646 | QDateTime dt = finf.lastModified (); | 1646 | QDateTime dt = finf.lastModified (); |
1647 | if ( dt < loadedFileVersion ) { | 1647 | if ( dt < loadedFileVersion ) { |
1648 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1648 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1649 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1649 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1650 | return; | 1650 | return; |
1651 | } | 1651 | } |
1652 | loadedFileVersion = dt; | 1652 | loadedFileVersion = dt; |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | bool CalendarView::checkFileVersion(QString fn) | 1655 | bool CalendarView::checkFileVersion(QString fn) |
1656 | { | 1656 | { |
1657 | QFileInfo finf ( fn ); | 1657 | QFileInfo finf ( fn ); |
1658 | if ( !finf.exists() ) | 1658 | if ( !finf.exists() ) |
1659 | return true; | 1659 | return true; |
1660 | QDateTime dt = finf.lastModified (); | 1660 | QDateTime dt = finf.lastModified (); |
1661 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1661 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1662 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1662 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1663 | if ( dt <= loadedFileVersion ) | 1663 | if ( dt <= loadedFileVersion ) |
1664 | return true; | 1664 | return true; |
1665 | 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)) , | 1665 | 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)) , |
1666 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1666 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1667 | i18n("Sync+save")); | 1667 | i18n("Sync+save")); |
1668 | 1668 | ||
1669 | if ( km == KMessageBox::Cancel ) | 1669 | if ( km == KMessageBox::Cancel ) |
1670 | return false; | 1670 | return false; |
1671 | if ( km == KMessageBox::Yes ) | 1671 | if ( km == KMessageBox::Yes ) |
1672 | return true; | 1672 | return true; |
1673 | 1673 | ||
1674 | setSyncDevice("deleteaftersync" ); | 1674 | setSyncDevice("deleteaftersync" ); |
1675 | mSyncManager->mAskForPreferences = true; | 1675 | mSyncManager->mAskForPreferences = true; |
1676 | mSyncManager->mSyncAlgoPrefs = 3; | 1676 | mSyncManager->mSyncAlgoPrefs = 3; |
1677 | mSyncManager->mWriteBackFile = false; | 1677 | mSyncManager->mWriteBackFile = false; |
1678 | mSyncManager->mWriteBackExistingOnly = false; | 1678 | mSyncManager->mWriteBackExistingOnly = false; |
1679 | mSyncManager->mShowSyncSummary = false; | 1679 | mSyncManager->mShowSyncSummary = false; |
1680 | syncCalendar( fn, 3 ); | 1680 | syncCalendar( fn, 3 ); |
1681 | Event * e = getLastSyncEvent(); | 1681 | Event * e = getLastSyncEvent(); |
1682 | mCalendar->deleteEvent ( e ); | 1682 | mCalendar->deleteEvent ( e ); |
1683 | updateView(); | 1683 | updateView(); |
1684 | return true; | 1684 | return true; |
1685 | } | 1685 | } |
1686 | 1686 | ||
1687 | bool CalendarView::saveCalendar( QString filename ) | 1687 | bool CalendarView::saveCalendar( QString filename ) |
1688 | { | 1688 | { |
1689 | 1689 | ||
1690 | // Store back all unsaved data into calendar object | 1690 | // Store back all unsaved data into calendar object |
1691 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1691 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1692 | if ( mViewManager->currentView() ) | 1692 | if ( mViewManager->currentView() ) |
1693 | mViewManager->currentView()->flushView(); | 1693 | mViewManager->currentView()->flushView(); |
1694 | 1694 | ||
1695 | 1695 | ||
1696 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1696 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1697 | mStorage->setSaveFormat( new ICalFormat() ); | 1697 | mStorage->setSaveFormat( new ICalFormat() ); |
1698 | mStorage->setFileName( filename ); | 1698 | mStorage->setFileName( filename ); |
1699 | bool success; | 1699 | bool success; |
1700 | success = mStorage->save(); | 1700 | success = mStorage->save(); |
1701 | if ( !success ) { | 1701 | if ( !success ) { |
1702 | return false; | 1702 | return false; |
1703 | } | 1703 | } |
1704 | if ( filename == MainWindow::defaultFileName() ) { | 1704 | if ( filename == MainWindow::defaultFileName() ) { |
1705 | setLoadedFileVersion( lfv ); | 1705 | setLoadedFileVersion( lfv ); |
1706 | watchSavedFile(); | 1706 | watchSavedFile(); |
1707 | } | 1707 | } |
1708 | return true; | 1708 | return true; |
1709 | } | 1709 | } |
1710 | 1710 | ||
1711 | void CalendarView::closeCalendar() | 1711 | void CalendarView::closeCalendar() |
1712 | { | 1712 | { |
1713 | 1713 | ||
1714 | // child windows no longer valid | 1714 | // child windows no longer valid |
1715 | emit closingDown(); | 1715 | emit closingDown(); |
1716 | 1716 | ||
1717 | mCalendar->close(); | 1717 | mCalendar->close(); |
1718 | setModified(false); | 1718 | setModified(false); |
1719 | updateView(); | 1719 | updateView(); |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | void CalendarView::archiveCalendar() | 1722 | void CalendarView::archiveCalendar() |
1723 | { | 1723 | { |
1724 | mDialogManager->showArchiveDialog(); | 1724 | mDialogManager->showArchiveDialog(); |
1725 | } | 1725 | } |
1726 | 1726 | ||
1727 | 1727 | ||
1728 | void CalendarView::readSettings() | 1728 | void CalendarView::readSettings() |
1729 | { | 1729 | { |
1730 | 1730 | ||
1731 | 1731 | ||
1732 | // mViewManager->showAgendaView(); | 1732 | // mViewManager->showAgendaView(); |
1733 | QString str; | 1733 | QString str; |
1734 | //qDebug("CalendarView::readSettings() "); | 1734 | //qDebug("CalendarView::readSettings() "); |
1735 | // read settings from the KConfig, supplying reasonable | 1735 | // read settings from the KConfig, supplying reasonable |
1736 | // defaults where none are to be found | 1736 | // defaults where none are to be found |
1737 | KConfig *config = KOGlobals::config(); | 1737 | KConfig *config = KOGlobals::config(); |
1738 | #ifndef KORG_NOSPLITTER | 1738 | #ifndef KORG_NOSPLITTER |
1739 | config->setGroup("KOrganizer Geometry"); | 1739 | config->setGroup("KOrganizer Geometry"); |
1740 | 1740 | ||
1741 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1741 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1742 | if (sizes.count() != 2) { | 1742 | if (sizes.count() != 2) { |
1743 | sizes << mDateNavigator->minimumSizeHint().width(); | 1743 | sizes << mDateNavigator->minimumSizeHint().width(); |
1744 | sizes << 300; | 1744 | sizes << 300; |
1745 | } | 1745 | } |
1746 | mPanner->setSizes(sizes); | 1746 | mPanner->setSizes(sizes); |
1747 | 1747 | ||
1748 | sizes = config->readIntListEntry("Separator2"); | 1748 | sizes = config->readIntListEntry("Separator2"); |
1749 | if ( ( mResourceView && sizes.count() == 4 ) || | 1749 | if ( ( mResourceView && sizes.count() == 4 ) || |
1750 | ( !mResourceView && sizes.count() == 3 ) ) { | 1750 | ( !mResourceView && sizes.count() == 3 ) ) { |
1751 | mLeftSplitter->setSizes(sizes); | 1751 | mLeftSplitter->setSizes(sizes); |
1752 | } | 1752 | } |
1753 | #endif | 1753 | #endif |
1754 | globalFlagBlockAgenda = 1; | 1754 | globalFlagBlockAgenda = 1; |
1755 | mViewManager->showAgendaView(); | 1755 | mViewManager->showAgendaView(); |
1756 | //mViewManager->readSettings( config ); | 1756 | //mViewManager->readSettings( config ); |
1757 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1757 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1758 | readFilterSettings(config); | 1758 | readFilterSettings(config); |
1759 | config->setGroup( "Views" ); | 1759 | config->setGroup( "Views" ); |
1760 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1760 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1761 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1761 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1762 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1762 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1763 | else mNavigator->selectDates( dateCount ); | 1763 | else mNavigator->selectDates( dateCount ); |
1764 | // mViewManager->readSettings( config ); | 1764 | // mViewManager->readSettings( config ); |
1765 | updateConfig(); | 1765 | updateConfig(); |
1766 | globalFlagBlockAgenda = 2; | 1766 | globalFlagBlockAgenda = 2; |
1767 | mViewManager->readSettings( config ); | 1767 | mViewManager->readSettings( config ); |
1768 | #ifdef DESKTOP_VERSION | 1768 | #ifdef DESKTOP_VERSION |
1769 | config->setGroup("WidgetLayout"); | 1769 | config->setGroup("WidgetLayout"); |
1770 | QStringList list; | 1770 | QStringList list; |
1771 | list = config->readListEntry("MainLayout"); | 1771 | list = config->readListEntry("MainLayout"); |
1772 | int x,y,w,h; | 1772 | int x,y,w,h; |
1773 | if ( ! list.isEmpty() ) { | 1773 | if ( ! list.isEmpty() ) { |
1774 | x = list[0].toInt(); | 1774 | x = list[0].toInt(); |
1775 | y = list[1].toInt(); | 1775 | y = list[1].toInt(); |
1776 | w = list[2].toInt(); | 1776 | w = list[2].toInt(); |
1777 | h = list[3].toInt(); | 1777 | h = list[3].toInt(); |
1778 | topLevelWidget()->setGeometry(x,y,w,h); | 1778 | topLevelWidget()->setGeometry(x,y,w,h); |
1779 | 1779 | ||
1780 | } else { | 1780 | } else { |
1781 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1781 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1782 | } | 1782 | } |
1783 | list = config->readListEntry("EditEventLayout"); | 1783 | list = config->readListEntry("EditEventLayout"); |
1784 | if ( ! list.isEmpty() ) { | 1784 | if ( ! list.isEmpty() ) { |
1785 | x = list[0].toInt(); | 1785 | x = list[0].toInt(); |
1786 | y = list[1].toInt(); | 1786 | y = list[1].toInt(); |
1787 | w = list[2].toInt(); | 1787 | w = list[2].toInt(); |
1788 | h = list[3].toInt(); | 1788 | h = list[3].toInt(); |
1789 | mEventEditor->setGeometry(x,y,w,h); | 1789 | mEventEditor->setGeometry(x,y,w,h); |
1790 | 1790 | ||
1791 | } | 1791 | } |
1792 | list = config->readListEntry("EditTodoLayout"); | 1792 | list = config->readListEntry("EditTodoLayout"); |
1793 | if ( ! list.isEmpty() ) { | 1793 | if ( ! list.isEmpty() ) { |
1794 | x = list[0].toInt(); | 1794 | x = list[0].toInt(); |
1795 | y = list[1].toInt(); | 1795 | y = list[1].toInt(); |
1796 | w = list[2].toInt(); | 1796 | w = list[2].toInt(); |
1797 | h = list[3].toInt(); | 1797 | h = list[3].toInt(); |
1798 | mTodoEditor->setGeometry(x,y,w,h); | 1798 | mTodoEditor->setGeometry(x,y,w,h); |
1799 | 1799 | ||
1800 | } | 1800 | } |
1801 | list = config->readListEntry("ViewerLayout"); | 1801 | list = config->readListEntry("ViewerLayout"); |
1802 | if ( ! list.isEmpty() ) { | 1802 | if ( ! list.isEmpty() ) { |
1803 | x = list[0].toInt(); | 1803 | x = list[0].toInt(); |
1804 | y = list[1].toInt(); | 1804 | y = list[1].toInt(); |
1805 | w = list[2].toInt(); | 1805 | w = list[2].toInt(); |
1806 | h = list[3].toInt(); | 1806 | h = list[3].toInt(); |
1807 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1807 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1808 | } | 1808 | } |
1809 | #endif | 1809 | #endif |
1810 | 1810 | ||
1811 | } | 1811 | } |
1812 | 1812 | ||
1813 | 1813 | ||
1814 | void CalendarView::writeSettings() | 1814 | void CalendarView::writeSettings() |
1815 | { | 1815 | { |
1816 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1816 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1817 | 1817 | ||
1818 | KConfig *config = KOGlobals::config(); | 1818 | KConfig *config = KOGlobals::config(); |
1819 | 1819 | ||
1820 | #ifndef KORG_NOSPLITTER | 1820 | #ifndef KORG_NOSPLITTER |
1821 | config->setGroup("KOrganizer Geometry"); | 1821 | config->setGroup("KOrganizer Geometry"); |
1822 | 1822 | ||
1823 | QValueList<int> list = mPanner->sizes(); | 1823 | QValueList<int> list = mPanner->sizes(); |
1824 | config->writeEntry("Separator1",list); | 1824 | config->writeEntry("Separator1",list); |
1825 | 1825 | ||
1826 | list = mLeftSplitter->sizes(); | 1826 | list = mLeftSplitter->sizes(); |
1827 | config->writeEntry("Separator2",list); | 1827 | config->writeEntry("Separator2",list); |
1828 | #endif | 1828 | #endif |
1829 | 1829 | ||
1830 | mViewManager->writeSettings( config ); | 1830 | mViewManager->writeSettings( config ); |
1831 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1831 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1832 | mDialogManager->writeSettings( config ); | 1832 | mDialogManager->writeSettings( config ); |
1833 | //KOPrefs::instance()->usrWriteConfig(); | 1833 | //KOPrefs::instance()->usrWriteConfig(); |
1834 | KOPrefs::instance()->writeConfig(); | 1834 | KOPrefs::instance()->writeConfig(); |
1835 | 1835 | ||
1836 | writeFilterSettings(config); | 1836 | writeFilterSettings(config); |
1837 | 1837 | ||
1838 | config->setGroup( "Views" ); | 1838 | config->setGroup( "Views" ); |
1839 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1839 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1840 | 1840 | ||
1841 | #ifdef DESKTOP_VERSION | 1841 | #ifdef DESKTOP_VERSION |
1842 | config->setGroup("WidgetLayout"); | 1842 | config->setGroup("WidgetLayout"); |
1843 | QStringList list ;//= config->readListEntry("MainLayout"); | 1843 | QStringList list ;//= config->readListEntry("MainLayout"); |
1844 | int x,y,w,h; | 1844 | int x,y,w,h; |
1845 | QWidget* wid; | 1845 | QWidget* wid; |
1846 | wid = topLevelWidget(); | 1846 | wid = topLevelWidget(); |
1847 | x = wid->geometry().x(); | 1847 | x = wid->geometry().x(); |
1848 | y = wid->geometry().y(); | 1848 | y = wid->geometry().y(); |
1849 | w = wid->width(); | 1849 | w = wid->width(); |
1850 | h = wid->height(); | 1850 | h = wid->height(); |
1851 | list.clear(); | 1851 | list.clear(); |
1852 | list << QString::number( x ); | 1852 | list << QString::number( x ); |
1853 | list << QString::number( y ); | 1853 | list << QString::number( y ); |
1854 | list << QString::number( w ); | 1854 | list << QString::number( w ); |
1855 | list << QString::number( h ); | 1855 | list << QString::number( h ); |
1856 | config->writeEntry("MainLayout",list ); | 1856 | config->writeEntry("MainLayout",list ); |
1857 | 1857 | ||
1858 | wid = mEventEditor; | 1858 | wid = mEventEditor; |
1859 | x = wid->geometry().x(); | 1859 | x = wid->geometry().x(); |
1860 | y = wid->geometry().y(); | 1860 | y = wid->geometry().y(); |
1861 | w = wid->width(); | 1861 | w = wid->width(); |
1862 | h = wid->height(); | 1862 | h = wid->height(); |
1863 | list.clear(); | 1863 | list.clear(); |
1864 | list << QString::number( x ); | 1864 | list << QString::number( x ); |
1865 | list << QString::number( y ); | 1865 | list << QString::number( y ); |
1866 | list << QString::number( w ); | 1866 | list << QString::number( w ); |
1867 | list << QString::number( h ); | 1867 | list << QString::number( h ); |
1868 | config->writeEntry("EditEventLayout",list ); | 1868 | config->writeEntry("EditEventLayout",list ); |
1869 | 1869 | ||
1870 | wid = mTodoEditor; | 1870 | wid = mTodoEditor; |
1871 | x = wid->geometry().x(); | 1871 | x = wid->geometry().x(); |
1872 | y = wid->geometry().y(); | 1872 | y = wid->geometry().y(); |
1873 | w = wid->width(); | 1873 | w = wid->width(); |
1874 | h = wid->height(); | 1874 | h = wid->height(); |
1875 | list.clear(); | 1875 | list.clear(); |
1876 | list << QString::number( x ); | 1876 | list << QString::number( x ); |
1877 | list << QString::number( y ); | 1877 | list << QString::number( y ); |
1878 | list << QString::number( w ); | 1878 | list << QString::number( w ); |
1879 | list << QString::number( h ); | 1879 | list << QString::number( h ); |
1880 | config->writeEntry("EditTodoLayout",list ); | 1880 | config->writeEntry("EditTodoLayout",list ); |
1881 | wid = getEventViewerDialog(); | 1881 | wid = getEventViewerDialog(); |
1882 | x = wid->geometry().x(); | 1882 | x = wid->geometry().x(); |
1883 | y = wid->geometry().y(); | 1883 | y = wid->geometry().y(); |
1884 | w = wid->width(); | 1884 | w = wid->width(); |
1885 | h = wid->height(); | 1885 | h = wid->height(); |
1886 | list.clear(); | 1886 | list.clear(); |
1887 | list << QString::number( x ); | 1887 | list << QString::number( x ); |
1888 | list << QString::number( y ); | 1888 | list << QString::number( y ); |
1889 | list << QString::number( w ); | 1889 | list << QString::number( w ); |
1890 | list << QString::number( h ); | 1890 | list << QString::number( h ); |
1891 | config->writeEntry("ViewerLayout",list ); | 1891 | config->writeEntry("ViewerLayout",list ); |
1892 | wid = mDialogManager->getSearchDialog(); | 1892 | wid = mDialogManager->getSearchDialog(); |
1893 | if ( wid ) { | 1893 | if ( wid ) { |
1894 | x = wid->geometry().x(); | 1894 | x = wid->geometry().x(); |
1895 | y = wid->geometry().y(); | 1895 | y = wid->geometry().y(); |
1896 | w = wid->width(); | 1896 | w = wid->width(); |
1897 | h = wid->height(); | 1897 | h = wid->height(); |
1898 | list.clear(); | 1898 | list.clear(); |
1899 | list << QString::number( x ); | 1899 | list << QString::number( x ); |
1900 | list << QString::number( y ); | 1900 | list << QString::number( y ); |
1901 | list << QString::number( w ); | 1901 | list << QString::number( w ); |
1902 | list << QString::number( h ); | 1902 | list << QString::number( h ); |
1903 | config->writeEntry("SearchLayout",list ); | 1903 | config->writeEntry("SearchLayout",list ); |
1904 | } | 1904 | } |
1905 | #endif | 1905 | #endif |
1906 | 1906 | ||
1907 | 1907 | ||
1908 | config->sync(); | 1908 | config->sync(); |
1909 | } | 1909 | } |
1910 | 1910 | ||
1911 | void CalendarView::readFilterSettings(KConfig *config) | 1911 | void CalendarView::readFilterSettings(KConfig *config) |
1912 | { | 1912 | { |
1913 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1913 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1914 | 1914 | ||
1915 | mFilters.clear(); | 1915 | mFilters.clear(); |
1916 | 1916 | ||
1917 | config->setGroup("General"); | 1917 | config->setGroup("General"); |
1918 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1918 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1919 | 1919 | ||
1920 | QStringList::ConstIterator it = filterList.begin(); | 1920 | QStringList::ConstIterator it = filterList.begin(); |
1921 | QStringList::ConstIterator end = filterList.end(); | 1921 | QStringList::ConstIterator end = filterList.end(); |
1922 | while(it != end) { | 1922 | while(it != end) { |
1923 | // kdDebug() << " filter: " << (*it) << endl; | 1923 | // kdDebug() << " filter: " << (*it) << endl; |
1924 | 1924 | ||
1925 | CalFilter *filter; | 1925 | CalFilter *filter; |
1926 | filter = new CalFilter(*it); | 1926 | filter = new CalFilter(*it); |
1927 | config->setGroup("Filter_" + (*it)); | 1927 | config->setGroup("Filter_" + (*it)); |
1928 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1928 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1929 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1929 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1930 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1930 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1931 | mFilters.append(filter); | 1931 | mFilters.append(filter); |
1932 | 1932 | ||
1933 | ++it; | 1933 | ++it; |
1934 | } | 1934 | } |
1935 | 1935 | ||
1936 | if (mFilters.count() == 0) { | 1936 | if (mFilters.count() == 0) { |
1937 | CalFilter *filter = new CalFilter(i18n("Default")); | 1937 | CalFilter *filter = new CalFilter(i18n("Default")); |
1938 | mFilters.append(filter); | 1938 | mFilters.append(filter); |
1939 | } | 1939 | } |
1940 | mFilterView->updateFilters(); | 1940 | mFilterView->updateFilters(); |
1941 | config->setGroup("FilterView"); | 1941 | config->setGroup("FilterView"); |
1942 | 1942 | ||
1943 | mFilterView->blockSignals(true); | 1943 | mFilterView->blockSignals(true); |
1944 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1944 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1945 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1945 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1946 | mFilterView->blockSignals(false); | 1946 | mFilterView->blockSignals(false); |
1947 | // We do it manually to avoid it being done twice by the above calls | 1947 | // We do it manually to avoid it being done twice by the above calls |
1948 | updateFilter(); | 1948 | updateFilter(); |
1949 | } | 1949 | } |
1950 | 1950 | ||
1951 | void CalendarView::writeFilterSettings(KConfig *config) | 1951 | void CalendarView::writeFilterSettings(KConfig *config) |
1952 | { | 1952 | { |
1953 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1953 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1954 | 1954 | ||
1955 | QStringList filterList; | 1955 | QStringList filterList; |
1956 | 1956 | ||
1957 | CalFilter *filter = mFilters.first(); | 1957 | CalFilter *filter = mFilters.first(); |
1958 | while(filter) { | 1958 | while(filter) { |
1959 | // kdDebug() << " fn: " << filter->name() << endl; | 1959 | // kdDebug() << " fn: " << filter->name() << endl; |
1960 | filterList << filter->name(); | 1960 | filterList << filter->name(); |
1961 | config->setGroup("Filter_" + filter->name()); | 1961 | config->setGroup("Filter_" + filter->name()); |
1962 | config->writeEntry("Criteria",filter->criteria()); | 1962 | config->writeEntry("Criteria",filter->criteria()); |
1963 | config->writeEntry("CategoryList",filter->categoryList()); | 1963 | config->writeEntry("CategoryList",filter->categoryList()); |
1964 | filter = mFilters.next(); | 1964 | filter = mFilters.next(); |
1965 | } | 1965 | } |
1966 | config->setGroup("General"); | 1966 | config->setGroup("General"); |
1967 | config->writeEntry("CalendarFilters",filterList); | 1967 | config->writeEntry("CalendarFilters",filterList); |
1968 | 1968 | ||
1969 | config->setGroup("FilterView"); | 1969 | config->setGroup("FilterView"); |
1970 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1970 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1971 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1971 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | 1974 | ||
1975 | void CalendarView::goToday() | 1975 | void CalendarView::goToday() |
1976 | { | 1976 | { |
1977 | mNavigator->selectToday(); | 1977 | mNavigator->selectToday(); |
1978 | } | 1978 | } |
1979 | 1979 | ||
1980 | void CalendarView::goNext() | 1980 | void CalendarView::goNext() |
1981 | { | 1981 | { |
1982 | mNavigator->selectNext(); | 1982 | mNavigator->selectNext(); |
1983 | } | 1983 | } |
1984 | 1984 | ||
1985 | void CalendarView::goPrevious() | 1985 | void CalendarView::goPrevious() |
1986 | { | 1986 | { |
1987 | mNavigator->selectPrevious(); | 1987 | mNavigator->selectPrevious(); |
1988 | } | 1988 | } |
1989 | void CalendarView::goNextMonth() | 1989 | void CalendarView::goNextMonth() |
1990 | { | 1990 | { |
1991 | mNavigator->selectNextMonth(); | 1991 | mNavigator->selectNextMonth(); |
1992 | } | 1992 | } |
1993 | 1993 | ||
1994 | void CalendarView::goPreviousMonth() | 1994 | void CalendarView::goPreviousMonth() |
1995 | { | 1995 | { |
1996 | mNavigator->selectPreviousMonth(); | 1996 | mNavigator->selectPreviousMonth(); |
1997 | } | 1997 | } |
1998 | void CalendarView::writeLocale() | 1998 | void CalendarView::writeLocale() |
1999 | { | 1999 | { |
2000 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2000 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2001 | #if 0 | 2001 | #if 0 |
2002 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2002 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2003 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2003 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2004 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2004 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2005 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2005 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2006 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2006 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2007 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2007 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2008 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2008 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2009 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2009 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2010 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2010 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2011 | KOPrefs::instance()->mDaylightsavingStart, | 2011 | KOPrefs::instance()->mDaylightsavingStart, |
2012 | KOPrefs::instance()->mDaylightsavingEnd ); | 2012 | KOPrefs::instance()->mDaylightsavingEnd ); |
2013 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2013 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2014 | #endif | 2014 | #endif |
2015 | } | 2015 | } |
2016 | void CalendarView::updateConfig() | 2016 | void CalendarView::updateConfig() |
2017 | { | 2017 | { |
2018 | writeLocale(); | 2018 | writeLocale(); |
2019 | if ( KOPrefs::instance()->mUseAppColors ) | 2019 | if ( KOPrefs::instance()->mUseAppColors ) |
2020 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2020 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2021 | emit configChanged(); | 2021 | emit configChanged(); |
2022 | mTodoList->updateConfig(); | 2022 | mTodoList->updateConfig(); |
2023 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2023 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2024 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2024 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2025 | // To make the "fill window" configurations work | 2025 | // To make the "fill window" configurations work |
2026 | //mViewManager->raiseCurrentView(); | 2026 | //mViewManager->raiseCurrentView(); |
2027 | } | 2027 | } |
2028 | 2028 | ||
2029 | 2029 | ||
2030 | void CalendarView::eventChanged(Event *event) | 2030 | void CalendarView::eventChanged(Event *event) |
2031 | { | 2031 | { |
2032 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2032 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2033 | //updateUnmanagedViews(); | 2033 | //updateUnmanagedViews(); |
2034 | } | 2034 | } |
2035 | 2035 | ||
2036 | void CalendarView::eventAdded(Event *event) | 2036 | void CalendarView::eventAdded(Event *event) |
2037 | { | 2037 | { |
2038 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2038 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2039 | } | 2039 | } |
2040 | 2040 | ||
2041 | void CalendarView::eventToBeDeleted(Event *) | 2041 | void CalendarView::eventToBeDeleted(Event *) |
2042 | { | 2042 | { |
2043 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2043 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2044 | } | 2044 | } |
2045 | 2045 | ||
2046 | void CalendarView::eventDeleted() | 2046 | void CalendarView::eventDeleted() |
2047 | { | 2047 | { |
2048 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2048 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2049 | } | 2049 | } |
2050 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2050 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2051 | { | 2051 | { |
2052 | changeIncidenceDisplay((Incidence *)which, action); | 2052 | changeIncidenceDisplay((Incidence *)which, action); |
2053 | mDateNavigator->updateView(); //LR | 2053 | mDateNavigator->updateView(); //LR |
2054 | //mDialogManager->updateSearchDialog(); | 2054 | //mDialogManager->updateSearchDialog(); |
2055 | 2055 | ||
2056 | if (which) { | 2056 | if (which) { |
2057 | mViewManager->updateWNview(); | 2057 | mViewManager->updateWNview(); |
2058 | //mTodoList->updateView(); | 2058 | //mTodoList->updateView(); |
2059 | } | 2059 | } |
2060 | 2060 | ||
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2063 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2064 | { | 2064 | { |
2065 | updateUnmanagedViews(); | 2065 | updateUnmanagedViews(); |
2066 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2066 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2067 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2067 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2068 | mCalendar->checkAlarmForIncidence( 0, true ); | 2068 | mCalendar->checkAlarmForIncidence( 0, true ); |
2069 | if ( mEventViewerDialog ) | 2069 | if ( mEventViewerDialog ) |
2070 | mEventViewerDialog->hide(); | 2070 | mEventViewerDialog->hide(); |
2071 | } | 2071 | } |
2072 | else | 2072 | else |
2073 | mCalendar->checkAlarmForIncidence( which , false ); | 2073 | mCalendar->checkAlarmForIncidence( which , false ); |
2074 | } | 2074 | } |
2075 | 2075 | ||
2076 | // most of the changeEventDisplays() right now just call the view's | 2076 | // most of the changeEventDisplays() right now just call the view's |
2077 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2077 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2078 | void CalendarView::changeEventDisplay(Event *which, int action) | 2078 | void CalendarView::changeEventDisplay(Event *which, int action) |
2079 | { | 2079 | { |
2080 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2080 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2081 | changeIncidenceDisplay((Incidence *)which, action); | 2081 | changeIncidenceDisplay((Incidence *)which, action); |
2082 | mDateNavigator->updateView(); | 2082 | mDateNavigator->updateView(); |
2083 | //mDialogManager->updateSearchDialog(); | 2083 | //mDialogManager->updateSearchDialog(); |
2084 | 2084 | ||
2085 | if (which) { | 2085 | if (which) { |
2086 | // If there is an event view visible update the display | 2086 | // If there is an event view visible update the display |
2087 | mViewManager->currentView()->changeEventDisplay(which,action); | 2087 | mViewManager->currentView()->changeEventDisplay(which,action); |
2088 | // TODO: check, if update needed | 2088 | // TODO: check, if update needed |
2089 | // if (which->getTodoStatus()) { | 2089 | // if (which->getTodoStatus()) { |
2090 | mTodoList->updateView(); | 2090 | mTodoList->updateView(); |
2091 | // } | 2091 | // } |
2092 | } else { | 2092 | } else { |
2093 | mViewManager->currentView()->updateView(); | 2093 | mViewManager->currentView()->updateView(); |
2094 | } | 2094 | } |
2095 | } | 2095 | } |
2096 | 2096 | ||
2097 | 2097 | ||
2098 | void CalendarView::updateTodoViews() | 2098 | void CalendarView::updateTodoViews() |
2099 | { | 2099 | { |
2100 | 2100 | ||
2101 | mTodoList->updateView(); | 2101 | mTodoList->updateView(); |
2102 | mViewManager->currentView()->updateView(); | 2102 | mViewManager->currentView()->updateView(); |
2103 | 2103 | ||
2104 | } | 2104 | } |
2105 | 2105 | ||
2106 | 2106 | ||
2107 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2107 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2108 | { | 2108 | { |
2109 | mTodoList->updateView(); | 2109 | mTodoList->updateView(); |
2110 | mViewManager->updateView(start, end); | 2110 | mViewManager->updateView(start, end); |
2111 | //mDateNavigator->updateView(); | 2111 | //mDateNavigator->updateView(); |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | void CalendarView::updateView() | 2114 | void CalendarView::updateView() |
2115 | { | 2115 | { |
2116 | DateList tmpList = mNavigator->selectedDates(); | 2116 | DateList tmpList = mNavigator->selectedDates(); |
2117 | 2117 | ||
2118 | // We assume that the navigator only selects consecutive days. | 2118 | // We assume that the navigator only selects consecutive days. |
2119 | updateView( tmpList.first(), tmpList.last() ); | 2119 | updateView( tmpList.first(), tmpList.last() ); |
2120 | } | 2120 | } |
2121 | 2121 | ||
2122 | void CalendarView::updateUnmanagedViews() | 2122 | void CalendarView::updateUnmanagedViews() |
2123 | { | 2123 | { |
2124 | mDateNavigator->updateDayMatrix(); | 2124 | mDateNavigator->updateDayMatrix(); |
2125 | } | 2125 | } |
2126 | 2126 | ||
2127 | int CalendarView::msgItemDelete() | 2127 | int CalendarView::msgItemDelete() |
2128 | { | 2128 | { |
2129 | return KMessageBox::warningContinueCancel(this, | 2129 | return KMessageBox::warningContinueCancel(this, |
2130 | i18n("This item will be\npermanently deleted."), | 2130 | i18n("This item will be\npermanently deleted."), |
2131 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2131 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2132 | } | 2132 | } |
2133 | 2133 | ||
2134 | 2134 | ||
2135 | void CalendarView::edit_cut() | 2135 | void CalendarView::edit_cut() |
2136 | { | 2136 | { |
2137 | Event *anEvent=0; | 2137 | Event *anEvent=0; |
2138 | 2138 | ||
2139 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2139 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2140 | 2140 | ||
2141 | if (mViewManager->currentView()->isEventView()) { | 2141 | if (mViewManager->currentView()->isEventView()) { |
2142 | if ( incidence && incidence->type() == "Event" ) { | 2142 | if ( incidence && incidence->type() == "Event" ) { |
2143 | anEvent = static_cast<Event *>(incidence); | 2143 | anEvent = static_cast<Event *>(incidence); |
2144 | } | 2144 | } |
2145 | } | 2145 | } |
2146 | 2146 | ||
2147 | if (!anEvent) { | 2147 | if (!anEvent) { |
2148 | KNotifyClient::beep(); | 2148 | KNotifyClient::beep(); |
2149 | return; | 2149 | return; |
2150 | } | 2150 | } |
2151 | DndFactory factory( mCalendar ); | 2151 | DndFactory factory( mCalendar ); |
2152 | factory.cutEvent(anEvent); | 2152 | factory.cutEvent(anEvent); |
2153 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2153 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2154 | } | 2154 | } |
2155 | 2155 | ||
2156 | void CalendarView::edit_copy() | 2156 | void CalendarView::edit_copy() |
2157 | { | 2157 | { |
2158 | Event *anEvent=0; | 2158 | Event *anEvent=0; |
2159 | 2159 | ||
2160 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2160 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2161 | 2161 | ||
2162 | if (mViewManager->currentView()->isEventView()) { | 2162 | if (mViewManager->currentView()->isEventView()) { |
2163 | if ( incidence && incidence->type() == "Event" ) { | 2163 | if ( incidence && incidence->type() == "Event" ) { |
2164 | anEvent = static_cast<Event *>(incidence); | 2164 | anEvent = static_cast<Event *>(incidence); |
2165 | } | 2165 | } |
2166 | } | 2166 | } |
2167 | 2167 | ||
2168 | if (!anEvent) { | 2168 | if (!anEvent) { |
2169 | KNotifyClient::beep(); | 2169 | KNotifyClient::beep(); |
2170 | return; | 2170 | return; |
2171 | } | 2171 | } |
2172 | DndFactory factory( mCalendar ); | 2172 | DndFactory factory( mCalendar ); |
2173 | factory.copyEvent(anEvent); | 2173 | factory.copyEvent(anEvent); |
2174 | } | 2174 | } |
2175 | 2175 | ||
2176 | void CalendarView::edit_paste() | 2176 | void CalendarView::edit_paste() |
2177 | { | 2177 | { |
2178 | QDate date = mNavigator->selectedDates().first(); | 2178 | QDate date = mNavigator->selectedDates().first(); |
2179 | 2179 | ||
2180 | DndFactory factory( mCalendar ); | 2180 | DndFactory factory( mCalendar ); |
2181 | Event *pastedEvent = factory.pasteEvent( date ); | 2181 | Event *pastedEvent = factory.pasteEvent( date ); |
2182 | 2182 | ||
2183 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2183 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2184 | } | 2184 | } |
2185 | 2185 | ||
2186 | void CalendarView::edit_options() | 2186 | void CalendarView::edit_options() |
2187 | { | 2187 | { |
2188 | mDialogManager->showOptionsDialog(); | 2188 | mDialogManager->showOptionsDialog(); |
2189 | //writeSettings(); | 2189 | //writeSettings(); |
2190 | } | 2190 | } |
2191 | 2191 | ||
2192 | void CalendarView::slotSelectPickerDate( QDate d) | 2192 | void CalendarView::slotSelectPickerDate( QDate d) |
2193 | { | 2193 | { |
2194 | mDateFrame->hide(); | 2194 | mDateFrame->hide(); |
2195 | if ( mDatePickerMode == 1 ) { | 2195 | if ( mDatePickerMode == 1 ) { |
2196 | mNavigator->slotDaySelect( d ); | 2196 | mNavigator->slotDaySelect( d ); |
2197 | } else if ( mDatePickerMode == 2 ) { | 2197 | } else if ( mDatePickerMode == 2 ) { |
2198 | if ( mMoveIncidence->type() == "Todo" ) { | 2198 | if ( mMoveIncidence->type() == "Todo" ) { |
2199 | Todo * to = (Todo *) mMoveIncidence; | 2199 | Todo * to = (Todo *) mMoveIncidence; |
2200 | QTime tim; | 2200 | QTime tim; |
2201 | if ( to->hasDueDate() ) | 2201 | if ( to->hasDueDate() ) |
2202 | tim = to->dtDue().time(); | 2202 | tim = to->dtDue().time(); |
2203 | else { | 2203 | else { |
2204 | tim = QTime ( 0,0,0 ); | 2204 | tim = QTime ( 0,0,0 ); |
2205 | to->setFloats( true ); | 2205 | to->setFloats( true ); |
2206 | to->setHasDueDate( true ); | 2206 | to->setHasDueDate( true ); |
2207 | } | 2207 | } |
2208 | QDateTime dt ( d,tim ); | 2208 | QDateTime dt ( d,tim ); |
2209 | to->setDtDue( dt ); | 2209 | to->setDtDue( dt ); |
2210 | todoChanged( to ); | 2210 | todoChanged( to ); |
2211 | } else { | 2211 | } else { |
2212 | QTime tim = mMoveIncidence->dtStart().time(); | 2212 | QTime tim = mMoveIncidence->dtStart().time(); |
2213 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2213 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2214 | QDateTime dt ( d,tim ); | 2214 | QDateTime dt ( d,tim ); |
2215 | mMoveIncidence->setDtStart( dt ); | 2215 | mMoveIncidence->setDtStart( dt ); |
2216 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2216 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2217 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2217 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2220 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2221 | } | 2221 | } |
2222 | } | 2222 | } |
2223 | 2223 | ||
2224 | void CalendarView::removeCategories() | 2224 | void CalendarView::removeCategories() |
2225 | { | 2225 | { |
2226 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2226 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2227 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2227 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2228 | QStringList catIncList; | 2228 | QStringList catIncList; |
2229 | QStringList newCatList; | 2229 | QStringList newCatList; |
2230 | Incidence* inc = incList.first(); | 2230 | Incidence* inc = incList.first(); |
2231 | int i; | 2231 | int i; |
2232 | int count = 0; | 2232 | int count = 0; |
2233 | while ( inc ) { | 2233 | while ( inc ) { |
2234 | newCatList.clear(); | 2234 | newCatList.clear(); |
2235 | catIncList = inc->categories() ; | 2235 | catIncList = inc->categories() ; |
2236 | for( i = 0; i< catIncList.count(); ++i ) { | 2236 | for( i = 0; i< catIncList.count(); ++i ) { |
2237 | if ( catList.contains (catIncList[i])) | 2237 | if ( catList.contains (catIncList[i])) |
2238 | newCatList.append( catIncList[i] ); | 2238 | newCatList.append( catIncList[i] ); |
2239 | } | 2239 | } |
2240 | newCatList.sort(); | 2240 | newCatList.sort(); |
2241 | inc->setCategories( newCatList.join(",") ); | 2241 | inc->setCategories( newCatList.join(",") ); |
2242 | inc = incList.next(); | 2242 | inc = incList.next(); |
2243 | } | 2243 | } |
2244 | } | 2244 | } |
2245 | 2245 | ||
2246 | int CalendarView::addCategories() | 2246 | int CalendarView::addCategories() |
2247 | { | 2247 | { |
2248 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2248 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2249 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2249 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2250 | QStringList catIncList; | 2250 | QStringList catIncList; |
2251 | Incidence* inc = incList.first(); | 2251 | Incidence* inc = incList.first(); |
2252 | int i; | 2252 | int i; |
2253 | int count = 0; | 2253 | int count = 0; |
2254 | while ( inc ) { | 2254 | while ( inc ) { |
2255 | catIncList = inc->categories() ; | 2255 | catIncList = inc->categories() ; |
2256 | for( i = 0; i< catIncList.count(); ++i ) { | 2256 | for( i = 0; i< catIncList.count(); ++i ) { |
2257 | if ( !catList.contains (catIncList[i])) { | 2257 | if ( !catList.contains (catIncList[i])) { |
2258 | catList.append( catIncList[i] ); | 2258 | catList.append( catIncList[i] ); |
2259 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2259 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2260 | ++count; | 2260 | ++count; |
2261 | } | 2261 | } |
2262 | } | 2262 | } |
2263 | inc = incList.next(); | 2263 | inc = incList.next(); |
2264 | } | 2264 | } |
2265 | catList.sort(); | 2265 | catList.sort(); |
2266 | KOPrefs::instance()->mCustomCategories = catList; | 2266 | KOPrefs::instance()->mCustomCategories = catList; |
2267 | return count; | 2267 | return count; |
2268 | } | 2268 | } |
2269 | 2269 | ||
2270 | void CalendarView::manageCategories() | 2270 | void CalendarView::manageCategories() |
2271 | { | 2271 | { |
2272 | KOCatPrefs* cp = new KOCatPrefs(); | 2272 | KOCatPrefs* cp = new KOCatPrefs(); |
2273 | cp->show(); | 2273 | cp->show(); |
2274 | int w =cp->sizeHint().width() ; | 2274 | int w =cp->sizeHint().width() ; |
2275 | int h = cp->sizeHint().height() ; | 2275 | int h = cp->sizeHint().height() ; |
2276 | int dw = QApplication::desktop()->width(); | 2276 | int dw = QApplication::desktop()->width(); |
2277 | int dh = QApplication::desktop()->height(); | 2277 | int dh = QApplication::desktop()->height(); |
2278 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2278 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2279 | if ( !cp->exec() ) { | 2279 | if ( !cp->exec() ) { |
2280 | delete cp; | 2280 | delete cp; |
2281 | return; | 2281 | return; |
2282 | } | 2282 | } |
2283 | int count = 0; | 2283 | int count = 0; |
2284 | if ( cp->addCat() ) { | 2284 | if ( cp->addCat() ) { |
2285 | count = addCategories(); | 2285 | count = addCategories(); |
2286 | if ( count ) { | 2286 | if ( count ) { |
2287 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2287 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2288 | writeSettings(); | 2288 | writeSettings(); |
2289 | } | 2289 | } |
2290 | } else { | 2290 | } else { |
2291 | removeCategories(); | 2291 | removeCategories(); |
2292 | updateView(); | 2292 | updateView(); |
2293 | } | 2293 | } |
2294 | delete cp; | 2294 | delete cp; |
2295 | } | 2295 | } |
2296 | 2296 | ||
2297 | void CalendarView::beamIncidence(Incidence * Inc) | 2297 | void CalendarView::beamIncidence(Incidence * Inc) |
2298 | { | 2298 | { |
2299 | QPtrList<Incidence> delSel ; | 2299 | QPtrList<Incidence> delSel ; |
2300 | delSel.append(Inc); | 2300 | delSel.append(Inc); |
2301 | beamIncidenceList( delSel ); | 2301 | beamIncidenceList( delSel ); |
2302 | } | 2302 | } |
2303 | void CalendarView::beamCalendar() | 2303 | void CalendarView::beamCalendar() |
2304 | { | 2304 | { |
2305 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2305 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2306 | //qDebug("beamCalendar() "); | 2306 | //qDebug("beamCalendar() "); |
2307 | beamIncidenceList( delSel ); | 2307 | beamIncidenceList( delSel ); |
2308 | } | 2308 | } |
2309 | void CalendarView::beamFilteredCalendar() | 2309 | void CalendarView::beamFilteredCalendar() |
2310 | { | 2310 | { |
2311 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2311 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2312 | //qDebug("beamFilteredCalendar() "); | 2312 | //qDebug("beamFilteredCalendar() "); |
2313 | beamIncidenceList( delSel ); | 2313 | beamIncidenceList( delSel ); |
2314 | } | 2314 | } |
2315 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2315 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2316 | { | 2316 | { |
2317 | if ( beamDialog->exec () == QDialog::Rejected ) | 2317 | if ( beamDialog->exec () == QDialog::Rejected ) |
2318 | return; | 2318 | return; |
2319 | #ifdef DESKTOP_VERSION | 2319 | #ifdef DESKTOP_VERSION |
2320 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2320 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2321 | #else | 2321 | #else |
2322 | QString fn = "/tmp/kopibeamfile"; | 2322 | QString fn = "/tmp/kopibeamfile"; |
2323 | #endif | 2323 | #endif |
2324 | QString mes; | 2324 | QString mes; |
2325 | bool createbup = true; | 2325 | bool createbup = true; |
2326 | if ( createbup ) { | 2326 | if ( createbup ) { |
2327 | QString description = "\n"; | 2327 | QString description = "\n"; |
2328 | CalendarLocal* cal = new CalendarLocal(); | 2328 | CalendarLocal* cal = new CalendarLocal(); |
2329 | if ( beamDialog->beamLocal() ) | 2329 | if ( beamDialog->beamLocal() ) |
2330 | cal->setLocalTime(); | 2330 | cal->setLocalTime(); |
2331 | else | 2331 | else |
2332 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2332 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2333 | Incidence *incidence = delSel.first(); | 2333 | Incidence *incidence = delSel.first(); |
2334 | bool addText = false; | 2334 | bool addText = false; |
2335 | if ( delSel.count() < 10 ) | 2335 | if ( delSel.count() < 10 ) |
2336 | addText = true; | 2336 | addText = true; |
2337 | else { | 2337 | else { |
2338 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2338 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2339 | } | 2339 | } |
2340 | while ( incidence ) { | 2340 | while ( incidence ) { |
2341 | Incidence *in = incidence->clone(); | 2341 | Incidence *in = incidence->clone(); |
2342 | if ( ! in->summary().isEmpty() ) { | 2342 | if ( ! in->summary().isEmpty() ) { |
2343 | in->setDescription(""); | 2343 | in->setDescription(""); |
2344 | } else { | 2344 | } else { |
2345 | in->setSummary( in->description().left(20)); | 2345 | in->setSummary( in->description().left(20)); |
2346 | in->setDescription(""); | 2346 | in->setDescription(""); |
2347 | } | 2347 | } |
2348 | if ( addText ) | 2348 | if ( addText ) |
2349 | description += in->summary() + "\n"; | 2349 | description += in->summary() + "\n"; |
2350 | cal->addIncidence( in ); | 2350 | cal->addIncidence( in ); |
2351 | incidence = delSel.next(); | 2351 | incidence = delSel.next(); |
2352 | } | 2352 | } |
2353 | if ( beamDialog->beamVcal() ) { | 2353 | if ( beamDialog->beamVcal() ) { |
2354 | fn += ".vcs"; | 2354 | fn += ".vcs"; |
2355 | FileStorage storage( cal, fn, new VCalFormat ); | 2355 | FileStorage storage( cal, fn, new VCalFormat ); |
2356 | storage.save(); | 2356 | storage.save(); |
2357 | } else { | 2357 | } else { |
2358 | fn += ".ics"; | 2358 | fn += ".ics"; |
2359 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2359 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2360 | storage.save(); | 2360 | storage.save(); |
2361 | } | 2361 | } |
2362 | delete cal; | 2362 | delete cal; |
2363 | mes = i18n("KO/Pi: Ready for beaming"); | 2363 | mes = i18n("KO/Pi: Ready for beaming"); |
2364 | topLevelWidget()->setCaption(mes); | 2364 | topLevelWidget()->setCaption(mes); |
2365 | KApplication::convert2latin1( fn ); | 2365 | KApplication::convert2latin1( fn ); |
2366 | #ifndef DESKTOP_VERSION | 2366 | #ifndef DESKTOP_VERSION |
2367 | Ir *ir = new Ir( this ); | 2367 | Ir *ir = new Ir( this ); |
2368 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2368 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2369 | ir->send( fn, description, "text/x-vCalendar" ); | 2369 | ir->send( fn, description, "text/x-vCalendar" ); |
2370 | #endif | 2370 | #endif |
2371 | } | 2371 | } |
2372 | } | 2372 | } |
2373 | void CalendarView::beamDone( Ir *ir ) | 2373 | void CalendarView::beamDone( Ir *ir ) |
2374 | { | 2374 | { |
2375 | #ifndef DESKTOP_VERSION | 2375 | #ifndef DESKTOP_VERSION |
2376 | delete ir; | 2376 | delete ir; |
2377 | #endif | 2377 | #endif |
2378 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2378 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2379 | topLevelWidget()->raise(); | 2379 | topLevelWidget()->raise(); |
2380 | } | 2380 | } |
2381 | 2381 | ||
2382 | void CalendarView::moveIncidence(Incidence * inc ) | 2382 | void CalendarView::moveIncidence(Incidence * inc ) |
2383 | { | 2383 | { |
2384 | if ( !inc ) return; | 2384 | if ( !inc ) return; |
2385 | // qDebug("showDatePickerForIncidence( ) "); | 2385 | // qDebug("showDatePickerForIncidence( ) "); |
2386 | if ( mDateFrame->isVisible() ) | 2386 | if ( mDateFrame->isVisible() ) |
2387 | mDateFrame->hide(); | 2387 | mDateFrame->hide(); |
2388 | else { | 2388 | else { |
2389 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2389 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2390 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2390 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2391 | int dw = QApplication::desktop()->width(); | 2391 | int dw = QApplication::desktop()->width(); |
2392 | int dh = QApplication::desktop()->height(); | 2392 | int dh = QApplication::desktop()->height(); |
2393 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2393 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2394 | mDateFrame->show(); | 2394 | mDateFrame->show(); |
2395 | } | 2395 | } |
2396 | mDatePickerMode = 2; | 2396 | mDatePickerMode = 2; |
2397 | mMoveIncidence = inc ; | 2397 | mMoveIncidence = inc ; |
2398 | QDate da; | 2398 | QDate da; |
2399 | if ( mMoveIncidence->type() == "Todo" ) { | 2399 | if ( mMoveIncidence->type() == "Todo" ) { |
2400 | Todo * to = (Todo *) mMoveIncidence; | 2400 | Todo * to = (Todo *) mMoveIncidence; |
2401 | if ( to->hasDueDate() ) | 2401 | if ( to->hasDueDate() ) |
2402 | da = to->dtDue().date(); | 2402 | da = to->dtDue().date(); |
2403 | else | 2403 | else |
2404 | da = QDate::currentDate(); | 2404 | da = QDate::currentDate(); |
2405 | } else { | 2405 | } else { |
2406 | da = mMoveIncidence->dtStart().date(); | 2406 | da = mMoveIncidence->dtStart().date(); |
2407 | } | 2407 | } |
2408 | mDatePicker->setDate( da ); | 2408 | mDatePicker->setDate( da ); |
2409 | } | 2409 | } |
2410 | void CalendarView::showDatePicker( ) | 2410 | void CalendarView::showDatePicker( ) |
2411 | { | 2411 | { |
2412 | //qDebug("CalendarView::showDatePicker( ) "); | 2412 | //qDebug("CalendarView::showDatePicker( ) "); |
2413 | if ( mDateFrame->isVisible() ) | 2413 | if ( mDateFrame->isVisible() ) |
2414 | mDateFrame->hide(); | 2414 | mDateFrame->hide(); |
2415 | else { | 2415 | else { |
2416 | int w =mDatePicker->sizeHint().width() ; | 2416 | int w =mDatePicker->sizeHint().width() ; |
2417 | int h = mDatePicker->sizeHint().height() ; | 2417 | int h = mDatePicker->sizeHint().height() ; |
2418 | int dw = QApplication::desktop()->width(); | 2418 | int dw = QApplication::desktop()->width(); |
2419 | int dh = QApplication::desktop()->height(); | 2419 | int dh = QApplication::desktop()->height(); |
2420 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2420 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2421 | mDateFrame->show(); | 2421 | mDateFrame->show(); |
2422 | } | 2422 | } |
2423 | mDatePickerMode = 1; | 2423 | mDatePickerMode = 1; |
2424 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2424 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2425 | } | 2425 | } |
2426 | 2426 | ||
2427 | void CalendarView::showEventEditor() | 2427 | void CalendarView::showEventEditor() |
2428 | { | 2428 | { |
2429 | #ifdef DESKTOP_VERSION | 2429 | #ifdef DESKTOP_VERSION |
2430 | mEventEditor->show(); | 2430 | mEventEditor->show(); |
2431 | #else | 2431 | #else |
2432 | mEventEditor->showMaximized(); | 2432 | mEventEditor->showMaximized(); |
2433 | #endif | 2433 | #endif |
2434 | } | 2434 | } |
2435 | void CalendarView::showTodoEditor() | 2435 | void CalendarView::showTodoEditor() |
2436 | { | 2436 | { |
2437 | #ifdef DESKTOP_VERSION | 2437 | #ifdef DESKTOP_VERSION |
2438 | mTodoEditor->show(); | 2438 | mTodoEditor->show(); |
2439 | #else | 2439 | #else |
2440 | mTodoEditor->showMaximized(); | 2440 | mTodoEditor->showMaximized(); |
2441 | #endif | 2441 | #endif |
2442 | } | 2442 | } |
2443 | 2443 | ||
2444 | void CalendarView::cloneIncidence() | 2444 | void CalendarView::cloneIncidence() |
2445 | { | 2445 | { |
2446 | Incidence *incidence = currentSelection(); | 2446 | Incidence *incidence = currentSelection(); |
2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2448 | if ( incidence ) { | 2448 | if ( incidence ) { |
2449 | cloneIncidence(incidence); | 2449 | cloneIncidence(incidence); |
2450 | } | 2450 | } |
2451 | } | 2451 | } |
2452 | void CalendarView::moveIncidence() | 2452 | void CalendarView::moveIncidence() |
2453 | { | 2453 | { |
2454 | Incidence *incidence = currentSelection(); | 2454 | Incidence *incidence = currentSelection(); |
2455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2456 | if ( incidence ) { | 2456 | if ( incidence ) { |
2457 | moveIncidence(incidence); | 2457 | moveIncidence(incidence); |
2458 | } | 2458 | } |
2459 | } | 2459 | } |
2460 | void CalendarView::beamIncidence() | 2460 | void CalendarView::beamIncidence() |
2461 | { | 2461 | { |
2462 | Incidence *incidence = currentSelection(); | 2462 | Incidence *incidence = currentSelection(); |
2463 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2463 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2464 | if ( incidence ) { | 2464 | if ( incidence ) { |
2465 | beamIncidence(incidence); | 2465 | beamIncidence(incidence); |
2466 | } | 2466 | } |
2467 | } | 2467 | } |
2468 | void CalendarView::toggleCancelIncidence() | 2468 | void CalendarView::toggleCancelIncidence() |
2469 | { | 2469 | { |
2470 | Incidence *incidence = currentSelection(); | 2470 | Incidence *incidence = currentSelection(); |
2471 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2471 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2472 | if ( incidence ) { | 2472 | if ( incidence ) { |
2473 | cancelIncidence(incidence); | 2473 | cancelIncidence(incidence); |
2474 | } | 2474 | } |
2475 | } | 2475 | } |
2476 | 2476 | ||
2477 | 2477 | ||
2478 | void CalendarView::cancelIncidence(Incidence * inc ) | 2478 | void CalendarView::cancelIncidence(Incidence * inc ) |
2479 | { | 2479 | { |
2480 | inc->setCancelled( ! inc->cancelled() ); | 2480 | inc->setCancelled( ! inc->cancelled() ); |
2481 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2481 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2482 | updateView(); | 2482 | updateView(); |
2483 | } | 2483 | } |
2484 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2484 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2485 | { | 2485 | { |
2486 | Incidence * newInc = orgInc->clone(); | 2486 | Incidence * newInc = orgInc->clone(); |
2487 | newInc->recreate(); | 2487 | newInc->recreate(); |
2488 | 2488 | ||
2489 | if ( newInc->type() == "Todo" ) { | 2489 | if ( newInc->type() == "Todo" ) { |
2490 | Todo* t = (Todo*) newInc; | 2490 | Todo* t = (Todo*) newInc; |
2491 | mTodoEditor->editTodo( t ); | 2491 | mTodoEditor->editTodo( t ); |
2492 | showTodoEditor(); | 2492 | showTodoEditor(); |
2493 | if ( mTodoEditor->exec() ) { | 2493 | if ( mTodoEditor->exec() ) { |
2494 | mCalendar->addTodo( t ); | 2494 | mCalendar->addTodo( t ); |
2495 | updateView(); | 2495 | updateView(); |
2496 | } else { | 2496 | } else { |
2497 | delete t; | 2497 | delete t; |
2498 | } | 2498 | } |
2499 | } | 2499 | } |
2500 | else { | 2500 | else { |
2501 | Event* e = (Event*) newInc; | 2501 | Event* e = (Event*) newInc; |
2502 | mEventEditor->editEvent( e ); | 2502 | mEventEditor->editEvent( e ); |
2503 | showEventEditor(); | 2503 | showEventEditor(); |
2504 | if ( mEventEditor->exec() ) { | 2504 | if ( mEventEditor->exec() ) { |
2505 | mCalendar->addEvent( e ); | 2505 | mCalendar->addEvent( e ); |
2506 | updateView(); | 2506 | updateView(); |
2507 | } else { | 2507 | } else { |
2508 | delete e; | 2508 | delete e; |
2509 | } | 2509 | } |
2510 | } | 2510 | } |
2511 | } | 2511 | } |
2512 | 2512 | ||
2513 | void CalendarView::newEvent() | 2513 | void CalendarView::newEvent() |
2514 | { | 2514 | { |
2515 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2515 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2516 | KOAgendaView *aView = mViewManager->agendaView(); | 2516 | KOAgendaView *aView = mViewManager->agendaView(); |
2517 | if (aView) { | 2517 | if (aView) { |
2518 | if (aView->selectionStart().isValid()) { | 2518 | if (aView->selectionStart().isValid()) { |
2519 | if (aView->selectedIsAllDay()) { | 2519 | if (aView->selectedIsAllDay()) { |
2520 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2520 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2521 | } else { | 2521 | } else { |
2522 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2522 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2523 | } | 2523 | } |
2524 | return; | 2524 | return; |
2525 | } | 2525 | } |
2526 | } | 2526 | } |
2527 | 2527 | ||
2528 | QDate date = mNavigator->selectedDates().first(); | 2528 | QDate date = mNavigator->selectedDates().first(); |
2529 | QDateTime current = QDateTime::currentDateTime(); | 2529 | QDateTime current = QDateTime::currentDateTime(); |
2530 | if ( date <= current.date() ) { | 2530 | if ( date <= current.date() ) { |
2531 | int hour = current.time().hour() +1; | 2531 | int hour = current.time().hour() +1; |
2532 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2532 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2533 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2533 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2534 | } else | 2534 | } else |
2535 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2535 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2536 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2536 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2537 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2537 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2538 | } | 2538 | } |
2539 | 2539 | ||
2540 | void CalendarView::newEvent(QDateTime fh) | 2540 | void CalendarView::newEvent(QDateTime fh) |
2541 | { | 2541 | { |
2542 | newEvent(fh, | 2542 | newEvent(fh, |
2543 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2543 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2544 | } | 2544 | } |
2545 | 2545 | ||
2546 | void CalendarView::newEvent(QDate dt) | 2546 | void CalendarView::newEvent(QDate dt) |
2547 | { | 2547 | { |
2548 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2548 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2549 | QDateTime(dt, QTime(0,0,0)), true); | 2549 | QDateTime(dt, QTime(0,0,0)), true); |
2550 | } | 2550 | } |
2551 | 2551 | ||
2552 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2552 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2553 | { | 2553 | { |
2554 | 2554 | ||
2555 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2555 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2556 | if ( mFilterView->filtersEnabled() ) { | 2556 | if ( mFilterView->filtersEnabled() ) { |
2557 | CalFilter *filter = mFilterView->selectedFilter(); | 2557 | CalFilter *filter = mFilterView->selectedFilter(); |
2558 | if (filter && filter->showCategories()) { | 2558 | if (filter && filter->showCategories()) { |
2559 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2559 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2560 | } | 2560 | } |
2561 | if ( filter ) | 2561 | if ( filter ) |
2562 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2562 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2563 | } | 2563 | } |
2564 | showEventEditor(); | 2564 | showEventEditor(); |
2565 | } | 2565 | } |
2566 | void CalendarView::todoAdded(Todo * t) | 2566 | void CalendarView::todoAdded(Todo * t) |
2567 | { | 2567 | { |
2568 | 2568 | ||
2569 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2569 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2570 | updateTodoViews(); | 2570 | updateTodoViews(); |
2571 | } | 2571 | } |
2572 | void CalendarView::todoChanged(Todo * t) | 2572 | void CalendarView::todoChanged(Todo * t) |
2573 | { | 2573 | { |
2574 | emit todoModified( t, 4 ); | 2574 | emit todoModified( t, 4 ); |
2575 | // updateTodoViews(); | 2575 | // updateTodoViews(); |
2576 | } | 2576 | } |
2577 | void CalendarView::todoToBeDeleted(Todo *) | 2577 | void CalendarView::todoToBeDeleted(Todo *) |
2578 | { | 2578 | { |
2579 | //qDebug("todoToBeDeleted(Todo *) "); | 2579 | //qDebug("todoToBeDeleted(Todo *) "); |
2580 | updateTodoViews(); | 2580 | updateTodoViews(); |
2581 | } | 2581 | } |
2582 | void CalendarView::todoDeleted() | 2582 | void CalendarView::todoDeleted() |
2583 | { | 2583 | { |
2584 | //qDebug(" todoDeleted()"); | 2584 | //qDebug(" todoDeleted()"); |
2585 | updateTodoViews(); | 2585 | updateTodoViews(); |
2586 | } | 2586 | } |
2587 | 2587 | ||
2588 | 2588 | ||
2589 | 2589 | ||
2590 | void CalendarView::newTodo() | 2590 | void CalendarView::newTodo() |
2591 | { | 2591 | { |
2592 | 2592 | ||
2593 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2593 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2594 | if ( mFilterView->filtersEnabled() ) { | 2594 | if ( mFilterView->filtersEnabled() ) { |
2595 | CalFilter *filter = mFilterView->selectedFilter(); | 2595 | CalFilter *filter = mFilterView->selectedFilter(); |
2596 | if (filter && filter->showCategories()) { | 2596 | if (filter && filter->showCategories()) { |
2597 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2597 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2598 | } | 2598 | } |
2599 | if ( filter ) | 2599 | if ( filter ) |
2600 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2600 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2601 | } | 2601 | } |
2602 | showTodoEditor(); | 2602 | showTodoEditor(); |
2603 | } | 2603 | } |
2604 | 2604 | ||
2605 | void CalendarView::newSubTodo() | 2605 | void CalendarView::newSubTodo() |
2606 | { | 2606 | { |
2607 | Todo *todo = selectedTodo(); | 2607 | Todo *todo = selectedTodo(); |
2608 | if ( todo ) newSubTodo( todo ); | 2608 | if ( todo ) newSubTodo( todo ); |
2609 | } | 2609 | } |
2610 | 2610 | ||
2611 | void CalendarView::newSubTodo(Todo *parentEvent) | 2611 | void CalendarView::newSubTodo(Todo *parentEvent) |
2612 | { | 2612 | { |
2613 | 2613 | ||
2614 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2614 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2615 | showTodoEditor(); | 2615 | showTodoEditor(); |
2616 | } | 2616 | } |
2617 | 2617 | ||
2618 | void CalendarView::newFloatingEvent() | 2618 | void CalendarView::newFloatingEvent() |
2619 | { | 2619 | { |
2620 | DateList tmpList = mNavigator->selectedDates(); | 2620 | DateList tmpList = mNavigator->selectedDates(); |
2621 | QDate date = tmpList.first(); | 2621 | QDate date = tmpList.first(); |
2622 | 2622 | ||
2623 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2623 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2624 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2624 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2625 | } | 2625 | } |
2626 | 2626 | ||
2627 | 2627 | ||
2628 | void CalendarView::editEvent( Event *event ) | 2628 | void CalendarView::editEvent( Event *event ) |
2629 | { | 2629 | { |
2630 | 2630 | ||
2631 | if ( !event ) return; | 2631 | if ( !event ) return; |
2632 | if ( event->isReadOnly() ) { | 2632 | if ( event->isReadOnly() ) { |
2633 | showEvent( event ); | 2633 | showEvent( event ); |
2634 | return; | 2634 | return; |
2635 | } | 2635 | } |
2636 | mEventEditor->editEvent( event , mFlagEditDescription); | 2636 | mEventEditor->editEvent( event , mFlagEditDescription); |
2637 | showEventEditor(); | 2637 | showEventEditor(); |
2638 | } | 2638 | } |
2639 | void CalendarView::editJournal( Journal *jour ) | 2639 | void CalendarView::editJournal( Journal *jour ) |
2640 | { | 2640 | { |
2641 | if ( !jour ) return; | 2641 | if ( !jour ) return; |
2642 | mDialogManager->hideSearchDialog(); | 2642 | mDialogManager->hideSearchDialog(); |
2643 | mViewManager->showJournalView(); | 2643 | mViewManager->showJournalView(); |
2644 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2644 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2645 | } | 2645 | } |
2646 | void CalendarView::editTodo( Todo *todo ) | 2646 | void CalendarView::editTodo( Todo *todo ) |
2647 | { | 2647 | { |
2648 | if ( !todo ) return; | 2648 | if ( !todo ) return; |
2649 | 2649 | ||
2650 | if ( todo->isReadOnly() ) { | 2650 | if ( todo->isReadOnly() ) { |
2651 | showTodo( todo ); | 2651 | showTodo( todo ); |
2652 | return; | 2652 | return; |
2653 | } | 2653 | } |
2654 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2654 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2655 | showTodoEditor(); | 2655 | showTodoEditor(); |
2656 | 2656 | ||
2657 | } | 2657 | } |
2658 | 2658 | ||
2659 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2659 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2660 | { | 2660 | { |
2661 | if ( !mEventViewerDialog ) { | 2661 | if ( !mEventViewerDialog ) { |
2662 | mEventViewerDialog = new KOEventViewerDialog(this); | 2662 | mEventViewerDialog = new KOEventViewerDialog(this); |
2663 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2663 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2664 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2664 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2665 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2665 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2666 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2666 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2667 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2667 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2668 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2668 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2669 | mEventViewerDialog->resize( 640, 480 ); | 2669 | mEventViewerDialog->resize( 640, 480 ); |
2670 | 2670 | ||
2671 | } | 2671 | } |
2672 | return mEventViewerDialog; | 2672 | return mEventViewerDialog; |
2673 | } | 2673 | } |
2674 | void CalendarView::showEvent(Event *event) | 2674 | void CalendarView::showEvent(Event *event) |
2675 | { | 2675 | { |
2676 | getEventViewerDialog()->setEvent(event); | 2676 | getEventViewerDialog()->setEvent(event); |
2677 | getEventViewerDialog()->showMe(); | 2677 | getEventViewerDialog()->showMe(); |
2678 | } | 2678 | } |
2679 | 2679 | ||
2680 | void CalendarView::showTodo(Todo *event) | 2680 | void CalendarView::showTodo(Todo *event) |
2681 | { | 2681 | { |
2682 | getEventViewerDialog()->setTodo(event); | 2682 | getEventViewerDialog()->setTodo(event); |
2683 | getEventViewerDialog()->showMe(); | 2683 | getEventViewerDialog()->showMe(); |
2684 | } | 2684 | } |
2685 | void CalendarView::showJournal( Journal *jour ) | 2685 | void CalendarView::showJournal( Journal *jour ) |
2686 | { | 2686 | { |
2687 | getEventViewerDialog()->setJournal(jour); | 2687 | getEventViewerDialog()->setJournal(jour); |
2688 | getEventViewerDialog()->showMe(); | 2688 | getEventViewerDialog()->showMe(); |
2689 | 2689 | ||
2690 | } | 2690 | } |
2691 | // void CalendarView::todoModified (Todo *event, int changed) | 2691 | // void CalendarView::todoModified (Todo *event, int changed) |
2692 | // { | 2692 | // { |
2693 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2693 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2694 | // // kdDebug() << "Todo modified and open" << endl; | 2694 | // // kdDebug() << "Todo modified and open" << endl; |
2695 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2695 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2696 | // // temp->modified (changed); | 2696 | // // temp->modified (changed); |
2697 | 2697 | ||
2698 | // // } | 2698 | // // } |
2699 | 2699 | ||
2700 | // mViewManager->updateView(); | 2700 | // mViewManager->updateView(); |
2701 | // } | 2701 | // } |
2702 | 2702 | ||
2703 | void CalendarView::appointment_show() | 2703 | void CalendarView::appointment_show() |
2704 | { | 2704 | { |
2705 | Event *anEvent = 0; | 2705 | Event *anEvent = 0; |
2706 | 2706 | ||
2707 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2707 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2708 | 2708 | ||
2709 | if (mViewManager->currentView()->isEventView()) { | 2709 | if (mViewManager->currentView()->isEventView()) { |
2710 | if ( incidence && incidence->type() == "Event" ) { | 2710 | if ( incidence && incidence->type() == "Event" ) { |
2711 | anEvent = static_cast<Event *>(incidence); | 2711 | anEvent = static_cast<Event *>(incidence); |
2712 | } | 2712 | } |
2713 | } | 2713 | } |
2714 | 2714 | ||
2715 | if (!anEvent) { | 2715 | if (!anEvent) { |
2716 | KNotifyClient::beep(); | 2716 | KNotifyClient::beep(); |
2717 | return; | 2717 | return; |
2718 | } | 2718 | } |
2719 | 2719 | ||
2720 | showEvent(anEvent); | 2720 | showEvent(anEvent); |
2721 | } | 2721 | } |
2722 | 2722 | ||
2723 | void CalendarView::appointment_edit() | 2723 | void CalendarView::appointment_edit() |
2724 | { | 2724 | { |
2725 | Event *anEvent = 0; | 2725 | Event *anEvent = 0; |
2726 | 2726 | ||
2727 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2727 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2728 | 2728 | ||
2729 | if (mViewManager->currentView()->isEventView()) { | 2729 | if (mViewManager->currentView()->isEventView()) { |
2730 | if ( incidence && incidence->type() == "Event" ) { | 2730 | if ( incidence && incidence->type() == "Event" ) { |
2731 | anEvent = static_cast<Event *>(incidence); | 2731 | anEvent = static_cast<Event *>(incidence); |
2732 | } | 2732 | } |
2733 | } | 2733 | } |
2734 | 2734 | ||
2735 | if (!anEvent) { | 2735 | if (!anEvent) { |
2736 | KNotifyClient::beep(); | 2736 | KNotifyClient::beep(); |
2737 | return; | 2737 | return; |
2738 | } | 2738 | } |
2739 | 2739 | ||
2740 | editEvent(anEvent); | 2740 | editEvent(anEvent); |
2741 | } | 2741 | } |
2742 | 2742 | ||
2743 | void CalendarView::appointment_delete() | 2743 | void CalendarView::appointment_delete() |
2744 | { | 2744 | { |
2745 | Event *anEvent = 0; | 2745 | Event *anEvent = 0; |
2746 | 2746 | ||
2747 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2747 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2748 | 2748 | ||
2749 | if (mViewManager->currentView()->isEventView()) { | 2749 | if (mViewManager->currentView()->isEventView()) { |
2750 | if ( incidence && incidence->type() == "Event" ) { | 2750 | if ( incidence && incidence->type() == "Event" ) { |
2751 | anEvent = static_cast<Event *>(incidence); | 2751 | anEvent = static_cast<Event *>(incidence); |
2752 | } | 2752 | } |
2753 | } | 2753 | } |
2754 | 2754 | ||
2755 | if (!anEvent) { | 2755 | if (!anEvent) { |
2756 | KNotifyClient::beep(); | 2756 | KNotifyClient::beep(); |
2757 | return; | 2757 | return; |
2758 | } | 2758 | } |
2759 | 2759 | ||
2760 | deleteEvent(anEvent); | 2760 | deleteEvent(anEvent); |
2761 | } | 2761 | } |
2762 | 2762 | ||
2763 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2763 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2764 | { | 2764 | { |
2765 | if (!sub) return; | 2765 | if (!sub) return; |
2766 | if (!parent) return; | 2766 | if (!parent) return; |
2767 | if ( sub->relatedTo() ) | 2767 | if ( sub->relatedTo() ) |
2768 | sub->relatedTo()->removeRelation(sub); | 2768 | sub->relatedTo()->removeRelation(sub); |
2769 | sub->setRelatedTo(parent); | 2769 | sub->setRelatedTo(parent); |
2770 | sub->setRelatedToUid(parent->uid()); | 2770 | sub->setRelatedToUid(parent->uid()); |
2771 | parent->addRelation(sub); | 2771 | parent->addRelation(sub); |
2772 | sub->updated(); | 2772 | sub->updated(); |
2773 | parent->updated(); | 2773 | parent->updated(); |
2774 | setModified(true); | 2774 | setModified(true); |
2775 | updateView(); | 2775 | updateView(); |
2776 | } | 2776 | } |
2777 | void CalendarView::todo_unsub(Todo *anTodo ) | 2777 | void CalendarView::todo_unsub(Todo *anTodo ) |
2778 | { | 2778 | { |
2779 | // Todo *anTodo = selectedTodo(); | 2779 | // Todo *anTodo = selectedTodo(); |
2780 | if (!anTodo) return; | 2780 | if (!anTodo) return; |
2781 | if (!anTodo->relatedTo()) return; | 2781 | if (!anTodo->relatedTo()) return; |
2782 | anTodo->relatedTo()->removeRelation(anTodo); | 2782 | anTodo->relatedTo()->removeRelation(anTodo); |
2783 | anTodo->setRelatedTo(0); | 2783 | anTodo->setRelatedTo(0); |
2784 | anTodo->updated(); | 2784 | anTodo->updated(); |
2785 | anTodo->setRelatedToUid(""); | 2785 | anTodo->setRelatedToUid(""); |
2786 | setModified(true); | 2786 | setModified(true); |
2787 | updateView(); | 2787 | updateView(); |
2788 | } | 2788 | } |
2789 | 2789 | ||
2790 | void CalendarView::deleteTodo(Todo *todo) | 2790 | void CalendarView::deleteTodo(Todo *todo) |
2791 | { | 2791 | { |
2792 | if (!todo) { | 2792 | if (!todo) { |
2793 | KNotifyClient::beep(); | 2793 | KNotifyClient::beep(); |
2794 | return; | 2794 | return; |
2795 | } | 2795 | } |
2796 | if (KOPrefs::instance()->mConfirm) { | 2796 | if (KOPrefs::instance()->mConfirm) { |
2797 | switch (msgItemDelete()) { | 2797 | switch (msgItemDelete()) { |
2798 | case KMessageBox::Continue: // OK | 2798 | case KMessageBox::Continue: // OK |
2799 | if (!todo->relations().isEmpty()) { | 2799 | if (!todo->relations().isEmpty()) { |
2800 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2800 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2801 | i18n("Delete To-Do")); | 2801 | i18n("Delete To-Do")); |
2802 | } else { | 2802 | } else { |
2803 | checkExternalId( todo ); | 2803 | checkExternalId( todo ); |
2804 | calendar()->deleteTodo(todo); | 2804 | calendar()->deleteTodo(todo); |
2805 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2805 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2806 | updateView(); | 2806 | updateView(); |
2807 | } | 2807 | } |
2808 | break; | 2808 | break; |
2809 | } // switch | 2809 | } // switch |
2810 | } else { | 2810 | } else { |
2811 | if (!todo->relations().isEmpty()) { | 2811 | if (!todo->relations().isEmpty()) { |
2812 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2812 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2813 | i18n("Delete To-Do")); | 2813 | i18n("Delete To-Do")); |
2814 | } else { | 2814 | } else { |
2815 | checkExternalId( todo ); | 2815 | checkExternalId( todo ); |
2816 | mCalendar->deleteTodo(todo); | 2816 | mCalendar->deleteTodo(todo); |
2817 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2817 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2818 | updateView(); | 2818 | updateView(); |
2819 | } | 2819 | } |
2820 | } | 2820 | } |
2821 | emit updateSearchDialog(); | 2821 | emit updateSearchDialog(); |
2822 | } | 2822 | } |
2823 | void CalendarView::deleteJournal(Journal *jour) | 2823 | void CalendarView::deleteJournal(Journal *jour) |
2824 | { | 2824 | { |
2825 | if (!jour) { | 2825 | if (!jour) { |
2826 | KNotifyClient::beep(); | 2826 | KNotifyClient::beep(); |
2827 | return; | 2827 | return; |
2828 | } | 2828 | } |
2829 | if (KOPrefs::instance()->mConfirm) { | 2829 | if (KOPrefs::instance()->mConfirm) { |
2830 | switch (msgItemDelete()) { | 2830 | switch (msgItemDelete()) { |
2831 | case KMessageBox::Continue: // OK | 2831 | case KMessageBox::Continue: // OK |
2832 | calendar()->deleteJournal(jour); | 2832 | calendar()->deleteJournal(jour); |
2833 | updateView(); | 2833 | updateView(); |
2834 | break; | 2834 | break; |
2835 | } // switch | 2835 | } // switch |
2836 | } else { | 2836 | } else { |
2837 | calendar()->deleteJournal(jour);; | 2837 | calendar()->deleteJournal(jour);; |
2838 | updateView(); | 2838 | updateView(); |
2839 | } | 2839 | } |
2840 | emit updateSearchDialog(); | 2840 | emit updateSearchDialog(); |
2841 | } | 2841 | } |
2842 | 2842 | ||
2843 | void CalendarView::deleteEvent(Event *anEvent) | 2843 | void CalendarView::deleteEvent(Event *anEvent) |
2844 | { | 2844 | { |
2845 | if (!anEvent) { | 2845 | if (!anEvent) { |
2846 | KNotifyClient::beep(); | 2846 | KNotifyClient::beep(); |
2847 | return; | 2847 | return; |
2848 | } | 2848 | } |
2849 | 2849 | ||
2850 | if (anEvent->recurrence()->doesRecur()) { | 2850 | if (anEvent->recurrence()->doesRecur()) { |
2851 | QDate itemDate = mViewManager->currentSelectionDate(); | 2851 | QDate itemDate = mViewManager->currentSelectionDate(); |
2852 | int km; | 2852 | int km; |
2853 | if (!itemDate.isValid()) { | 2853 | if (!itemDate.isValid()) { |
2854 | //kdDebug() << "Date Not Valid" << endl; | 2854 | //kdDebug() << "Date Not Valid" << endl; |
2855 | if (KOPrefs::instance()->mConfirm) { | 2855 | if (KOPrefs::instance()->mConfirm) { |
2856 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2856 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2857 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2857 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2858 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2858 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2859 | if ( km == KMessageBox::Continue ) | 2859 | if ( km == KMessageBox::Continue ) |
2860 | km = KMessageBox::No; // No = all below | 2860 | km = KMessageBox::No; // No = all below |
2861 | } else | 2861 | } else |
2862 | km = KMessageBox::No; | 2862 | km = KMessageBox::No; |
2863 | } else { | 2863 | } else { |
2864 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2864 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2865 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2865 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2866 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2866 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2867 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2867 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2868 | i18n("All")); | 2868 | i18n("All")); |
2869 | } | 2869 | } |
2870 | switch(km) { | 2870 | switch(km) { |
2871 | 2871 | ||
2872 | case KMessageBox::No: // Continue // all | 2872 | case KMessageBox::No: // Continue // all |
2873 | //qDebug("KMessageBox::No "); | 2873 | //qDebug("KMessageBox::No "); |
2874 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2874 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2875 | schedule(Scheduler::Cancel,anEvent); | 2875 | schedule(Scheduler::Cancel,anEvent); |
2876 | 2876 | ||
2877 | checkExternalId( anEvent); | 2877 | checkExternalId( anEvent); |
2878 | mCalendar->deleteEvent(anEvent); | 2878 | mCalendar->deleteEvent(anEvent); |
2879 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2879 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2880 | break; | 2880 | break; |
2881 | 2881 | ||
2882 | // Disabled because it does not work | 2882 | // Disabled because it does not work |
2883 | //#if 0 | 2883 | //#if 0 |
2884 | case KMessageBox::Yes: // just this one | 2884 | case KMessageBox::Yes: // just this one |
2885 | //QDate qd = mNavigator->selectedDates().first(); | 2885 | //QDate qd = mNavigator->selectedDates().first(); |
2886 | //if (!qd.isValid()) { | 2886 | //if (!qd.isValid()) { |
2887 | // kdDebug() << "no date selected, or invalid date" << endl; | 2887 | // kdDebug() << "no date selected, or invalid date" << endl; |
2888 | // KNotifyClient::beep(); | 2888 | // KNotifyClient::beep(); |
2889 | // return; | 2889 | // return; |
2890 | //} | 2890 | //} |
2891 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2891 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2892 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2892 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2893 | anEvent->addExDate(itemDate); | 2893 | anEvent->addExDate(itemDate); |
2894 | int duration = anEvent->recurrence()->duration(); | 2894 | int duration = anEvent->recurrence()->duration(); |
2895 | if ( duration > 0 ) { | 2895 | if ( duration > 0 ) { |
2896 | anEvent->recurrence()->setDuration( duration - 1 ); | 2896 | anEvent->recurrence()->setDuration( duration - 1 ); |
2897 | } | 2897 | } |
2898 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2898 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2899 | } | 2899 | } |
2900 | break; | 2900 | break; |
2901 | //#endif | 2901 | //#endif |
2902 | } // switch | 2902 | } // switch |
2903 | } else { | 2903 | } else { |
2904 | if (KOPrefs::instance()->mConfirm) { | 2904 | if (KOPrefs::instance()->mConfirm) { |
2905 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2905 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2906 | i18n("\nAre you sure you want\nto delete this event?"), | 2906 | i18n("\nAre you sure you want\nto delete this event?"), |
2907 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2907 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2908 | case KMessageBox::Continue: // OK | 2908 | case KMessageBox::Continue: // OK |
2909 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2909 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2910 | schedule(Scheduler::Cancel,anEvent); | 2910 | schedule(Scheduler::Cancel,anEvent); |
2911 | checkExternalId( anEvent); | 2911 | checkExternalId( anEvent); |
2912 | mCalendar->deleteEvent(anEvent); | 2912 | mCalendar->deleteEvent(anEvent); |
2913 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2913 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2914 | break; | 2914 | break; |
2915 | } // switch | 2915 | } // switch |
2916 | } else { | 2916 | } else { |
2917 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2917 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2918 | schedule(Scheduler::Cancel,anEvent); | 2918 | schedule(Scheduler::Cancel,anEvent); |
2919 | checkExternalId( anEvent); | 2919 | checkExternalId( anEvent); |
2920 | mCalendar->deleteEvent(anEvent); | 2920 | mCalendar->deleteEvent(anEvent); |
2921 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2921 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2922 | } | 2922 | } |
2923 | } // if-else | 2923 | } // if-else |
2924 | emit updateSearchDialog(); | 2924 | emit updateSearchDialog(); |
2925 | } | 2925 | } |
2926 | 2926 | ||
2927 | bool CalendarView::deleteEvent(const QString &uid) | 2927 | bool CalendarView::deleteEvent(const QString &uid) |
2928 | { | 2928 | { |
2929 | Event *ev = mCalendar->event(uid); | 2929 | Event *ev = mCalendar->event(uid); |
2930 | if (ev) { | 2930 | if (ev) { |
2931 | deleteEvent(ev); | 2931 | deleteEvent(ev); |
2932 | return true; | 2932 | return true; |
2933 | } else { | 2933 | } else { |
2934 | return false; | 2934 | return false; |
2935 | } | 2935 | } |
2936 | } | 2936 | } |
2937 | 2937 | ||
2938 | /*****************************************************************************/ | 2938 | /*****************************************************************************/ |
2939 | 2939 | ||
2940 | void CalendarView::action_mail() | 2940 | void CalendarView::action_mail() |
2941 | { | 2941 | { |
2942 | #ifndef KORG_NOMAIL | 2942 | #ifndef KORG_NOMAIL |
2943 | KOMailClient mailClient; | 2943 | KOMailClient mailClient; |
2944 | 2944 | ||
2945 | Incidence *incidence = currentSelection(); | 2945 | Incidence *incidence = currentSelection(); |
2946 | 2946 | ||
2947 | if (!incidence) { | 2947 | if (!incidence) { |
2948 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2948 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2949 | return; | 2949 | return; |
2950 | } | 2950 | } |
2951 | if(incidence->attendeeCount() == 0 ) { | 2951 | if(incidence->attendeeCount() == 0 ) { |
2952 | KMessageBox::sorry(this, | 2952 | KMessageBox::sorry(this, |
2953 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2953 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2954 | return; | 2954 | return; |
2955 | } | 2955 | } |
2956 | 2956 | ||
2957 | CalendarLocal cal_tmp; | 2957 | CalendarLocal cal_tmp; |
2958 | Event *event = 0; | 2958 | Event *event = 0; |
2959 | Event *ev = 0; | 2959 | Event *ev = 0; |
2960 | if ( incidence && incidence->type() == "Event" ) { | 2960 | if ( incidence && incidence->type() == "Event" ) { |
2961 | event = static_cast<Event *>(incidence); | 2961 | event = static_cast<Event *>(incidence); |
2962 | ev = new Event(*event); | 2962 | ev = new Event(*event); |
2963 | cal_tmp.addEvent(ev); | 2963 | cal_tmp.addEvent(ev); |
2964 | } | 2964 | } |
2965 | ICalFormat mForm(); | 2965 | ICalFormat mForm(); |
2966 | QString attachment = mForm.toString( &cal_tmp ); | 2966 | QString attachment = mForm.toString( &cal_tmp ); |
2967 | if (ev) delete(ev); | 2967 | if (ev) delete(ev); |
2968 | 2968 | ||
2969 | mailClient.mailAttendees(currentSelection(), attachment); | 2969 | mailClient.mailAttendees(currentSelection(), attachment); |
2970 | 2970 | ||
2971 | #endif | 2971 | #endif |
2972 | 2972 | ||
2973 | #if 0 | 2973 | #if 0 |
2974 | Event *anEvent = 0; | 2974 | Event *anEvent = 0; |
2975 | if (mViewManager->currentView()->isEventView()) { | 2975 | if (mViewManager->currentView()->isEventView()) { |
2976 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2976 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2977 | } | 2977 | } |
2978 | 2978 | ||
2979 | if (!anEvent) { | 2979 | if (!anEvent) { |
2980 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2980 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2981 | return; | 2981 | return; |
2982 | } | 2982 | } |
2983 | if(anEvent->attendeeCount() == 0 ) { | 2983 | if(anEvent->attendeeCount() == 0 ) { |
2984 | KMessageBox::sorry(this, | 2984 | KMessageBox::sorry(this, |
2985 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2985 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2986 | return; | 2986 | return; |
2987 | } | 2987 | } |
2988 | 2988 | ||
2989 | mailobject.emailEvent(anEvent); | 2989 | mailobject.emailEvent(anEvent); |
2990 | #endif | 2990 | #endif |
2991 | } | 2991 | } |
2992 | 2992 | ||
2993 | 2993 | ||
2994 | void CalendarView::schedule_publish(Incidence *incidence) | 2994 | void CalendarView::schedule_publish(Incidence *incidence) |
2995 | { | 2995 | { |
2996 | Event *event = 0; | 2996 | Event *event = 0; |
2997 | Todo *todo = 0; | 2997 | Todo *todo = 0; |
2998 | 2998 | ||
2999 | if (incidence == 0) { | 2999 | if (incidence == 0) { |
3000 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3000 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3001 | if (incidence == 0) { | 3001 | if (incidence == 0) { |
3002 | incidence = mTodoList->selectedIncidences().first(); | 3002 | incidence = mTodoList->selectedIncidences().first(); |
3003 | } | 3003 | } |
3004 | } | 3004 | } |
3005 | if ( incidence && incidence->type() == "Event" ) { | 3005 | if ( incidence && incidence->type() == "Event" ) { |
3006 | event = static_cast<Event *>(incidence); | 3006 | event = static_cast<Event *>(incidence); |
3007 | } else { | 3007 | } else { |
3008 | if ( incidence && incidence->type() == "Todo" ) { | 3008 | if ( incidence && incidence->type() == "Todo" ) { |
3009 | todo = static_cast<Todo *>(incidence); | 3009 | todo = static_cast<Todo *>(incidence); |
3010 | } | 3010 | } |
3011 | } | 3011 | } |
3012 | 3012 | ||
3013 | if (!event && !todo) { | 3013 | if (!event && !todo) { |
3014 | KMessageBox::sorry(this,i18n("No event selected.")); | 3014 | KMessageBox::sorry(this,i18n("No event selected.")); |
3015 | return; | 3015 | return; |
3016 | } | 3016 | } |
3017 | 3017 | ||
3018 | PublishDialog *publishdlg = new PublishDialog(); | 3018 | PublishDialog *publishdlg = new PublishDialog(); |
3019 | if (incidence->attendeeCount()>0) { | 3019 | if (incidence->attendeeCount()>0) { |
3020 | QPtrList<Attendee> attendees = incidence->attendees(); | 3020 | QPtrList<Attendee> attendees = incidence->attendees(); |
3021 | attendees.first(); | 3021 | attendees.first(); |
3022 | while ( attendees.current()!=0 ) { | 3022 | while ( attendees.current()!=0 ) { |
3023 | publishdlg->addAttendee(attendees.current()); | 3023 | publishdlg->addAttendee(attendees.current()); |
3024 | attendees.next(); | 3024 | attendees.next(); |
3025 | } | 3025 | } |
3026 | } | 3026 | } |
3027 | bool send = true; | 3027 | bool send = true; |
3028 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3028 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3029 | if ( publishdlg->exec() != QDialog::Accepted ) | 3029 | if ( publishdlg->exec() != QDialog::Accepted ) |
3030 | send = false; | 3030 | send = false; |
3031 | } | 3031 | } |
3032 | if ( send ) { | 3032 | if ( send ) { |
3033 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3033 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3034 | if ( event ) { | 3034 | if ( event ) { |
3035 | Event *ev = new Event(*event); | 3035 | Event *ev = new Event(*event); |
3036 | ev->registerObserver(0); | 3036 | ev->registerObserver(0); |
3037 | ev->clearAttendees(); | 3037 | ev->clearAttendees(); |
3038 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3038 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3039 | delete(ev); | 3039 | delete(ev); |
3040 | } | 3040 | } |
3041 | } else { | 3041 | } else { |
3042 | if ( todo ) { | 3042 | if ( todo ) { |
3043 | Todo *ev = new Todo(*todo); | 3043 | Todo *ev = new Todo(*todo); |
3044 | ev->registerObserver(0); | 3044 | ev->registerObserver(0); |
3045 | ev->clearAttendees(); | 3045 | ev->clearAttendees(); |
3046 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3046 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3047 | delete(ev); | 3047 | delete(ev); |
3048 | } | 3048 | } |
3049 | } | 3049 | } |
3050 | } | 3050 | } |
3051 | } | 3051 | } |
3052 | delete publishdlg; | 3052 | delete publishdlg; |
3053 | } | 3053 | } |
3054 | 3054 | ||
3055 | void CalendarView::schedule_request(Incidence *incidence) | 3055 | void CalendarView::schedule_request(Incidence *incidence) |
3056 | { | 3056 | { |
3057 | schedule(Scheduler::Request,incidence); | 3057 | schedule(Scheduler::Request,incidence); |
3058 | } | 3058 | } |
3059 | 3059 | ||
3060 | void CalendarView::schedule_refresh(Incidence *incidence) | 3060 | void CalendarView::schedule_refresh(Incidence *incidence) |
3061 | { | 3061 | { |
3062 | schedule(Scheduler::Refresh,incidence); | 3062 | schedule(Scheduler::Refresh,incidence); |
3063 | } | 3063 | } |
3064 | 3064 | ||
3065 | void CalendarView::schedule_cancel(Incidence *incidence) | 3065 | void CalendarView::schedule_cancel(Incidence *incidence) |
3066 | { | 3066 | { |
3067 | schedule(Scheduler::Cancel,incidence); | 3067 | schedule(Scheduler::Cancel,incidence); |
3068 | } | 3068 | } |
3069 | 3069 | ||
3070 | void CalendarView::schedule_add(Incidence *incidence) | 3070 | void CalendarView::schedule_add(Incidence *incidence) |
3071 | { | 3071 | { |
3072 | schedule(Scheduler::Add,incidence); | 3072 | schedule(Scheduler::Add,incidence); |
3073 | } | 3073 | } |
3074 | 3074 | ||
3075 | void CalendarView::schedule_reply(Incidence *incidence) | 3075 | void CalendarView::schedule_reply(Incidence *incidence) |
3076 | { | 3076 | { |
3077 | schedule(Scheduler::Reply,incidence); | 3077 | schedule(Scheduler::Reply,incidence); |
3078 | } | 3078 | } |
3079 | 3079 | ||
3080 | void CalendarView::schedule_counter(Incidence *incidence) | 3080 | void CalendarView::schedule_counter(Incidence *incidence) |
3081 | { | 3081 | { |
3082 | schedule(Scheduler::Counter,incidence); | 3082 | schedule(Scheduler::Counter,incidence); |
3083 | } | 3083 | } |
3084 | 3084 | ||
3085 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3085 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3086 | { | 3086 | { |
3087 | schedule(Scheduler::Declinecounter,incidence); | 3087 | schedule(Scheduler::Declinecounter,incidence); |
3088 | } | 3088 | } |
3089 | 3089 | ||
3090 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3090 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3091 | { | 3091 | { |
3092 | QDateTime start = QDateTime::currentDateTime(); | 3092 | QDateTime start = QDateTime::currentDateTime(); |
3093 | QDateTime end = start.addDays(daysToPublish); | 3093 | QDateTime end = start.addDays(daysToPublish); |
3094 | 3094 | ||
3095 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3095 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3096 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3096 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3097 | 3097 | ||
3098 | 3098 | ||
3099 | PublishDialog *publishdlg = new PublishDialog(); | 3099 | PublishDialog *publishdlg = new PublishDialog(); |
3100 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3100 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3101 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3101 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3102 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3102 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3103 | delete(freebusy); | 3103 | delete(freebusy); |
3104 | } | 3104 | } |
3105 | } | 3105 | } |
3106 | delete publishdlg; | 3106 | delete publishdlg; |
3107 | } | 3107 | } |
3108 | 3108 | ||
3109 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3109 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3110 | { | 3110 | { |
3111 | Event *event = 0; | 3111 | Event *event = 0; |
3112 | Todo *todo = 0; | 3112 | Todo *todo = 0; |
3113 | 3113 | ||
3114 | if (incidence == 0) { | 3114 | if (incidence == 0) { |
3115 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3115 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3116 | if (incidence == 0) { | 3116 | if (incidence == 0) { |
3117 | incidence = mTodoList->selectedIncidences().first(); | 3117 | incidence = mTodoList->selectedIncidences().first(); |
3118 | } | 3118 | } |
3119 | } | 3119 | } |
3120 | if ( incidence && incidence->type() == "Event" ) { | 3120 | if ( incidence && incidence->type() == "Event" ) { |
3121 | event = static_cast<Event *>(incidence); | 3121 | event = static_cast<Event *>(incidence); |
3122 | } | 3122 | } |
3123 | if ( incidence && incidence->type() == "Todo" ) { | 3123 | if ( incidence && incidence->type() == "Todo" ) { |
3124 | todo = static_cast<Todo *>(incidence); | 3124 | todo = static_cast<Todo *>(incidence); |
3125 | } | 3125 | } |
3126 | 3126 | ||
3127 | if (!event && !todo) { | 3127 | if (!event && !todo) { |
3128 | KMessageBox::sorry(this,i18n("No event selected.")); | 3128 | KMessageBox::sorry(this,i18n("No event selected.")); |
3129 | return; | 3129 | return; |
3130 | } | 3130 | } |
3131 | 3131 | ||
3132 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3132 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3133 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3133 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3134 | return; | 3134 | return; |
3135 | } | 3135 | } |
3136 | 3136 | ||
3137 | Event *ev = 0; | 3137 | Event *ev = 0; |
3138 | if (event) ev = new Event(*event); | 3138 | if (event) ev = new Event(*event); |
3139 | Todo *to = 0; | 3139 | Todo *to = 0; |
3140 | if (todo) to = new Todo(*todo); | 3140 | if (todo) to = new Todo(*todo); |
3141 | 3141 | ||
3142 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3142 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3143 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3143 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3144 | if (!me) { | 3144 | if (!me) { |
3145 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3145 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3146 | return; | 3146 | return; |
3147 | } | 3147 | } |
3148 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3148 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3149 | StatusDialog *statdlg = new StatusDialog(this); | 3149 | StatusDialog *statdlg = new StatusDialog(this); |
3150 | if (!statdlg->exec()==QDialog::Accepted) return; | 3150 | if (!statdlg->exec()==QDialog::Accepted) return; |
3151 | me->setStatus( statdlg->status() ); | 3151 | me->setStatus( statdlg->status() ); |
3152 | delete(statdlg); | 3152 | delete(statdlg); |
3153 | } | 3153 | } |
3154 | Attendee *menew = new Attendee(*me); | 3154 | Attendee *menew = new Attendee(*me); |
3155 | if (ev) { | 3155 | if (ev) { |
3156 | ev->clearAttendees(); | 3156 | ev->clearAttendees(); |
3157 | ev->addAttendee(menew,false); | 3157 | ev->addAttendee(menew,false); |
3158 | } else { | 3158 | } else { |
3159 | if (to) { | 3159 | if (to) { |
3160 | todo->clearAttendees(); | 3160 | todo->clearAttendees(); |
3161 | todo->addAttendee(menew,false); | 3161 | todo->addAttendee(menew,false); |
3162 | } | 3162 | } |
3163 | } | 3163 | } |
3164 | } | 3164 | } |
3165 | 3165 | ||
3166 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3166 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3167 | if (ev) { | 3167 | if (ev) { |
3168 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3168 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3169 | } else { | 3169 | } else { |
3170 | if (to) { | 3170 | if (to) { |
3171 | if ( !dlg->addMessage(to,method) ) delete(to); | 3171 | if ( !dlg->addMessage(to,method) ) delete(to); |
3172 | } | 3172 | } |
3173 | } | 3173 | } |
3174 | } | 3174 | } |
3175 | 3175 | ||
3176 | void CalendarView::openAddressbook() | 3176 | void CalendarView::openAddressbook() |
3177 | { | 3177 | { |
3178 | KRun::runCommand("kaddressbook"); | 3178 | KRun::runCommand("kaddressbook"); |
3179 | } | 3179 | } |
3180 | 3180 | ||
3181 | void CalendarView::setModified(bool modified) | 3181 | void CalendarView::setModified(bool modified) |
3182 | { | 3182 | { |
3183 | if ( modified ) | 3183 | if ( modified ) |
3184 | emit signalmodified(); | 3184 | emit signalmodified(); |
3185 | if (mModified != modified) { | 3185 | if (mModified != modified) { |
3186 | mModified = modified; | 3186 | mModified = modified; |
3187 | emit modifiedChanged(mModified); | 3187 | emit modifiedChanged(mModified); |
3188 | } | 3188 | } |
3189 | } | 3189 | } |
3190 | 3190 | ||
3191 | bool CalendarView::isReadOnly() | 3191 | bool CalendarView::isReadOnly() |
3192 | { | 3192 | { |
3193 | return mReadOnly; | 3193 | return mReadOnly; |
3194 | } | 3194 | } |
3195 | 3195 | ||
3196 | void CalendarView::setReadOnly(bool readOnly) | 3196 | void CalendarView::setReadOnly(bool readOnly) |
3197 | { | 3197 | { |
3198 | if (mReadOnly != readOnly) { | 3198 | if (mReadOnly != readOnly) { |
3199 | mReadOnly = readOnly; | 3199 | mReadOnly = readOnly; |
3200 | emit readOnlyChanged(mReadOnly); | 3200 | emit readOnlyChanged(mReadOnly); |
3201 | } | 3201 | } |
3202 | } | 3202 | } |
3203 | 3203 | ||
3204 | bool CalendarView::isModified() | 3204 | bool CalendarView::isModified() |
3205 | { | 3205 | { |
3206 | return mModified; | 3206 | return mModified; |
3207 | } | 3207 | } |
3208 | 3208 | ||
3209 | void CalendarView::printSetup() | 3209 | void CalendarView::printSetup() |
3210 | { | 3210 | { |
3211 | #ifndef KORG_NOPRINTER | 3211 | #ifndef KORG_NOPRINTER |
3212 | createPrinter(); | 3212 | createPrinter(); |
3213 | 3213 | ||
3214 | mCalPrinter->setupPrinter(); | 3214 | mCalPrinter->setupPrinter(); |
3215 | #endif | 3215 | #endif |
3216 | } | 3216 | } |
3217 | 3217 | ||
3218 | void CalendarView::print() | 3218 | void CalendarView::print() |
3219 | { | 3219 | { |
3220 | #ifndef KORG_NOPRINTER | 3220 | #ifndef KORG_NOPRINTER |
3221 | createPrinter(); | 3221 | createPrinter(); |
3222 | 3222 | ||
3223 | DateList tmpDateList = mNavigator->selectedDates(); | 3223 | DateList tmpDateList = mNavigator->selectedDates(); |
3224 | mCalPrinter->print(CalPrinter::Month, | 3224 | mCalPrinter->print(CalPrinter::Month, |
3225 | tmpDateList.first(), tmpDateList.last()); | 3225 | tmpDateList.first(), tmpDateList.last()); |
3226 | #endif | 3226 | #endif |
3227 | } | 3227 | } |
3228 | 3228 | ||
3229 | void CalendarView::printPreview() | 3229 | void CalendarView::printPreview() |
3230 | { | 3230 | { |
3231 | #ifndef KORG_NOPRINTER | 3231 | #ifndef KORG_NOPRINTER |
3232 | kdDebug() << "CalendarView::printPreview()" << endl; | 3232 | kdDebug() << "CalendarView::printPreview()" << endl; |
3233 | 3233 | ||
3234 | createPrinter(); | 3234 | createPrinter(); |
3235 | 3235 | ||
3236 | DateList tmpDateList = mNavigator->selectedDates(); | 3236 | DateList tmpDateList = mNavigator->selectedDates(); |
3237 | 3237 | ||
3238 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3238 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3239 | tmpDateList.last()); | 3239 | tmpDateList.last()); |
3240 | #endif | 3240 | #endif |
3241 | } | 3241 | } |
3242 | 3242 | ||
3243 | void CalendarView::exportICalendar() | 3243 | void CalendarView::exportICalendar() |
3244 | { | 3244 | { |
3245 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3245 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3246 | 3246 | ||
3247 | // Force correct extension | 3247 | // Force correct extension |
3248 | if (filename.right(4) != ".ics") filename += ".ics"; | 3248 | if (filename.right(4) != ".ics") filename += ".ics"; |
3249 | 3249 | ||
3250 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3250 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3251 | storage.save(); | 3251 | storage.save(); |
3252 | } | 3252 | } |
3253 | 3253 | ||
3254 | bool CalendarView::exportVCalendar( QString filename ) | 3254 | bool CalendarView::exportVCalendar( QString filename ) |
3255 | { | 3255 | { |
3256 | if (mCalendar->journals().count() > 0) { | 3256 | if (mCalendar->journals().count() > 0) { |
3257 | int result = KMessageBox::warningContinueCancel(this, | 3257 | int result = KMessageBox::warningContinueCancel(this, |
3258 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3258 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3259 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3259 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3260 | true); | 3260 | true); |
3261 | if (result != KMessageBox::Continue) return false; | 3261 | if (result != KMessageBox::Continue) return false; |
3262 | } | 3262 | } |
3263 | 3263 | ||
3264 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3264 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3265 | 3265 | ||
3266 | // Force correct extension | 3266 | // Force correct extension |
3267 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3267 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3268 | 3268 | ||
3269 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3269 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3270 | return storage.save(); | 3270 | return storage.save(); |
3271 | 3271 | ||
3272 | } | 3272 | } |
3273 | 3273 | ||
3274 | void CalendarView::eventUpdated(Incidence *) | 3274 | void CalendarView::eventUpdated(Incidence *) |
3275 | { | 3275 | { |
3276 | setModified(); | 3276 | setModified(); |
3277 | // Don't call updateView here. The code, which has caused the update of the | 3277 | // Don't call updateView here. The code, which has caused the update of the |
3278 | // event is responsible for updating the view. | 3278 | // event is responsible for updating the view. |
3279 | // updateView(); | 3279 | // updateView(); |
3280 | } | 3280 | } |
3281 | 3281 | ||
3282 | void CalendarView::adaptNavigationUnits() | 3282 | void CalendarView::adaptNavigationUnits() |
3283 | { | 3283 | { |
3284 | if (mViewManager->currentView()->isEventView()) { | 3284 | if (mViewManager->currentView()->isEventView()) { |
3285 | int days = mViewManager->currentView()->currentDateCount(); | 3285 | int days = mViewManager->currentView()->currentDateCount(); |
3286 | if (days == 1) { | 3286 | if (days == 1) { |
3287 | emit changeNavStringPrev(i18n("&Previous Day")); | 3287 | emit changeNavStringPrev(i18n("&Previous Day")); |
3288 | emit changeNavStringNext(i18n("&Next Day")); | 3288 | emit changeNavStringNext(i18n("&Next Day")); |
3289 | } else { | 3289 | } else { |
3290 | emit changeNavStringPrev(i18n("&Previous Week")); | 3290 | emit changeNavStringPrev(i18n("&Previous Week")); |
3291 | emit changeNavStringNext(i18n("&Next Week")); | 3291 | emit changeNavStringNext(i18n("&Next Week")); |
3292 | } | 3292 | } |
3293 | } | 3293 | } |
3294 | } | 3294 | } |
3295 | 3295 | ||
3296 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3296 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3297 | { | 3297 | { |
3298 | if ( incidence ) mTodoList->clearSelection(); | 3298 | if ( incidence ) mTodoList->clearSelection(); |
3299 | processIncidenceSelection( incidence ); | 3299 | processIncidenceSelection( incidence ); |
3300 | } | 3300 | } |
3301 | 3301 | ||
3302 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3302 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3303 | { | 3303 | { |
3304 | if ( incidence && mViewManager->currentView() ) { | 3304 | if ( incidence && mViewManager->currentView() ) { |
3305 | mViewManager->currentView()->clearSelection(); | 3305 | mViewManager->currentView()->clearSelection(); |
3306 | } | 3306 | } |
3307 | processIncidenceSelection( incidence ); | 3307 | processIncidenceSelection( incidence ); |
3308 | } | 3308 | } |
3309 | 3309 | ||
3310 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3310 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3311 | { | 3311 | { |
3312 | if ( incidence == mSelectedIncidence ) return; | 3312 | if ( incidence == mSelectedIncidence ) return; |
3313 | 3313 | ||
3314 | mSelectedIncidence = incidence; | 3314 | mSelectedIncidence = incidence; |
3315 | 3315 | ||
3316 | emit incidenceSelected( mSelectedIncidence ); | 3316 | emit incidenceSelected( mSelectedIncidence ); |
3317 | 3317 | ||
3318 | if ( incidence && incidence->type() == "Event" ) { | 3318 | if ( incidence && incidence->type() == "Event" ) { |
3319 | Event *event = static_cast<Event *>( incidence ); | 3319 | Event *event = static_cast<Event *>( incidence ); |
3320 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3320 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3321 | emit organizerEventsSelected( true ); | 3321 | emit organizerEventsSelected( true ); |
3322 | } else { | 3322 | } else { |
3323 | emit organizerEventsSelected(false); | 3323 | emit organizerEventsSelected(false); |
3324 | } | 3324 | } |
3325 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3325 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3326 | KOPrefs::instance()->email() ) ) { | 3326 | KOPrefs::instance()->email() ) ) { |
3327 | emit groupEventsSelected( true ); | 3327 | emit groupEventsSelected( true ); |
3328 | } else { | 3328 | } else { |
3329 | emit groupEventsSelected(false); | 3329 | emit groupEventsSelected(false); |
3330 | } | 3330 | } |
3331 | return; | 3331 | return; |
3332 | } else { | 3332 | } else { |
3333 | if ( incidence && incidence->type() == "Todo" ) { | 3333 | if ( incidence && incidence->type() == "Todo" ) { |
3334 | emit todoSelected( true ); | 3334 | emit todoSelected( true ); |
3335 | Todo *event = static_cast<Todo *>( incidence ); | 3335 | Todo *event = static_cast<Todo *>( incidence ); |
3336 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3336 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3337 | emit organizerEventsSelected( true ); | 3337 | emit organizerEventsSelected( true ); |
3338 | } else { | 3338 | } else { |
3339 | emit organizerEventsSelected(false); | 3339 | emit organizerEventsSelected(false); |
3340 | } | 3340 | } |
3341 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3341 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3342 | KOPrefs::instance()->email() ) ) { | 3342 | KOPrefs::instance()->email() ) ) { |
3343 | emit groupEventsSelected( true ); | 3343 | emit groupEventsSelected( true ); |
3344 | } else { | 3344 | } else { |
3345 | emit groupEventsSelected(false); | 3345 | emit groupEventsSelected(false); |
3346 | } | 3346 | } |
3347 | return; | 3347 | return; |
3348 | } else { | 3348 | } else { |
3349 | emit todoSelected( false ); | 3349 | emit todoSelected( false ); |
3350 | emit organizerEventsSelected(false); | 3350 | emit organizerEventsSelected(false); |
3351 | emit groupEventsSelected(false); | 3351 | emit groupEventsSelected(false); |
3352 | } | 3352 | } |
3353 | return; | 3353 | return; |
3354 | } | 3354 | } |
3355 | 3355 | ||
3356 | /* if ( incidence && incidence->type() == "Todo" ) { | 3356 | /* if ( incidence && incidence->type() == "Todo" ) { |
3357 | emit todoSelected( true ); | 3357 | emit todoSelected( true ); |
3358 | } else { | 3358 | } else { |
3359 | emit todoSelected( false ); | 3359 | emit todoSelected( false ); |
3360 | }*/ | 3360 | }*/ |
3361 | } | 3361 | } |
3362 | 3362 | ||
3363 | 3363 | ||
3364 | void CalendarView::checkClipboard() | 3364 | void CalendarView::checkClipboard() |
3365 | { | 3365 | { |
3366 | #ifndef KORG_NODND | 3366 | #ifndef KORG_NODND |
3367 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3367 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3368 | emit pasteEnabled(true); | 3368 | emit pasteEnabled(true); |
3369 | } else { | 3369 | } else { |
3370 | emit pasteEnabled(false); | 3370 | emit pasteEnabled(false); |
3371 | } | 3371 | } |
3372 | #endif | 3372 | #endif |
3373 | } | 3373 | } |
3374 | 3374 | ||
3375 | void CalendarView::showDates(const DateList &selectedDates) | 3375 | void CalendarView::showDates(const DateList &selectedDates) |
3376 | { | 3376 | { |
3377 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3377 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3378 | 3378 | ||
3379 | if ( mViewManager->currentView() ) { | 3379 | if ( mViewManager->currentView() ) { |
3380 | updateView( selectedDates.first(), selectedDates.last() ); | 3380 | updateView( selectedDates.first(), selectedDates.last() ); |
3381 | } else { | 3381 | } else { |
3382 | mViewManager->showAgendaView(); | 3382 | mViewManager->showAgendaView(); |
3383 | } | 3383 | } |
3384 | 3384 | ||
3385 | QString selDates; | 3385 | QString selDates; |
3386 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3386 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3387 | if (selectedDates.first() < selectedDates.last() ) | 3387 | if (selectedDates.first() < selectedDates.last() ) |
3388 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3388 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3389 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3389 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3390 | 3390 | ||
3391 | } | 3391 | } |
3392 | 3392 | ||
3393 | QPtrList<CalFilter> CalendarView::filters() | 3393 | QPtrList<CalFilter> CalendarView::filters() |
3394 | { | 3394 | { |
3395 | return mFilters; | 3395 | return mFilters; |
3396 | 3396 | ||
3397 | } | 3397 | } |
3398 | void CalendarView::editFilters() | 3398 | void CalendarView::editFilters() |
3399 | { | 3399 | { |
3400 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3400 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3401 | 3401 | ||
3402 | CalFilter *filter = mFilters.first(); | 3402 | CalFilter *filter = mFilters.first(); |
3403 | while(filter) { | 3403 | while(filter) { |
3404 | kdDebug() << " Filter: " << filter->name() << endl; | 3404 | kdDebug() << " Filter: " << filter->name() << endl; |
3405 | filter = mFilters.next(); | 3405 | filter = mFilters.next(); |
3406 | } | 3406 | } |
3407 | 3407 | ||
3408 | mDialogManager->showFilterEditDialog(&mFilters); | 3408 | mDialogManager->showFilterEditDialog(&mFilters); |
3409 | } | 3409 | } |
3410 | void CalendarView::toggleFilter() | 3410 | void CalendarView::toggleFilter() |
3411 | { | 3411 | { |
3412 | showFilter(! mFilterView->isVisible()); | 3412 | showFilter(! mFilterView->isVisible()); |
3413 | } | 3413 | } |
3414 | 3414 | ||
3415 | KOFilterView *CalendarView::filterView() | 3415 | KOFilterView *CalendarView::filterView() |
3416 | { | 3416 | { |
3417 | return mFilterView; | 3417 | return mFilterView; |
3418 | } | 3418 | } |
3419 | void CalendarView::selectFilter( int fil ) | 3419 | void CalendarView::selectFilter( int fil ) |
3420 | { | 3420 | { |
3421 | mFilterView->setSelectedFilter( fil ); | 3421 | mFilterView->setSelectedFilter( fil ); |
3422 | } | 3422 | } |
3423 | void CalendarView::showFilter(bool visible) | 3423 | void CalendarView::showFilter(bool visible) |
3424 | { | 3424 | { |
3425 | if (visible) mFilterView->show(); | 3425 | if (visible) mFilterView->show(); |
3426 | else mFilterView->hide(); | 3426 | else mFilterView->hide(); |
3427 | } | 3427 | } |
3428 | void CalendarView::toggleFilerEnabled( ) | 3428 | void CalendarView::toggleFilerEnabled( ) |
3429 | { | 3429 | { |
3430 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3430 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3431 | if ( !mFilterView->filtersEnabled() ) | 3431 | if ( !mFilterView->filtersEnabled() ) |
3432 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3432 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3433 | 3433 | ||
3434 | } | 3434 | } |
3435 | void CalendarView::updateFilter() | 3435 | void CalendarView::updateFilter() |
3436 | { | 3436 | { |
3437 | CalFilter *filter = mFilterView->selectedFilter(); | 3437 | CalFilter *filter = mFilterView->selectedFilter(); |
3438 | if (filter) { | 3438 | if (filter) { |
3439 | if (mFilterView->filtersEnabled()) { | 3439 | if (mFilterView->filtersEnabled()) { |
3440 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3440 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3441 | filter->setEnabled(true); | 3441 | filter->setEnabled(true); |
3442 | } | 3442 | } |
3443 | else filter->setEnabled(false); | 3443 | else filter->setEnabled(false); |
3444 | mCalendar->setFilter(filter); | 3444 | mCalendar->setFilter(filter); |
3445 | updateView(); | 3445 | updateView(); |
3446 | } | 3446 | } |
3447 | } | 3447 | } |
3448 | 3448 | ||
3449 | void CalendarView::filterEdited() | 3449 | void CalendarView::filterEdited() |
3450 | { | 3450 | { |
3451 | mFilterView->updateFilters(); | 3451 | mFilterView->updateFilters(); |
3452 | updateFilter(); | 3452 | updateFilter(); |
3453 | writeSettings(); | 3453 | writeSettings(); |
3454 | } | 3454 | } |
3455 | 3455 | ||
3456 | 3456 | ||
3457 | void CalendarView::takeOverEvent() | 3457 | void CalendarView::takeOverEvent() |
3458 | { | 3458 | { |
3459 | Incidence *incidence = currentSelection(); | 3459 | Incidence *incidence = currentSelection(); |
3460 | 3460 | ||
3461 | if (!incidence) return; | 3461 | if (!incidence) return; |
3462 | 3462 | ||
3463 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3463 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3464 | incidence->recreate(); | 3464 | incidence->recreate(); |
3465 | incidence->setReadOnly(false); | 3465 | incidence->setReadOnly(false); |
3466 | 3466 | ||
3467 | updateView(); | 3467 | updateView(); |
3468 | } | 3468 | } |
3469 | 3469 | ||
3470 | void CalendarView::takeOverCalendar() | 3470 | void CalendarView::takeOverCalendar() |
3471 | { | 3471 | { |
3472 | // TODO: Create Calendar::allIncidences() function and use it here | 3472 | // TODO: Create Calendar::allIncidences() function and use it here |
3473 | 3473 | ||
3474 | QPtrList<Event> events = mCalendar->events(); | 3474 | QPtrList<Event> events = mCalendar->events(); |
3475 | for(uint i=0; i<events.count(); ++i) { | 3475 | for(uint i=0; i<events.count(); ++i) { |
3476 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3476 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3477 | events.at(i)->recreate(); | 3477 | events.at(i)->recreate(); |
3478 | events.at(i)->setReadOnly(false); | 3478 | events.at(i)->setReadOnly(false); |
3479 | } | 3479 | } |
3480 | 3480 | ||
3481 | QPtrList<Todo> todos = mCalendar->todos(); | 3481 | QPtrList<Todo> todos = mCalendar->todos(); |
3482 | for(uint i=0; i<todos.count(); ++i) { | 3482 | for(uint i=0; i<todos.count(); ++i) { |
3483 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3483 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3484 | todos.at(i)->recreate(); | 3484 | todos.at(i)->recreate(); |
3485 | todos.at(i)->setReadOnly(false); | 3485 | todos.at(i)->setReadOnly(false); |
3486 | } | 3486 | } |
3487 | 3487 | ||
3488 | QPtrList<Journal> journals = mCalendar->journals(); | 3488 | QPtrList<Journal> journals = mCalendar->journals(); |
3489 | for(uint i=0; i<journals.count(); ++i) { | 3489 | for(uint i=0; i<journals.count(); ++i) { |
3490 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3490 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3491 | journals.at(i)->recreate(); | 3491 | journals.at(i)->recreate(); |
3492 | journals.at(i)->setReadOnly(false); | 3492 | journals.at(i)->setReadOnly(false); |
3493 | } | 3493 | } |
3494 | 3494 | ||
3495 | updateView(); | 3495 | updateView(); |
3496 | } | 3496 | } |
3497 | 3497 | ||
3498 | void CalendarView::showIntro() | 3498 | void CalendarView::showIntro() |
3499 | { | 3499 | { |
3500 | kdDebug() << "To be implemented." << endl; | 3500 | kdDebug() << "To be implemented." << endl; |
3501 | } | 3501 | } |
3502 | 3502 | ||
3503 | QWidgetStack *CalendarView::viewStack() | 3503 | QWidgetStack *CalendarView::viewStack() |
3504 | { | 3504 | { |
3505 | return mRightFrame; | 3505 | return mRightFrame; |
3506 | } | 3506 | } |
3507 | 3507 | ||
3508 | QWidget *CalendarView::leftFrame() | 3508 | QWidget *CalendarView::leftFrame() |
3509 | { | 3509 | { |
3510 | return mLeftFrame; | 3510 | return mLeftFrame; |
3511 | } | 3511 | } |
3512 | 3512 | ||
3513 | DateNavigator *CalendarView::dateNavigator() | 3513 | DateNavigator *CalendarView::dateNavigator() |
3514 | { | 3514 | { |
3515 | return mNavigator; | 3515 | return mNavigator; |
3516 | } | 3516 | } |
3517 | 3517 | ||
3518 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3518 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3519 | { | 3519 | { |
3520 | return mDateNavigator; | 3520 | return mDateNavigator; |
3521 | } | 3521 | } |
3522 | void CalendarView::toggleDateNavigatorWidget() | 3522 | void CalendarView::toggleDateNavigatorWidget() |
3523 | { | 3523 | { |
3524 | if (mDateNavigator->isVisible()) | 3524 | if (mDateNavigator->isVisible()) |
3525 | mDateNavigator->hide(); | 3525 | mDateNavigator->hide(); |
3526 | else | 3526 | else |
3527 | mDateNavigator->show(); | 3527 | mDateNavigator->show(); |
3528 | } | 3528 | } |
3529 | void CalendarView::addView(KOrg::BaseView *view) | 3529 | void CalendarView::addView(KOrg::BaseView *view) |
3530 | { | 3530 | { |
3531 | mViewManager->addView(view); | 3531 | mViewManager->addView(view); |
3532 | } | 3532 | } |
3533 | 3533 | ||
3534 | void CalendarView::showView(KOrg::BaseView *view) | 3534 | void CalendarView::showView(KOrg::BaseView *view) |
3535 | { | 3535 | { |
3536 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3536 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3537 | } | 3537 | } |
3538 | 3538 | ||
3539 | Incidence *CalendarView::currentSelection() | 3539 | Incidence *CalendarView::currentSelection() |
3540 | { | 3540 | { |
3541 | return mViewManager->currentSelection(); | 3541 | return mViewManager->currentSelection(); |
3542 | } | 3542 | } |
3543 | void CalendarView::toggleAllDaySize() | 3543 | void CalendarView::toggleAllDaySize() |
3544 | { | 3544 | { |
3545 | /* | 3545 | /* |
3546 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3546 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3547 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3547 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3548 | else | 3548 | else |
3549 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3549 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3550 | */ | 3550 | */ |
3551 | viewManager()->agendaView()->toggleAllDay(); | 3551 | viewManager()->agendaView()->toggleAllDay(); |
3552 | } | 3552 | } |
3553 | void CalendarView::toggleExpand() | 3553 | void CalendarView::toggleExpand() |
3554 | { | 3554 | { |
3555 | // if ( mLeftFrame->isHidden() ) { | 3555 | // if ( mLeftFrame->isHidden() ) { |
3556 | // mLeftFrame->show(); | 3556 | // mLeftFrame->show(); |
3557 | // emit calendarViewExpanded( false ); | 3557 | // emit calendarViewExpanded( false ); |
3558 | // } else { | 3558 | // } else { |
3559 | // mLeftFrame->hide(); | 3559 | // mLeftFrame->hide(); |
3560 | // emit calendarViewExpanded( true ); | 3560 | // emit calendarViewExpanded( true ); |
3561 | // } | 3561 | // } |
3562 | 3562 | ||
3563 | globalFlagBlockAgenda = 1; | 3563 | globalFlagBlockAgenda = 1; |
3564 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3564 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3565 | globalFlagBlockAgenda = 5; | 3565 | globalFlagBlockAgenda = 5; |
3566 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3566 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3567 | //mViewManager->showView( 0, true ); | 3567 | //mViewManager->showView( 0, true ); |
3568 | } | 3568 | } |
3569 | 3569 | ||
3570 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3570 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3571 | { | 3571 | { |
3572 | setModified( modified ); | 3572 | setModified( modified ); |
3573 | } | 3573 | } |
3574 | 3574 | ||
3575 | Todo *CalendarView::selectedTodo() | 3575 | Todo *CalendarView::selectedTodo() |
3576 | { | 3576 | { |
3577 | Incidence *incidence = currentSelection(); | 3577 | Incidence *incidence = currentSelection(); |
3578 | if ( incidence && incidence->type() == "Todo" ) { | 3578 | if ( incidence && incidence->type() == "Todo" ) { |
3579 | return static_cast<Todo *>( incidence ); | 3579 | return static_cast<Todo *>( incidence ); |
3580 | } | 3580 | } |
3581 | 3581 | ||
3582 | incidence = mTodoList->selectedIncidences().first(); | 3582 | incidence = mTodoList->selectedIncidences().first(); |
3583 | if ( incidence && incidence->type() == "Todo" ) { | 3583 | if ( incidence && incidence->type() == "Todo" ) { |
3584 | return static_cast<Todo *>( incidence ); | 3584 | return static_cast<Todo *>( incidence ); |
3585 | } | 3585 | } |
3586 | 3586 | ||
3587 | return 0; | 3587 | return 0; |
3588 | } | 3588 | } |
3589 | 3589 | ||
3590 | void CalendarView::dialogClosing(Incidence *in) | 3590 | void CalendarView::dialogClosing(Incidence *in) |
3591 | { | 3591 | { |
3592 | // mDialogList.remove(in); | 3592 | // mDialogList.remove(in); |
3593 | } | 3593 | } |
3594 | 3594 | ||
3595 | void CalendarView::showIncidence() | 3595 | void CalendarView::showIncidence() |
3596 | { | 3596 | { |
3597 | Incidence *incidence = currentSelection(); | 3597 | Incidence *incidence = currentSelection(); |
3598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3599 | if ( incidence ) { | 3599 | if ( incidence ) { |
3600 | ShowIncidenceVisitor v; | 3600 | ShowIncidenceVisitor v; |
3601 | v.act( incidence, this ); | 3601 | v.act( incidence, this ); |
3602 | } | 3602 | } |
3603 | } | 3603 | } |
3604 | void CalendarView::editIncidenceDescription() | 3604 | void CalendarView::editIncidenceDescription() |
3605 | { | 3605 | { |
3606 | mFlagEditDescription = true; | 3606 | mFlagEditDescription = true; |
3607 | editIncidence(); | 3607 | editIncidence(); |
3608 | mFlagEditDescription = false; | 3608 | mFlagEditDescription = false; |
3609 | } | 3609 | } |
3610 | void CalendarView::editIncidence() | 3610 | void CalendarView::editIncidence() |
3611 | { | 3611 | { |
3612 | // qDebug("editIncidence() "); | 3612 | // qDebug("editIncidence() "); |
3613 | Incidence *incidence = currentSelection(); | 3613 | Incidence *incidence = currentSelection(); |
3614 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3614 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3615 | if ( incidence ) { | 3615 | if ( incidence ) { |
3616 | EditIncidenceVisitor v; | 3616 | EditIncidenceVisitor v; |
3617 | v.act( incidence, this ); | 3617 | v.act( incidence, this ); |
3618 | } | 3618 | } |
3619 | } | 3619 | } |
3620 | 3620 | ||
3621 | void CalendarView::deleteIncidence() | 3621 | void CalendarView::deleteIncidence() |
3622 | { | 3622 | { |
3623 | Incidence *incidence = currentSelection(); | 3623 | Incidence *incidence = currentSelection(); |
3624 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3624 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3625 | if ( incidence ) { | 3625 | if ( incidence ) { |
3626 | deleteIncidence(incidence); | 3626 | deleteIncidence(incidence); |
3627 | } | 3627 | } |
3628 | } | 3628 | } |
3629 | 3629 | ||
3630 | void CalendarView::showIncidence(Incidence *incidence) | 3630 | void CalendarView::showIncidence(Incidence *incidence) |
3631 | { | 3631 | { |
3632 | if ( incidence ) { | 3632 | if ( incidence ) { |
3633 | ShowIncidenceVisitor v; | 3633 | ShowIncidenceVisitor v; |
3634 | v.act( incidence, this ); | 3634 | v.act( incidence, this ); |
3635 | } | 3635 | } |
3636 | } | 3636 | } |
3637 | 3637 | ||
3638 | void CalendarView::editIncidence(Incidence *incidence) | 3638 | void CalendarView::editIncidence(Incidence *incidence) |
3639 | { | 3639 | { |
3640 | if ( incidence ) { | 3640 | if ( incidence ) { |
3641 | 3641 | ||
3642 | EditIncidenceVisitor v; | 3642 | EditIncidenceVisitor v; |
3643 | v.act( incidence, this ); | 3643 | v.act( incidence, this ); |
3644 | 3644 | ||
3645 | } | 3645 | } |
3646 | } | 3646 | } |
3647 | 3647 | ||
3648 | void CalendarView::deleteIncidence(Incidence *incidence) | 3648 | void CalendarView::deleteIncidence(Incidence *incidence) |
3649 | { | 3649 | { |
3650 | //qDebug(" CalendarView::deleteIncidence "); | 3650 | //qDebug(" CalendarView::deleteIncidence "); |
3651 | if ( incidence ) { | 3651 | if ( incidence ) { |
3652 | DeleteIncidenceVisitor v; | 3652 | DeleteIncidenceVisitor v; |
3653 | v.act( incidence, this ); | 3653 | v.act( incidence, this ); |
3654 | } | 3654 | } |
3655 | } | 3655 | } |
3656 | 3656 | ||
3657 | 3657 | ||
3658 | void CalendarView::lookForOutgoingMessages() | 3658 | void CalendarView::lookForOutgoingMessages() |
3659 | { | 3659 | { |
3660 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3660 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3661 | ogd->loadMessages(); | 3661 | ogd->loadMessages(); |
3662 | } | 3662 | } |
3663 | 3663 | ||
3664 | void CalendarView::lookForIncomingMessages() | 3664 | void CalendarView::lookForIncomingMessages() |
3665 | { | 3665 | { |
3666 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3666 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3667 | icd->retrieve(); | 3667 | icd->retrieve(); |
3668 | } | 3668 | } |
3669 | 3669 | ||
3670 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3670 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3671 | { | 3671 | { |
3672 | bool deleteTodo = true; | 3672 | bool deleteTodo = true; |
3673 | QPtrList<Incidence> subTodos; | 3673 | QPtrList<Incidence> subTodos; |
3674 | Incidence *aTodo; | 3674 | Incidence *aTodo; |
3675 | subTodos = t->relations(); | 3675 | subTodos = t->relations(); |
3676 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3676 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3677 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3677 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3678 | deleteTodo = false; | 3678 | deleteTodo = false; |
3679 | } | 3679 | } |
3680 | if ( deleteTodo ) { | 3680 | if ( deleteTodo ) { |
3681 | if ( t->isCompleted() ) { | 3681 | if ( t->isCompleted() ) { |
3682 | checkExternalId( t ); | 3682 | checkExternalId( t ); |
3683 | mCalendar->deleteTodo( t ); | 3683 | mCalendar->deleteTodo( t ); |
3684 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3684 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3685 | } | 3685 | } |
3686 | else | 3686 | else |
3687 | deleteTodo = false; | 3687 | deleteTodo = false; |
3688 | } | 3688 | } |
3689 | return deleteTodo; | 3689 | return deleteTodo; |
3690 | 3690 | ||
3691 | } | 3691 | } |
3692 | void CalendarView::purgeCompleted() | 3692 | void CalendarView::purgeCompleted() |
3693 | { | 3693 | { |
3694 | int result = KMessageBox::warningContinueCancel(this, | 3694 | int result = KMessageBox::warningContinueCancel(this, |
3695 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3695 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3696 | 3696 | ||
3697 | if (result == KMessageBox::Continue) { | 3697 | if (result == KMessageBox::Continue) { |
3698 | 3698 | ||
3699 | QPtrList<Todo> todoCal; | 3699 | QPtrList<Todo> todoCal; |
3700 | QPtrList<Todo> rootTodos; | 3700 | QPtrList<Todo> rootTodos; |
3701 | //QPtrList<Incidence> rel; | 3701 | //QPtrList<Incidence> rel; |
3702 | Todo *aTodo;//, *rTodo; | 3702 | Todo *aTodo;//, *rTodo; |
3703 | Incidence *rIncidence; | 3703 | Incidence *rIncidence; |
3704 | bool childDelete = false; | 3704 | bool childDelete = false; |
3705 | bool deletedOne = true; | 3705 | bool deletedOne = true; |
3706 | todoCal = calendar()->todos(); | 3706 | todoCal = calendar()->todos(); |
3707 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3707 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3708 | if ( !aTodo->relatedTo() ) | 3708 | if ( !aTodo->relatedTo() ) |
3709 | rootTodos.append( aTodo ); | 3709 | rootTodos.append( aTodo ); |
3710 | } | 3710 | } |
3711 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3711 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3712 | removeCompletedSubTodos( aTodo ); | 3712 | removeCompletedSubTodos( aTodo ); |
3713 | } | 3713 | } |
3714 | 3714 | ||
3715 | updateView(); | 3715 | updateView(); |
3716 | } | 3716 | } |
3717 | } | 3717 | } |
3718 | 3718 | ||
3719 | void CalendarView::slotCalendarChanged() | 3719 | void CalendarView::slotCalendarChanged() |
3720 | { | 3720 | { |
3721 | ; | 3721 | ; |
3722 | } | 3722 | } |
3723 | 3723 | ||
3724 | NavigatorBar *CalendarView::navigatorBar() | 3724 | NavigatorBar *CalendarView::navigatorBar() |
3725 | { | 3725 | { |
3726 | return mNavigatorBar; | 3726 | return mNavigatorBar; |
3727 | } | 3727 | } |
3728 | 3728 | ||
3729 | 3729 | ||
3730 | 3730 | ||
3731 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3731 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3732 | { | 3732 | { |
3733 | //qDebug(" alendarView::keyPressEvent "); | 3733 | //qDebug(" alendarView::keyPressEvent "); |
3734 | e->ignore(); | 3734 | e->ignore(); |
3735 | } | 3735 | } |
3736 | 3736 | ||
3737 | 3737 | ||
3738 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3738 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3739 | { | 3739 | { |
3740 | // mSyncManager = manager; | 3740 | // mSyncManager = manager; |
3741 | mSyncKDE = false; | 3741 | mSyncKDE = false; |
3742 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3742 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3743 | qDebug("SyncKDE request detected!"); | 3743 | qDebug("SyncKDE request detected!"); |
3744 | mSyncKDE = true; | 3744 | mSyncKDE = true; |
3745 | } | 3745 | } |
3746 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3746 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3747 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3747 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3748 | return syncCalendar( filename, mode ); | 3748 | return syncCalendar( filename, mode ); |
3749 | } | 3749 | } |
3750 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3750 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3751 | { | 3751 | { |
3752 | mSyncKDE = false; | 3752 | mSyncKDE = false; |
3753 | //mSyncManager = manager; | 3753 | //mSyncManager = manager; |
3754 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3754 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3755 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3755 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3756 | if ( resource == "sharp" ) | 3756 | if ( resource == "sharp" ) |
3757 | syncExternal( 0 ); | 3757 | syncExternal( 0 ); |
3758 | if ( resource == "phone" ) | 3758 | if ( resource == "phone" ) |
3759 | syncExternal( 1 ); | 3759 | syncExternal( 1 ); |
3760 | // pending setmodified | 3760 | // pending setmodified |
3761 | return true; | 3761 | return true; |
3762 | } | 3762 | } |
3763 | void CalendarView::setSyncManager(KSyncManager* manager) | 3763 | void CalendarView::setSyncManager(KSyncManager* manager) |
3764 | { | 3764 | { |
3765 | mSyncManager = manager; | 3765 | mSyncManager = manager; |
3766 | } | 3766 | } |
3767 | 3767 | ||
3768 | void CalendarView::removeSyncInfo( QString syncProfile) | 3768 | void CalendarView::removeSyncInfo( QString syncProfile) |
3769 | { | 3769 | { |
3770 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3770 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3771 | mCalendar->removeSyncInfo( syncProfile ); | ||
3771 | 3772 | ||
3772 | } | 3773 | } |