Commit 0d7103a3 authored by David Jarvie's avatar David Jarvie
Browse files

Ensure that changes to display name in collection EntityDisplayAttribute cause

updates in the config file settings.

svn path=/trunk/KDE/kdepim/runtime/; revision=1148184
parent 481f8246
/*
Copyright (c) 2008 Bertjan Broeksema <b.broeksema@kdemail.net>
Copyright (c) 2008 Volker Krause <vkrause@kde.org>
Copyright (c) 2010 David Jarvie <djarvie@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
......@@ -220,6 +221,20 @@ class SingleFileResource : public SingleFileResourceBase
}
public Q_SLOTS:
virtual void collectionChanged( const Collection &collection )
{
QString newName;
if ( collection.hasAttribute<EntityDisplayAttribute>() ) {
EntityDisplayAttribute *attr = collection.attribute<EntityDisplayAttribute>();
newName = attr->displayName();
}
const QString oldName = Settings::self()->displayName();
if ( newName != oldName ) {
Settings::self()->setDisplayName( newName );
}
SingleFileResourceBase::collectionChanged( collection );
}
/**
* Display the configuration dialog for the resource.
*/
......
......@@ -46,6 +46,9 @@ SingleFileResourceBase::SingleFileResourceBase( const QString & id )
changeRecorder()->fetchCollection( true );
connect( changeRecorder(), SIGNAL( changesAdded() ), SLOT( scheduleWrite() ) );
//TODO: The following is only necessary because inheriting from AgentBase::Observer doesn't work
connect( changeRecorder(), SIGNAL( collectionChanged(const Akonadi::Collection&)), SLOT(collectionChanged(const Akonadi::Collection&)));
connect( KDirWatch::self(), SIGNAL( dirty( QString ) ), SLOT( fileChanged( QString ) ) );
connect( KDirWatch::self(), SIGNAL( created( QString ) ), SLOT( fileChanged( QString ) ) );
......
......@@ -49,9 +49,8 @@ class SingleFileResourceBase : public ResourceBase, public Akonadi::AgentBase::O
*/
void setSupportedMimetypes( const QStringList &mimeTypes, const QString &icon = QString() );
void collectionChanged( const Akonadi::Collection &collection );
public Q_SLOTS:
virtual void collectionChanged( const Akonadi::Collection &collection );
void reloadFile();
virtual void readFile() = 0;
virtual void writeFile() = 0;
......
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