summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-07 07:59:05 (UTC)
committer zautrix <zautrix>2004-10-07 07:59:05 (UTC)
commitf1699230250cdfb37216121257196b5be9f094fa (patch) (unidiff)
treee6bf9c6a3814e9a5ee617a726266489aa820bb9c
parent77280f6a176a15b60004f312e6cacdfbbd3909c1 (diff)
downloadkdepimpi-f1699230250cdfb37216121257196b5be9f094fa.zip
kdepimpi-f1699230250cdfb37216121257196b5be9f094fa.tar.gz
kdepimpi-f1699230250cdfb37216121257196b5be9f094fa.tar.bz2
Fixed debug messages
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp63
1 files changed, 32 insertions, 31 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b3b4cdb..d71ea08 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -659,1570 +659,1571 @@ void CalendarView::selectWeekNum ( int num )
659 dateNavigator()->selectWeek( num ); 659 dateNavigator()->selectWeek( num );
660 mViewManager->showWeekView(); 660 mViewManager->showWeekView();
661} 661}
662KOViewManager *CalendarView::viewManager() 662KOViewManager *CalendarView::viewManager()
663{ 663{
664 return mViewManager; 664 return mViewManager;
665} 665}
666 666
667KODialogManager *CalendarView::dialogManager() 667KODialogManager *CalendarView::dialogManager()
668{ 668{
669 return mDialogManager; 669 return mDialogManager;
670} 670}
671 671
672QDate CalendarView::startDate() 672QDate CalendarView::startDate()
673{ 673{
674 DateList dates = mNavigator->selectedDates(); 674 DateList dates = mNavigator->selectedDates();
675 675
676 return dates.first(); 676 return dates.first();
677} 677}
678 678
679QDate CalendarView::endDate() 679QDate CalendarView::endDate()
680{ 680{
681 DateList dates = mNavigator->selectedDates(); 681 DateList dates = mNavigator->selectedDates();
682 682
683 return dates.last(); 683 return dates.last();
684} 684}
685 685
686 686
687void CalendarView::createPrinter() 687void CalendarView::createPrinter()
688{ 688{
689#ifndef KORG_NOPRINTER 689#ifndef KORG_NOPRINTER
690 if (!mCalPrinter) { 690 if (!mCalPrinter) {
691 mCalPrinter = new CalPrinter(this, mCalendar); 691 mCalPrinter = new CalPrinter(this, mCalendar);
692 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 692 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
693 } 693 }
694#endif 694#endif
695} 695}
696 696
697void CalendarView::confSync() 697void CalendarView::confSync()
698{ 698{
699 static KSyncPrefsDialog* sp = 0; 699 static KSyncPrefsDialog* sp = 0;
700 if ( ! sp ) { 700 if ( ! sp ) {
701 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 701 sp = new KSyncPrefsDialog( this, "syncprefs", true );
702 } 702 }
703 sp->usrReadConfig(); 703 sp->usrReadConfig();
704#ifndef DESKTOP_VERSION 704#ifndef DESKTOP_VERSION
705 sp->showMaximized(); 705 sp->showMaximized();
706#else 706#else
707 sp->show(); 707 sp->show();
708#endif 708#endif
709 sp->exec(); 709 sp->exec();
710 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 710 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
711 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 711 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
712} 712}
713 713
714 714
715//KOPrefs::instance()->mWriteBackFile 715//KOPrefs::instance()->mWriteBackFile
716//KOPrefs::instance()->mWriteBackExistingOnly 716//KOPrefs::instance()->mWriteBackExistingOnly
717 717
718// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 718// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
719// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 719// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
720// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 720// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
721// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 721// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
722// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 722// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
723// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 723// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
724 724
725int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 725int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
726{ 726{
727 727
728 //void setZaurusId(int id); 728 //void setZaurusId(int id);
729 // int zaurusId() const; 729 // int zaurusId() const;
730 // void setZaurusUid(int id); 730 // void setZaurusUid(int id);
731 // int zaurusUid() const; 731 // int zaurusUid() const;
732 // void setZaurusStat(int id); 732 // void setZaurusStat(int id);
733 // int zaurusStat() const; 733 // int zaurusStat() const;
734 // 0 equal 734 // 0 equal
735 // 1 take local 735 // 1 take local
736 // 2 take remote 736 // 2 take remote
737 // 3 cancel 737 // 3 cancel
738 QDateTime lastSync = mLastCalendarSync; 738 QDateTime lastSync = mLastCalendarSync;
739 QDateTime localMod = local->lastModified(); 739 QDateTime localMod = local->lastModified();
740 QDateTime remoteMod = remote->lastModified(); 740 QDateTime remoteMod = remote->lastModified();
741 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 741 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
742 bool remCh, locCh; 742 bool remCh, locCh;
743 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 743 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
744 //if ( remCh ) 744 //if ( remCh )
745 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 745 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
746 locCh = ( localMod > mLastCalendarSync ); 746 locCh = ( localMod > mLastCalendarSync );
747 if ( !remCh && ! locCh ) { 747 if ( !remCh && ! locCh ) {
748 //qDebug("both not changed "); 748 //qDebug("both not changed ");
749 lastSync = localMod.addDays(1); 749 lastSync = localMod.addDays(1);
750 if ( mode <= SYNC_PREF_ASK ) 750 if ( mode <= SYNC_PREF_ASK )
751 return 0; 751 return 0;
752 } else { 752 } else {
753 if ( locCh ) { 753 if ( locCh ) {
754 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 754 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
755 lastSync = localMod.addDays( -1 ); 755 lastSync = localMod.addDays( -1 );
756 if ( !remCh ) 756 if ( !remCh )
757 remoteMod = ( lastSync.addDays( -1 ) ); 757 remoteMod = ( lastSync.addDays( -1 ) );
758 } else { 758 } else {
759 //qDebug(" not loc changed "); 759 //qDebug(" not loc changed ");
760 lastSync = localMod.addDays( 1 ); 760 lastSync = localMod.addDays( 1 );
761 if ( remCh ) 761 if ( remCh )
762 remoteMod =( lastSync.addDays( 1 ) ); 762 remoteMod =( lastSync.addDays( 1 ) );
763 763
764 } 764 }
765 } 765 }
766 full = true; 766 full = true;
767 if ( mode < SYNC_PREF_ASK ) 767 if ( mode < SYNC_PREF_ASK )
768 mode = SYNC_PREF_ASK; 768 mode = SYNC_PREF_ASK;
769 } else { 769 } else {
770 if ( localMod == remoteMod ) 770 if ( localMod == remoteMod )
771 if ( local->revision() == remote->revision() ) 771 if ( local->revision() == remote->revision() )
772 return 0; 772 return 0;
773 773
774 } 774 }
775 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 775 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
776 776
777 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 777 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
778 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 778 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
779 //full = true; //debug only 779 //full = true; //debug only
780 if ( full ) { 780 if ( full ) {
781 bool equ = false; 781 bool equ = false;
782 if ( local->type() == "Event" ) { 782 if ( local->type() == "Event" ) {
783 equ = (*((Event*) local) == *((Event*) remote)); 783 equ = (*((Event*) local) == *((Event*) remote));
784 } 784 }
785 else if ( local->type() =="Todo" ) 785 else if ( local->type() =="Todo" )
786 equ = (*((Todo*) local) == (*(Todo*) remote)); 786 equ = (*((Todo*) local) == (*(Todo*) remote));
787 else if ( local->type() =="Journal" ) 787 else if ( local->type() =="Journal" )
788 equ = (*((Journal*) local) == *((Journal*) remote)); 788 equ = (*((Journal*) local) == *((Journal*) remote));
789 if ( equ ) { 789 if ( equ ) {
790 //qDebug("equal "); 790 //qDebug("equal ");
791 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 791 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
792 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 792 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
793 } 793 }
794 if ( mode < SYNC_PREF_FORCE_LOCAL ) 794 if ( mode < SYNC_PREF_FORCE_LOCAL )
795 return 0; 795 return 0;
796 796
797 }//else //debug only 797 }//else //debug only
798 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 798 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
799 } 799 }
800 int result; 800 int result;
801 bool localIsNew; 801 bool localIsNew;
802 //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() ); 802 //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() );
803 803
804 if ( full && mode < SYNC_PREF_NEWEST ) 804 if ( full && mode < SYNC_PREF_NEWEST )
805 mode = SYNC_PREF_ASK; 805 mode = SYNC_PREF_ASK;
806 806
807 switch( mode ) { 807 switch( mode ) {
808 case SYNC_PREF_LOCAL: 808 case SYNC_PREF_LOCAL:
809 if ( lastSync > remoteMod ) 809 if ( lastSync > remoteMod )
810 return 1; 810 return 1;
811 if ( lastSync > localMod ) 811 if ( lastSync > localMod )
812 return 2; 812 return 2;
813 return 1; 813 return 1;
814 break; 814 break;
815 case SYNC_PREF_REMOTE: 815 case SYNC_PREF_REMOTE:
816 if ( lastSync > remoteMod ) 816 if ( lastSync > remoteMod )
817 return 1; 817 return 1;
818 if ( lastSync > localMod ) 818 if ( lastSync > localMod )
819 return 2; 819 return 2;
820 return 2; 820 return 2;
821 break; 821 break;
822 case SYNC_PREF_NEWEST: 822 case SYNC_PREF_NEWEST:
823 if ( localMod > remoteMod ) 823 if ( localMod > remoteMod )
824 return 1; 824 return 1;
825 else 825 else
826 return 2; 826 return 2;
827 break; 827 break;
828 case SYNC_PREF_ASK: 828 case SYNC_PREF_ASK:
829 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 829 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
830 if ( lastSync > remoteMod ) 830 if ( lastSync > remoteMod )
831 return 1; 831 return 1;
832 if ( lastSync > localMod ) 832 if ( lastSync > localMod )
833 return 2; 833 return 2;
834 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 834 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
835 localIsNew = localMod >= remoteMod; 835 localIsNew = localMod >= remoteMod;
836 if ( localIsNew ) 836 if ( localIsNew )
837 getEventViewerDialog()->setColorMode( 1 ); 837 getEventViewerDialog()->setColorMode( 1 );
838 else 838 else
839 getEventViewerDialog()->setColorMode( 2 ); 839 getEventViewerDialog()->setColorMode( 2 );
840 getEventViewerDialog()->setIncidence(local); 840 getEventViewerDialog()->setIncidence(local);
841 if ( localIsNew ) 841 if ( localIsNew )
842 getEventViewerDialog()->setColorMode( 2 ); 842 getEventViewerDialog()->setColorMode( 2 );
843 else 843 else
844 getEventViewerDialog()->setColorMode( 1 ); 844 getEventViewerDialog()->setColorMode( 1 );
845 getEventViewerDialog()->addIncidence(remote); 845 getEventViewerDialog()->addIncidence(remote);
846 getEventViewerDialog()->setColorMode( 0 ); 846 getEventViewerDialog()->setColorMode( 0 );
847 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 847 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
848 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 848 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
849 getEventViewerDialog()->showMe(); 849 getEventViewerDialog()->showMe();
850 result = getEventViewerDialog()->executeS( localIsNew ); 850 result = getEventViewerDialog()->executeS( localIsNew );
851 return result; 851 return result;
852 852
853 break; 853 break;
854 case SYNC_PREF_FORCE_LOCAL: 854 case SYNC_PREF_FORCE_LOCAL:
855 return 1; 855 return 1;
856 break; 856 break;
857 case SYNC_PREF_FORCE_REMOTE: 857 case SYNC_PREF_FORCE_REMOTE:
858 return 2; 858 return 2;
859 break; 859 break;
860 860
861 default: 861 default:
862 // SYNC_PREF_TAKE_BOTH not implemented 862 // SYNC_PREF_TAKE_BOTH not implemented
863 break; 863 break;
864 } 864 }
865 return 0; 865 return 0;
866} 866}
867Event* CalendarView::getLastSyncEvent() 867Event* CalendarView::getLastSyncEvent()
868{ 868{
869 Event* lse; 869 Event* lse;
870 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 870 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
871 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 871 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
872 if (!lse) { 872 if (!lse) {
873 lse = new Event(); 873 lse = new Event();
874 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 874 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
875 QString sum = ""; 875 QString sum = "";
876 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 876 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
877 sum = "E: "; 877 sum = "E: ";
878 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 878 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
879 lse->setDtStart( mLastCalendarSync ); 879 lse->setDtStart( mLastCalendarSync );
880 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 880 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
881 lse->setCategories( i18n("SyncEvent") ); 881 lse->setCategories( i18n("SyncEvent") );
882 lse->setReadOnly( true ); 882 lse->setReadOnly( true );
883 mCalendar->addEvent( lse ); 883 mCalendar->addEvent( lse );
884 } 884 }
885 885
886 return lse; 886 return lse;
887 887
888} 888}
889 889
890// we check, if the to delete event has a id for a profile 890// we check, if the to delete event has a id for a profile
891// if yes, we set this id in the profile to delete 891// if yes, we set this id in the profile to delete
892void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 892void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
893{ 893{
894 if ( lastSync.count() == 0 ) { 894 if ( lastSync.count() == 0 ) {
895 //qDebug(" lastSync.count() == 0"); 895 //qDebug(" lastSync.count() == 0");
896 return; 896 return;
897 } 897 }
898 if ( toDelete->type() == "Journal" ) 898 if ( toDelete->type() == "Journal" )
899 return; 899 return;
900 900
901 Event* eve = lastSync.first(); 901 Event* eve = lastSync.first();
902 902
903 while ( eve ) { 903 while ( eve ) {
904 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 904 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
905 if ( !id.isEmpty() ) { 905 if ( !id.isEmpty() ) {
906 QString des = eve->description(); 906 QString des = eve->description();
907 QString pref = "e"; 907 QString pref = "e";
908 if ( toDelete->type() == "Todo" ) 908 if ( toDelete->type() == "Todo" )
909 pref = "t"; 909 pref = "t";
910 des += pref+ id + ","; 910 des += pref+ id + ",";
911 eve->setReadOnly( false ); 911 eve->setReadOnly( false );
912 eve->setDescription( des ); 912 eve->setDescription( des );
913 //qDebug("setdes %s ", des.latin1()); 913 //qDebug("setdes %s ", des.latin1());
914 eve->setReadOnly( true ); 914 eve->setReadOnly( true );
915 } 915 }
916 eve = lastSync.next(); 916 eve = lastSync.next();
917 } 917 }
918 918
919} 919}
920void CalendarView::checkExternalId( Incidence * inc ) 920void CalendarView::checkExternalId( Incidence * inc )
921{ 921{
922 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 922 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
923 checkExternSyncEvent( lastSync, inc ); 923 checkExternSyncEvent( lastSync, inc );
924 924
925} 925}
926bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 926bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
927{ 927{
928 bool syncOK = true; 928 bool syncOK = true;
929 int addedEvent = 0; 929 int addedEvent = 0;
930 int addedEventR = 0; 930 int addedEventR = 0;
931 int deletedEventR = 0; 931 int deletedEventR = 0;
932 int deletedEventL = 0; 932 int deletedEventL = 0;
933 int changedLocal = 0; 933 int changedLocal = 0;
934 int changedRemote = 0; 934 int changedRemote = 0;
935 //QPtrList<Event> el = local->rawEvents(); 935 //QPtrList<Event> el = local->rawEvents();
936 Event* eventR; 936 Event* eventR;
937 QString uid; 937 QString uid;
938 int take; 938 int take;
939 Event* eventL; 939 Event* eventL;
940 Event* eventRSync; 940 Event* eventRSync;
941 Event* eventLSync; 941 Event* eventLSync;
942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
944 bool fullDateRange = false; 944 bool fullDateRange = false;
945 local->resetTempSyncStat(); 945 local->resetTempSyncStat();
946 mLastCalendarSync = QDateTime::currentDateTime(); 946 mLastCalendarSync = QDateTime::currentDateTime();
947 QDateTime modifiedCalendar = mLastCalendarSync;; 947 QDateTime modifiedCalendar = mLastCalendarSync;;
948 eventLSync = getLastSyncEvent(); 948 eventLSync = getLastSyncEvent();
949 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 949 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
950 if ( eventR ) { 950 if ( eventR ) {
951 eventRSync = (Event*) eventR->clone(); 951 eventRSync = (Event*) eventR->clone();
952 remote->deleteEvent(eventR ); 952 remote->deleteEvent(eventR );
953 953
954 } else { 954 } else {
955 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 955 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
956 eventRSync = (Event*)eventLSync->clone(); 956 eventRSync = (Event*)eventLSync->clone();
957 } else { 957 } else {
958 fullDateRange = true; 958 fullDateRange = true;
959 eventRSync = new Event(); 959 eventRSync = new Event();
960 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 960 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
961 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 961 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
962 eventRSync->setDtStart( mLastCalendarSync ); 962 eventRSync->setDtStart( mLastCalendarSync );
963 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 963 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
964 eventRSync->setCategories( i18n("SyncEvent") ); 964 eventRSync->setCategories( i18n("SyncEvent") );
965 } 965 }
966 } 966 }
967 if ( eventLSync->dtStart() == mLastCalendarSync ) 967 if ( eventLSync->dtStart() == mLastCalendarSync )
968 fullDateRange = true; 968 fullDateRange = true;
969 969
970 if ( ! fullDateRange ) { 970 if ( ! fullDateRange ) {
971 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 971 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
972 972
973 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 973 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
974 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 974 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
975 fullDateRange = true; 975 fullDateRange = true;
976 } 976 }
977 } 977 }
978 if ( fullDateRange ) 978 if ( fullDateRange )
979 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 979 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
980 else 980 else
981 mLastCalendarSync = eventLSync->dtStart(); 981 mLastCalendarSync = eventLSync->dtStart();
982 // for resyncing if own file has changed 982 // for resyncing if own file has changed
983 if ( mCurrentSyncDevice == "deleteaftersync" ) { 983 if ( mCurrentSyncDevice == "deleteaftersync" ) {
984 mLastCalendarSync = loadedFileVersion; 984 mLastCalendarSync = loadedFileVersion;
985 qDebug("setting mLastCalendarSync "); 985 qDebug("setting mLastCalendarSync ");
986 } 986 }
987 //qDebug("*************************** "); 987 //qDebug("*************************** ");
988 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 988 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
989 QPtrList<Incidence> er = remote->rawIncidences(); 989 QPtrList<Incidence> er = remote->rawIncidences();
990 Incidence* inR = er.first(); 990 Incidence* inR = er.first();
991 Incidence* inL; 991 Incidence* inL;
992 QProgressBar bar( er.count(),0 ); 992 QProgressBar bar( er.count(),0 );
993 bar.setCaption (i18n("Syncing - close to abort!") ); 993 bar.setCaption (i18n("Syncing - close to abort!") );
994 994
995 int w = 300; 995 int w = 300;
996 if ( QApplication::desktop()->width() < 320 ) 996 if ( QApplication::desktop()->width() < 320 )
997 w = 220; 997 w = 220;
998 int h = bar.sizeHint().height() ; 998 int h = bar.sizeHint().height() ;
999 int dw = QApplication::desktop()->width(); 999 int dw = QApplication::desktop()->width();
1000 int dh = QApplication::desktop()->height(); 1000 int dh = QApplication::desktop()->height();
1001 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1001 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1002 bar.show(); 1002 bar.show();
1003 int modulo = (er.count()/10)+1; 1003 int modulo = (er.count()/10)+1;
1004 int incCounter = 0; 1004 int incCounter = 0;
1005 while ( inR ) { 1005 while ( inR ) {
1006 if ( ! bar.isVisible() ) 1006 if ( ! bar.isVisible() )
1007 return false; 1007 return false;
1008 if ( incCounter % modulo == 0 ) 1008 if ( incCounter % modulo == 0 )
1009 bar.setProgress( incCounter ); 1009 bar.setProgress( incCounter );
1010 ++incCounter; 1010 ++incCounter;
1011 uid = inR->uid(); 1011 uid = inR->uid();
1012 bool skipIncidence = false; 1012 bool skipIncidence = false;
1013 if ( uid.left(15) == QString("last-syncEvent-") ) 1013 if ( uid.left(15) == QString("last-syncEvent-") )
1014 skipIncidence = true; 1014 skipIncidence = true;
1015 QString idS; 1015 QString idS;
1016 qApp->processEvents(); 1016 qApp->processEvents();
1017 if ( !skipIncidence ) { 1017 if ( !skipIncidence ) {
1018 inL = local->incidence( uid ); 1018 inL = local->incidence( uid );
1019 if ( inL ) { // maybe conflict - same uid in both calendars 1019 if ( inL ) { // maybe conflict - same uid in both calendars
1020 int maxrev = inL->revision(); 1020 int maxrev = inL->revision();
1021 if ( maxrev < inR->revision() ) 1021 if ( maxrev < inR->revision() )
1022 maxrev = inR->revision(); 1022 maxrev = inR->revision();
1023 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1023 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1024 //qDebug("take %d %s ", take, inL->summary().latin1()); 1024 //qDebug("take %d %s ", take, inL->summary().latin1());
1025 if ( take == 3 ) 1025 if ( take == 3 )
1026 return false; 1026 return false;
1027 if ( take == 1 ) {// take local 1027 if ( take == 1 ) {// take local
1028 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1028 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1029 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1029 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1030 else 1030 else
1031 idS = inR->IDStr(); 1031 idS = inR->IDStr();
1032 remote->deleteIncidence( inR ); 1032 remote->deleteIncidence( inR );
1033 if ( inL->revision() < maxrev ) 1033 if ( inL->revision() < maxrev )
1034 inL->setRevision( maxrev ); 1034 inL->setRevision( maxrev );
1035 inR = inL->clone(); 1035 inR = inL->clone();
1036 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1036 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1037 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1037 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1038 inR->setIDStr( idS ); 1038 inR->setIDStr( idS );
1039 remote->addIncidence( inR ); 1039 remote->addIncidence( inR );
1040 ++changedRemote; 1040 ++changedRemote;
1041 } else { 1041 } else {
1042 if ( inR->revision() < maxrev ) 1042 if ( inR->revision() < maxrev )
1043 inR->setRevision( maxrev ); 1043 inR->setRevision( maxrev );
1044 idS = inL->IDStr(); 1044 idS = inL->IDStr();
1045 local->deleteIncidence( inL ); 1045 local->deleteIncidence( inL );
1046 inL = inR->clone(); 1046 inL = inR->clone();
1047 inL->setIDStr( idS ); 1047 inL->setIDStr( idS );
1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1050 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1050 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1051 } 1051 }
1052 local->addIncidence( inL ); 1052 local->addIncidence( inL );
1053 ++changedLocal; 1053 ++changedLocal;
1054 } 1054 }
1055 } 1055 }
1056 } else { // no conflict 1056 } else { // no conflict
1057 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1057 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1058 QString des = eventLSync->description(); 1058 QString des = eventLSync->description();
1059 QString pref = "e"; 1059 QString pref = "e";
1060 if ( inR->type() == "Todo" ) 1060 if ( inR->type() == "Todo" )
1061 pref = "t"; 1061 pref = "t";
1062 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1062 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1063 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1063 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1064 //remote->deleteIncidence( inR ); 1064 //remote->deleteIncidence( inR );
1065 ++deletedEventR; 1065 ++deletedEventR;
1066 } else { 1066 } else {
1067 inR->setLastModified( modifiedCalendar ); 1067 inR->setLastModified( modifiedCalendar );
1068 inL = inR->clone(); 1068 inL = inR->clone();
1069 local->addIncidence( inL ); 1069 local->addIncidence( inL );
1070 ++addedEvent; 1070 ++addedEvent;
1071 } 1071 }
1072 } else { 1072 } else {
1073 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1073 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1074 inR->setLastModified( modifiedCalendar ); 1074 inR->setLastModified( modifiedCalendar );
1075 local->addIncidence( inR->clone() ); 1075 local->addIncidence( inR->clone() );
1076 ++addedEvent; 1076 ++addedEvent;
1077 } else { 1077 } else {
1078 checkExternSyncEvent(eventRSyncSharp, inR); 1078 checkExternSyncEvent(eventRSyncSharp, inR);
1079 remote->deleteIncidence( inR ); 1079 remote->deleteIncidence( inR );
1080 ++deletedEventR; 1080 ++deletedEventR;
1081 } 1081 }
1082 } 1082 }
1083 } 1083 }
1084 } 1084 }
1085 inR = er.next(); 1085 inR = er.next();
1086 } 1086 }
1087 QPtrList<Incidence> el = local->rawIncidences(); 1087 QPtrList<Incidence> el = local->rawIncidences();
1088 inL = el.first(); 1088 inL = el.first();
1089 modulo = (el.count()/10)+1; 1089 modulo = (el.count()/10)+1;
1090 bar.setCaption (i18n("Add / remove events") ); 1090 bar.setCaption (i18n("Add / remove events") );
1091 bar.setTotalSteps ( el.count() ) ; 1091 bar.setTotalSteps ( el.count() ) ;
1092 bar.show(); 1092 bar.show();
1093 incCounter = 0; 1093 incCounter = 0;
1094 1094
1095 while ( inL ) { 1095 while ( inL ) {
1096 1096
1097 qApp->processEvents(); 1097 qApp->processEvents();
1098 if ( ! bar.isVisible() ) 1098 if ( ! bar.isVisible() )
1099 return false; 1099 return false;
1100 if ( incCounter % modulo == 0 ) 1100 if ( incCounter % modulo == 0 )
1101 bar.setProgress( incCounter ); 1101 bar.setProgress( incCounter );
1102 ++incCounter; 1102 ++incCounter;
1103 uid = inL->uid(); 1103 uid = inL->uid();
1104 bool skipIncidence = false; 1104 bool skipIncidence = false;
1105 if ( uid.left(15) == QString("last-syncEvent-") ) 1105 if ( uid.left(15) == QString("last-syncEvent-") )
1106 skipIncidence = true; 1106 skipIncidence = true;
1107 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1107 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1108 skipIncidence = true; 1108 skipIncidence = true;
1109 if ( !skipIncidence ) { 1109 if ( !skipIncidence ) {
1110 inR = remote->incidence( uid ); 1110 inR = remote->incidence( uid );
1111 if ( ! inR ) { 1111 if ( ! inR ) {
1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1113 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1113 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1114 checkExternSyncEvent(eventLSyncSharp, inL); 1114 checkExternSyncEvent(eventLSyncSharp, inL);
1115 local->deleteIncidence( inL ); 1115 local->deleteIncidence( inL );
1116 ++deletedEventL; 1116 ++deletedEventL;
1117 } else { 1117 } else {
1118 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1118 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1119 inL->removeID(mCurrentSyncDevice ); 1119 inL->removeID(mCurrentSyncDevice );
1120 ++addedEventR; 1120 ++addedEventR;
1121 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1121 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1122 inL->setLastModified( modifiedCalendar ); 1122 inL->setLastModified( modifiedCalendar );
1123 inR = inL->clone(); 1123 inR = inL->clone();
1124 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1124 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1125 remote->addIncidence( inR ); 1125 remote->addIncidence( inR );
1126 } 1126 }
1127 } 1127 }
1128 } else { 1128 } else {
1129 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1129 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1130 checkExternSyncEvent(eventLSyncSharp, inL); 1130 checkExternSyncEvent(eventLSyncSharp, inL);
1131 local->deleteIncidence( inL ); 1131 local->deleteIncidence( inL );
1132 ++deletedEventL; 1132 ++deletedEventL;
1133 } else { 1133 } else {
1134 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1134 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1135 ++addedEventR; 1135 ++addedEventR;
1136 inL->setLastModified( modifiedCalendar ); 1136 inL->setLastModified( modifiedCalendar );
1137 remote->addIncidence( inL->clone() ); 1137 remote->addIncidence( inL->clone() );
1138 } 1138 }
1139 } 1139 }
1140 } 1140 }
1141 } 1141 }
1142 } 1142 }
1143 inL = el.next(); 1143 inL = el.next();
1144 } 1144 }
1145 int delFut = 0; 1145 int delFut = 0;
1146 if ( KOPrefs::instance()->mWriteBackInFuture ) { 1146 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1147 er = remote->rawIncidences(); 1147 er = remote->rawIncidences();
1148 inR = er.first(); 1148 inR = er.first();
1149 QDateTime dt; 1149 QDateTime dt;
1150 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1150 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1151 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); 1151 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 );
1152 while ( inR ) { 1152 while ( inR ) {
1153 if ( inR->type() == "Todo" ) { 1153 if ( inR->type() == "Todo" ) {
1154 Todo * t = (Todo*)inR; 1154 Todo * t = (Todo*)inR;
1155 if ( t->hasDueDate() ) 1155 if ( t->hasDueDate() )
1156 dt = t->dtDue(); 1156 dt = t->dtDue();
1157 else 1157 else
1158 dt = cur.addSecs( 62 ); 1158 dt = cur.addSecs( 62 );
1159 } 1159 }
1160 else if (inR->type() == "Event" ) { 1160 else if (inR->type() == "Event" ) {
1161 bool ok; 1161 bool ok;
1162 dt = inR->getNextOccurence( cur, &ok ); 1162 dt = inR->getNextOccurence( cur, &ok );
1163 if ( !ok ) 1163 if ( !ok )
1164 dt = cur.addSecs( -62 ); 1164 dt = cur.addSecs( -62 );
1165 } 1165 }
1166 else 1166 else
1167 dt = inR->dtStart(); 1167 dt = inR->dtStart();
1168 if ( dt < cur || dt > end ) { 1168 if ( dt < cur || dt > end ) {
1169 remote->deleteIncidence( inR ); 1169 remote->deleteIncidence( inR );
1170 ++delFut; 1170 ++delFut;
1171 } 1171 }
1172 inR = er.next(); 1172 inR = er.next();
1173 } 1173 }
1174 } 1174 }
1175 bar.hide(); 1175 bar.hide();
1176 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1176 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1177 eventLSync->setReadOnly( false ); 1177 eventLSync->setReadOnly( false );
1178 eventLSync->setDtStart( mLastCalendarSync ); 1178 eventLSync->setDtStart( mLastCalendarSync );
1179 eventRSync->setDtStart( mLastCalendarSync ); 1179 eventRSync->setDtStart( mLastCalendarSync );
1180 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1180 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1181 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1181 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1182 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1182 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1183 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1183 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1184 eventLSync->setReadOnly( true ); 1184 eventLSync->setReadOnly( true );
1185 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1185 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1186 remote->addEvent( eventRSync ); 1186 remote->addEvent( eventRSync );
1187 QString mes; 1187 QString mes;
1188 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 ); 1188 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 );
1189 QString delmess; 1189 QString delmess;
1190 if ( delFut ) { 1190 if ( delFut ) {
1191 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); 1191 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
1192 mes += delmess; 1192 mes += delmess;
1193 } 1193 }
1194 if ( KOPrefs::instance()->mShowSyncSummary ) { 1194 if ( KOPrefs::instance()->mShowSyncSummary ) {
1195 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1195 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1196 } 1196 }
1197 qDebug( mes ); 1197 qDebug( mes );
1198 mCalendar->checkAlarmForIncidence( 0, true ); 1198 mCalendar->checkAlarmForIncidence( 0, true );
1199 return syncOK; 1199 return syncOK;
1200} 1200}
1201 1201
1202void CalendarView::setSyncDevice( QString s ) 1202void CalendarView::setSyncDevice( QString s )
1203{ 1203{
1204 mCurrentSyncDevice= s; 1204 mCurrentSyncDevice= s;
1205} 1205}
1206void CalendarView::setSyncName( QString s ) 1206void CalendarView::setSyncName( QString s )
1207{ 1207{
1208 mCurrentSyncName= s; 1208 mCurrentSyncName= s;
1209} 1209}
1210bool CalendarView::syncCalendar(QString filename, int mode) 1210bool CalendarView::syncCalendar(QString filename, int mode)
1211{ 1211{
1212 mGlobalSyncMode = SYNC_MODE_NORMAL; 1212 mGlobalSyncMode = SYNC_MODE_NORMAL;
1213 CalendarLocal* calendar = new CalendarLocal(); 1213 CalendarLocal* calendar = new CalendarLocal();
1214 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1214 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1215 FileStorage* storage = new FileStorage( calendar ); 1215 FileStorage* storage = new FileStorage( calendar );
1216 bool syncOK = false; 1216 bool syncOK = false;
1217 storage->setFileName( filename ); 1217 storage->setFileName( filename );
1218 // qDebug("loading ... "); 1218 // qDebug("loading ... ");
1219 if ( storage->load() ) { 1219 if ( storage->load() ) {
1220 getEventViewerDialog()->setSyncMode( true ); 1220 getEventViewerDialog()->setSyncMode( true );
1221 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1221 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1222 getEventViewerDialog()->setSyncMode( false ); 1222 getEventViewerDialog()->setSyncMode( false );
1223 if ( syncOK ) { 1223 if ( syncOK ) {
1224 if ( KOPrefs::instance()->mWriteBackFile ) 1224 if ( KOPrefs::instance()->mWriteBackFile )
1225 { 1225 {
1226 storage->setSaveFormat( new ICalFormat() ); 1226 storage->setSaveFormat( new ICalFormat() );
1227 storage->save(); 1227 storage->save();
1228 } 1228 }
1229 } 1229 }
1230 setModified( true ); 1230 setModified( true );
1231 } 1231 }
1232 delete storage; 1232 delete storage;
1233 delete calendar; 1233 delete calendar;
1234 if ( syncOK ) 1234 if ( syncOK )
1235 updateView(); 1235 updateView();
1236 return syncOK; 1236 return syncOK;
1237} 1237}
1238void CalendarView::syncPhone() 1238void CalendarView::syncPhone()
1239{ 1239{
1240 syncExternal( 1 ); 1240 syncExternal( 1 );
1241} 1241}
1242void CalendarView::syncExternal( int mode ) 1242void CalendarView::syncExternal( int mode )
1243{ 1243{
1244 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1244 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1245 //mCurrentSyncDevice = "sharp-DTM"; 1245 //mCurrentSyncDevice = "sharp-DTM";
1246 if ( KOPrefs::instance()->mAskForPreferences ) 1246 if ( KOPrefs::instance()->mAskForPreferences )
1247 edit_sync_options(); 1247 edit_sync_options();
1248 qApp->processEvents(); 1248 qApp->processEvents();
1249 CalendarLocal* calendar = new CalendarLocal(); 1249 CalendarLocal* calendar = new CalendarLocal();
1250 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1250 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1251 bool syncOK = false; 1251 bool syncOK = false;
1252 bool loadSuccess = false; 1252 bool loadSuccess = false;
1253 PhoneFormat* phoneFormat = 0; 1253 PhoneFormat* phoneFormat = 0;
1254#ifndef DESKTOP_VERSION 1254#ifndef DESKTOP_VERSION
1255 SharpFormat* sharpFormat = 0; 1255 SharpFormat* sharpFormat = 0;
1256 if ( mode == 0 ) { // sharp 1256 if ( mode == 0 ) { // sharp
1257 sharpFormat = new SharpFormat () ; 1257 sharpFormat = new SharpFormat () ;
1258 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1258 loadSuccess = sharpFormat->load( calendar, mCalendar );
1259 1259
1260 } else 1260 } else
1261#endif 1261#endif
1262 if ( mode == 1 ) { // phone 1262 if ( mode == 1 ) { // phone
1263 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1263 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1264 KOPrefs::instance()->mPhoneDevice, 1264 KOPrefs::instance()->mPhoneDevice,
1265 KOPrefs::instance()->mPhoneConnection, 1265 KOPrefs::instance()->mPhoneConnection,
1266 KOPrefs::instance()->mPhoneModel); 1266 KOPrefs::instance()->mPhoneModel);
1267 loadSuccess = phoneFormat->load( calendar,mCalendar); 1267 loadSuccess = phoneFormat->load( calendar,mCalendar);
1268 1268
1269 } else 1269 } else
1270 return; 1270 return;
1271 if ( loadSuccess ) { 1271 if ( loadSuccess ) {
1272 getEventViewerDialog()->setSyncMode( true ); 1272 getEventViewerDialog()->setSyncMode( true );
1273 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1273 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1274 getEventViewerDialog()->setSyncMode( false ); 1274 getEventViewerDialog()->setSyncMode( false );
1275 qApp->processEvents(); 1275 qApp->processEvents();
1276 if ( syncOK ) { 1276 if ( syncOK ) {
1277 if ( KOPrefs::instance()->mWriteBackFile ) 1277 if ( KOPrefs::instance()->mWriteBackFile )
1278 { 1278 {
1279 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1279 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1280 Incidence* inc = iL.first(); 1280 Incidence* inc = iL.first();
1281 if ( phoneFormat ) { 1281 if ( phoneFormat ) {
1282 while ( inc ) { 1282 while ( inc ) {
1283 inc->removeID(mCurrentSyncDevice); 1283 inc->removeID(mCurrentSyncDevice);
1284 inc = iL.next(); 1284 inc = iL.next();
1285 } 1285 }
1286 } 1286 }
1287#ifndef DESKTOP_VERSION 1287#ifndef DESKTOP_VERSION
1288 if ( sharpFormat ) 1288 if ( sharpFormat )
1289 sharpFormat->save(calendar); 1289 sharpFormat->save(calendar);
1290#endif 1290#endif
1291 if ( phoneFormat ) 1291 if ( phoneFormat )
1292 phoneFormat->save(calendar); 1292 phoneFormat->save(calendar);
1293 iL = calendar->rawIncidences(); 1293 iL = calendar->rawIncidences();
1294 inc = iL.first(); 1294 inc = iL.first();
1295 Incidence* loc; 1295 Incidence* loc;
1296 while ( inc ) { 1296 while ( inc ) {
1297 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1297 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1298 loc = mCalendar->incidence(inc->uid() ); 1298 loc = mCalendar->incidence(inc->uid() );
1299 if ( loc ) { 1299 if ( loc ) {
1300 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1300 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1301 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1301 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1302 } 1302 }
1303 } 1303 }
1304 inc = iL.next(); 1304 inc = iL.next();
1305 } 1305 }
1306 Incidence* lse = getLastSyncEvent(); 1306 Incidence* lse = getLastSyncEvent();
1307 if ( lse ) { 1307 if ( lse ) {
1308 lse->setReadOnly( false ); 1308 lse->setReadOnly( false );
1309 lse->setDescription( "" ); 1309 lse->setDescription( "" );
1310 lse->setReadOnly( true ); 1310 lse->setReadOnly( true );
1311 } 1311 }
1312 } 1312 }
1313 } 1313 }
1314 setModified( true ); 1314 setModified( true );
1315 } else { 1315 } else {
1316 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1316 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1317 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1317 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1318 question, i18n("Ok")) ; 1318 question, i18n("Ok")) ;
1319 1319
1320 } 1320 }
1321 delete calendar; 1321 delete calendar;
1322 updateView(); 1322 updateView();
1323 return ;//syncOK; 1323 return ;//syncOK;
1324 1324
1325} 1325}
1326void CalendarView::syncSharp() 1326void CalendarView::syncSharp()
1327{ 1327{
1328 syncExternal( 0 ); 1328 syncExternal( 0 );
1329 1329
1330} 1330}
1331 1331
1332 1332
1333//#include <kabc/stdaddressbook.h> 1333//#include <kabc/stdaddressbook.h>
1334bool CalendarView::importBday() 1334bool CalendarView::importBday()
1335{ 1335{
1336#ifndef KORG_NOKABC 1336#ifndef KORG_NOKABC
1337 1337
1338#ifdef DESKTOP_VERSION 1338#ifdef DESKTOP_VERSION
1339 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1339 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1340 KABC::AddressBook::Iterator it; 1340 KABC::AddressBook::Iterator it;
1341 int count = 0; 1341 int count = 0;
1342 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1342 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1343 ++count; 1343 ++count;
1344 } 1344 }
1345 QProgressBar bar(count,0 ); 1345 QProgressBar bar(count,0 );
1346 int w = 300; 1346 int w = 300;
1347 if ( QApplication::desktop()->width() < 320 ) 1347 if ( QApplication::desktop()->width() < 320 )
1348 w = 220; 1348 w = 220;
1349 int h = bar.sizeHint().height() ; 1349 int h = bar.sizeHint().height() ;
1350 int dw = QApplication::desktop()->width(); 1350 int dw = QApplication::desktop()->width();
1351 int dh = QApplication::desktop()->height(); 1351 int dh = QApplication::desktop()->height();
1352 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1352 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1353 bar.show(); 1353 bar.show();
1354 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1354 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1355 qApp->processEvents(); 1355 qApp->processEvents();
1356 count = 0; 1356 count = 0;
1357 int addCount = 0; 1357 int addCount = 0;
1358 KCal::Attendee* a = 0; 1358 KCal::Attendee* a = 0;
1359 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1359 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1360 if ( ! bar.isVisible() ) 1360 if ( ! bar.isVisible() )
1361 return false; 1361 return false;
1362 bar.setProgress( count++ ); 1362 bar.setProgress( count++ );
1363 qApp->processEvents(); 1363 qApp->processEvents();
1364 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1364 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1365 if ( (*it).birthday().date().isValid() ){ 1365 if ( (*it).birthday().date().isValid() ){
1366 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1366 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1367 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1367 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1368 ++addCount; 1368 ++addCount;
1369 } 1369 }
1370 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1370 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1371 if ( anni.isValid() ){ 1371 if ( anni.isValid() ){
1372 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1372 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1373 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1373 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1374 ++addCount; 1374 ++addCount;
1375 } 1375 }
1376 } 1376 }
1377 updateView(); 1377 updateView();
1378 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1378 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1379#else //DESKTOP_VERSION 1379#else //DESKTOP_VERSION
1380 1380
1381 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1381 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1382 // the result should now arrive through method insertBirthdays 1382 // the result should now arrive through method insertBirthdays
1383 1383
1384#endif //DESKTOP_VERSION 1384#endif //DESKTOP_VERSION
1385 1385
1386#endif //KORG_NOKABC 1386#endif //KORG_NOKABC
1387 1387
1388 1388
1389 return true; 1389 return true;
1390} 1390}
1391 1391
1392// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1392// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1393void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1393void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1394 const QStringList& anniversaryList, const QStringList& realNameList, 1394 const QStringList& anniversaryList, const QStringList& realNameList,
1395 const QStringList& emailList, const QStringList& assembledNameList, 1395 const QStringList& emailList, const QStringList& assembledNameList,
1396 const QStringList& uidList) 1396 const QStringList& uidList)
1397{ 1397{
1398 qDebug("CalendarView::insertBirthdays"); 1398 qDebug("CalendarView::insertBirthdays");
1399 if (uid == this->name()) 1399 if (uid == this->name())
1400 { 1400 {
1401 int count = birthdayList.count(); 1401 int count = birthdayList.count();
1402 int addCount = 0; 1402 int addCount = 0;
1403 KCal::Attendee* a = 0; 1403 KCal::Attendee* a = 0;
1404 1404
1405 qDebug("CalView 1 %i", count); 1405 qDebug("CalView 1 %i", count);
1406 1406
1407 QProgressBar bar(count,0 ); 1407 QProgressBar bar(count,0 );
1408 int w = 300; 1408 int w = 300;
1409 if ( QApplication::desktop()->width() < 320 ) 1409 if ( QApplication::desktop()->width() < 320 )
1410 w = 220; 1410 w = 220;
1411 int h = bar.sizeHint().height() ; 1411 int h = bar.sizeHint().height() ;
1412 int dw = QApplication::desktop()->width(); 1412 int dw = QApplication::desktop()->width();
1413 int dh = QApplication::desktop()->height(); 1413 int dh = QApplication::desktop()->height();
1414 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1414 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1415 bar.show(); 1415 bar.show();
1416 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1416 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1417 qApp->processEvents(); 1417 qApp->processEvents();
1418 1418
1419 QDate birthday; 1419 QDate birthday;
1420 QDate anniversary; 1420 QDate anniversary;
1421 QString realName; 1421 QString realName;
1422 QString email; 1422 QString email;
1423 QString assembledName; 1423 QString assembledName;
1424 QString uid; 1424 QString uid;
1425 bool ok = true; 1425 bool ok = true;
1426 for ( int i = 0; i < count; i++) 1426 for ( int i = 0; i < count; i++)
1427 { 1427 {
1428 if ( ! bar.isVisible() ) 1428 if ( ! bar.isVisible() )
1429 return; 1429 return;
1430 bar.setProgress( i ); 1430 bar.setProgress( i );
1431 qApp->processEvents(); 1431 qApp->processEvents();
1432
1433 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() );
1434
1435 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1436 if (!ok)
1437 qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1438
1439 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1440 if (!ok)
1441 qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1442 realName = realNameList[i];
1443 email = emailList[i];
1444 assembledName = assembledNameList[i];
1445 uid = uidList[i];
1446 1432
1447 if ( birthday.isValid() ){ 1433 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1448 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1434 if (!ok) {
1449 KCal::Attendee::ReqParticipant,uid) ; 1435 ; //qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1450 if ( addAnniversary( birthday, assembledName, a, true ) ) 1436 }
1451 ++addCount;
1452 }
1453 1437
1454 if ( anniversary.isValid() ){ 1438 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1455 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1439 if (!ok) {
1456 KCal::Attendee::ReqParticipant,uid) ; 1440 ;// qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1457 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1441 }
1458 ++addCount; 1442 realName = realNameList[i];
1443 email = emailList[i];
1444 assembledName = assembledNameList[i];
1445 uid = uidList[i];
1446 //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() );
1447
1448 if ( birthday.isValid() ){
1449 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1450 KCal::Attendee::ReqParticipant,uid) ;
1451 if ( addAnniversary( birthday, assembledName, a, true ) )
1452 ++addCount;
1453 }
1454
1455 if ( anniversary.isValid() ){
1456 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1457 KCal::Attendee::ReqParticipant,uid) ;
1458 if ( addAnniversary( anniversary, assembledName, a, false ) )
1459 ++addCount;
1460 }
1459 } 1461 }
1460 }
1461 1462
1462 updateView(); 1463 updateView();
1463 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1464 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1464 1465
1465 } 1466 }
1466 1467
1467} 1468}
1468 1469
1469 1470
1470 1471
1471bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1472bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1472{ 1473{
1473 //qDebug("addAnni "); 1474 //qDebug("addAnni ");
1474 Event * ev = new Event(); 1475 Event * ev = new Event();
1475 if ( a ) { 1476 if ( a ) {
1476 ev->addAttendee( a ); 1477 ev->addAttendee( a );
1477 } 1478 }
1478 QString kind; 1479 QString kind;
1479 if ( birthday ) 1480 if ( birthday )
1480 kind = i18n( "Birthday" ); 1481 kind = i18n( "Birthday" );
1481 else 1482 else
1482 kind = i18n( "Anniversary" ); 1483 kind = i18n( "Anniversary" );
1483 ev->setSummary( name + " - " + kind ); 1484 ev->setSummary( name + " - " + kind );
1484 ev->setOrganizer( "nobody@nowhere" ); 1485 ev->setOrganizer( "nobody@nowhere" );
1485 ev->setCategories( kind ); 1486 ev->setCategories( kind );
1486 ev->setDtStart( QDateTime(date) ); 1487 ev->setDtStart( QDateTime(date) );
1487 ev->setDtEnd( QDateTime(date) ); 1488 ev->setDtEnd( QDateTime(date) );
1488 ev->setFloats( true ); 1489 ev->setFloats( true );
1489 Recurrence * rec = ev->recurrence(); 1490 Recurrence * rec = ev->recurrence();
1490 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1491 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1491 rec->addYearlyNum( date.month() ); 1492 rec->addYearlyNum( date.month() );
1492 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1493 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1493 delete ev; 1494 delete ev;
1494 return false; 1495 return false;
1495 } 1496 }
1496 return true; 1497 return true;
1497 1498
1498} 1499}
1499bool CalendarView::importQtopia( const QString &categories, 1500bool CalendarView::importQtopia( const QString &categories,
1500 const QString &datebook, 1501 const QString &datebook,
1501 const QString &todolist ) 1502 const QString &todolist )
1502{ 1503{
1503 1504
1504 QtopiaFormat qtopiaFormat; 1505 QtopiaFormat qtopiaFormat;
1505 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1506 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1506 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1507 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1507 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1508 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1508 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1509 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1509 1510
1510 updateView(); 1511 updateView();
1511 return true; 1512 return true;
1512 1513
1513#if 0 1514#if 0
1514 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1515 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1515 mCurrentSyncDevice = "qtopia-XML"; 1516 mCurrentSyncDevice = "qtopia-XML";
1516 if ( KOPrefs::instance()->mAskForPreferences ) 1517 if ( KOPrefs::instance()->mAskForPreferences )
1517 edit_sync_options(); 1518 edit_sync_options();
1518 qApp->processEvents(); 1519 qApp->processEvents();
1519 CalendarLocal* calendar = new CalendarLocal(); 1520 CalendarLocal* calendar = new CalendarLocal();
1520 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1521 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1521 bool syncOK = false; 1522 bool syncOK = false;
1522 QtopiaFormat qtopiaFormat; 1523 QtopiaFormat qtopiaFormat;
1523 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1524 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1524 bool loadOk = true; 1525 bool loadOk = true;
1525 if ( !categories.isEmpty() ) 1526 if ( !categories.isEmpty() )
1526 loadOk = qtopiaFormat.load( calendar, categories ); 1527 loadOk = qtopiaFormat.load( calendar, categories );
1527 if ( loadOk && !datebook.isEmpty() ) 1528 if ( loadOk && !datebook.isEmpty() )
1528 loadOk = qtopiaFormat.load( calendar, datebook ); 1529 loadOk = qtopiaFormat.load( calendar, datebook );
1529 if ( loadOk && !todolist.isEmpty() ) 1530 if ( loadOk && !todolist.isEmpty() )
1530 loadOk = qtopiaFormat.load( calendar, todolist ); 1531 loadOk = qtopiaFormat.load( calendar, todolist );
1531 1532
1532 if ( loadOk ) { 1533 if ( loadOk ) {
1533 getEventViewerDialog()->setSyncMode( true ); 1534 getEventViewerDialog()->setSyncMode( true );
1534 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1535 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1535 getEventViewerDialog()->setSyncMode( false ); 1536 getEventViewerDialog()->setSyncMode( false );
1536 qApp->processEvents(); 1537 qApp->processEvents();
1537 if ( syncOK ) { 1538 if ( syncOK ) {
1538 if ( KOPrefs::instance()->mWriteBackFile ) 1539 if ( KOPrefs::instance()->mWriteBackFile )
1539 { 1540 {
1540 // write back XML file 1541 // write back XML file
1541 1542
1542 } 1543 }
1543 setModified( true ); 1544 setModified( true );
1544 } 1545 }
1545 } else { 1546 } else {
1546 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1547 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1547 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1548 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1548 question, i18n("Ok")) ; 1549 question, i18n("Ok")) ;
1549 } 1550 }
1550 delete calendar; 1551 delete calendar;
1551 updateView(); 1552 updateView();
1552 return syncOK; 1553 return syncOK;
1553 1554
1554 1555
1555#endif 1556#endif
1556 1557
1557} 1558}
1558 1559
1559void CalendarView::setSyncEventsReadOnly() 1560void CalendarView::setSyncEventsReadOnly()
1560{ 1561{
1561 Event * ev; 1562 Event * ev;
1562 QPtrList<Event> eL = mCalendar->rawEvents(); 1563 QPtrList<Event> eL = mCalendar->rawEvents();
1563 ev = eL.first(); 1564 ev = eL.first();
1564 while ( ev ) { 1565 while ( ev ) {
1565 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1566 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1566 ev->setReadOnly( true ); 1567 ev->setReadOnly( true );
1567 ev = eL.next(); 1568 ev = eL.next();
1568 } 1569 }
1569} 1570}
1570bool CalendarView::openCalendar(QString filename, bool merge) 1571bool CalendarView::openCalendar(QString filename, bool merge)
1571{ 1572{
1572 1573
1573 if (filename.isEmpty()) { 1574 if (filename.isEmpty()) {
1574 return false; 1575 return false;
1575 } 1576 }
1576 1577
1577 if (!QFile::exists(filename)) { 1578 if (!QFile::exists(filename)) {
1578 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1579 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1579 return false; 1580 return false;
1580 } 1581 }
1581 1582
1582 globalFlagBlockAgenda = 1; 1583 globalFlagBlockAgenda = 1;
1583 if (!merge) mCalendar->close(); 1584 if (!merge) mCalendar->close();
1584 1585
1585 mStorage->setFileName( filename ); 1586 mStorage->setFileName( filename );
1586 1587
1587 if ( mStorage->load() ) { 1588 if ( mStorage->load() ) {
1588 if ( merge ) ;//setModified( true ); 1589 if ( merge ) ;//setModified( true );
1589 else { 1590 else {
1590 //setModified( true ); 1591 //setModified( true );
1591 mViewManager->setDocumentId( filename ); 1592 mViewManager->setDocumentId( filename );
1592 mDialogManager->setDocumentId( filename ); 1593 mDialogManager->setDocumentId( filename );
1593 mTodoList->setDocumentId( filename ); 1594 mTodoList->setDocumentId( filename );
1594 } 1595 }
1595 globalFlagBlockAgenda = 2; 1596 globalFlagBlockAgenda = 2;
1596 // if ( getLastSyncEvent() ) 1597 // if ( getLastSyncEvent() )
1597 // getLastSyncEvent()->setReadOnly( true ); 1598 // getLastSyncEvent()->setReadOnly( true );
1598 mCalendar->reInitAlarmSettings(); 1599 mCalendar->reInitAlarmSettings();
1599 setSyncEventsReadOnly(); 1600 setSyncEventsReadOnly();
1600 updateUnmanagedViews(); 1601 updateUnmanagedViews();
1601 updateView(); 1602 updateView();
1602 setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); 1603 setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 ));
1603 if ( filename != MainWindow::defaultFileName() ) { 1604 if ( filename != MainWindow::defaultFileName() ) {
1604 saveCalendar( MainWindow::defaultFileName() ); 1605 saveCalendar( MainWindow::defaultFileName() );
1605 watchSavedFile(); 1606 watchSavedFile();
1606 } 1607 }
1607 return true; 1608 return true;
1608 } else { 1609 } else {
1609 // while failing to load, the calendar object could 1610 // while failing to load, the calendar object could
1610 // have become partially populated. Clear it out. 1611 // have become partially populated. Clear it out.
1611 if ( !merge ) { 1612 if ( !merge ) {
1612 mCalendar->close(); 1613 mCalendar->close();
1613 mViewManager->setDocumentId( filename ); 1614 mViewManager->setDocumentId( filename );
1614 mDialogManager->setDocumentId( filename ); 1615 mDialogManager->setDocumentId( filename );
1615 mTodoList->setDocumentId( filename ); 1616 mTodoList->setDocumentId( filename );
1616 } 1617 }
1617 1618
1618 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1619 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1619 1620
1620 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1621 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1621 globalFlagBlockAgenda = 2; 1622 globalFlagBlockAgenda = 2;
1622 mCalendar->reInitAlarmSettings(); 1623 mCalendar->reInitAlarmSettings();
1623 setSyncEventsReadOnly(); 1624 setSyncEventsReadOnly();
1624 updateUnmanagedViews(); 1625 updateUnmanagedViews();
1625 updateView(); 1626 updateView();
1626 } 1627 }
1627 return false; 1628 return false;
1628} 1629}
1629void CalendarView::showOpenError() 1630void CalendarView::showOpenError()
1630{ 1631{
1631 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1632 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1632} 1633}
1633void CalendarView::setLoadedFileVersion(QDateTime dt) 1634void CalendarView::setLoadedFileVersion(QDateTime dt)
1634{ 1635{
1635 loadedFileVersion = dt; 1636 loadedFileVersion = dt;
1636} 1637}
1637bool CalendarView::checkFileChanged(QString fn) 1638bool CalendarView::checkFileChanged(QString fn)
1638{ 1639{
1639 QFileInfo finf ( fn ); 1640 QFileInfo finf ( fn );
1640 if ( !finf.exists() ) 1641 if ( !finf.exists() )
1641 return true; 1642 return true;
1642 QDateTime dt = finf.lastModified (); 1643 QDateTime dt = finf.lastModified ();
1643 if ( dt <= loadedFileVersion ) 1644 if ( dt <= loadedFileVersion )
1644 return false; 1645 return false;
1645 return true; 1646 return true;
1646 1647
1647} 1648}
1648void CalendarView::watchSavedFile() 1649void CalendarView::watchSavedFile()
1649{ 1650{
1650 QFileInfo finf ( MainWindow::defaultFileName()); 1651 QFileInfo finf ( MainWindow::defaultFileName());
1651 if ( !finf.exists() ) 1652 if ( !finf.exists() )
1652 return; 1653 return;
1653 QDateTime dt = finf.lastModified (); 1654 QDateTime dt = finf.lastModified ();
1654 if ( dt < loadedFileVersion ) { 1655 if ( dt < loadedFileVersion ) {
1655 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1656 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1656 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1657 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1657 return; 1658 return;
1658 } 1659 }
1659 loadedFileVersion = dt; 1660 loadedFileVersion = dt;
1660} 1661}
1661 1662
1662bool CalendarView::checkFileVersion(QString fn) 1663bool CalendarView::checkFileVersion(QString fn)
1663{ 1664{
1664 QFileInfo finf ( fn ); 1665 QFileInfo finf ( fn );
1665 if ( !finf.exists() ) 1666 if ( !finf.exists() )
1666 return true; 1667 return true;
1667 QDateTime dt = finf.lastModified (); 1668 QDateTime dt = finf.lastModified ();
1668 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1669 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1669 //qDebug("file on disk version %s",dt.toString().latin1()); 1670 //qDebug("file on disk version %s",dt.toString().latin1());
1670 if ( dt <= loadedFileVersion ) 1671 if ( dt <= loadedFileVersion )
1671 return true; 1672 return true;
1672 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)) , 1673 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)) ,
1673 i18n("KO/Pi Warning"),i18n("Overwrite"), 1674 i18n("KO/Pi Warning"),i18n("Overwrite"),
1674 i18n("Sync+save")); 1675 i18n("Sync+save"));
1675 1676
1676 if ( km == KMessageBox::Cancel ) 1677 if ( km == KMessageBox::Cancel )
1677 return false; 1678 return false;
1678 if ( km == KMessageBox::Yes ) 1679 if ( km == KMessageBox::Yes )
1679 return true; 1680 return true;
1680 1681
1681 setSyncDevice("deleteaftersync" ); 1682 setSyncDevice("deleteaftersync" );
1682 KOPrefs::instance()->mAskForPreferences = true; 1683 KOPrefs::instance()->mAskForPreferences = true;
1683 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1684 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1684 KOPrefs::instance()->mWriteBackFile = false; 1685 KOPrefs::instance()->mWriteBackFile = false;
1685 KOPrefs::instance()->mWriteBackExistingOnly = false; 1686 KOPrefs::instance()->mWriteBackExistingOnly = false;
1686 KOPrefs::instance()->mShowSyncSummary = false; 1687 KOPrefs::instance()->mShowSyncSummary = false;
1687 syncCalendar( fn, 3 ); 1688 syncCalendar( fn, 3 );
1688 Event * e = getLastSyncEvent(); 1689 Event * e = getLastSyncEvent();
1689 mCalendar->deleteEvent ( e ); 1690 mCalendar->deleteEvent ( e );
1690 updateView(); 1691 updateView();
1691 return true; 1692 return true;
1692} 1693}
1693 1694
1694bool CalendarView::saveCalendar( QString filename ) 1695bool CalendarView::saveCalendar( QString filename )
1695{ 1696{
1696 1697
1697 // Store back all unsaved data into calendar object 1698 // Store back all unsaved data into calendar object
1698 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1699 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1699 if ( mViewManager->currentView() ) 1700 if ( mViewManager->currentView() )
1700 mViewManager->currentView()->flushView(); 1701 mViewManager->currentView()->flushView();
1701 1702
1702 //mStorage->setFileName( filename ); 1703 //mStorage->setFileName( filename );
1703 1704
1704 mStorage->setSaveFormat( new ICalFormat() ); 1705 mStorage->setSaveFormat( new ICalFormat() );
1705 mStorage->setFileName( filename ); 1706 mStorage->setFileName( filename );
1706 bool success; 1707 bool success;
1707 success = mStorage->save(); 1708 success = mStorage->save();
1708 if ( !success ) { 1709 if ( !success ) {
1709 return false; 1710 return false;
1710 } 1711 }
1711 1712
1712 return true; 1713 return true;
1713} 1714}
1714 1715
1715void CalendarView::closeCalendar() 1716void CalendarView::closeCalendar()
1716{ 1717{
1717 1718
1718 // child windows no longer valid 1719 // child windows no longer valid
1719 emit closingDown(); 1720 emit closingDown();
1720 1721
1721 mCalendar->close(); 1722 mCalendar->close();
1722 setModified(false); 1723 setModified(false);
1723 updateView(); 1724 updateView();
1724} 1725}
1725 1726
1726void CalendarView::archiveCalendar() 1727void CalendarView::archiveCalendar()
1727{ 1728{
1728 mDialogManager->showArchiveDialog(); 1729 mDialogManager->showArchiveDialog();
1729} 1730}
1730 1731
1731 1732
1732void CalendarView::readSettings() 1733void CalendarView::readSettings()
1733{ 1734{
1734 1735
1735 1736
1736 // mViewManager->showAgendaView(); 1737 // mViewManager->showAgendaView();
1737 QString str; 1738 QString str;
1738 //qDebug("CalendarView::readSettings() "); 1739 //qDebug("CalendarView::readSettings() ");
1739 // read settings from the KConfig, supplying reasonable 1740 // read settings from the KConfig, supplying reasonable
1740 // defaults where none are to be found 1741 // defaults where none are to be found
1741 KConfig *config = KOGlobals::config(); 1742 KConfig *config = KOGlobals::config();
1742#ifndef KORG_NOSPLITTER 1743#ifndef KORG_NOSPLITTER
1743 config->setGroup("KOrganizer Geometry"); 1744 config->setGroup("KOrganizer Geometry");
1744 1745
1745 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1746 QValueList<int> sizes = config->readIntListEntry("Separator1");
1746 if (sizes.count() != 2) { 1747 if (sizes.count() != 2) {
1747 sizes << mDateNavigator->minimumSizeHint().width(); 1748 sizes << mDateNavigator->minimumSizeHint().width();
1748 sizes << 300; 1749 sizes << 300;
1749 } 1750 }
1750 mPanner->setSizes(sizes); 1751 mPanner->setSizes(sizes);
1751 1752
1752 sizes = config->readIntListEntry("Separator2"); 1753 sizes = config->readIntListEntry("Separator2");
1753 if ( ( mResourceView && sizes.count() == 4 ) || 1754 if ( ( mResourceView && sizes.count() == 4 ) ||
1754 ( !mResourceView && sizes.count() == 3 ) ) { 1755 ( !mResourceView && sizes.count() == 3 ) ) {
1755 mLeftSplitter->setSizes(sizes); 1756 mLeftSplitter->setSizes(sizes);
1756 } 1757 }
1757#endif 1758#endif
1758 globalFlagBlockAgenda = 1; 1759 globalFlagBlockAgenda = 1;
1759 mViewManager->showAgendaView(); 1760 mViewManager->showAgendaView();
1760 //mViewManager->readSettings( config ); 1761 //mViewManager->readSettings( config );
1761 mTodoList->restoreLayout(config,QString("Todo Layout")); 1762 mTodoList->restoreLayout(config,QString("Todo Layout"));
1762 readFilterSettings(config); 1763 readFilterSettings(config);
1763 config->setGroup( "Views" ); 1764 config->setGroup( "Views" );
1764 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1765 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1765 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1766 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1766 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1767 else if ( dateCount == 7 ) mNavigator->selectWeek();
1767 else mNavigator->selectDates( dateCount ); 1768 else mNavigator->selectDates( dateCount );
1768 // mViewManager->readSettings( config ); 1769 // mViewManager->readSettings( config );
1769 updateConfig(); 1770 updateConfig();
1770 globalFlagBlockAgenda = 2; 1771 globalFlagBlockAgenda = 2;
1771 mViewManager->readSettings( config ); 1772 mViewManager->readSettings( config );
1772#ifdef DESKTOP_VERSION 1773#ifdef DESKTOP_VERSION
1773 config->setGroup("WidgetLayout"); 1774 config->setGroup("WidgetLayout");
1774 QStringList list; 1775 QStringList list;
1775 list = config->readListEntry("MainLayout"); 1776 list = config->readListEntry("MainLayout");
1776 int x,y,w,h; 1777 int x,y,w,h;
1777 if ( ! list.isEmpty() ) { 1778 if ( ! list.isEmpty() ) {
1778 x = list[0].toInt(); 1779 x = list[0].toInt();
1779 y = list[1].toInt(); 1780 y = list[1].toInt();
1780 w = list[2].toInt(); 1781 w = list[2].toInt();
1781 h = list[3].toInt(); 1782 h = list[3].toInt();
1782 topLevelWidget()->setGeometry(x,y,w,h); 1783 topLevelWidget()->setGeometry(x,y,w,h);
1783 1784
1784 } else { 1785 } else {
1785 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1786 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1786 } 1787 }
1787 list = config->readListEntry("EditEventLayout"); 1788 list = config->readListEntry("EditEventLayout");
1788 if ( ! list.isEmpty() ) { 1789 if ( ! list.isEmpty() ) {
1789 x = list[0].toInt(); 1790 x = list[0].toInt();
1790 y = list[1].toInt(); 1791 y = list[1].toInt();
1791 w = list[2].toInt(); 1792 w = list[2].toInt();
1792 h = list[3].toInt(); 1793 h = list[3].toInt();
1793 mEventEditor->setGeometry(x,y,w,h); 1794 mEventEditor->setGeometry(x,y,w,h);
1794 1795
1795 } 1796 }
1796 list = config->readListEntry("EditTodoLayout"); 1797 list = config->readListEntry("EditTodoLayout");
1797 if ( ! list.isEmpty() ) { 1798 if ( ! list.isEmpty() ) {
1798 x = list[0].toInt(); 1799 x = list[0].toInt();
1799 y = list[1].toInt(); 1800 y = list[1].toInt();
1800 w = list[2].toInt(); 1801 w = list[2].toInt();
1801 h = list[3].toInt(); 1802 h = list[3].toInt();
1802 mTodoEditor->setGeometry(x,y,w,h); 1803 mTodoEditor->setGeometry(x,y,w,h);
1803 1804
1804 } 1805 }
1805 list = config->readListEntry("ViewerLayout"); 1806 list = config->readListEntry("ViewerLayout");
1806 if ( ! list.isEmpty() ) { 1807 if ( ! list.isEmpty() ) {
1807 x = list[0].toInt(); 1808 x = list[0].toInt();
1808 y = list[1].toInt(); 1809 y = list[1].toInt();
1809 w = list[2].toInt(); 1810 w = list[2].toInt();
1810 h = list[3].toInt(); 1811 h = list[3].toInt();
1811 getEventViewerDialog()->setGeometry(x,y,w,h); 1812 getEventViewerDialog()->setGeometry(x,y,w,h);
1812 } 1813 }
1813#endif 1814#endif
1814 1815
1815} 1816}
1816 1817
1817 1818
1818void CalendarView::writeSettings() 1819void CalendarView::writeSettings()
1819{ 1820{
1820 // kdDebug() << "CalendarView::writeSettings" << endl; 1821 // kdDebug() << "CalendarView::writeSettings" << endl;
1821 1822
1822 KConfig *config = KOGlobals::config(); 1823 KConfig *config = KOGlobals::config();
1823 1824
1824#ifndef KORG_NOSPLITTER 1825#ifndef KORG_NOSPLITTER
1825 config->setGroup("KOrganizer Geometry"); 1826 config->setGroup("KOrganizer Geometry");
1826 1827
1827 QValueList<int> list = mPanner->sizes(); 1828 QValueList<int> list = mPanner->sizes();
1828 config->writeEntry("Separator1",list); 1829 config->writeEntry("Separator1",list);
1829 1830
1830 list = mLeftSplitter->sizes(); 1831 list = mLeftSplitter->sizes();
1831 config->writeEntry("Separator2",list); 1832 config->writeEntry("Separator2",list);
1832#endif 1833#endif
1833 1834
1834 mViewManager->writeSettings( config ); 1835 mViewManager->writeSettings( config );
1835 mTodoList->saveLayout(config,QString("Todo Layout")); 1836 mTodoList->saveLayout(config,QString("Todo Layout"));
1836 mDialogManager->writeSettings( config ); 1837 mDialogManager->writeSettings( config );
1837 //KOPrefs::instance()->usrWriteConfig(); 1838 //KOPrefs::instance()->usrWriteConfig();
1838 KOPrefs::instance()->writeConfig(); 1839 KOPrefs::instance()->writeConfig();
1839 1840
1840 writeFilterSettings(config); 1841 writeFilterSettings(config);
1841 1842
1842 config->setGroup( "Views" ); 1843 config->setGroup( "Views" );
1843 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1844 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1844 1845
1845#ifdef DESKTOP_VERSION 1846#ifdef DESKTOP_VERSION
1846 config->setGroup("WidgetLayout"); 1847 config->setGroup("WidgetLayout");
1847 QStringList list ;//= config->readListEntry("MainLayout"); 1848 QStringList list ;//= config->readListEntry("MainLayout");
1848 int x,y,w,h; 1849 int x,y,w,h;
1849 QWidget* wid; 1850 QWidget* wid;
1850 wid = topLevelWidget(); 1851 wid = topLevelWidget();
1851 x = wid->geometry().x(); 1852 x = wid->geometry().x();
1852 y = wid->geometry().y(); 1853 y = wid->geometry().y();
1853 w = wid->width(); 1854 w = wid->width();
1854 h = wid->height(); 1855 h = wid->height();
1855 list.clear(); 1856 list.clear();
1856 list << QString::number( x ); 1857 list << QString::number( x );
1857 list << QString::number( y ); 1858 list << QString::number( y );
1858 list << QString::number( w ); 1859 list << QString::number( w );
1859 list << QString::number( h ); 1860 list << QString::number( h );
1860 config->writeEntry("MainLayout",list ); 1861 config->writeEntry("MainLayout",list );
1861 1862
1862 wid = mEventEditor; 1863 wid = mEventEditor;
1863 x = wid->geometry().x(); 1864 x = wid->geometry().x();
1864 y = wid->geometry().y(); 1865 y = wid->geometry().y();
1865 w = wid->width(); 1866 w = wid->width();
1866 h = wid->height(); 1867 h = wid->height();
1867 list.clear(); 1868 list.clear();
1868 list << QString::number( x ); 1869 list << QString::number( x );
1869 list << QString::number( y ); 1870 list << QString::number( y );
1870 list << QString::number( w ); 1871 list << QString::number( w );
1871 list << QString::number( h ); 1872 list << QString::number( h );
1872 config->writeEntry("EditEventLayout",list ); 1873 config->writeEntry("EditEventLayout",list );
1873 1874
1874 wid = mTodoEditor; 1875 wid = mTodoEditor;
1875 x = wid->geometry().x(); 1876 x = wid->geometry().x();
1876 y = wid->geometry().y(); 1877 y = wid->geometry().y();
1877 w = wid->width(); 1878 w = wid->width();
1878 h = wid->height(); 1879 h = wid->height();
1879 list.clear(); 1880 list.clear();
1880 list << QString::number( x ); 1881 list << QString::number( x );
1881 list << QString::number( y ); 1882 list << QString::number( y );
1882 list << QString::number( w ); 1883 list << QString::number( w );
1883 list << QString::number( h ); 1884 list << QString::number( h );
1884 config->writeEntry("EditTodoLayout",list ); 1885 config->writeEntry("EditTodoLayout",list );
1885 wid = getEventViewerDialog(); 1886 wid = getEventViewerDialog();
1886 x = wid->geometry().x(); 1887 x = wid->geometry().x();
1887 y = wid->geometry().y(); 1888 y = wid->geometry().y();
1888 w = wid->width(); 1889 w = wid->width();
1889 h = wid->height(); 1890 h = wid->height();
1890 list.clear(); 1891 list.clear();
1891 list << QString::number( x ); 1892 list << QString::number( x );
1892 list << QString::number( y ); 1893 list << QString::number( y );
1893 list << QString::number( w ); 1894 list << QString::number( w );
1894 list << QString::number( h ); 1895 list << QString::number( h );
1895 config->writeEntry("ViewerLayout",list ); 1896 config->writeEntry("ViewerLayout",list );
1896 wid = mDialogManager->getSearchDialog(); 1897 wid = mDialogManager->getSearchDialog();
1897 if ( wid ) { 1898 if ( wid ) {
1898 x = wid->geometry().x(); 1899 x = wid->geometry().x();
1899 y = wid->geometry().y(); 1900 y = wid->geometry().y();
1900 w = wid->width(); 1901 w = wid->width();
1901 h = wid->height(); 1902 h = wid->height();
1902 list.clear(); 1903 list.clear();
1903 list << QString::number( x ); 1904 list << QString::number( x );
1904 list << QString::number( y ); 1905 list << QString::number( y );
1905 list << QString::number( w ); 1906 list << QString::number( w );
1906 list << QString::number( h ); 1907 list << QString::number( h );
1907 config->writeEntry("SearchLayout",list ); 1908 config->writeEntry("SearchLayout",list );
1908 } 1909 }
1909#endif 1910#endif
1910 1911
1911 1912
1912 config->sync(); 1913 config->sync();
1913} 1914}
1914 1915
1915void CalendarView::readFilterSettings(KConfig *config) 1916void CalendarView::readFilterSettings(KConfig *config)
1916{ 1917{
1917 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1918 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1918 1919
1919 mFilters.clear(); 1920 mFilters.clear();
1920 1921
1921 config->setGroup("General"); 1922 config->setGroup("General");
1922 QStringList filterList = config->readListEntry("CalendarFilters"); 1923 QStringList filterList = config->readListEntry("CalendarFilters");
1923 1924
1924 QStringList::ConstIterator it = filterList.begin(); 1925 QStringList::ConstIterator it = filterList.begin();
1925 QStringList::ConstIterator end = filterList.end(); 1926 QStringList::ConstIterator end = filterList.end();
1926 while(it != end) { 1927 while(it != end) {
1927 // kdDebug() << " filter: " << (*it) << endl; 1928 // kdDebug() << " filter: " << (*it) << endl;
1928 1929
1929 CalFilter *filter; 1930 CalFilter *filter;
1930 filter = new CalFilter(*it); 1931 filter = new CalFilter(*it);
1931 config->setGroup("Filter_" + (*it)); 1932 config->setGroup("Filter_" + (*it));
1932 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1933 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1933 filter->setCriteria(config->readNumEntry("Criteria",0)); 1934 filter->setCriteria(config->readNumEntry("Criteria",0));
1934 filter->setCategoryList(config->readListEntry("CategoryList")); 1935 filter->setCategoryList(config->readListEntry("CategoryList"));
1935 mFilters.append(filter); 1936 mFilters.append(filter);
1936 1937
1937 ++it; 1938 ++it;
1938 } 1939 }
1939 1940
1940 if (mFilters.count() == 0) { 1941 if (mFilters.count() == 0) {
1941 CalFilter *filter = new CalFilter(i18n("Default")); 1942 CalFilter *filter = new CalFilter(i18n("Default"));
1942 mFilters.append(filter); 1943 mFilters.append(filter);
1943 } 1944 }
1944 mFilterView->updateFilters(); 1945 mFilterView->updateFilters();
1945 config->setGroup("FilterView"); 1946 config->setGroup("FilterView");
1946 1947
1947 mFilterView->blockSignals(true); 1948 mFilterView->blockSignals(true);
1948 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1949 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1949 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1950 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1950 mFilterView->blockSignals(false); 1951 mFilterView->blockSignals(false);
1951 // We do it manually to avoid it being done twice by the above calls 1952 // We do it manually to avoid it being done twice by the above calls
1952 updateFilter(); 1953 updateFilter();
1953} 1954}
1954 1955
1955void CalendarView::writeFilterSettings(KConfig *config) 1956void CalendarView::writeFilterSettings(KConfig *config)
1956{ 1957{
1957 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1958 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1958 1959
1959 QStringList filterList; 1960 QStringList filterList;
1960 1961
1961 CalFilter *filter = mFilters.first(); 1962 CalFilter *filter = mFilters.first();
1962 while(filter) { 1963 while(filter) {
1963 // kdDebug() << " fn: " << filter->name() << endl; 1964 // kdDebug() << " fn: " << filter->name() << endl;
1964 filterList << filter->name(); 1965 filterList << filter->name();
1965 config->setGroup("Filter_" + filter->name()); 1966 config->setGroup("Filter_" + filter->name());
1966 config->writeEntry("Criteria",filter->criteria()); 1967 config->writeEntry("Criteria",filter->criteria());
1967 config->writeEntry("CategoryList",filter->categoryList()); 1968 config->writeEntry("CategoryList",filter->categoryList());
1968 filter = mFilters.next(); 1969 filter = mFilters.next();
1969 } 1970 }
1970 config->setGroup("General"); 1971 config->setGroup("General");
1971 config->writeEntry("CalendarFilters",filterList); 1972 config->writeEntry("CalendarFilters",filterList);
1972 1973
1973 config->setGroup("FilterView"); 1974 config->setGroup("FilterView");
1974 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1975 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1975 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1976 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1976} 1977}
1977 1978
1978 1979
1979void CalendarView::goToday() 1980void CalendarView::goToday()
1980{ 1981{
1981 mNavigator->selectToday(); 1982 mNavigator->selectToday();
1982} 1983}
1983 1984
1984void CalendarView::goNext() 1985void CalendarView::goNext()
1985{ 1986{
1986 mNavigator->selectNext(); 1987 mNavigator->selectNext();
1987} 1988}
1988 1989
1989void CalendarView::goPrevious() 1990void CalendarView::goPrevious()
1990{ 1991{
1991 mNavigator->selectPrevious(); 1992 mNavigator->selectPrevious();
1992} 1993}
1993void CalendarView::goNextMonth() 1994void CalendarView::goNextMonth()
1994{ 1995{
1995 mNavigator->selectNextMonth(); 1996 mNavigator->selectNextMonth();
1996} 1997}
1997 1998
1998void CalendarView::goPreviousMonth() 1999void CalendarView::goPreviousMonth()
1999{ 2000{
2000 mNavigator->selectPreviousMonth(); 2001 mNavigator->selectPreviousMonth();
2001} 2002}
2002void CalendarView::writeLocale() 2003void CalendarView::writeLocale()
2003{ 2004{
2004 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2005 //KPimGlobalPrefs::instance()->setGlobalConfig();
2005#if 0 2006#if 0
2006 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2007 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2007 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2008 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2008 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2009 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2009 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2010 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2010 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2011 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2011 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2012 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2012 dummy = KOPrefs::instance()->mUserDateFormatShort; 2013 dummy = KOPrefs::instance()->mUserDateFormatShort;
2013 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2014 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2014 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2015 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2015 KOPrefs::instance()->mDaylightsavingStart, 2016 KOPrefs::instance()->mDaylightsavingStart,
2016 KOPrefs::instance()->mDaylightsavingEnd ); 2017 KOPrefs::instance()->mDaylightsavingEnd );
2017 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 2018 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
2018#endif 2019#endif
2019} 2020}
2020void CalendarView::updateConfig() 2021void CalendarView::updateConfig()
2021{ 2022{
2022 writeLocale(); 2023 writeLocale();
2023 if ( KOPrefs::instance()->mUseAppColors ) 2024 if ( KOPrefs::instance()->mUseAppColors )
2024 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2025 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2025 emit configChanged(); 2026 emit configChanged();
2026 mTodoList->updateConfig(); 2027 mTodoList->updateConfig();
2027 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2028 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2028 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2029 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2029 // To make the "fill window" configurations work 2030 // To make the "fill window" configurations work
2030 //mViewManager->raiseCurrentView(); 2031 //mViewManager->raiseCurrentView();
2031} 2032}
2032 2033
2033 2034
2034void CalendarView::eventChanged(Event *event) 2035void CalendarView::eventChanged(Event *event)
2035{ 2036{
2036 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2037 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2037 //updateUnmanagedViews(); 2038 //updateUnmanagedViews();
2038} 2039}
2039 2040
2040void CalendarView::eventAdded(Event *event) 2041void CalendarView::eventAdded(Event *event)
2041{ 2042{
2042 changeEventDisplay(event,KOGlobals::EVENTADDED); 2043 changeEventDisplay(event,KOGlobals::EVENTADDED);
2043} 2044}
2044 2045
2045void CalendarView::eventToBeDeleted(Event *) 2046void CalendarView::eventToBeDeleted(Event *)
2046{ 2047{
2047 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2048 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2048} 2049}
2049 2050
2050void CalendarView::eventDeleted() 2051void CalendarView::eventDeleted()
2051{ 2052{
2052 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2053 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2053} 2054}
2054void CalendarView::changeTodoDisplay(Todo *which, int action) 2055void CalendarView::changeTodoDisplay(Todo *which, int action)
2055{ 2056{
2056 changeIncidenceDisplay((Incidence *)which, action); 2057 changeIncidenceDisplay((Incidence *)which, action);
2057 mDateNavigator->updateView(); //LR 2058 mDateNavigator->updateView(); //LR
2058 //mDialogManager->updateSearchDialog(); 2059 //mDialogManager->updateSearchDialog();
2059 2060
2060 if (which) { 2061 if (which) {
2061 mViewManager->updateWNview(); 2062 mViewManager->updateWNview();
2062 //mTodoList->updateView(); 2063 //mTodoList->updateView();
2063 } 2064 }
2064 2065
2065} 2066}
2066 2067
2067void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2068void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2068{ 2069{
2069 updateUnmanagedViews(); 2070 updateUnmanagedViews();
2070 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2071 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2071 if ( action == KOGlobals::EVENTDELETED ) { //delete 2072 if ( action == KOGlobals::EVENTDELETED ) { //delete
2072 mCalendar->checkAlarmForIncidence( 0, true ); 2073 mCalendar->checkAlarmForIncidence( 0, true );
2073 if ( mEventViewerDialog ) 2074 if ( mEventViewerDialog )
2074 mEventViewerDialog->hide(); 2075 mEventViewerDialog->hide();
2075 } 2076 }
2076 else 2077 else
2077 mCalendar->checkAlarmForIncidence( which , false ); 2078 mCalendar->checkAlarmForIncidence( which , false );
2078} 2079}
2079 2080
2080// most of the changeEventDisplays() right now just call the view's 2081// most of the changeEventDisplays() right now just call the view's
2081// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2082// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2082void CalendarView::changeEventDisplay(Event *which, int action) 2083void CalendarView::changeEventDisplay(Event *which, int action)
2083{ 2084{
2084 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2085 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2085 changeIncidenceDisplay((Incidence *)which, action); 2086 changeIncidenceDisplay((Incidence *)which, action);
2086 mDateNavigator->updateView(); 2087 mDateNavigator->updateView();
2087 //mDialogManager->updateSearchDialog(); 2088 //mDialogManager->updateSearchDialog();
2088 2089
2089 if (which) { 2090 if (which) {
2090 // If there is an event view visible update the display 2091 // If there is an event view visible update the display
2091 mViewManager->currentView()->changeEventDisplay(which,action); 2092 mViewManager->currentView()->changeEventDisplay(which,action);
2092 // TODO: check, if update needed 2093 // TODO: check, if update needed
2093 // if (which->getTodoStatus()) { 2094 // if (which->getTodoStatus()) {
2094 mTodoList->updateView(); 2095 mTodoList->updateView();
2095 // } 2096 // }
2096 } else { 2097 } else {
2097 mViewManager->currentView()->updateView(); 2098 mViewManager->currentView()->updateView();
2098 } 2099 }
2099} 2100}
2100 2101
2101 2102
2102void CalendarView::updateTodoViews() 2103void CalendarView::updateTodoViews()
2103{ 2104{
2104 2105
2105 mTodoList->updateView(); 2106 mTodoList->updateView();
2106 mViewManager->currentView()->updateView(); 2107 mViewManager->currentView()->updateView();
2107 2108
2108} 2109}
2109 2110
2110 2111
2111void CalendarView::updateView(const QDate &start, const QDate &end) 2112void CalendarView::updateView(const QDate &start, const QDate &end)
2112{ 2113{
2113 mTodoList->updateView(); 2114 mTodoList->updateView();
2114 mViewManager->updateView(start, end); 2115 mViewManager->updateView(start, end);
2115 //mDateNavigator->updateView(); 2116 //mDateNavigator->updateView();
2116} 2117}
2117 2118
2118void CalendarView::updateView() 2119void CalendarView::updateView()
2119{ 2120{
2120 DateList tmpList = mNavigator->selectedDates(); 2121 DateList tmpList = mNavigator->selectedDates();
2121 2122
2122 // We assume that the navigator only selects consecutive days. 2123 // We assume that the navigator only selects consecutive days.
2123 updateView( tmpList.first(), tmpList.last() ); 2124 updateView( tmpList.first(), tmpList.last() );
2124} 2125}
2125 2126
2126void CalendarView::updateUnmanagedViews() 2127void CalendarView::updateUnmanagedViews()
2127{ 2128{
2128 mDateNavigator->updateDayMatrix(); 2129 mDateNavigator->updateDayMatrix();
2129} 2130}
2130 2131
2131int CalendarView::msgItemDelete() 2132int CalendarView::msgItemDelete()
2132{ 2133{
2133 return KMessageBox::warningContinueCancel(this, 2134 return KMessageBox::warningContinueCancel(this,
2134 i18n("This item will be\npermanently deleted."), 2135 i18n("This item will be\npermanently deleted."),
2135 i18n("KO/Pi Confirmation"),i18n("Delete")); 2136 i18n("KO/Pi Confirmation"),i18n("Delete"));
2136} 2137}
2137 2138
2138 2139
2139void CalendarView::edit_cut() 2140void CalendarView::edit_cut()
2140{ 2141{
2141 Event *anEvent=0; 2142 Event *anEvent=0;
2142 2143
2143 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2144 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2144 2145
2145 if (mViewManager->currentView()->isEventView()) { 2146 if (mViewManager->currentView()->isEventView()) {
2146 if ( incidence && incidence->type() == "Event" ) { 2147 if ( incidence && incidence->type() == "Event" ) {
2147 anEvent = static_cast<Event *>(incidence); 2148 anEvent = static_cast<Event *>(incidence);
2148 } 2149 }
2149 } 2150 }
2150 2151
2151 if (!anEvent) { 2152 if (!anEvent) {
2152 KNotifyClient::beep(); 2153 KNotifyClient::beep();
2153 return; 2154 return;
2154 } 2155 }
2155 DndFactory factory( mCalendar ); 2156 DndFactory factory( mCalendar );
2156 factory.cutEvent(anEvent); 2157 factory.cutEvent(anEvent);
2157 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2158 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2158} 2159}
2159 2160
2160void CalendarView::edit_copy() 2161void CalendarView::edit_copy()
2161{ 2162{
2162 Event *anEvent=0; 2163 Event *anEvent=0;
2163 2164
2164 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2165 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2165 2166
2166 if (mViewManager->currentView()->isEventView()) { 2167 if (mViewManager->currentView()->isEventView()) {
2167 if ( incidence && incidence->type() == "Event" ) { 2168 if ( incidence && incidence->type() == "Event" ) {
2168 anEvent = static_cast<Event *>(incidence); 2169 anEvent = static_cast<Event *>(incidence);
2169 } 2170 }
2170 } 2171 }
2171 2172
2172 if (!anEvent) { 2173 if (!anEvent) {
2173 KNotifyClient::beep(); 2174 KNotifyClient::beep();
2174 return; 2175 return;
2175 } 2176 }
2176 DndFactory factory( mCalendar ); 2177 DndFactory factory( mCalendar );
2177 factory.copyEvent(anEvent); 2178 factory.copyEvent(anEvent);
2178} 2179}
2179 2180
2180void CalendarView::edit_paste() 2181void CalendarView::edit_paste()
2181{ 2182{
2182 QDate date = mNavigator->selectedDates().first(); 2183 QDate date = mNavigator->selectedDates().first();
2183 2184
2184 DndFactory factory( mCalendar ); 2185 DndFactory factory( mCalendar );
2185 Event *pastedEvent = factory.pasteEvent( date ); 2186 Event *pastedEvent = factory.pasteEvent( date );
2186 2187
2187 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2188 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2188} 2189}
2189 2190
2190void CalendarView::edit_options() 2191void CalendarView::edit_options()
2191{ 2192{
2192 mDialogManager->showOptionsDialog(); 2193 mDialogManager->showOptionsDialog();
2193 //writeSettings(); 2194 //writeSettings();
2194} 2195}
2195void CalendarView::edit_sync_options() 2196void CalendarView::edit_sync_options()
2196{ 2197{
2197 //mDialogManager->showSyncOptions(); 2198 //mDialogManager->showSyncOptions();
2198 //KOPrefs::instance()->mSyncAlgoPrefs 2199 //KOPrefs::instance()->mSyncAlgoPrefs
2199 QDialog dia( this, "dia", true ); 2200 QDialog dia( this, "dia", true );
2200 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2201 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2201 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2202 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2202 QVBoxLayout lay ( &dia ); 2203 QVBoxLayout lay ( &dia );
2203 lay.setSpacing( 2 ); 2204 lay.setSpacing( 2 );
2204 lay.setMargin( 3 ); 2205 lay.setMargin( 3 );
2205 lay.addWidget(&gr); 2206 lay.addWidget(&gr);
2206 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2207 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2207 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2208 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2208 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2209 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2209 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2210 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2210 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2211 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2211 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2212 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2212 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2213 //QRadioButton both( i18n("Take both on conflict"), &gr );
2213 QPushButton pb ( "OK", &dia); 2214 QPushButton pb ( "OK", &dia);
2214 lay.addWidget( &pb ); 2215 lay.addWidget( &pb );
2215 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2216 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2216 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 2217 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
2217 case 0: 2218 case 0:
2218 loc.setChecked( true); 2219 loc.setChecked( true);
2219 break; 2220 break;
2220 case 1: 2221 case 1:
2221 rem.setChecked( true ); 2222 rem.setChecked( true );
2222 break; 2223 break;
2223 case 2: 2224 case 2:
2224 newest.setChecked( true); 2225 newest.setChecked( true);
2225 break; 2226 break;
2226 case 3: 2227 case 3:
2227 ask.setChecked( true); 2228 ask.setChecked( true);
2228 break; 2229 break;