-rw-r--r-- | korganizer/mainwindow.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index d8aa43a..aa30b52 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -869,96 +869,99 @@ void MainWindow::fillSyncMenu() | |||
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!")); |
@@ -972,96 +975,99 @@ void MainWindow::multiSync( bool askforPrefs ) | |||
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 ); |