diff --git a/kmailicalIface.h b/kmailicalIface.h index 81948fdfa..488df8d20 100644 --- a/kmailicalIface.h +++ b/kmailicalIface.h @@ -131,6 +131,7 @@ k_dcop: * Causes all resource folders of the given type to be synced with the server. */ virtual bool triggerSync( const QString & ) = 0; + virtual void changeResourceUIName( const QString &folderPath, const QString &newName ) = 0; k_dcop_signals: void incidenceAdded( const QString& type, const QString& folder, diff --git a/kmailicalifaceimpl.cpp b/kmailicalifaceimpl.cpp index f405167dc..e6ed5debd 100644 --- a/kmailicalifaceimpl.cpp +++ b/kmailicalifaceimpl.cpp @@ -76,6 +76,8 @@ using KMail::AccountManager; using namespace KMail; +QMap *KMailICalIfaceImpl::mSubResourceUINamesMap = new QMap; + // Local helper methods static void vPartMicroParser( const QString& str, QString& s ); static void reloadFolderTree(); @@ -655,8 +657,13 @@ static int dimapAccountCount() static QString subresourceLabelForPresentation( const KMFolder * folder ) { + if( KMailICalIfaceImpl::getResourceMap()->contains( folder->location() ) ) { + return folder->label(); + } + QString label = folder->prettyURL(); QStringList parts = QStringList::split( QString::fromLatin1("/"), label ); + // In the common special case of some other user's folder shared with us // the url looks like "Server Name/user/$USERNAME/Folder/Name". Make // those a bit nicer. @@ -1579,7 +1586,6 @@ void KMailICalIfaceImpl::slotFolderPropertiesChanged( KMFolder* folder ) subresourceAdded( contentsTypeStr, location, subresourceLabelForPresentation( folder ), !folder->isReadOnly(), folderIsAlarmRelevant( folder ) ); - } } @@ -1630,6 +1636,18 @@ KMFolder* KMailICalIfaceImpl::findResourceFolder( const QString& resource ) return 0; } +void KMailICalIfaceImpl::changeResourceUIName( const QString &folderPath, const QString &newName ) +{ + kdDebug() << "Folder path " << folderPath << endl; + KMFolder *f = findResourceFolder( folderPath ); + if ( f ) { + KMailICalIfaceImpl::getResourceMap()->insert( folderPath, newName ); + kmkernel->folderMgr()->renameFolder( f, newName ); + KConfigGroup configGroup( kmkernel->config(), "Resource UINames" ); + configGroup.writeEntry( folderPath, newName ); + } +} + /**************************** * The config stuff */ @@ -1903,6 +1921,10 @@ void KMailICalIfaceImpl::readConfig() subresourceAdded( folderContentsType( KMail::ContentsTypeNote ), mNotes->location(), mNotes->label(), true, false ); } + KConfig *config = kmkernel->config(); + config->setGroup("Resource UINames"); + *KMailICalIfaceImpl::mSubResourceUINamesMap = config->entryMap( "Resource UINames" ); + reloadFolderTree(); } diff --git a/kmailicalifaceimpl.h b/kmailicalifaceimpl.h index 5f56e4fb1..53c7883a5 100644 --- a/kmailicalifaceimpl.h +++ b/kmailicalifaceimpl.h @@ -223,6 +223,8 @@ public: bool isResourceQuiet() const; void setResourceQuiet(bool q); + static QMap* getResourceMap() { return mSubResourceUINamesMap; } + public slots: /* (Re-)Read configuration file */ void readConfig(); @@ -235,6 +237,7 @@ public slots: // Called when a folder is made readonly or readwrite, or renamed, // or any other similar change that affects the resources void slotFolderPropertiesChanged( KMFolder* folder ); + void changeResourceUIName( const QString &folderPath, const QString &newName ); private slots: void slotRefreshFolder( KMFolder* ); @@ -344,6 +347,7 @@ private: QMap mTheUnGetMes; QMap mPendingUpdates; QMap mInTransit; + static QMap *mSubResourceUINamesMap; };