Commit c551ad2f authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Preserve icaldir resource/collection display name

Match the root collection's display name to AgentBase::name() and
update the agent name when user modifies the root collection's name.
This way it's possible to persistently customize icaldir resource
names instead of having multiple "Calendar Folder" entries in Korganizer.
It also makes the resource visible under the "nice" name in resource
listing, instead of using the agent identifier.

BUG: 376379
FIXED-IN: 5.4.3
parent a3e6dc0a
......@@ -234,6 +234,18 @@ void ICalDirResource::itemRemoved(const Akonadi::Item &item)
changeProcessed();
}
void ICalDirResource::collectionChanged(const Collection &collection)
{
if (collection.hasAttribute<EntityDisplayAttribute>()) {
auto attr = collection.attribute<EntityDisplayAttribute>();
if (attr->displayName() != name()) {
setName(attr->displayName());
}
}
changeProcessed();
}
void ICalDirResource::retrieveCollections()
{
Collection c;
......@@ -257,7 +269,7 @@ void ICalDirResource::retrieveCollections()
}
EntityDisplayAttribute *attr = c.attribute<EntityDisplayAttribute>(Collection::AddIfMissing);
attr->setDisplayName(i18n("Calendar Folder"));
attr->setDisplayName(name() == identifier() ? i18n("Calendar Folder") : name());
attr->setIconName(QStringLiteral("office-calendar"));
Collection::List list;
......
......@@ -52,6 +52,8 @@ protected:
void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &parts) Q_DECL_OVERRIDE;
void itemRemoved(const Akonadi::Item &item) Q_DECL_OVERRIDE;
void collectionChanged(const Akonadi::Collection &collection) Q_DECL_OVERRIDE;
private:
bool loadIncidences();
QString iCalDirectoryName() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment