author | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
commit | 6385f303bef3cbcd19d097a7b05c30e144d5dd6e (patch) (unidiff) | |
tree | 770795d94ea6ec1dc8bcaa67cc174a9c0add564a /libkdepim/ksyncmanager.cpp | |
parent | 13e996beddabc5e88f4f2fe49b2ce6cb8408eb30 (diff) | |
download | kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.zip kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.tar.gz kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.tar.bz2 |
implemented remove sync info for kopi and kapi
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 4390a06..feb184b 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -84,21 +84,26 @@ void KSyncManager::fillSyncMenu() | |||
84 | { | 84 | { |
85 | if ( mSyncMenu->count() ) | 85 | if ( mSyncMenu->count() ) |
86 | mSyncMenu->clear(); | 86 | mSyncMenu->clear(); |
87 | 87 | ||
88 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 88 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
89 | mSyncMenu->insertSeparator(); | 89 | mSyncMenu->insertSeparator(); |
90 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | ||
91 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | ||
92 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | ||
93 | clearMenu->insertSeparator(); | ||
94 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | ||
95 | mSyncMenu->insertSeparator(); | ||
90 | if ( mServerSocket == 0 ) { | 96 | if ( mServerSocket == 0 ) { |
91 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 97 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
92 | } else { | 98 | } else { |
93 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 99 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
94 | } | 100 | } |
95 | mSyncMenu->insertSeparator(); | 101 | mSyncMenu->insertSeparator(); |
96 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 102 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
97 | mSyncMenu->insertSeparator(); | 103 | mSyncMenu->insertSeparator(); |
98 | |||
99 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 104 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
100 | config.setGroup("General"); | 105 | config.setGroup("General"); |
101 | QStringList prof = config.readListEntry("SyncProfileNames"); | 106 | QStringList prof = config.readListEntry("SyncProfileNames"); |
102 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 107 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
103 | if ( prof.count() < 2 ) { | 108 | if ( prof.count() < 2 ) { |
104 | prof.clear(); | 109 | prof.clear(); |
@@ -129,32 +134,59 @@ void KSyncManager::fillSyncMenu() | |||
129 | delete temp; | 134 | delete temp; |
130 | } | 135 | } |
131 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 136 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
132 | mSyncProfileNames = prof; | 137 | mSyncProfileNames = prof; |
133 | unsigned int i; | 138 | unsigned int i; |
134 | for ( i = 0; i < prof.count(); ++i ) { | 139 | for ( i = 0; i < prof.count(); ++i ) { |
135 | mSyncMenu->insertItem( prof[i], 1000+i ); | 140 | mSyncMenu->insertItem( prof[i], 1000+i ); |
141 | clearMenu->insertItem( prof[i], 1000+i ); | ||
136 | if ( i == 2 ) | 142 | if ( i == 2 ) |
137 | mSyncMenu->insertSeparator(); | 143 | mSyncMenu->insertSeparator(); |
138 | } | 144 | } |
139 | QDir app_dir; | 145 | QDir app_dir; |
140 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 146 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
141 | if ( mTargetApp == PWMPI) { | 147 | if ( mTargetApp == PWMPI) { |
142 | mSyncMenu->removeItem( 1000 ); | 148 | mSyncMenu->removeItem( 1000 ); |
149 | clearMenu->removeItem( 1000 ); | ||
143 | } | 150 | } |
144 | #ifndef DESKTOP_VERSION | 151 | #ifndef DESKTOP_VERSION |
145 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 152 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
146 | mSyncMenu->removeItem( 1000 ); | 153 | mSyncMenu->removeItem( 1000 ); |
154 | clearMenu->removeItem( 1000 ); | ||
147 | } | 155 | } |
148 | #endif | 156 | #endif |
149 | mSyncMenu->removeItem( 1002 ); | 157 | mSyncMenu->removeItem( 1002 ); |
158 | clearMenu->removeItem( 1002 ); | ||
150 | } | 159 | } |
160 | void KSyncManager::slotClearMenu( int action ) | ||
161 | { | ||
162 | QString syncDevice; | ||
163 | if ( action > 999 ) { | ||
164 | syncDevice = mSyncProfileNames[action - 1000] ; | ||
165 | } | ||
151 | 166 | ||
167 | |||
168 | |||
169 | int result = 0; | ||
170 | QString sd; | ||
171 | if ( syncDevice.isEmpty() ) | ||
172 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | ||
173 | else | ||
174 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | ||
175 | |||
176 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | ||
177 | 0, 1 ); | ||
178 | if ( result ) | ||
179 | return; | ||
180 | mImplementation->removeSyncInfo( syncDevice ); | ||
181 | } | ||
152 | void KSyncManager::slotSyncMenu( int action ) | 182 | void KSyncManager::slotSyncMenu( int action ) |
153 | { | 183 | { |
154 | qDebug("syncaction %d ", action); | 184 | qDebug("syncaction %d ", action); |
185 | if ( action == 5000 ) | ||
186 | return; | ||
155 | if ( action == 0 ) { | 187 | if ( action == 0 ) { |
156 | 188 | ||
157 | // seems to be a Qt2 event handling bug | 189 | // seems to be a Qt2 event handling bug |
158 | // syncmenu.clear causes a segfault at first time | 190 | // syncmenu.clear causes a segfault at first time |
159 | // when we call it after the main event loop, it is ok | 191 | // when we call it after the main event loop, it is ok |
160 | // same behaviour when calling OM/Pi via QCOP for the first time | 192 | // same behaviour when calling OM/Pi via QCOP for the first time |
@@ -832,14 +864,20 @@ void KSyncManager::confSync() | |||
832 | #ifndef DESKTOP_VERSION | 864 | #ifndef DESKTOP_VERSION |
833 | sp->showMaximized(); | 865 | sp->showMaximized(); |
834 | #else | 866 | #else |
835 | sp->show(); | 867 | sp->show(); |
836 | #endif | 868 | #endif |
837 | sp->exec(); | 869 | sp->exec(); |
870 | QStringList oldSyncProfileNames = mSyncProfileNames; | ||
838 | mSyncProfileNames = sp->getSyncProfileNames(); | 871 | mSyncProfileNames = sp->getSyncProfileNames(); |
839 | mLocalMachineName = sp->getLocalMachineName (); | 872 | mLocalMachineName = sp->getLocalMachineName (); |
873 | int ii; | ||
874 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | ||
875 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | ||
876 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | ||
877 | } | ||
840 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 878 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
841 | } | 879 | } |
842 | void KSyncManager::syncKDE() | 880 | void KSyncManager::syncKDE() |
843 | { | 881 | { |
844 | emit save(); | 882 | emit save(); |
845 | switch(mTargetApp) | 883 | switch(mTargetApp) |