-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 @@ -89,2 +89,8 @@ void KSyncManager::fillSyncMenu() mSyncMenu->insertSeparator(); + QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); + mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); + clearMenu->insertItem( i18n("For all profiles"), 1 ); + clearMenu->insertSeparator(); + connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); + mSyncMenu->insertSeparator(); if ( mServerSocket == 0 ) { @@ -97,3 +103,2 @@ void KSyncManager::fillSyncMenu() mSyncMenu->insertSeparator(); - KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); @@ -134,3 +139,4 @@ void KSyncManager::fillSyncMenu() for ( i = 0; i < prof.count(); ++i ) { - mSyncMenu->insertItem( prof[i], 1000+i ); + mSyncMenu->insertItem( prof[i], 1000+i ); + clearMenu->insertItem( prof[i], 1000+i ); if ( i == 2 ) @@ -142,2 +148,3 @@ void KSyncManager::fillSyncMenu() mSyncMenu->removeItem( 1000 ); + clearMenu->removeItem( 1000 ); } @@ -146,2 +153,3 @@ void KSyncManager::fillSyncMenu() mSyncMenu->removeItem( 1000 ); + clearMenu->removeItem( 1000 ); } @@ -149,4 +157,26 @@ void KSyncManager::fillSyncMenu() mSyncMenu->removeItem( 1002 ); + clearMenu->removeItem( 1002 ); } +void KSyncManager::slotClearMenu( int action ) +{ + QString syncDevice; + if ( action > 999 ) { + syncDevice = mSyncProfileNames[action - 1000] ; + } + + + int result = 0; + QString sd; + if ( syncDevice.isEmpty() ) + sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); + else + sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); + + result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, + 0, 1 ); + if ( result ) + return; + mImplementation->removeSyncInfo( syncDevice ); +} void KSyncManager::slotSyncMenu( int action ) @@ -154,2 +184,4 @@ void KSyncManager::slotSyncMenu( int action ) qDebug("syncaction %d ", action); + if ( action == 5000 ) + return; if ( action == 0 ) { @@ -837,4 +869,10 @@ void KSyncManager::confSync() sp->exec(); + QStringList oldSyncProfileNames = mSyncProfileNames; mSyncProfileNames = sp->getSyncProfileNames(); mLocalMachineName = sp->getLocalMachineName (); + int ii; + for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { + if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) + mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); + } QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |