From 6385f303bef3cbcd19d097a7b05c30e144d5dd6e Mon Sep 17 00:00:00 2001 From: zautrix Date: Tue, 26 Oct 2004 22:19:18 +0000 Subject: implemented remove sync info for kopi and kapi --- diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 3641c0c..2785131 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -553,6 +553,14 @@ void AddressBook::smplifyAddressees() (*ait).simplifyAddresses(); } } +void AddressBook::removeSyncInfo( QString syncProfile) +{ + Iterator ait; + for ( ait = begin(); ait != end(); ++ait ) { + (*ait).removeID( syncProfile ); + } + +} void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) { Iterator ait; diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 5edca06..f124dc9 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -144,6 +144,7 @@ class AddressBook : public QObject bool saveAB( ); bool saveABphone( QString fileName ); void smplifyAddressees(); + void removeSyncInfo( QString syncProfile); void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); void export2File( QString fileName ); bool export2PhoneFormat( QStringList uids ,QString fileName ); diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 40877ef..a660a9d 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -553,7 +553,10 @@ void Addressee::simplifyPhoneNumberTypes() void Addressee::removeID(const QString &prof) { detach(); - mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); + if ( prof.isEmpty() ) + mData->mExternalId = ":"; + else + mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); } void Addressee::setID( const QString & prof , const QString & id ) diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index efae874..e56e46a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2812,8 +2812,8 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) } void KABCore::removeSyncInfo( QString syncProfile) { - qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); - + qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); + mAddressBook->removeSyncInfo( syncProfile ); } diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index af01625..a08f243 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -3768,5 +3768,6 @@ void CalendarView::setSyncManager(KSyncManager* manager) void CalendarView::removeSyncInfo( QString syncProfile) { qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); + mCalendar->removeSyncInfo( syncProfile ); } diff --git a/libkcal/calendar.h b/libkcal/calendar.h index b801186..b7d6a1f 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -78,6 +78,7 @@ public: */ virtual void save() = 0; virtual QPtrList getExternLastSyncEvents() = 0; + virtual void removeSyncInfo( QString syncProfile) = 0; virtual bool isSaving() { return false; } /** diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 21b4aaf..3f46d53 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -221,7 +221,28 @@ Todo *CalendarLocal::todo( QString syncProf, QString id ) return 0; } - +void CalendarLocal::removeSyncInfo( QString syncProfile) +{ + QPtrList all = rawIncidences() ; + Incidence *inc; + for ( inc = all.first(); inc; inc = all.next() ) { + inc->removeID( syncProfile ); + } + if ( syncProfile.isEmpty() ) { + QPtrList el; + Event *todo; + for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { + if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) + el.append( todo ); + } + for ( todo = el.first(); todo; todo = el.next() ) { + deleteIncidence ( todo ); + } + } else { + Event *lse = event( "last-syncEvent-"+ syncProfile); + deleteIncidence ( lse ); + } +} QPtrList CalendarLocal::getExternLastSyncEvents() { QPtrList el; diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 5b6c64c..98ec710 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -69,6 +69,7 @@ class CalendarLocal : public Calendar /** Add Event to calendar. */ + void removeSyncInfo( QString syncProfile); bool addAnniversaryNoDup( Event *event ); bool addEventNoDup( Event *event ); bool addEvent( Event *event ); diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index b36dc1a..9aa517c 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp @@ -353,7 +353,10 @@ void IncidenceBase::setTempSyncStat( int id ) void IncidenceBase::removeID(const QString &prof) { - mExternalId = KIdManager::removeId ( mExternalId, prof); + if ( prof.isEmpty() ) + mExternalId = ":"; + else + mExternalId = KIdManager::removeId ( mExternalId, prof); } void IncidenceBase::setID( const QString & prof , const QString & id ) diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 4390a06..feb184b 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -87,6 +87,12 @@ void KSyncManager::fillSyncMenu() mSyncMenu->insertItem( i18n("Configure..."), 0 ); 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 ) { mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); } else { @@ -95,7 +101,6 @@ void KSyncManager::fillSyncMenu() mSyncMenu->insertSeparator(); mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); mSyncMenu->insertSeparator(); - KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); config.setGroup("General"); QStringList prof = config.readListEntry("SyncProfileNames"); @@ -132,7 +137,8 @@ void KSyncManager::fillSyncMenu() mSyncProfileNames = prof; unsigned int i; 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 ) mSyncMenu->insertSeparator(); } @@ -140,18 +146,44 @@ void KSyncManager::fillSyncMenu() //US do not display SharpDTM if app is pwmpi, or no sharpfiles available if ( mTargetApp == PWMPI) { mSyncMenu->removeItem( 1000 ); + clearMenu->removeItem( 1000 ); } #ifndef DESKTOP_VERSION else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { mSyncMenu->removeItem( 1000 ); + clearMenu->removeItem( 1000 ); } #endif 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 ) { qDebug("syncaction %d ", action); + if ( action == 5000 ) + return; if ( action == 0 ) { // seems to be a Qt2 event handling bug @@ -835,8 +867,14 @@ void KSyncManager::confSync() sp->show(); #endif 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() ) ); } void KSyncManager::syncKDE() diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index af4f1ab..aa32e28 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -154,6 +154,7 @@ class KSyncManager : public QObject public slots: void slotSyncMenu( int ); + void slotClearMenu( int action ); void deleteCommandSocket(KCommandSocket*s, int state); void readFileFromSocket(); void fillSyncMenu(); -- cgit v0.9.0.2