author | zautrix <zautrix> | 2004-09-12 17:18:27 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 17:18:27 (UTC) |
commit | bc4153a99e205f43d0144e2e910730dd1a14d402 (patch) (unidiff) | |
tree | 16aeb28cd765539bac6e85e714478f31a7b93bac | |
parent | a222c2f7369eeefd19454c973c0cc48300f72bec (diff) | |
download | kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.zip kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.tar.gz kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.tar.bz2 |
added missing sync featute
-rw-r--r-- | korganizer/calendarview.cpp | 53 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 6 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 15 |
4 files changed, 55 insertions, 20 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index db07713..cfd9290 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -636,580 +636,607 @@ void CalendarView::recheckTimerAlarm() | |||
636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
637 | { | 637 | { |
638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
640 | #ifndef DESKTOP_VERSION | 640 | #ifndef DESKTOP_VERSION |
641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
642 | #endif | 642 | #endif |
643 | return; | 643 | return; |
644 | } | 644 | } |
645 | mAlarmTimer->stop(); | 645 | mAlarmTimer->stop(); |
646 | } | 646 | } |
647 | void CalendarView::selectWeekNum ( int num ) | 647 | void CalendarView::selectWeekNum ( int num ) |
648 | { | 648 | { |
649 | dateNavigator()->selectWeek( num ); | 649 | dateNavigator()->selectWeek( num ); |
650 | mViewManager->showWeekView(); | 650 | mViewManager->showWeekView(); |
651 | } | 651 | } |
652 | KOViewManager *CalendarView::viewManager() | 652 | KOViewManager *CalendarView::viewManager() |
653 | { | 653 | { |
654 | return mViewManager; | 654 | return mViewManager; |
655 | } | 655 | } |
656 | 656 | ||
657 | KODialogManager *CalendarView::dialogManager() | 657 | KODialogManager *CalendarView::dialogManager() |
658 | { | 658 | { |
659 | return mDialogManager; | 659 | return mDialogManager; |
660 | } | 660 | } |
661 | 661 | ||
662 | QDate CalendarView::startDate() | 662 | QDate CalendarView::startDate() |
663 | { | 663 | { |
664 | DateList dates = mNavigator->selectedDates(); | 664 | DateList dates = mNavigator->selectedDates(); |
665 | 665 | ||
666 | return dates.first(); | 666 | return dates.first(); |
667 | } | 667 | } |
668 | 668 | ||
669 | QDate CalendarView::endDate() | 669 | QDate CalendarView::endDate() |
670 | { | 670 | { |
671 | DateList dates = mNavigator->selectedDates(); | 671 | DateList dates = mNavigator->selectedDates(); |
672 | 672 | ||
673 | return dates.last(); | 673 | return dates.last(); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | void CalendarView::createPrinter() | 677 | void CalendarView::createPrinter() |
678 | { | 678 | { |
679 | #ifndef KORG_NOPRINTER | 679 | #ifndef KORG_NOPRINTER |
680 | if (!mCalPrinter) { | 680 | if (!mCalPrinter) { |
681 | mCalPrinter = new CalPrinter(this, mCalendar); | 681 | mCalPrinter = new CalPrinter(this, mCalendar); |
682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | } | 685 | } |
686 | 686 | ||
687 | void CalendarView::confSync() | 687 | void CalendarView::confSync() |
688 | { | 688 | { |
689 | static KSyncPrefsDialog* sp = 0; | 689 | static KSyncPrefsDialog* sp = 0; |
690 | if ( ! sp ) { | 690 | if ( ! sp ) { |
691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
692 | } | 692 | } |
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
726 | // 2 take remote | 726 | // 2 take remote |
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 730 | bool remCh, locCh; |
731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
732 | if ( remCh ) | ||
733 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | ||
732 | locCh = ( local->lastModified() > mLastCalendarSync ); | 734 | locCh = ( local->lastModified() > mLastCalendarSync ); |
733 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); | 735 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); |
734 | if ( !remCh && ! locCh ) { | 736 | if ( !remCh && ! locCh ) { |
735 | //qDebug("both not changed "); | 737 | qDebug("both not changed "); |
736 | lastSync = local->lastModified().addDays(1); | 738 | lastSync = local->lastModified().addDays(1); |
737 | } else { | 739 | } else { |
738 | if ( locCh ) { | 740 | if ( locCh ) { |
739 | //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); | 741 | qDebug("loc changed %d", local->revision() ); |
740 | lastSync = local->lastModified().addDays( -1 ); | 742 | lastSync = local->lastModified().addDays( -1 ); |
741 | if ( !remCh ) | 743 | if ( !remCh ) |
742 | remote->setLastModified( lastSync.addDays( -1 ) ); | 744 | remote->setLastModified( lastSync.addDays( -1 ) ); |
743 | } else { | 745 | } else { |
744 | //qDebug(" not loc changed "); | 746 | qDebug(" not loc changed "); |
745 | lastSync = local->lastModified().addDays( 1 ); | 747 | lastSync = local->lastModified().addDays( 1 ); |
746 | if ( remCh ) | 748 | if ( remCh ) |
747 | remote->setLastModified( lastSync.addDays( 1 ) ); | 749 | remote->setLastModified( lastSync.addDays( 1 ) ); |
748 | 750 | ||
749 | } | 751 | } |
750 | } | 752 | } |
751 | full = true; | 753 | full = true; |
752 | if ( mode < SYNC_PREF_ASK ) | 754 | if ( mode < SYNC_PREF_ASK ) |
753 | mode = SYNC_PREF_ASK; | 755 | mode = SYNC_PREF_ASK; |
754 | } else { | 756 | } else { |
755 | if ( local->lastModified() == remote->lastModified() ) | 757 | if ( local->lastModified() == remote->lastModified() ) |
756 | if ( local->revision() == remote->revision() ) | 758 | if ( local->revision() == remote->revision() ) |
757 | return 0; | 759 | return 0; |
758 | 760 | ||
759 | } | 761 | } |
760 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
761 | 763 | ||
762 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 764 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
763 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 765 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
764 | //full = true; //debug only | 766 | //full = true; //debug only |
765 | if ( full ) { | 767 | if ( full ) { |
766 | bool equ = false; | 768 | bool equ = false; |
767 | if ( local->type() == "Event" ) { | 769 | if ( local->type() == "Event" ) { |
768 | equ = (*((Event*) local) == *((Event*) remote)); | 770 | equ = (*((Event*) local) == *((Event*) remote)); |
769 | } | 771 | } |
770 | else if ( local->type() =="Todo" ) | 772 | else if ( local->type() =="Todo" ) |
771 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 773 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
772 | else if ( local->type() =="Journal" ) | 774 | else if ( local->type() =="Journal" ) |
773 | equ = (*((Journal*) local) == *((Journal*) remote)); | 775 | equ = (*((Journal*) local) == *((Journal*) remote)); |
774 | if ( equ ) { | 776 | if ( equ ) { |
775 | //qDebug("equal "); | 777 | //qDebug("equal "); |
776 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 778 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
777 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 779 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
778 | } | 780 | } |
779 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 781 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
780 | return 0; | 782 | return 0; |
781 | 783 | ||
782 | }//else //debug only | 784 | }//else //debug only |
783 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 785 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
784 | } | 786 | } |
785 | int result; | 787 | int result; |
786 | bool localIsNew; | 788 | bool localIsNew; |
789 | qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | ||
790 | |||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 791 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 792 | mode = SYNC_PREF_ASK; |
789 | 793 | ||
790 | switch( mode ) { | 794 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 795 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remote->lastModified() ) | 796 | if ( lastSync > remote->lastModified() ) |
793 | return 1; | 797 | return 1; |
794 | if ( lastSync > local->lastModified() ) | 798 | if ( lastSync > local->lastModified() ) |
795 | return 2; | 799 | return 2; |
796 | return 1; | 800 | return 1; |
797 | break; | 801 | break; |
798 | case SYNC_PREF_REMOTE: | 802 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remote->lastModified() ) | 803 | if ( lastSync > remote->lastModified() ) |
800 | return 1; | 804 | return 1; |
801 | if ( lastSync > local->lastModified() ) | 805 | if ( lastSync > local->lastModified() ) |
802 | return 2; | 806 | return 2; |
803 | return 2; | 807 | return 2; |
804 | break; | 808 | break; |
805 | case SYNC_PREF_NEWEST: | 809 | case SYNC_PREF_NEWEST: |
806 | if ( local->lastModified() > remote->lastModified() ) | 810 | if ( local->lastModified() > remote->lastModified() ) |
807 | return 1; | 811 | return 1; |
808 | else | 812 | else |
809 | return 2; | 813 | return 2; |
810 | break; | 814 | break; |
811 | case SYNC_PREF_ASK: | 815 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
813 | if ( lastSync > remote->lastModified() ) | 817 | if ( lastSync > remote->lastModified() ) |
814 | return 1; | 818 | return 1; |
815 | if ( lastSync > local->lastModified() ) | 819 | if ( lastSync > local->lastModified() ) |
816 | return 2; | 820 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
818 | localIsNew = local->lastModified() > remote->lastModified(); | 822 | localIsNew = local->lastModified() >= remote->lastModified(); |
819 | if ( localIsNew ) | 823 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 824 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 825 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 826 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 827 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 828 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 829 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 830 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 831 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 832 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 833 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 834 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 835 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 836 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 837 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 838 | return result; |
835 | 839 | ||
836 | break; | 840 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 841 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 842 | return 1; |
839 | break; | 843 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 844 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 845 | return 2; |
842 | break; | 846 | break; |
843 | 847 | ||
844 | default: | 848 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 849 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 850 | break; |
847 | } | 851 | } |
848 | return 0; | 852 | return 0; |
849 | } | 853 | } |
850 | Event* CalendarView::getLastSyncEvent() | 854 | Event* CalendarView::getLastSyncEvent() |
851 | { | 855 | { |
852 | Event* lse; | 856 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 857 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 858 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 859 | if (!lse) { |
856 | lse = new Event(); | 860 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 861 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 862 | QString sum = ""; |
859 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 863 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 864 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 865 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 866 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 867 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 868 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 869 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 870 | mCalendar->addEvent( lse ); |
867 | } | 871 | } |
868 | 872 | ||
869 | return lse; | 873 | return lse; |
870 | 874 | ||
871 | } | 875 | } |
872 | // probaly useless | 876 | // probaly useless |
873 | void CalendarView::setupExternSyncProfiles() | 877 | void CalendarView::setupExternSyncProfiles() |
874 | { | 878 | { |
875 | Event* lse; | 879 | Event* lse; |
876 | mExternLastSyncEvent.clear(); | 880 | mExternLastSyncEvent.clear(); |
877 | int i; | 881 | int i; |
878 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 882 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
879 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 883 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
880 | if ( lse ) | 884 | if ( lse ) |
881 | mExternLastSyncEvent.append( lse ); | 885 | mExternLastSyncEvent.append( lse ); |
882 | else | 886 | else |
883 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 887 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
884 | } | 888 | } |
885 | 889 | ||
886 | } | 890 | } |
887 | // we check, if the to delete event has a id for a profile | 891 | // we check, if the to delete event has a id for a profile |
888 | // if yes, we set this id in the profile to delete | 892 | // if yes, we set this id in the profile to delete |
889 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 893 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
890 | { | 894 | { |
891 | if ( lastSync.count() == 0 ) { | 895 | if ( lastSync.count() == 0 ) { |
892 | //qDebug(" lastSync.count() == 0"); | 896 | //qDebug(" lastSync.count() == 0"); |
893 | return; | 897 | return; |
894 | } | 898 | } |
895 | if ( toDelete->type() == "Journal" ) | 899 | if ( toDelete->type() == "Journal" ) |
896 | return; | 900 | return; |
897 | 901 | ||
898 | Event* eve = lastSync.first(); | 902 | Event* eve = lastSync.first(); |
899 | 903 | ||
900 | while ( eve ) { | 904 | while ( eve ) { |
901 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 905 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
902 | if ( !id.isEmpty() ) { | 906 | if ( !id.isEmpty() ) { |
903 | QString des = eve->description(); | 907 | QString des = eve->description(); |
904 | QString pref = "e"; | 908 | QString pref = "e"; |
905 | if ( toDelete->type() == "Todo" ) | 909 | if ( toDelete->type() == "Todo" ) |
906 | pref = "t"; | 910 | pref = "t"; |
907 | des += pref+ id + ","; | 911 | des += pref+ id + ","; |
908 | eve->setReadOnly( false ); | 912 | eve->setReadOnly( false ); |
909 | eve->setDescription( des ); | 913 | eve->setDescription( des ); |
910 | //qDebug("setdes %s ", des.latin1()); | 914 | //qDebug("setdes %s ", des.latin1()); |
911 | eve->setReadOnly( true ); | 915 | eve->setReadOnly( true ); |
912 | } | 916 | } |
913 | eve = lastSync.next(); | 917 | eve = lastSync.next(); |
914 | } | 918 | } |
915 | 919 | ||
916 | } | 920 | } |
917 | void CalendarView::checkExternalId( Incidence * inc ) | 921 | void CalendarView::checkExternalId( Incidence * inc ) |
918 | { | 922 | { |
919 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 923 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
920 | checkExternSyncEvent( lastSync, inc ); | 924 | checkExternSyncEvent( lastSync, inc ); |
921 | 925 | ||
922 | } | 926 | } |
923 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 927 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
924 | { | 928 | { |
925 | bool syncOK = true; | 929 | bool syncOK = true; |
926 | int addedEvent = 0; | 930 | int addedEvent = 0; |
927 | int addedEventR = 0; | 931 | int addedEventR = 0; |
928 | int deletedEventR = 0; | 932 | int deletedEventR = 0; |
929 | int deletedEventL = 0; | 933 | int deletedEventL = 0; |
930 | int changedLocal = 0; | 934 | int changedLocal = 0; |
931 | int changedRemote = 0; | 935 | int changedRemote = 0; |
932 | //QPtrList<Event> el = local->rawEvents(); | 936 | //QPtrList<Event> el = local->rawEvents(); |
933 | Event* eventR; | 937 | Event* eventR; |
934 | QString uid; | 938 | QString uid; |
935 | int take; | 939 | int take; |
936 | Event* eventL; | 940 | Event* eventL; |
937 | Event* eventRSync; | 941 | Event* eventRSync; |
938 | Event* eventLSync; | 942 | Event* eventLSync; |
939 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 943 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
940 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 944 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
941 | bool fullDateRange = false; | 945 | bool fullDateRange = false; |
942 | local->resetTempSyncStat(); | 946 | local->resetTempSyncStat(); |
943 | mLastCalendarSync = QDateTime::currentDateTime(); | 947 | mLastCalendarSync = QDateTime::currentDateTime(); |
944 | QDateTime modifiedCalendar = mLastCalendarSync;; | 948 | QDateTime modifiedCalendar = mLastCalendarSync;; |
949 | eventLSync = getLastSyncEvent(); | ||
945 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
946 | if ( eventR ) { | 951 | if ( eventR ) { |
947 | eventRSync = (Event*) eventR->clone(); | 952 | eventRSync = (Event*) eventR->clone(); |
948 | remote->deleteEvent(eventR ); | 953 | remote->deleteEvent(eventR ); |
949 | 954 | ||
950 | } else { | 955 | } else { |
951 | fullDateRange = true; | 956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
952 | eventRSync = new Event(); | 957 | eventRSync = (Event*)eventLSync->clone(); |
953 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 958 | } else { |
954 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 959 | fullDateRange = true; |
955 | eventRSync->setDtStart( mLastCalendarSync ); | 960 | eventRSync = new Event(); |
956 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
957 | eventRSync->setCategories( i18n("SyncEvent") ); | 962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
963 | eventRSync->setDtStart( mLastCalendarSync ); | ||
964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | ||
965 | eventRSync->setCategories( i18n("SyncEvent") ); | ||
966 | } | ||
958 | } | 967 | } |
959 | eventLSync = getLastSyncEvent(); | ||
960 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 968 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
961 | fullDateRange = true; | 969 | fullDateRange = true; |
962 | 970 | ||
963 | if ( ! fullDateRange ) { | 971 | if ( ! fullDateRange ) { |
964 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
965 | 973 | ||
966 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
967 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
968 | fullDateRange = true; | 976 | fullDateRange = true; |
969 | } | 977 | } |
970 | } | 978 | } |
971 | if ( fullDateRange ) | 979 | if ( fullDateRange ) |
972 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 980 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
973 | else | 981 | else |
974 | mLastCalendarSync = eventLSync->dtStart(); | 982 | mLastCalendarSync = eventLSync->dtStart(); |
975 | // for resyncing if own file has changed | 983 | // for resyncing if own file has changed |
976 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 984 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
977 | mLastCalendarSync = loadedFileVersion; | 985 | mLastCalendarSync = loadedFileVersion; |
978 | qDebug("setting mLastCalendarSync "); | 986 | qDebug("setting mLastCalendarSync "); |
979 | } | 987 | } |
980 | //qDebug("*************************** "); | 988 | //qDebug("*************************** "); |
981 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
982 | QPtrList<Incidence> er = remote->rawIncidences(); | 990 | QPtrList<Incidence> er = remote->rawIncidences(); |
983 | Incidence* inR = er.first(); | 991 | Incidence* inR = er.first(); |
984 | Incidence* inL; | 992 | Incidence* inL; |
985 | QProgressBar bar( er.count(),0 ); | 993 | QProgressBar bar( er.count(),0 ); |
986 | bar.setCaption (i18n("Syncing - close to abort!") ); | 994 | bar.setCaption (i18n("Syncing - close to abort!") ); |
987 | 995 | ||
988 | int w = 300; | 996 | int w = 300; |
989 | if ( QApplication::desktop()->width() < 320 ) | 997 | if ( QApplication::desktop()->width() < 320 ) |
990 | w = 220; | 998 | w = 220; |
991 | int h = bar.sizeHint().height() ; | 999 | int h = bar.sizeHint().height() ; |
992 | int dw = QApplication::desktop()->width(); | 1000 | int dw = QApplication::desktop()->width(); |
993 | int dh = QApplication::desktop()->height(); | 1001 | int dh = QApplication::desktop()->height(); |
994 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1002 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
995 | bar.show(); | 1003 | bar.show(); |
996 | int modulo = (er.count()/10)+1; | 1004 | int modulo = (er.count()/10)+1; |
997 | int incCounter = 0; | 1005 | int incCounter = 0; |
998 | while ( inR ) { | 1006 | while ( inR ) { |
999 | if ( ! bar.isVisible() ) | 1007 | if ( ! bar.isVisible() ) |
1000 | return false; | 1008 | return false; |
1001 | if ( incCounter % modulo == 0 ) | 1009 | if ( incCounter % modulo == 0 ) |
1002 | bar.setProgress( incCounter ); | 1010 | bar.setProgress( incCounter ); |
1003 | ++incCounter; | 1011 | ++incCounter; |
1004 | uid = inR->uid(); | 1012 | uid = inR->uid(); |
1005 | bool skipIncidence = false; | 1013 | bool skipIncidence = false; |
1006 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1014 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1007 | skipIncidence = true; | 1015 | skipIncidence = true; |
1008 | 1016 | ||
1009 | qApp->processEvents(); | 1017 | qApp->processEvents(); |
1010 | if ( !skipIncidence ) { | 1018 | if ( !skipIncidence ) { |
1011 | inL = local->incidence( uid ); | 1019 | inL = local->incidence( uid ); |
1012 | if ( inL ) { // maybe conflict - same uid in both calendars | 1020 | if ( inL ) { // maybe conflict - same uid in both calendars |
1013 | int maxrev = inL->revision(); | 1021 | int maxrev = inL->revision(); |
1014 | if ( maxrev < inR->revision() ) | 1022 | if ( maxrev < inR->revision() ) |
1015 | maxrev = inR->revision(); | 1023 | maxrev = inR->revision(); |
1016 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1017 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1018 | if ( take == 3 ) | 1026 | if ( take == 3 ) |
1019 | return false; | 1027 | return false; |
1020 | if ( take == 1 ) {// take local | 1028 | if ( take == 1 ) {// take local |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1029 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | remote->deleteIncidence( inR ); | 1030 | remote->deleteIncidence( inR ); |
1023 | if ( inL->revision() < maxrev ) | 1031 | if ( inL->revision() < maxrev ) |
1024 | inL->setRevision( maxrev ); | 1032 | inL->setRevision( maxrev ); |
1025 | remote->addIncidence( inL->clone() ); | 1033 | remote->addIncidence( inL->clone() ); |
1026 | ++changedRemote; | 1034 | ++changedRemote; |
1027 | } else { | 1035 | } else { |
1028 | if ( inR->revision() < maxrev ) | 1036 | if ( inR->revision() < maxrev ) |
1029 | inR->setRevision( maxrev ); | 1037 | inR->setRevision( maxrev ); |
1030 | local->deleteIncidence( inL ); | 1038 | local->deleteIncidence( inL ); |
1031 | local->addIncidence( inR->clone() ); | 1039 | local->addIncidence( inR->clone() ); |
1032 | ++changedLocal; | 1040 | ++changedLocal; |
1033 | } | 1041 | } |
1034 | } | 1042 | } |
1035 | } else { // no conflict | 1043 | } else { // no conflict |
1036 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1037 | QString des = eventLSync->description(); | 1045 | QString des = eventLSync->description(); |
1038 | QString pref = "e"; | 1046 | QString pref = "e"; |
1039 | if ( inR->type() == "Todo" ) | 1047 | if ( inR->type() == "Todo" ) |
1040 | pref = "t"; | 1048 | pref = "t"; |
1041 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1049 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1042 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1050 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1043 | //remote->deleteIncidence( inR ); | 1051 | //remote->deleteIncidence( inR ); |
1044 | ++deletedEventR; | 1052 | ++deletedEventR; |
1045 | } else { | 1053 | } else { |
1046 | inR->setLastModified( modifiedCalendar ); | 1054 | inR->setLastModified( modifiedCalendar ); |
1047 | local->addIncidence( inR->clone() ); | 1055 | local->addIncidence( inR->clone() ); |
1048 | ++addedEvent; | 1056 | ++addedEvent; |
1049 | } | 1057 | } |
1050 | } else { | 1058 | } else { |
1051 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1059 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1052 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1053 | local->addIncidence( inR->clone() ); | 1061 | local->addIncidence( inR->clone() ); |
1054 | ++addedEvent; | 1062 | ++addedEvent; |
1055 | } else { | 1063 | } else { |
1056 | checkExternSyncEvent(eventRSyncSharp, inR); | 1064 | checkExternSyncEvent(eventRSyncSharp, inR); |
1057 | remote->deleteIncidence( inR ); | 1065 | remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1066 | ++deletedEventR; |
1059 | } | 1067 | } |
1060 | } | 1068 | } |
1061 | } | 1069 | } |
1062 | } | 1070 | } |
1063 | inR = er.next(); | 1071 | inR = er.next(); |
1064 | } | 1072 | } |
1065 | QPtrList<Incidence> el = local->rawIncidences(); | 1073 | QPtrList<Incidence> el = local->rawIncidences(); |
1066 | inL = el.first(); | 1074 | inL = el.first(); |
1067 | modulo = (el.count()/10)+1; | 1075 | modulo = (el.count()/10)+1; |
1068 | bar.setCaption (i18n("Add / remove events") ); | 1076 | bar.setCaption (i18n("Add / remove events") ); |
1069 | bar.setTotalSteps ( el.count() ) ; | 1077 | bar.setTotalSteps ( el.count() ) ; |
1070 | bar.show(); | 1078 | bar.show(); |
1071 | incCounter = 0; | 1079 | incCounter = 0; |
1072 | 1080 | ||
1073 | while ( inL ) { | 1081 | while ( inL ) { |
1074 | 1082 | ||
1075 | qApp->processEvents(); | 1083 | qApp->processEvents(); |
1076 | if ( ! bar.isVisible() ) | 1084 | if ( ! bar.isVisible() ) |
1077 | return false; | 1085 | return false; |
1078 | if ( incCounter % modulo == 0 ) | 1086 | if ( incCounter % modulo == 0 ) |
1079 | bar.setProgress( incCounter ); | 1087 | bar.setProgress( incCounter ); |
1080 | ++incCounter; | 1088 | ++incCounter; |
1081 | uid = inL->uid(); | 1089 | uid = inL->uid(); |
1082 | bool skipIncidence = false; | 1090 | bool skipIncidence = false; |
1083 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1091 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1084 | skipIncidence = true; | 1092 | skipIncidence = true; |
1085 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1093 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1086 | skipIncidence = true; | 1094 | skipIncidence = true; |
1087 | if ( !skipIncidence ) { | 1095 | if ( !skipIncidence ) { |
1088 | inR = remote->incidence( uid ); | 1096 | inR = remote->incidence( uid ); |
1089 | if ( ! inR ) { | 1097 | if ( ! inR ) { |
1090 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1098 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1091 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1099 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1092 | local->deleteIncidence( inL ); | 1100 | local->deleteIncidence( inL ); |
1093 | ++deletedEventL; | 1101 | ++deletedEventL; |
1094 | } else { | 1102 | } else { |
1095 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1103 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1096 | inL->removeID(mCurrentSyncDevice ); | 1104 | inL->removeID(mCurrentSyncDevice ); |
1097 | ++addedEventR; | 1105 | ++addedEventR; |
1098 | inL->setLastModified( modifiedCalendar ); | 1106 | inL->setLastModified( modifiedCalendar ); |
1099 | remote->addIncidence( inL->clone() ); | 1107 | remote->addIncidence( inL->clone() ); |
1100 | } | 1108 | } |
1101 | } | 1109 | } |
1102 | } else { | 1110 | } else { |
1103 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1111 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1104 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1105 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1106 | ++deletedEventL; | 1114 | ++deletedEventL; |
1107 | } else { | 1115 | } else { |
1108 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1109 | ++addedEventR; | 1117 | ++addedEventR; |
1110 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1111 | remote->addIncidence( inL->clone() ); | 1119 | remote->addIncidence( inL->clone() ); |
1112 | } | 1120 | } |
1113 | } | 1121 | } |
1114 | } | 1122 | } |
1115 | } | 1123 | } |
1116 | } | 1124 | } |
1117 | inL = el.next(); | 1125 | inL = el.next(); |
1118 | } | 1126 | } |
1119 | 1127 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | |
1128 | er = remote->rawIncidences(); | ||
1129 | inR = er.first(); | ||
1130 | QDateTime dt; | ||
1131 | QDateTime cur = QDateTime::currentDateTime(); | ||
1132 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | ||
1133 | while ( inR ) { | ||
1134 | if ( inR->type() == "Todo" ) { | ||
1135 | Todo * t = (Todo*)inR; | ||
1136 | if ( t->hasDueDate() ) | ||
1137 | dt = t->dtDue(); | ||
1138 | else | ||
1139 | dt = cur.addSecs( 62 ); | ||
1140 | } | ||
1141 | else dt = inR->dtStart(); | ||
1142 | if ( dt < cur || dt > end ) | ||
1143 | remote->deleteIncidence( inR ); | ||
1144 | inR = er.next(); | ||
1145 | } | ||
1146 | } | ||
1120 | bar.hide(); | 1147 | bar.hide(); |
1121 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1148 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1122 | eventLSync->setReadOnly( false ); | 1149 | eventLSync->setReadOnly( false ); |
1123 | eventLSync->setDtStart( mLastCalendarSync ); | 1150 | eventLSync->setDtStart( mLastCalendarSync ); |
1124 | eventRSync->setDtStart( mLastCalendarSync ); | 1151 | eventRSync->setDtStart( mLastCalendarSync ); |
1125 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1152 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1126 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1153 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1127 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1154 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1128 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1155 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1129 | eventLSync->setReadOnly( true ); | 1156 | eventLSync->setReadOnly( true ); |
1130 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1157 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1131 | remote->addEvent( eventRSync ); | 1158 | remote->addEvent( eventRSync ); |
1132 | QString mes; | 1159 | QString mes; |
1133 | 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 ); | 1160 | 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 ); |
1134 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1161 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1135 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1162 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1136 | } | 1163 | } |
1137 | qDebug( mes ); | 1164 | qDebug( mes ); |
1138 | mCalendar->checkAlarmForIncidence( 0, true ); | 1165 | mCalendar->checkAlarmForIncidence( 0, true ); |
1139 | return syncOK; | 1166 | return syncOK; |
1140 | } | 1167 | } |
1141 | 1168 | ||
1142 | void CalendarView::setSyncDevice( QString s ) | 1169 | void CalendarView::setSyncDevice( QString s ) |
1143 | { | 1170 | { |
1144 | mCurrentSyncDevice= s; | 1171 | mCurrentSyncDevice= s; |
1145 | } | 1172 | } |
1146 | void CalendarView::setSyncName( QString s ) | 1173 | void CalendarView::setSyncName( QString s ) |
1147 | { | 1174 | { |
1148 | mCurrentSyncName= s; | 1175 | mCurrentSyncName= s; |
1149 | } | 1176 | } |
1150 | bool CalendarView::syncCalendar(QString filename, int mode) | 1177 | bool CalendarView::syncCalendar(QString filename, int mode) |
1151 | { | 1178 | { |
1152 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1179 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1153 | CalendarLocal* calendar = new CalendarLocal(); | 1180 | CalendarLocal* calendar = new CalendarLocal(); |
1154 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1181 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1155 | FileStorage* storage = new FileStorage( calendar ); | 1182 | FileStorage* storage = new FileStorage( calendar ); |
1156 | bool syncOK = false; | 1183 | bool syncOK = false; |
1157 | storage->setFileName( filename ); | 1184 | storage->setFileName( filename ); |
1158 | // qDebug("loading ... "); | 1185 | // qDebug("loading ... "); |
1159 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1186 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1160 | getEventViewerDialog()->setSyncMode( true ); | 1187 | getEventViewerDialog()->setSyncMode( true ); |
1161 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1188 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1162 | getEventViewerDialog()->setSyncMode( false ); | 1189 | getEventViewerDialog()->setSyncMode( false ); |
1163 | if ( syncOK ) { | 1190 | if ( syncOK ) { |
1164 | if ( KOPrefs::instance()->mWriteBackFile ) | 1191 | if ( KOPrefs::instance()->mWriteBackFile ) |
1165 | { | 1192 | { |
1166 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1193 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1167 | storage->save(); | 1194 | storage->save(); |
1168 | } | 1195 | } |
1169 | } | 1196 | } |
1170 | setModified( true ); | 1197 | setModified( true ); |
1171 | } | 1198 | } |
1172 | delete storage; | 1199 | delete storage; |
1173 | delete calendar; | 1200 | delete calendar; |
1174 | if ( syncOK ) | 1201 | if ( syncOK ) |
1175 | updateView(); | 1202 | updateView(); |
1176 | return syncOK; | 1203 | return syncOK; |
1177 | } | 1204 | } |
1178 | void CalendarView::syncPhone() | 1205 | void CalendarView::syncPhone() |
1179 | { | 1206 | { |
1180 | syncExternal( 1 ); | 1207 | syncExternal( 1 ); |
1181 | } | 1208 | } |
1182 | void CalendarView::syncExternal( int mode ) | 1209 | void CalendarView::syncExternal( int mode ) |
1183 | { | 1210 | { |
1184 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1211 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1185 | //mCurrentSyncDevice = "sharp-DTM"; | 1212 | //mCurrentSyncDevice = "sharp-DTM"; |
1186 | if ( KOPrefs::instance()->mAskForPreferences ) | 1213 | if ( KOPrefs::instance()->mAskForPreferences ) |
1187 | edit_sync_options(); | 1214 | edit_sync_options(); |
1188 | qApp->processEvents(); | 1215 | qApp->processEvents(); |
1189 | CalendarLocal* calendar = new CalendarLocal(); | 1216 | CalendarLocal* calendar = new CalendarLocal(); |
1190 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1217 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1191 | bool syncOK = false; | 1218 | bool syncOK = false; |
1192 | bool loadSuccess = false; | 1219 | bool loadSuccess = false; |
1193 | PhoneFormat* phoneFormat = 0; | 1220 | PhoneFormat* phoneFormat = 0; |
1194 | #ifndef DESKTOP_VERSION | 1221 | #ifndef DESKTOP_VERSION |
1195 | SharpFormat* sharpFormat = 0; | 1222 | SharpFormat* sharpFormat = 0; |
1196 | if ( mode == 0 ) { // sharp | 1223 | if ( mode == 0 ) { // sharp |
1197 | sharpFormat = new SharpFormat () ; | 1224 | sharpFormat = new SharpFormat () ; |
1198 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1225 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1199 | 1226 | ||
1200 | } else | 1227 | } else |
1201 | #endif | 1228 | #endif |
1202 | if ( mode == 1 ) { // phone | 1229 | if ( mode == 1 ) { // phone |
1203 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1230 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1204 | KOPrefs::instance()->mPhoneDevice, | 1231 | KOPrefs::instance()->mPhoneDevice, |
1205 | KOPrefs::instance()->mPhoneConnection, | 1232 | KOPrefs::instance()->mPhoneConnection, |
1206 | KOPrefs::instance()->mPhoneModel); | 1233 | KOPrefs::instance()->mPhoneModel); |
1207 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1234 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1208 | 1235 | ||
1209 | } else | 1236 | } else |
1210 | return; | 1237 | return; |
1211 | if ( loadSuccess ) { | 1238 | if ( loadSuccess ) { |
1212 | getEventViewerDialog()->setSyncMode( true ); | 1239 | getEventViewerDialog()->setSyncMode( true ); |
1213 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1240 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1214 | getEventViewerDialog()->setSyncMode( false ); | 1241 | getEventViewerDialog()->setSyncMode( false ); |
1215 | qApp->processEvents(); | 1242 | qApp->processEvents(); |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 446fe2e..a9ac52f 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -106,192 +106,193 @@ class KOPrefs : public KPimPrefs | |||
106 | int mDefaultDuration; | 106 | int mDefaultDuration; |
107 | int mAlarmTime; | 107 | int mAlarmTime; |
108 | int mDaylightSavings; | 108 | int mDaylightSavings; |
109 | 109 | ||
110 | int mWorkingHoursStart; | 110 | int mWorkingHoursStart; |
111 | int mWorkingHoursEnd; | 111 | int mWorkingHoursEnd; |
112 | bool mExcludeHolidays; | 112 | bool mExcludeHolidays; |
113 | bool mExcludeSaturdays; | 113 | bool mExcludeSaturdays; |
114 | bool mMarcusBainsShowSeconds; | 114 | bool mMarcusBainsShowSeconds; |
115 | 115 | ||
116 | QFont mTimeBarFont; | 116 | QFont mTimeBarFont; |
117 | QFont mMonthViewFont; | 117 | QFont mMonthViewFont; |
118 | QFont mAgendaViewFont; | 118 | QFont mAgendaViewFont; |
119 | QFont mMarcusBainsFont; | 119 | QFont mMarcusBainsFont; |
120 | QFont mTimeLabelsFont; | 120 | QFont mTimeLabelsFont; |
121 | QFont mTodoViewFont; | 121 | QFont mTodoViewFont; |
122 | QFont mListViewFont; | 122 | QFont mListViewFont; |
123 | QFont mDateNavigatorFont; | 123 | QFont mDateNavigatorFont; |
124 | QFont mEditBoxFont; | 124 | QFont mEditBoxFont; |
125 | QFont mJornalViewFont; | 125 | QFont mJornalViewFont; |
126 | QFont mWhatsNextFont; | 126 | QFont mWhatsNextFont; |
127 | QFont mEventViewFont; | 127 | QFont mEventViewFont; |
128 | 128 | ||
129 | 129 | ||
130 | 130 | ||
131 | 131 | ||
132 | QColor mHolidayColor; | 132 | QColor mHolidayColor; |
133 | QColor mHighlightColor; | 133 | QColor mHighlightColor; |
134 | QColor mEventColor; | 134 | QColor mEventColor; |
135 | QColor mAgendaBgColor; | 135 | QColor mAgendaBgColor; |
136 | QColor mWorkingHoursColor; | 136 | QColor mWorkingHoursColor; |
137 | QColor mTodoDueTodayColor; | 137 | QColor mTodoDueTodayColor; |
138 | QColor mTodoOverdueColor; | 138 | QColor mTodoOverdueColor; |
139 | QColor mMonthViewEvenColor; | 139 | QColor mMonthViewEvenColor; |
140 | QColor mMonthViewOddColor; | 140 | QColor mMonthViewOddColor; |
141 | QColor mMonthViewHolidayColor; | 141 | QColor mMonthViewHolidayColor; |
142 | bool mMonthViewUsesDayColors; | 142 | bool mMonthViewUsesDayColors; |
143 | bool mMonthViewSatSunTog; | 143 | bool mMonthViewSatSunTog; |
144 | QColor mAppColor1; | 144 | QColor mAppColor1; |
145 | QColor mAppColor2; | 145 | QColor mAppColor2; |
146 | bool mUseAppColors; | 146 | bool mUseAppColors; |
147 | 147 | ||
148 | int mDayBegins; | 148 | int mDayBegins; |
149 | int mHourSize; | 149 | int mHourSize; |
150 | int mAllDaySize; | 150 | int mAllDaySize; |
151 | bool mShowFullMenu; | 151 | bool mShowFullMenu; |
152 | bool mDailyRecur; | 152 | bool mDailyRecur; |
153 | bool mWeeklyRecur; | 153 | bool mWeeklyRecur; |
154 | bool mMonthDailyRecur; | 154 | bool mMonthDailyRecur; |
155 | bool mMonthWeeklyRecur; | 155 | bool mMonthWeeklyRecur; |
156 | bool mMonthShowIcons; | 156 | bool mMonthShowIcons; |
157 | bool mMonthShowShort; | 157 | bool mMonthShowShort; |
158 | bool mEnableToolTips; | 158 | bool mEnableToolTips; |
159 | bool mEnableMonthScroll; | 159 | bool mEnableMonthScroll; |
160 | bool mFullViewMonth; | 160 | bool mFullViewMonth; |
161 | bool mMonthViewUsesCategoryColor; | 161 | bool mMonthViewUsesCategoryColor; |
162 | bool mFullViewTodo; | 162 | bool mFullViewTodo; |
163 | bool mShowCompletedTodo; | 163 | bool mShowCompletedTodo; |
164 | bool mMarcusBainsEnabled; | 164 | bool mMarcusBainsEnabled; |
165 | int mNextXDays; | 165 | int mNextXDays; |
166 | int mWhatsNextDays; | 166 | int mWhatsNextDays; |
167 | int mWhatsNextPrios; | 167 | int mWhatsNextPrios; |
168 | bool mEnableQuickTodo; | 168 | bool mEnableQuickTodo; |
169 | bool mLanguageChanged; | 169 | bool mLanguageChanged; |
170 | 170 | ||
171 | bool mCompactDialogs; | 171 | bool mCompactDialogs; |
172 | bool mVerticalScreen; | 172 | bool mVerticalScreen; |
173 | 173 | ||
174 | bool mShowIconNewTodo; | 174 | bool mShowIconNewTodo; |
175 | bool mShowIconNewEvent; | 175 | bool mShowIconNewEvent; |
176 | bool mShowIconSearch; | 176 | bool mShowIconSearch; |
177 | bool mShowIconList; | 177 | bool mShowIconList; |
178 | bool mShowIconDay1; | 178 | bool mShowIconDay1; |
179 | bool mShowIconDay5; | 179 | bool mShowIconDay5; |
180 | bool mShowIconDay7; | 180 | bool mShowIconDay7; |
181 | bool mShowIconMonth; | 181 | bool mShowIconMonth; |
182 | bool mShowIconTodoview; | 182 | bool mShowIconTodoview; |
183 | bool mShowIconBackFast; | 183 | bool mShowIconBackFast; |
184 | bool mShowIconBack; | 184 | bool mShowIconBack; |
185 | bool mShowIconToday; | 185 | bool mShowIconToday; |
186 | bool mShowIconForward; | 186 | bool mShowIconForward; |
187 | bool mShowIconForwardFast; | 187 | bool mShowIconForwardFast; |
188 | bool mShowIconWhatsThis; | 188 | bool mShowIconWhatsThis; |
189 | bool mShowIconNextDays; | 189 | bool mShowIconNextDays; |
190 | bool mShowIconNext; | 190 | bool mShowIconNext; |
191 | bool mShowIconJournal; | 191 | bool mShowIconJournal; |
192 | 192 | ||
193 | bool mShowIconStretch; | 193 | bool mShowIconStretch; |
194 | 194 | ||
195 | bool mToolBarHor; | 195 | bool mToolBarHor; |
196 | bool mToolBarUp; | 196 | bool mToolBarUp; |
197 | bool mToolBarMiniIcons; | 197 | bool mToolBarMiniIcons; |
198 | 198 | ||
199 | bool mAskForQuit; | 199 | bool mAskForQuit; |
200 | bool mUsePassWd; | 200 | bool mUsePassWd; |
201 | bool mWriteBackFile; | 201 | bool mWriteBackFile; |
202 | int mWriteBackInFuture; | ||
202 | bool mAskForPreferences; | 203 | bool mAskForPreferences; |
203 | bool mShowSyncSummary; | 204 | bool mShowSyncSummary; |
204 | bool mShowSyncEvents; | 205 | bool mShowSyncEvents; |
205 | bool mShowTodoInAgenda; | 206 | bool mShowTodoInAgenda; |
206 | bool mWriteBackExistingOnly; | 207 | bool mWriteBackExistingOnly; |
207 | 208 | ||
208 | QString mRemoteIP; | 209 | QString mRemoteIP; |
209 | QString mRemoteUser; | 210 | QString mRemoteUser; |
210 | QString mRemotePassWd; | 211 | QString mRemotePassWd; |
211 | QString mRemoteFile; | 212 | QString mRemoteFile; |
212 | QString mLocalTempFile; | 213 | QString mLocalTempFile; |
213 | QString mPhoneDevice; | 214 | QString mPhoneDevice; |
214 | QString mPhoneConnection; | 215 | QString mPhoneConnection; |
215 | QString mPhoneModel; | 216 | QString mPhoneModel; |
216 | 217 | ||
217 | int mLastSyncTime; | 218 | int mLastSyncTime; |
218 | int mSyncAlgoPrefs; | 219 | int mSyncAlgoPrefs; |
219 | int mRingSyncAlgoPrefs; | 220 | int mRingSyncAlgoPrefs; |
220 | QStringList mSyncProfileNames; | 221 | QStringList mSyncProfileNames; |
221 | QStringList mExternSyncProfiles; | 222 | QStringList mExternSyncProfiles; |
222 | QString mLocalMachineName; | 223 | QString mLocalMachineName; |
223 | void setCategoryColor(QString cat,const QColor & color); | 224 | void setCategoryColor(QString cat,const QColor & color); |
224 | QColor *categoryColor(QString cat); | 225 | QColor *categoryColor(QString cat); |
225 | 226 | ||
226 | QString mArchiveFile; | 227 | QString mArchiveFile; |
227 | QString mHtmlExportFile; | 228 | QString mHtmlExportFile; |
228 | bool mHtmlWithSave; | 229 | bool mHtmlWithSave; |
229 | 230 | ||
230 | QStringList mSelectedPlugins; | 231 | QStringList mSelectedPlugins; |
231 | 232 | ||
232 | QString mLastImportFile; | 233 | QString mLastImportFile; |
233 | QString mLastVcalFile; | 234 | QString mLastVcalFile; |
234 | QString mLastSaveFile; | 235 | QString mLastSaveFile; |
235 | QString mLastLoadFile; | 236 | QString mLastLoadFile; |
236 | QString mLastSyncedLocalFile; | 237 | QString mLastSyncedLocalFile; |
237 | 238 | ||
238 | 239 | ||
239 | QString mDefaultAlarmFile; | 240 | QString mDefaultAlarmFile; |
240 | int mIMIPScheduler; | 241 | int mIMIPScheduler; |
241 | int mIMIPSend; | 242 | int mIMIPSend; |
242 | QStringList mAdditionalMails; | 243 | QStringList mAdditionalMails; |
243 | int mIMIPAutoRefresh; | 244 | int mIMIPAutoRefresh; |
244 | int mIMIPAutoInsertReply; | 245 | int mIMIPAutoInsertReply; |
245 | int mIMIPAutoInsertRequest; | 246 | int mIMIPAutoInsertRequest; |
246 | int mIMIPAutoFreeBusy; | 247 | int mIMIPAutoFreeBusy; |
247 | int mIMIPAutoFreeBusyReply; | 248 | int mIMIPAutoFreeBusyReply; |
248 | 249 | ||
249 | QStringList mTodoTemplates; | 250 | QStringList mTodoTemplates; |
250 | QStringList mEventTemplates; | 251 | QStringList mEventTemplates; |
251 | 252 | ||
252 | int mDestination; | 253 | int mDestination; |
253 | 254 | ||
254 | 255 | ||
255 | bool mEditOnDoubleClick; | 256 | bool mEditOnDoubleClick; |
256 | bool mViewChangeHoldFullscreen; | 257 | bool mViewChangeHoldFullscreen; |
257 | bool mViewChangeHoldNonFullscreen; | 258 | bool mViewChangeHoldNonFullscreen; |
258 | bool mCenterOnCurrentTime; | 259 | bool mCenterOnCurrentTime; |
259 | bool mSetTimeToDayStartAt; | 260 | bool mSetTimeToDayStartAt; |
260 | bool mHighlightCurrentDay; | 261 | bool mHighlightCurrentDay; |
261 | bool mUseHighlightLightColor; | 262 | bool mUseHighlightLightColor; |
262 | bool mListViewMonthTimespan; | 263 | bool mListViewMonthTimespan; |
263 | bool mWNViewShowsParents; | 264 | bool mWNViewShowsParents; |
264 | bool mWNViewShowLocation; | 265 | bool mWNViewShowLocation; |
265 | bool mTodoViewShowsPercentage; | 266 | bool mTodoViewShowsPercentage; |
266 | bool mTodoViewUsesCatColors; | 267 | bool mTodoViewUsesCatColors; |
267 | bool mTodoViewUsesSmallFont; | 268 | bool mTodoViewUsesSmallFont; |
268 | bool mTodoViewUsesForegroundColor; | 269 | bool mTodoViewUsesForegroundColor; |
269 | bool mMonthViewUsesForegroundColor; | 270 | bool mMonthViewUsesForegroundColor; |
270 | 271 | ||
271 | bool mHightlightDateTimeEdit; | 272 | bool mHightlightDateTimeEdit; |
272 | int mPreferredLanguage; | 273 | int mPreferredLanguage; |
273 | bool mUseQuicksave; | 274 | bool mUseQuicksave; |
274 | int mPreferredTime; | 275 | int mPreferredTime; |
275 | int mPreferredDate; | 276 | int mPreferredDate; |
276 | bool mWeekStartsOnSunday; | 277 | bool mWeekStartsOnSunday; |
277 | bool mShortDateInViewer; | 278 | bool mShortDateInViewer; |
278 | QString mUserDateFormatLong; | 279 | QString mUserDateFormatLong; |
279 | QString mUserDateFormatShort; | 280 | QString mUserDateFormatShort; |
280 | 281 | ||
281 | QStringList mLocationDefaults; | 282 | QStringList mLocationDefaults; |
282 | QStringList mEventSummaryUser; | 283 | QStringList mEventSummaryUser; |
283 | QStringList mTodoSummaryUser; | 284 | QStringList mTodoSummaryUser; |
284 | 285 | ||
285 | bool mUseInternalAlarmNotification; | 286 | bool mUseInternalAlarmNotification; |
286 | int mAlarmPlayBeeps; | 287 | int mAlarmPlayBeeps; |
287 | int mAlarmSuspendTime; | 288 | int mAlarmSuspendTime; |
288 | int mAlarmSuspendCount; | 289 | int mAlarmSuspendCount; |
289 | int mAlarmBeepInterval; | 290 | int mAlarmBeepInterval; |
290 | 291 | ||
291 | private: | 292 | private: |
292 | QDict<QColor> mCategoryColors; | 293 | QDict<QColor> mCategoryColors; |
293 | QColor mDefaultCategoryColor; | 294 | QColor mDefaultCategoryColor; |
294 | 295 | ||
295 | QFont mDefaultTimeBarFont; | 296 | QFont mDefaultTimeBarFont; |
296 | QFont mDefaultViewFont; | 297 | QFont mDefaultViewFont; |
297 | QFont mDefaultMonthViewFont; | 298 | QFont mDefaultMonthViewFont; |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index d8aa43a..aa30b52 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -821,295 +821,301 @@ void MainWindow::initActions() | |||
821 | if (p-> mShowIconBackFast) | 821 | if (p-> mShowIconBackFast) |
822 | configureToolBarMenu->setItemChecked( 200, true ); | 822 | configureToolBarMenu->setItemChecked( 200, true ); |
823 | if (p-> mShowIconBack) | 823 | if (p-> mShowIconBack) |
824 | configureToolBarMenu->setItemChecked( 210, true ); | 824 | configureToolBarMenu->setItemChecked( 210, true ); |
825 | if (p-> mShowIconToday) | 825 | if (p-> mShowIconToday) |
826 | configureToolBarMenu->setItemChecked( 130, true ); | 826 | configureToolBarMenu->setItemChecked( 130, true ); |
827 | if (p-> mShowIconForward) | 827 | if (p-> mShowIconForward) |
828 | configureToolBarMenu->setItemChecked( 220, true ); | 828 | configureToolBarMenu->setItemChecked( 220, true ); |
829 | if (p-> mShowIconForwardFast) | 829 | if (p-> mShowIconForwardFast) |
830 | configureToolBarMenu->setItemChecked( 230, true ); | 830 | configureToolBarMenu->setItemChecked( 230, true ); |
831 | if (p-> mShowIconNextDays) | 831 | if (p-> mShowIconNextDays) |
832 | configureToolBarMenu->setItemChecked( 100, true ); | 832 | configureToolBarMenu->setItemChecked( 100, true ); |
833 | if (p-> mShowIconNext) | 833 | if (p-> mShowIconNext) |
834 | configureToolBarMenu->setItemChecked( 110, true ); | 834 | configureToolBarMenu->setItemChecked( 110, true ); |
835 | if (p-> mShowIconJournal) | 835 | if (p-> mShowIconJournal) |
836 | configureToolBarMenu->setItemChecked( 90, true ); | 836 | configureToolBarMenu->setItemChecked( 90, true ); |
837 | if (p-> mShowIconWhatsThis) | 837 | if (p-> mShowIconWhatsThis) |
838 | configureToolBarMenu->setItemChecked( 300, true ); | 838 | configureToolBarMenu->setItemChecked( 300, true ); |
839 | 839 | ||
840 | QLabel* dummy = new QLabel( iconToolBar ); | 840 | QLabel* dummy = new QLabel( iconToolBar ); |
841 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 841 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
842 | if (!p-> mShowIconStretch) | 842 | if (!p-> mShowIconStretch) |
843 | iconToolBar->setStretchableWidget ( dummy ) ; | 843 | iconToolBar->setStretchableWidget ( dummy ) ; |
844 | else | 844 | else |
845 | configureToolBarMenu->setItemChecked( 5, true ); | 845 | configureToolBarMenu->setItemChecked( 5, true ); |
846 | if (p-> mShowIconWhatsThis) | 846 | if (p-> mShowIconWhatsThis) |
847 | QWhatsThis::whatsThisButton ( iconToolBar ); | 847 | QWhatsThis::whatsThisButton ( iconToolBar ); |
848 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 848 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
849 | configureAgenda( p->mHourSize ); | 849 | configureAgenda( p->mHourSize ); |
850 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 850 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
851 | } | 851 | } |
852 | void MainWindow::fillSyncMenu() | 852 | void MainWindow::fillSyncMenu() |
853 | { | 853 | { |
854 | if ( syncMenu->count() ) | 854 | if ( syncMenu->count() ) |
855 | syncMenu->clear(); | 855 | syncMenu->clear(); |
856 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 856 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
857 | syncMenu->insertSeparator(); | 857 | syncMenu->insertSeparator(); |
858 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 858 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
859 | syncMenu->insertSeparator(); | 859 | syncMenu->insertSeparator(); |
860 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 860 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
861 | config.setGroup("General"); | 861 | config.setGroup("General"); |
862 | QStringList prof = config.readListEntry("SyncProfileNames"); | 862 | QStringList prof = config.readListEntry("SyncProfileNames"); |
863 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 863 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
864 | if ( prof.count() < 3 ) { | 864 | if ( prof.count() < 3 ) { |
865 | prof.clear(); | 865 | prof.clear(); |
866 | prof << i18n("Sharp_DTM"); | 866 | prof << i18n("Sharp_DTM"); |
867 | prof << i18n("Local_file"); | 867 | prof << i18n("Local_file"); |
868 | prof << i18n("Last_file"); | 868 | prof << i18n("Last_file"); |
869 | KSyncProfile* temp = new KSyncProfile (); | 869 | KSyncProfile* temp = new KSyncProfile (); |
870 | temp->setName( prof[0] ); | 870 | temp->setName( prof[0] ); |
871 | temp->writeConfig(&config); | 871 | temp->writeConfig(&config); |
872 | temp->setName( prof[1] ); | 872 | temp->setName( prof[1] ); |
873 | temp->writeConfig(&config); | 873 | temp->writeConfig(&config); |
874 | temp->setName( prof[2] ); | 874 | temp->setName( prof[2] ); |
875 | temp->writeConfig(&config); | 875 | temp->writeConfig(&config); |
876 | config.setGroup("General"); | 876 | config.setGroup("General"); |
877 | config.writeEntry("SyncProfileNames",prof); | 877 | config.writeEntry("SyncProfileNames",prof); |
878 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 878 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
879 | config.sync(); | 879 | config.sync(); |
880 | delete temp; | 880 | delete temp; |
881 | } | 881 | } |
882 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 882 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
883 | KOPrefs::instance()->mSyncProfileNames = prof; | 883 | KOPrefs::instance()->mSyncProfileNames = prof; |
884 | int i; | 884 | int i; |
885 | for ( i = 0; i < prof.count(); ++i ) { | 885 | for ( i = 0; i < prof.count(); ++i ) { |
886 | 886 | ||
887 | syncMenu->insertItem( prof[i], 1000+i ); | 887 | syncMenu->insertItem( prof[i], 1000+i ); |
888 | if ( i == 2 ) | 888 | if ( i == 2 ) |
889 | syncMenu->insertSeparator(); | 889 | syncMenu->insertSeparator(); |
890 | } | 890 | } |
891 | QDir app_dir; | 891 | QDir app_dir; |
892 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 892 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
893 | syncMenu->setItemEnabled( false , 1000 ); | 893 | syncMenu->setItemEnabled( false , 1000 ); |
894 | } | 894 | } |
895 | mView->setupExternSyncProfiles(); | 895 | mView->setupExternSyncProfiles(); |
896 | } | 896 | } |
897 | 897 | ||
898 | int MainWindow::ringSync() | 898 | int MainWindow::ringSync() |
899 | { | 899 | { |
900 | int syncedProfiles = 0; | 900 | int syncedProfiles = 0; |
901 | int i; | 901 | int i; |
902 | QTime timer; | 902 | QTime timer; |
903 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 903 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
904 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 904 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
905 | KSyncProfile* temp = new KSyncProfile (); | 905 | KSyncProfile* temp = new KSyncProfile (); |
906 | KOPrefs::instance()->mAskForPreferences = false; | 906 | KOPrefs::instance()->mAskForPreferences = false; |
907 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 907 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
908 | mCurrentSyncProfile = i; | 908 | mCurrentSyncProfile = i; |
909 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 909 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
910 | temp->readConfig(&config); | 910 | temp->readConfig(&config); |
911 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 911 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
912 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 912 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
913 | ++syncedProfiles; | 913 | ++syncedProfiles; |
914 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 914 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
915 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 915 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
916 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 916 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
917 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
918 | if ( temp->getWriteBackFuture() ) | ||
919 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
917 | KOPrefs::instance()->mShowSyncSummary = false; | 920 | KOPrefs::instance()->mShowSyncSummary = false; |
918 | mView->setSyncDevice(syncProfileNames[i] ); | 921 | mView->setSyncDevice(syncProfileNames[i] ); |
919 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 922 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
920 | if ( i == 0 ) { | 923 | if ( i == 0 ) { |
921 | syncSharp(); | 924 | syncSharp(); |
922 | } else { | 925 | } else { |
923 | if ( temp->getIsLocalFileSync() ) { | 926 | if ( temp->getIsLocalFileSync() ) { |
924 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 927 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
925 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 928 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
926 | } else { | 929 | } else { |
927 | if ( temp->getIsPhoneSync() ) { | 930 | if ( temp->getIsPhoneSync() ) { |
928 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 931 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
929 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 932 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
930 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 933 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
931 | syncPhone(); | 934 | syncPhone(); |
932 | } else | 935 | } else |
933 | syncRemote( temp, false ); | 936 | syncRemote( temp, false ); |
934 | 937 | ||
935 | } | 938 | } |
936 | } | 939 | } |
937 | timer.start(); | 940 | timer.start(); |
938 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 941 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
939 | while ( timer.elapsed () < 2000 ) { | 942 | while ( timer.elapsed () < 2000 ) { |
940 | qApp->processEvents(); | 943 | qApp->processEvents(); |
941 | #ifndef _WIN32_ | 944 | #ifndef _WIN32_ |
942 | sleep (1); | 945 | sleep (1); |
943 | #endif | 946 | #endif |
944 | } | 947 | } |
945 | 948 | ||
946 | } | 949 | } |
947 | 950 | ||
948 | } | 951 | } |
949 | delete temp; | 952 | delete temp; |
950 | return syncedProfiles; | 953 | return syncedProfiles; |
951 | } | 954 | } |
952 | 955 | ||
953 | void MainWindow::multiSync( bool askforPrefs ) | 956 | void MainWindow::multiSync( bool askforPrefs ) |
954 | { | 957 | { |
955 | if (mBlockSaveFlag) | 958 | if (mBlockSaveFlag) |
956 | return; | 959 | return; |
957 | mBlockSaveFlag = true; | 960 | mBlockSaveFlag = true; |
958 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 961 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
959 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 962 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
960 | question, | 963 | question, |
961 | i18n("Yes"), i18n("No"), | 964 | i18n("Yes"), i18n("No"), |
962 | 0, 0 ) != 0 ) { | 965 | 0, 0 ) != 0 ) { |
963 | mBlockSaveFlag = false; | 966 | mBlockSaveFlag = false; |
964 | setCaption(i18n("Aborted! Nothing synced!")); | 967 | setCaption(i18n("Aborted! Nothing synced!")); |
965 | return; | 968 | return; |
966 | } | 969 | } |
967 | mView->setSyncDevice(i18n("Multiple profiles") ); | 970 | mView->setSyncDevice(i18n("Multiple profiles") ); |
968 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | 971 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; |
969 | if ( askforPrefs ) { | 972 | if ( askforPrefs ) { |
970 | mView->edit_sync_options(); | 973 | mView->edit_sync_options(); |
971 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | 974 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; |
972 | } | 975 | } |
973 | setCaption(i18n("Multiple sync started.") ); | 976 | setCaption(i18n("Multiple sync started.") ); |
974 | qApp->processEvents(); | 977 | qApp->processEvents(); |
975 | int num = ringSync() ; | 978 | int num = ringSync() ; |
976 | if ( num > 1 ) | 979 | if ( num > 1 ) |
977 | ringSync(); | 980 | ringSync(); |
978 | mBlockSaveFlag = false; | 981 | mBlockSaveFlag = false; |
979 | if ( num ) | 982 | if ( num ) |
980 | save(); | 983 | save(); |
981 | if ( num ) | 984 | if ( num ) |
982 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 985 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
983 | else | 986 | else |
984 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 987 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
985 | return; | 988 | return; |
986 | } | 989 | } |
987 | void MainWindow::slotSyncMenu( int action ) | 990 | void MainWindow::slotSyncMenu( int action ) |
988 | { | 991 | { |
989 | //qDebug("syncaction %d ", action); | 992 | //qDebug("syncaction %d ", action); |
990 | if ( action == 0 ) { | 993 | if ( action == 0 ) { |
991 | 994 | ||
992 | // seems to be a Qt2 event handling bug | 995 | // seems to be a Qt2 event handling bug |
993 | // syncmenu.clear causes a segfault at first time | 996 | // syncmenu.clear causes a segfault at first time |
994 | // when we call it after the main event loop, it is ok | 997 | // when we call it after the main event loop, it is ok |
995 | // same behaviour when calling OM/Pi via QCOP for the first time | 998 | // same behaviour when calling OM/Pi via QCOP for the first time |
996 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 999 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
997 | //confSync(); | 1000 | //confSync(); |
998 | 1001 | ||
999 | return; | 1002 | return; |
1000 | } | 1003 | } |
1001 | if ( action == 1 ) { | 1004 | if ( action == 1 ) { |
1002 | multiSync( true ); | 1005 | multiSync( true ); |
1003 | return; | 1006 | return; |
1004 | } | 1007 | } |
1005 | 1008 | ||
1006 | if (mBlockSaveFlag) | 1009 | if (mBlockSaveFlag) |
1007 | return; | 1010 | return; |
1008 | mBlockSaveFlag = true; | 1011 | mBlockSaveFlag = true; |
1009 | mCurrentSyncProfile = action - 1000 ; | 1012 | mCurrentSyncProfile = action - 1000 ; |
1010 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 1013 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
1011 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1014 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1012 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1015 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1013 | KSyncProfile* temp = new KSyncProfile (); | 1016 | KSyncProfile* temp = new KSyncProfile (); |
1014 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1017 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1015 | temp->readConfig(&config); | 1018 | temp->readConfig(&config); |
1016 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1019 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1017 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 1020 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
1018 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1021 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1019 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1022 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1023 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
1024 | if ( temp->getWriteBackFuture() ) | ||
1025 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
1020 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1026 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1021 | if ( action == 1000 ) { | 1027 | if ( action == 1000 ) { |
1022 | syncSharp(); | 1028 | syncSharp(); |
1023 | 1029 | ||
1024 | } else if ( action == 1001 ) { | 1030 | } else if ( action == 1001 ) { |
1025 | syncLocalFile(); | 1031 | syncLocalFile(); |
1026 | 1032 | ||
1027 | } else if ( action == 1002 ) { | 1033 | } else if ( action == 1002 ) { |
1028 | quickSyncLocalFile(); | 1034 | quickSyncLocalFile(); |
1029 | 1035 | ||
1030 | } else if ( action >= 1003 ) { | 1036 | } else if ( action >= 1003 ) { |
1031 | if ( temp->getIsLocalFileSync() ) { | 1037 | if ( temp->getIsLocalFileSync() ) { |
1032 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1038 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1033 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1039 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1034 | } else { | 1040 | } else { |
1035 | if ( temp->getIsPhoneSync() ) { | 1041 | if ( temp->getIsPhoneSync() ) { |
1036 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1042 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1037 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1043 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1038 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1044 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1039 | syncPhone(); | 1045 | syncPhone(); |
1040 | } else | 1046 | } else |
1041 | syncRemote( temp ); | 1047 | syncRemote( temp ); |
1042 | 1048 | ||
1043 | } | 1049 | } |
1044 | } | 1050 | } |
1045 | delete temp; | 1051 | delete temp; |
1046 | mBlockSaveFlag = false; | 1052 | mBlockSaveFlag = false; |
1047 | } | 1053 | } |
1048 | void MainWindow::setDefaultPreferences() | 1054 | void MainWindow::setDefaultPreferences() |
1049 | { | 1055 | { |
1050 | KOPrefs *p = KOPrefs::instance(); | 1056 | KOPrefs *p = KOPrefs::instance(); |
1051 | 1057 | ||
1052 | p->mCompactDialogs = true; | 1058 | p->mCompactDialogs = true; |
1053 | p->mConfirm = true; | 1059 | p->mConfirm = true; |
1054 | // p->mEnableQuickTodo = false; | 1060 | // p->mEnableQuickTodo = false; |
1055 | } | 1061 | } |
1056 | 1062 | ||
1057 | QString MainWindow::resourcePath() | 1063 | QString MainWindow::resourcePath() |
1058 | { | 1064 | { |
1059 | return KGlobal::iconLoader()->iconPath(); | 1065 | return KGlobal::iconLoader()->iconPath(); |
1060 | } | 1066 | } |
1061 | 1067 | ||
1062 | void MainWindow::displayText( QString text ,QString cap ) | 1068 | void MainWindow::displayText( QString text ,QString cap ) |
1063 | { | 1069 | { |
1064 | QDialog dia( this, "name", true ); ; | 1070 | QDialog dia( this, "name", true ); ; |
1065 | dia.setCaption( cap ); | 1071 | dia.setCaption( cap ); |
1066 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1072 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1067 | lay->setSpacing( 3 ); | 1073 | lay->setSpacing( 3 ); |
1068 | lay->setMargin( 3 ); | 1074 | lay->setMargin( 3 ); |
1069 | QTextBrowser tb ( &dia ); | 1075 | QTextBrowser tb ( &dia ); |
1070 | lay->addWidget( &tb ); | 1076 | lay->addWidget( &tb ); |
1071 | tb.setText( text ); | 1077 | tb.setText( text ); |
1072 | #ifdef DESKTOP_VERSION | 1078 | #ifdef DESKTOP_VERSION |
1073 | dia.resize( 640, 480); | 1079 | dia.resize( 640, 480); |
1074 | #else | 1080 | #else |
1075 | dia.showMaximized(); | 1081 | dia.showMaximized(); |
1076 | #endif | 1082 | #endif |
1077 | dia.exec(); | 1083 | dia.exec(); |
1078 | } | 1084 | } |
1079 | void MainWindow::displayFile( QString fn, QString cap ) | 1085 | void MainWindow::displayFile( QString fn, QString cap ) |
1080 | { | 1086 | { |
1081 | QString fileName = resourcePath() + fn; | 1087 | QString fileName = resourcePath() + fn; |
1082 | QString text; | 1088 | QString text; |
1083 | QFile file( fileName ); | 1089 | QFile file( fileName ); |
1084 | if (!file.open( IO_ReadOnly ) ) { | 1090 | if (!file.open( IO_ReadOnly ) ) { |
1085 | return ; | 1091 | return ; |
1086 | 1092 | ||
1087 | } | 1093 | } |
1088 | QTextStream ts( &file ); | 1094 | QTextStream ts( &file ); |
1089 | text = ts.read(); | 1095 | text = ts.read(); |
1090 | file.close(); | 1096 | file.close(); |
1091 | displayText( text, cap); | 1097 | displayText( text, cap); |
1092 | } | 1098 | } |
1093 | void MainWindow::features() | 1099 | void MainWindow::features() |
1094 | { | 1100 | { |
1095 | 1101 | ||
1096 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1102 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1097 | } | 1103 | } |
1098 | 1104 | ||
1099 | void MainWindow::usertrans() | 1105 | void MainWindow::usertrans() |
1100 | { | 1106 | { |
1101 | 1107 | ||
1102 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1108 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1103 | } | 1109 | } |
1104 | #if 0 | 1110 | #if 0 |
1105 | #include <libkcal/vcalformat.h> | 1111 | #include <libkcal/vcalformat.h> |
1106 | #include <libkcal/event.h> | 1112 | #include <libkcal/event.h> |
1107 | #include <libkcal/todo.h> | 1113 | #include <libkcal/todo.h> |
1108 | #include <libkcal/incidence.h> | 1114 | #include <libkcal/incidence.h> |
1109 | #endif | 1115 | #endif |
1110 | void MainWindow::synchowto() | 1116 | void MainWindow::synchowto() |
1111 | { | 1117 | { |
1112 | #if 0 | 1118 | #if 0 |
1113 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1119 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1114 | Incidence* inR = er.first(); | 1120 | Incidence* inR = er.first(); |
1115 | VCalFormat vf; | 1121 | VCalFormat vf; |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index ef69bce..6d0da5c 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -182,455 +182,456 @@ ulong PhoneFormat::getCsumEvent( Event* event ) | |||
182 | { | 182 | { |
183 | int days = 0; | 183 | int days = 0; |
184 | QBitArray weekDays = rec->days(); | 184 | QBitArray weekDays = rec->days(); |
185 | int i; | 185 | int i; |
186 | for( i = 1; i <= 7; ++i ) { | 186 | for( i = 1; i <= 7; ++i ) { |
187 | if ( weekDays[i-1] ) { | 187 | if ( weekDays[i-1] ) { |
188 | days += 1 << (i-1); | 188 | days += 1 << (i-1); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | list.append( QString::number( days ) ); | 191 | list.append( QString::number( days ) ); |
192 | } | 192 | } |
193 | //pending weekdays | 193 | //pending weekdays |
194 | writeEndDate = true; | 194 | writeEndDate = true; |
195 | 195 | ||
196 | break; | 196 | break; |
197 | case Recurrence::rMonthlyPos:// 2 | 197 | case Recurrence::rMonthlyPos:// 2 |
198 | list.append( "2" ); | 198 | list.append( "2" ); |
199 | list.append( QString::number( rec->frequency()) );//12 | 199 | list.append( QString::number( rec->frequency()) );//12 |
200 | 200 | ||
201 | writeEndDate = true; | 201 | writeEndDate = true; |
202 | { | 202 | { |
203 | int count = 1; | 203 | int count = 1; |
204 | QPtrList<Recurrence::rMonthPos> rmp; | 204 | QPtrList<Recurrence::rMonthPos> rmp; |
205 | rmp = rec->monthPositions(); | 205 | rmp = rec->monthPositions(); |
206 | if ( rmp.first()->negative ) | 206 | if ( rmp.first()->negative ) |
207 | count = 5 - rmp.first()->rPos - 1; | 207 | count = 5 - rmp.first()->rPos - 1; |
208 | else | 208 | else |
209 | count = rmp.first()->rPos - 1; | 209 | count = rmp.first()->rPos - 1; |
210 | list.append( QString::number( count ) ); | 210 | list.append( QString::number( count ) ); |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | list.append( "0" ); | 214 | list.append( "0" ); |
215 | break; | 215 | break; |
216 | case Recurrence::rMonthlyDay:// 3 | 216 | case Recurrence::rMonthlyDay:// 3 |
217 | list.append( "3" ); | 217 | list.append( "3" ); |
218 | list.append( QString::number( rec->frequency()) );//12 | 218 | list.append( QString::number( rec->frequency()) );//12 |
219 | list.append( "0" ); | 219 | list.append( "0" ); |
220 | list.append( "0" ); | 220 | list.append( "0" ); |
221 | writeEndDate = true; | 221 | writeEndDate = true; |
222 | break; | 222 | break; |
223 | case Recurrence::rYearlyMonth://4 | 223 | case Recurrence::rYearlyMonth://4 |
224 | list.append( "4" ); | 224 | list.append( "4" ); |
225 | list.append( QString::number( rec->frequency()) );//12 | 225 | list.append( QString::number( rec->frequency()) );//12 |
226 | list.append( "0" ); | 226 | list.append( "0" ); |
227 | list.append( "0" ); | 227 | list.append( "0" ); |
228 | writeEndDate = true; | 228 | writeEndDate = true; |
229 | break; | 229 | break; |
230 | 230 | ||
231 | default: | 231 | default: |
232 | list.append( "255" ); | 232 | list.append( "255" ); |
233 | list.append( QString() ); | 233 | list.append( QString() ); |
234 | list.append( "0" ); | 234 | list.append( "0" ); |
235 | list.append( QString() ); | 235 | list.append( QString() ); |
236 | list.append( "0" ); | 236 | list.append( "0" ); |
237 | list.append( "20991231T000000" ); | 237 | list.append( "20991231T000000" ); |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | if ( writeEndDate ) { | 240 | if ( writeEndDate ) { |
241 | 241 | ||
242 | if ( rec->endDate().isValid() ) { // 15 + 16 | 242 | if ( rec->endDate().isValid() ) { // 15 + 16 |
243 | list.append( "1" ); | 243 | list.append( "1" ); |
244 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 244 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
245 | } else { | 245 | } else { |
246 | list.append( "0" ); | 246 | list.append( "0" ); |
247 | list.append( "20991231T000000" ); | 247 | list.append( "20991231T000000" ); |
248 | } | 248 | } |
249 | 249 | ||
250 | } | 250 | } |
251 | attList << list.join(""); | 251 | attList << list.join(""); |
252 | attList << event->categoriesStr(); | 252 | attList << event->categoriesStr(); |
253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | 253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); |
254 | 254 | ||
255 | attList << event->secrecyStr(); | 255 | attList << event->secrecyStr(); |
256 | return PhoneFormat::getCsum(attList ); | 256 | return PhoneFormat::getCsum(attList ); |
257 | } | 257 | } |
258 | ulong PhoneFormat::getCsum( const QStringList & attList) | 258 | ulong PhoneFormat::getCsum( const QStringList & attList) |
259 | { | 259 | { |
260 | int max = attList.count(); | 260 | int max = attList.count(); |
261 | ulong cSum = 0; | 261 | ulong cSum = 0; |
262 | int j,k,i; | 262 | int j,k,i; |
263 | int add; | 263 | int add; |
264 | for ( i = 0; i < max ; ++i ) { | 264 | for ( i = 0; i < max ; ++i ) { |
265 | QString s = attList[i]; | 265 | QString s = attList[i]; |
266 | if ( ! s.isEmpty() ){ | 266 | if ( ! s.isEmpty() ){ |
267 | j = s.length(); | 267 | j = s.length(); |
268 | for ( k = 0; k < j; ++k ) { | 268 | for ( k = 0; k < j; ++k ) { |
269 | int mul = k +1; | 269 | int mul = k +1; |
270 | add = s[k].unicode (); | 270 | add = s[k].unicode (); |
271 | if ( k < 16 ) | 271 | if ( k < 16 ) |
272 | mul = mul * mul; | 272 | mul = mul * mul; |
273 | int ii = i+1; | 273 | int ii = i+1; |
274 | add = add * mul *ii*ii*ii; | 274 | add = add * mul *ii*ii*ii; |
275 | cSum += add; | 275 | cSum += add; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | if ( i == 0 ) | ||
279 | qDebug("csum: i == 0 %d ", cSum); | ||
280 | 278 | ||
281 | } | 279 | } |
282 | QString dump = attList.join(","); | 280 | QString dump = attList.join(","); |
283 | qDebug("csum: %d %s", cSum,dump.latin1()); | 281 | qDebug("csum: %d %s", cSum,dump.latin1()); |
284 | 282 | ||
285 | return cSum; | 283 | return cSum; |
286 | 284 | ||
287 | } | 285 | } |
288 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
289 | #include <stdlib.h> | 287 | #include <stdlib.h> |
290 | #define DEBUGMODE false | 288 | #define DEBUGMODE false |
291 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
292 | { | 290 | { |
293 | 291 | ||
294 | QString fileName; | 292 | QString fileName; |
295 | #ifdef _WIN32_ | 293 | #ifdef _WIN32_ |
296 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 294 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
297 | #else | 295 | #else |
298 | fileName = "/tmp/kdepimtemp.vcs"; | 296 | fileName = "/tmp/kdepimtemp.vcs"; |
299 | #endif | 297 | #endif |
300 | QString command ="./kammu --backup " + fileName + " -yes" ; | 298 | QString command ="./kammu --backup " + fileName + " -yes" ; |
301 | int ret = system ( command.latin1() ); | 299 | int ret = system ( command.latin1() ); |
302 | if ( ret != 0 ) { | 300 | if ( ret != 0 ) { |
303 | qDebug("Error::command returned %d", ret); | 301 | qDebug("Error::command returned %d", ret); |
304 | return false; | 302 | return false; |
305 | } | 303 | } |
306 | qDebug("Command returned %d", ret); | 304 | qDebug("Command returned %d", ret); |
307 | VCalFormat vfload; | 305 | VCalFormat vfload; |
308 | vfload.setLocalTime ( true ); | 306 | vfload.setLocalTime ( true ); |
309 | qDebug("loading file ..."); | 307 | qDebug("loading file ..."); |
310 | 308 | ||
311 | if ( ! vfload.load( calendar, fileName ) ) | 309 | if ( ! vfload.load( calendar, fileName ) ) |
312 | return false; | 310 | return false; |
313 | QPtrList<Event> er = calendar->rawEvents(); | 311 | QPtrList<Event> er = calendar->rawEvents(); |
314 | Event* ev = er.first(); | 312 | Event* ev = er.first(); |
315 | qDebug("reading events... "); | 313 | qDebug("reading events... "); |
316 | while ( ev ) { | 314 | while ( ev ) { |
317 | QStringList cat = ev->categories(); | 315 | QStringList cat = ev->categories(); |
318 | if ( cat.contains( "MeetingDEF" )) { | 316 | if ( cat.contains( "MeetingDEF" )) { |
319 | ev->setCategories( QStringList() ); | 317 | ev->setCategories( QStringList() ); |
320 | } | 318 | } |
321 | int id = ev->pilotId(); | 319 | int id = ev->pilotId(); |
322 | Event *event; | 320 | Event *event; |
323 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 321 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
324 | if ( event ) { | 322 | if ( event ) { |
325 | event = (Event*)event->clone(); | 323 | event = (Event*)event->clone(); |
326 | copyEvent( event, ev ); | 324 | copyEvent( event, ev ); |
327 | calendar->deleteEvent( ev ); | 325 | calendar->deleteEvent( ev ); |
328 | calendar->addEvent( event); | 326 | calendar->addEvent( event); |
329 | } | 327 | } |
330 | else | 328 | else |
331 | event = ev; | 329 | event = ev; |
332 | uint cSum; | 330 | uint cSum; |
333 | cSum = PhoneFormat::getCsumEvent( event ); | 331 | cSum = PhoneFormat::getCsumEvent( event ); |
334 | event->setCsum( mProfileName, QString::number( cSum )); | 332 | event->setCsum( mProfileName, QString::number( cSum )); |
335 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 333 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
336 | event->setID( mProfileName,QString::number( id ) ); | 334 | event->setID( mProfileName,QString::number( id ) ); |
337 | ev = er.next(); | 335 | ev = er.next(); |
338 | } | 336 | } |
339 | { | 337 | { |
340 | qDebug("reading todos... "); | 338 | qDebug("reading todos... "); |
341 | QPtrList<Todo> tr = calendar->rawTodos(); | 339 | QPtrList<Todo> tr = calendar->rawTodos(); |
342 | Todo* ev = tr.first(); | 340 | Todo* ev = tr.first(); |
343 | while ( ev ) { | 341 | while ( ev ) { |
344 | 342 | ||
345 | QStringList cat = ev->categories(); | 343 | QStringList cat = ev->categories(); |
346 | if ( cat.contains( "MeetingDEF" )) { | 344 | if ( cat.contains( "MeetingDEF" )) { |
347 | ev->setCategories( QStringList() ); | 345 | ev->setCategories( QStringList() ); |
348 | } | 346 | } |
349 | int id = ev->pilotId(); | 347 | int id = ev->pilotId(); |
350 | Todo *event; | 348 | Todo *event; |
351 | event = existingCal->todo( mProfileName ,QString::number( id ) ); | 349 | event = existingCal->todo( mProfileName ,QString::number( id ) ); |
352 | if ( event ) { | 350 | if ( event ) { |
353 | qDebug("copy todo %s ", event->summary().latin1()); | 351 | qDebug("copy todo %s ", event->summary().latin1()); |
354 | 352 | ||
355 | event = (Todo*)event->clone(); | 353 | event = (Todo*)event->clone(); |
356 | copyTodo( event, ev ); | 354 | copyTodo( event, ev ); |
357 | calendar->deleteTodo( ev ); | 355 | calendar->deleteTodo( ev ); |
358 | calendar->addTodo( event); | 356 | calendar->addTodo( event); |
359 | } | 357 | } |
360 | else | 358 | else |
361 | event = ev; | 359 | event = ev; |
362 | uint cSum; | 360 | uint cSum; |
363 | cSum = PhoneFormat::getCsumTodo( event ); | 361 | cSum = PhoneFormat::getCsumTodo( event ); |
364 | event->setCsum( mProfileName, QString::number( cSum )); | 362 | event->setCsum( mProfileName, QString::number( cSum )); |
365 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 363 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
366 | event->setID( mProfileName,QString::number( id ) ); | 364 | event->setID( mProfileName,QString::number( id ) ); |
367 | ev = tr.next(); | 365 | ev = tr.next(); |
368 | } | 366 | } |
369 | } | 367 | } |
370 | return true; | 368 | return true; |
371 | } | 369 | } |
372 | void PhoneFormat::copyEvent( Event* to, Event* from ) | 370 | void PhoneFormat::copyEvent( Event* to, Event* from ) |
373 | { | 371 | { |
374 | if ( from->dtStart().isValid() ) | 372 | if ( from->dtStart().isValid() ) |
375 | to->setDtStart( from->dtStart() ); | 373 | to->setDtStart( from->dtStart() ); |
376 | if ( from->dtEnd().isValid() ) | 374 | if ( from->dtEnd().isValid() ) |
377 | to->setDtEnd( from->dtEnd() ); | 375 | to->setDtEnd( from->dtEnd() ); |
378 | if ( !from->location().isEmpty() ) | 376 | if ( !from->location().isEmpty() ) |
379 | to->setLocation( from->location() ); | 377 | to->setLocation( from->location() ); |
380 | if ( !from->description().isEmpty() ) | 378 | if ( !from->description().isEmpty() ) |
381 | to->setDescription( from->description() ); | 379 | to->setDescription( from->description() ); |
382 | if ( !from->summary().isEmpty() ) | 380 | if ( !from->summary().isEmpty() ) |
383 | to->setSummary( from->summary() ); | 381 | to->setSummary( from->summary() ); |
384 | 382 | ||
385 | QPtrListIterator<Alarm> it( from->alarms() ); | 383 | QPtrListIterator<Alarm> it( from->alarms() ); |
386 | if ( it.current() ) | 384 | if ( it.current() ) |
387 | to->clearAlarms(); | 385 | to->clearAlarms(); |
388 | const Alarm *a; | 386 | const Alarm *a; |
389 | while( (a = it.current()) ) { | 387 | while( (a = it.current()) ) { |
390 | Alarm *b = new Alarm( *a ); | 388 | Alarm *b = new Alarm( *a ); |
391 | b->setParent( to ); | 389 | b->setParent( to ); |
392 | to->addAlarm( b ); | 390 | to->addAlarm( b ); |
393 | ++it; | 391 | ++it; |
394 | } | 392 | } |
395 | QStringList cat = to->categories(); | 393 | QStringList cat = to->categories(); |
396 | QStringList catFrom = from->categories(); | 394 | QStringList catFrom = from->categories(); |
397 | QString nCat; | 395 | QString nCat; |
398 | int iii; | 396 | int iii; |
399 | for ( iii = 0; iii < catFrom.count();++iii ) { | 397 | for ( iii = 0; iii < catFrom.count();++iii ) { |
400 | nCat = catFrom[iii]; | 398 | nCat = catFrom[iii]; |
401 | if ( !nCat.isEmpty() ) | 399 | if ( !nCat.isEmpty() ) |
402 | if ( !cat.contains( nCat )) { | 400 | if ( !cat.contains( nCat )) { |
403 | cat << nCat; | 401 | cat << nCat; |
404 | } | 402 | } |
405 | } | 403 | } |
406 | to->setCategories( cat ); | 404 | to->setCategories( cat ); |
407 | Recurrence * r = new Recurrence( *from->recurrence(),to); | 405 | Recurrence * r = new Recurrence( *from->recurrence(),to); |
408 | to->setRecurrence( r ) ; | 406 | to->setRecurrence( r ) ; |
409 | 407 | ||
410 | 408 | ||
411 | } | 409 | } |
412 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) | 410 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) |
413 | { | 411 | { |
414 | if ( from->dtStart().isValid() ) | 412 | if ( from->dtStart().isValid() ) |
415 | to->setDtStart( from->dtStart() ); | 413 | to->setDtStart( from->dtStart() ); |
416 | if ( from->dtDue().isValid() ) | 414 | if ( from->dtDue().isValid() ) |
417 | to->setDtDue( from->dtDue() ); | 415 | to->setDtDue( from->dtDue() ); |
418 | if ( !from->location().isEmpty() ) | 416 | if ( !from->location().isEmpty() ) |
419 | to->setLocation( from->location() ); | 417 | to->setLocation( from->location() ); |
420 | if ( !from->description().isEmpty() ) | 418 | if ( !from->description().isEmpty() ) |
421 | to->setDescription( from->description() ); | 419 | to->setDescription( from->description() ); |
422 | if ( !from->summary().isEmpty() ) | 420 | if ( !from->summary().isEmpty() ) |
423 | to->setSummary( from->summary() ); | 421 | to->setSummary( from->summary() ); |
424 | 422 | ||
425 | QPtrListIterator<Alarm> it( from->alarms() ); | 423 | QPtrListIterator<Alarm> it( from->alarms() ); |
426 | if ( it.current() ) | 424 | if ( it.current() ) |
427 | to->clearAlarms(); | 425 | to->clearAlarms(); |
428 | const Alarm *a; | 426 | const Alarm *a; |
429 | while( (a = it.current()) ) { | 427 | while( (a = it.current()) ) { |
430 | Alarm *b = new Alarm( *a ); | 428 | Alarm *b = new Alarm( *a ); |
431 | b->setParent( to ); | 429 | b->setParent( to ); |
432 | to->addAlarm( b ); | 430 | to->addAlarm( b ); |
433 | ++it; | 431 | ++it; |
434 | } | 432 | } |
435 | QStringList cat = to->categories(); | 433 | QStringList cat = to->categories(); |
436 | QStringList catFrom = from->categories(); | 434 | QStringList catFrom = from->categories(); |
437 | QString nCat; | 435 | QString nCat; |
438 | int iii; | 436 | int iii; |
439 | for ( iii = 0; iii < catFrom.count();++iii ) { | 437 | for ( iii = 0; iii < catFrom.count();++iii ) { |
440 | nCat = catFrom[iii]; | 438 | nCat = catFrom[iii]; |
441 | if ( !nCat.isEmpty() ) | 439 | if ( !nCat.isEmpty() ) |
442 | if ( !cat.contains( nCat )) { | 440 | if ( !cat.contains( nCat )) { |
443 | cat << nCat; | 441 | cat << nCat; |
444 | } | 442 | } |
445 | } | 443 | } |
446 | to->setCategories( cat ); | 444 | to->setCategories( cat ); |
447 | if ( from->isCompleted() ) { | 445 | if ( from->isCompleted() ) { |
448 | to->setCompleted( true ); | 446 | to->setCompleted( true ); |
449 | if( from->completed().isValid() ) | 447 | if( from->completed().isValid() ) |
450 | to->setCompleted( from->completed() ); | 448 | to->setCompleted( from->completed() ); |
451 | } else { | 449 | } else { |
452 | // set percentcomplete only, if to->isCompleted() | 450 | // set percentcomplete only, if to->isCompleted() |
453 | if ( to->isCompleted() ) | 451 | if ( to->isCompleted() ) |
454 | to->setPercentComplete(from->percentComplete()); | 452 | to->setPercentComplete(from->percentComplete()); |
455 | } | 453 | } |
456 | if( to->priority() == 2 && from->priority() == 1 ) | 454 | if( to->priority() == 2 && from->priority() == 1 ) |
457 | ; //skip | 455 | ; //skip |
458 | else if (to->priority() == 4 && from->priority() == 5 ) | 456 | else if (to->priority() == 4 && from->priority() == 5 ) |
459 | ; | 457 | ; |
460 | else | 458 | else |
461 | to->setPriority(from->priority()); | 459 | to->setPriority(from->priority()); |
462 | 460 | ||
463 | } | 461 | } |
464 | #include <qcstring.h> | 462 | #include <qcstring.h> |
465 | 463 | ||
466 | void PhoneFormat::afterSave( Incidence* inc) | 464 | void PhoneFormat::afterSave( Incidence* inc) |
467 | { | 465 | { |
468 | uint csum; | 466 | uint csum; |
469 | inc->removeID( mProfileName ); | 467 | inc->removeID( mProfileName ); |
470 | #if 0 | ||
471 | if ( inc->type() == "Event") | 468 | if ( inc->type() == "Event") |
472 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | 469 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); |
473 | else | 470 | else |
474 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | 471 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); |
475 | inc->setCsum( mProfileName, QString::number( csum )); | 472 | inc->setCsum( mProfileName, QString::number( csum )); |
476 | #endif | 473 | |
477 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
478 | 475 | ||
479 | } | 476 | } |
480 | bool PhoneFormat::save( Calendar *calendar) | 477 | bool PhoneFormat::save( Calendar *calendar) |
481 | { | 478 | { |
482 | QLabel status ( i18n(" Opening device ..."), 0 ); | 479 | QLabel status ( i18n(" Opening device ..."), 0 ); |
483 | int w = status.sizeHint().width()+20 ; | 480 | int w = status.sizeHint().width()+20 ; |
484 | if ( w < 200 ) w = 230; | 481 | if ( w < 200 ) w = 230; |
485 | int h = status.sizeHint().height()+20 ; | 482 | int h = status.sizeHint().height()+20 ; |
486 | int dw = QApplication::desktop()->width(); | 483 | int dw = QApplication::desktop()->width(); |
487 | int dh = QApplication::desktop()->height(); | 484 | int dh = QApplication::desktop()->height(); |
488 | status.setCaption(i18n("Writing to phone...") ); | 485 | status.setCaption(i18n("Writing to phone...") ); |
489 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 486 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
490 | status.show(); | 487 | status.show(); |
491 | status.raise(); | 488 | status.raise(); |
492 | qApp->processEvents(); | 489 | qApp->processEvents(); |
493 | QString message; | 490 | QString message; |
494 | #ifdef _WIN32_ | 491 | #ifdef _WIN32_ |
495 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 492 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
496 | #else | 493 | #else |
497 | QString fileName = "/tmp/kdepimtemp.vcs"; | 494 | QString fileName = "/tmp/kdepimtemp.vcs"; |
498 | #endif | 495 | #endif |
499 | 496 | ||
500 | // 1 remove events which should be deleted | 497 | // 1 remove events which should be deleted |
501 | QPtrList<Event> er = calendar->rawEvents(); | 498 | QPtrList<Event> er = calendar->rawEvents(); |
502 | Event* ev = er.first(); | 499 | Event* ev = er.first(); |
503 | while ( ev ) { | 500 | while ( ev ) { |
504 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 501 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
505 | calendar->deleteEvent( ev ); | 502 | calendar->deleteEvent( ev ); |
506 | } else { | 503 | } else { |
507 | 504 | ||
508 | } | 505 | } |
509 | ev = er.next(); | 506 | ev = er.next(); |
510 | } | 507 | } |
511 | // 2 remove todos which should be deleted | 508 | // 2 remove todos which should be deleted |
512 | QPtrList<Todo> tl = calendar->rawTodos(); | 509 | QPtrList<Todo> tl = calendar->rawTodos(); |
513 | Todo* to = tl.first(); | 510 | Todo* to = tl.first(); |
514 | while ( to ) { | 511 | while ( to ) { |
515 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 512 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
516 | calendar->deleteTodo( to ); | 513 | calendar->deleteTodo( to ); |
517 | } | 514 | } else { |
515 | if ( to->isCompleted()) { | ||
516 | calendar->deleteTodo( to ); | ||
517 | } | ||
518 | } | ||
518 | to = tl.next(); | 519 | to = tl.next(); |
519 | } | 520 | } |
520 | // 3 save file | 521 | // 3 save file |
521 | VCalFormat vfsave; | 522 | VCalFormat vfsave; |
522 | vfsave.setLocalTime ( true ); | 523 | vfsave.setLocalTime ( true ); |
523 | if ( ! vfsave.save( calendar, fileName ) ) | 524 | if ( ! vfsave.save( calendar, fileName ) ) |
524 | return false; | 525 | return false; |
525 | // 4 call kammu | 526 | // 4 call kammu |
526 | QString command ="./kammu --restore " + fileName ; | 527 | QString command ="./kammu --restore " + fileName ; |
527 | int ret; | 528 | int ret; |
528 | while ( (ret = system ( command.latin1())) != 0 ) { | 529 | while ( (ret = system ( command.latin1())) != 0 ) { |
529 | qDebug("Error S::command returned %d. asking users", ret); | 530 | qDebug("Error S::command returned %d. asking users", ret); |
530 | int retval = KMessageBox::warningContinueCancel(0, | 531 | int retval = KMessageBox::warningContinueCancel(0, |
531 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); | 532 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); |
532 | if ( retval != KMessageBox::Continue ) | 533 | if ( retval != KMessageBox::Continue ) |
533 | return false; | 534 | return false; |
534 | } | 535 | } |
535 | if ( ret != 0 ) { | 536 | if ( ret != 0 ) { |
536 | qDebug("Error S::command returned %d", ret); | 537 | qDebug("Error S::command returned %d", ret); |
537 | return false; | 538 | return false; |
538 | } | 539 | } |
539 | // 5 reread data | 540 | // 5 reread data |
540 | message = i18n(" Rereading all data ... "); | 541 | message = i18n(" Rereading all data ... "); |
541 | status.setText ( message ); | 542 | status.setText ( message ); |
542 | qApp->processEvents(); | 543 | qApp->processEvents(); |
543 | CalendarLocal* calendarTemp = new CalendarLocal(); | 544 | CalendarLocal* calendarTemp = new CalendarLocal(); |
544 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 545 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
545 | if ( ! load( calendarTemp,calendar) ){ | 546 | if ( ! load( calendarTemp,calendar) ){ |
546 | qDebug("error reloading calendar "); | 547 | qDebug("error reloading calendar "); |
547 | delete calendarTemp; | 548 | delete calendarTemp; |
548 | return false; | 549 | return false; |
549 | } | 550 | } |
550 | // 6 compare data | 551 | // 6 compare data |
551 | 552 | ||
552 | //algo 6 compare event | 553 | //algo 6 compare event |
553 | er = calendar->rawEvents(); | 554 | er = calendar->rawEvents(); |
554 | ev = er.first(); | 555 | ev = er.first(); |
555 | message = i18n(" Comparing event # "); | 556 | message = i18n(" Comparing event # "); |
556 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 557 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
557 | Event* ev1; | 558 | Event* ev1; |
558 | int procCount = 0; | 559 | int procCount = 0; |
559 | while ( ev ) { | 560 | while ( ev ) { |
560 | //qDebug("event new ID %s",ev->summary().latin1()); | 561 | //qDebug("event new ID %s",ev->summary().latin1()); |
561 | status.setText ( message + QString::number ( ++procCount ) ); | 562 | status.setText ( message + QString::number ( ++procCount ) ); |
562 | qApp->processEvents(); | 563 | qApp->processEvents(); |
563 | uint csum; | 564 | uint csum; |
564 | csum = PhoneFormat::getCsumEvent( ev ); | 565 | csum = PhoneFormat::getCsumEvent( ev ); |
565 | QString cSum = QString::number( csum ); | 566 | QString cSum = QString::number( csum ); |
566 | ev->setCsum( mProfileName, cSum ); | 567 | //ev->setCsum( mProfileName, cSum ); |
567 | //qDebug("Event cSum %s ", cSum.latin1()); | 568 | //qDebug("Event cSum %s ", cSum.latin1()); |
568 | ev1 = er1.first(); | 569 | ev1 = er1.first(); |
569 | while ( ev1 ) { | 570 | while ( ev1 ) { |
570 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 571 | if ( ev1->getCsum( mProfileName ) == cSum ) { |
571 | er1.remove( ev1 ); | 572 | er1.remove( ev1 ); |
572 | afterSave( ev ); | 573 | afterSave( ev ); |
573 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | 574 | ev->setID(mProfileName, ev1->getID(mProfileName) ); |
574 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); | 575 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); |
575 | 576 | ||
576 | break; | 577 | break; |
577 | } | 578 | } |
578 | ev1 = er1.next(); | 579 | ev1 = er1.next(); |
579 | } | 580 | } |
580 | if ( ! ev1 ) { | 581 | if ( ! ev1 ) { |
581 | ev->removeID(mProfileName); | 582 | ev->removeID(mProfileName); |
582 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 583 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
583 | } | 584 | } |
584 | 585 | ||
585 | 586 | ||
586 | ev = er.next(); | 587 | ev = er.next(); |
587 | } | 588 | } |
588 | //algo 6 compare todo | 589 | //algo 6 compare todo |
589 | tl = calendar->rawTodos(); | 590 | tl = calendar->rawTodos(); |
590 | to = tl.first(); | 591 | to = tl.first(); |
591 | procCount = 0; | 592 | procCount = 0; |
592 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 593 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
593 | Todo* to1 ; | 594 | Todo* to1 ; |
594 | message = i18n(" Comparing todo # "); | 595 | message = i18n(" Comparing todo # "); |
595 | while ( to ) { | 596 | while ( to ) { |
596 | qDebug("todo2 %d ", procCount); | 597 | qDebug("todo2 %d ", procCount); |
597 | status.setText ( message + QString::number ( ++procCount ) ); | 598 | status.setText ( message + QString::number ( ++procCount ) ); |
598 | qApp->processEvents(); | 599 | qApp->processEvents(); |
599 | uint csum; | 600 | uint csum; |
600 | csum = PhoneFormat::getCsumTodo( to ); | 601 | csum = PhoneFormat::getCsumTodo( to ); |
601 | QString cSum = QString::number( csum ); | 602 | QString cSum = QString::number( csum ); |
602 | to->setCsum( mProfileName, cSum ); | 603 | //to->setCsum( mProfileName, cSum ); |
603 | qDebug("Todo cSum %s ", cSum.latin1()); | 604 | qDebug("Todo cSum %s ", cSum.latin1()); |
604 | Todo* to1 = tl1.first(); | 605 | Todo* to1 = tl1.first(); |
605 | while ( to1 ) { | 606 | while ( to1 ) { |
606 | if ( to1->getCsum( mProfileName ) == cSum ) { | 607 | if ( to1->getCsum( mProfileName ) == cSum ) { |
607 | tl1.remove( to1 ); | 608 | tl1.remove( to1 ); |
608 | afterSave( to ); | 609 | afterSave( to ); |
609 | to->setID(mProfileName, to1->getID(mProfileName) ); | 610 | to->setID(mProfileName, to1->getID(mProfileName) ); |
610 | break; | 611 | break; |
611 | } | 612 | } |
612 | to1 = tl1.next(); | 613 | to1 = tl1.next(); |
613 | } | 614 | } |
614 | if ( ! to1 ) { | 615 | if ( ! to1 ) { |
615 | to->removeID(mProfileName); | 616 | to->removeID(mProfileName); |
616 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 617 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
617 | } | 618 | } |
618 | 619 | ||
619 | to = tl.next(); | 620 | to = tl.next(); |
620 | } | 621 | } |
621 | delete calendarTemp; | 622 | delete calendarTemp; |
622 | return true; | 623 | return true; |
623 | 624 | ||
624 | 625 | ||
625 | 626 | ||
626 | } | 627 | } |
627 | 628 | ||
628 | 629 | ||
629 | QString PhoneFormat::toString( Calendar * ) | 630 | QString PhoneFormat::toString( Calendar * ) |
630 | { | 631 | { |
631 | return QString::null; | 632 | return QString::null; |
632 | } | 633 | } |
633 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 634 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) |
634 | { | 635 | { |
635 | return false; | 636 | return false; |
636 | } | 637 | } |