diff --git a/folderstorage.cpp b/folderstorage.cpp index 480fa79f5..faa601382 100644 --- a/folderstorage.cpp +++ b/folderstorage.cpp @@ -675,6 +675,7 @@ int FolderStorage::rename(const QString& newName, KMFolderDir *newParent) // delete the old entry as we get two entries with the same ID otherwise KMKernel::config()->deleteGroup( oldConfigString ); + emit locationChanged( oldLoc, newLoc ); emit nameChanged(); return rc; } diff --git a/folderstorage.h b/folderstorage.h index d26c5b27a..4a799e755 100644 --- a/folderstorage.h +++ b/folderstorage.h @@ -427,6 +427,11 @@ signals: /** Emitted when the name of the folder changes. */ void nameChanged(); + /** Emitted when the location on disk of the folder changes. This + * is used by all code which uses the locatio on disk of the folder storage + * ( or the cache storage ) as an identifier for the folder. */ + void locationChanged( const QString &, const QString & ); + /** Emitted when the readonly status of the folder changes. */ void readOnlyChanged(KMFolder*); diff --git a/kmailicalifaceimpl.cpp b/kmailicalifaceimpl.cpp index 9be865bc3..32b86b744 100644 --- a/kmailicalifaceimpl.cpp +++ b/kmailicalifaceimpl.cpp @@ -1455,6 +1455,19 @@ void KMailICalIfaceImpl::slotFolderRenamed() slotFolderPropertiesChanged( const_cast( folder ) ); } +void KMailICalIfaceImpl::slotFolderLocationChanged( const QString &oldLocation, + const QString &newLocation ) +{ + ExtraFolder* ef = mExtraFolders.find( oldLocation ); + if ( ef ) { + // reuse the ExtraFolder entry, but adjust the key + mExtraFolders.setAutoDelete( false ); + mExtraFolders.remove( oldLocation ); + mExtraFolders.setAutoDelete( true ); + mExtraFolders.insert( newLocation, ef ); + } +} + KMFolder* KMailICalIfaceImpl::findResourceFolder( const QString& resource ) { // Try the standard folders @@ -1752,6 +1765,8 @@ void KMailICalIfaceImpl::connectFolder( KMFolder* folder ) this, SLOT( slotFolderPropertiesChanged( KMFolder* ) ) ); disconnect( folder, SIGNAL( nameChanged() ), this, SLOT( slotFolderRenamed() ) ); + disconnect( folder->storage(), SIGNAL( locationChanged( const QString&, const QString&) ), + this, SLOT( slotFolderLocationChanged( const QString&, const QString&) ) ); // Setup the signals to listen for changes connect( folder, SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), @@ -1764,6 +1779,9 @@ void KMailICalIfaceImpl::connectFolder( KMFolder* folder ) this, SLOT( slotFolderPropertiesChanged( KMFolder* ) ) ); connect( folder, SIGNAL( nameChanged() ), this, SLOT( slotFolderRenamed() ) ); + connect( folder->storage(), SIGNAL( locationChanged( const QString&, const QString&) ), + this, SLOT( slotFolderLocationChanged( const QString&, const QString&) ) ); + } static void cleanupFolder( KMFolder* folder, KMailICalIfaceImpl* _this ) diff --git a/kmailicalifaceimpl.h b/kmailicalifaceimpl.h index c9caac390..0867ba7e7 100644 --- a/kmailicalifaceimpl.h +++ b/kmailicalifaceimpl.h @@ -205,6 +205,7 @@ public slots: private slots: void slotRefreshFolder( KMFolder* ); void slotCheckDone(); + void slotFolderLocationChanged( const QString&, const QString& ); void slotFolderRenamed(); private: