Commit 2a82e143 authored by David Jarvie's avatar David Jarvie
Browse files

Update to use ResourceBase::invalidateCache() instead of clearCache()

parent 74ca4265
......@@ -197,8 +197,9 @@ void KAlarmResource::settingsChanged()
else
{
// Update the backend storage format to the current KAlarm format
KAlarm::Calendar::setKAlarmVersion(fileStorage()->calendar());
QString filename = fileStorage()->fileName();
kDebug() << "Updating storage for" << filename;
KAlarm::Calendar::setKAlarmVersion(fileStorage()->calendar());
if (!writeToFile(filename))
kWarning() << "Error updating calendar storage format";
else
......
......@@ -36,10 +36,6 @@ class KAlarmResource : public ICalResourceBase
KAlarmResource(const QString& id);
virtual ~KAlarmResource();
protected Q_SLOTS:
void doRetrieveItems(const Akonadi::Collection&);
bool doRetrieveItem(const Akonadi::Item&, const QSet<QByteArray>& parts);
protected:
/**
* Customize the configuration dialog before it is displayed.
......@@ -47,6 +43,8 @@ class KAlarmResource : public ICalResourceBase
virtual void customizeConfigDialog(Akonadi::SingleFileResourceConfigDialog<Akonadi_KAlarm_Resource::Settings>*);
virtual void configDialogAcceptedActions(Akonadi::SingleFileResourceConfigDialog<Akonadi_KAlarm_Resource::Settings>*);
virtual void doRetrieveItems(const Akonadi::Collection&);
virtual bool doRetrieveItem(const Akonadi::Item&, const QSet<QByteArray>& parts);
virtual bool readFromFile(const QString& fileName);
virtual bool writeToFile(const QString& fileName);
virtual void itemAdded(const Akonadi::Item&, const Akonadi::Collection&);
......
......@@ -125,7 +125,6 @@ void ICalResourceBase::itemRemoved( const Akonadi::Item &item )
void ICalResourceBase::retrieveItems( const Akonadi::Collection &col )
{
SingleFileResource<Settings>::retrieveItems( col );
reloadFile();
if ( mCalendar ) {
doRetrieveItems( col );
......
......@@ -254,6 +254,31 @@ class SingleFileResource : public SingleFileResourceBase
SingleFileResourceBase::collectionChanged( collection );
}
virtual Collection rootCollection() const
{
Collection c;
c.setParentCollection( Collection::root() );
c.setRemoteId( mSettings->path() );
const QString display = mSettings->displayName();
c.setName( display.isEmpty() ? identifier() : display );
QStringList mimeTypes;
c.setContentMimeTypes( mSupportedMimetypes );
if ( readOnly() ) {
c.setRights( Collection::CanChangeCollection );
} else {
Collection::Rights rights;
rights |= Collection::CanChangeItem;
rights |= Collection::CanCreateItem;
rights |= Collection::CanDeleteItem;
rights |= Collection::CanChangeCollection;
c.setRights( rights );
}
EntityDisplayAttribute* attr = c.attribute<EntityDisplayAttribute>( Collection::AddIfMissing );
attr->setDisplayName( name() );
attr->setIconName( mCollectionIcon );
return c;
}
public Q_SLOTS:
/**
* Display the configuration dialog for the resource.
......@@ -297,29 +322,8 @@ class SingleFileResource : public SingleFileResourceBase
void retrieveCollections()
{
Collection c;
c.setParentCollection( Collection::root() );
c.setRemoteId( mSettings->path() );
const QString display = mSettings->displayName();
c.setName( display.isEmpty() ? identifier() : display );
QStringList mimeTypes;
c.setContentMimeTypes( mSupportedMimetypes );
if ( readOnly() ) {
c.setRights( Collection::CanChangeCollection );
} else {
Collection::Rights rights;
rights |= Collection::CanChangeItem;
rights |= Collection::CanCreateItem;
rights |= Collection::CanDeleteItem;
rights |= Collection::CanChangeCollection;
c.setRights( rights );
}
EntityDisplayAttribute* attr = c.attribute<EntityDisplayAttribute>( Collection::AddIfMissing );
attr->setDisplayName( name() );
attr->setIconName( mCollectionIcon );
Collection::List list;
list << c;
list << rootCollection();
collectionsRetrieved( list );
}
......
......@@ -85,7 +85,7 @@ bool SingleFileResourceBase::readLocalFile( const QString &fileName )
// the last time this file was read. Before we synchronize first
// clearCache is called to make sure that the cached items get the
// actual values as present in the file.
clearCache();
invalidateCache( rootCollection() );
synchronize();
} else {
// The hash didn't change, notify implementing resources about the
......@@ -167,6 +167,8 @@ void SingleFileResourceBase::collectionChanged( const Akonadi::Collection & coll
EntityDisplayAttribute *attr = collection.attribute<EntityDisplayAttribute>();
if ( !attr->displayName().isEmpty() )
newName = attr->displayName();
if ( !attr->iconName().isEmpty() )
mCollectionIcon = attr->iconName();
}
if ( newName != name() )
......@@ -237,7 +239,7 @@ void SingleFileResourceBase::fileChanged( const QString & fileName )
// Notify resources, so that information bound to the file like indexes etc.
// can be updated.
handleHashChange();
clearCache();
invalidateCache( rootCollection() );
synchronize();
}
......
......@@ -160,6 +160,11 @@ class SingleFileResourceBase : public ResourceBase, public AgentBase::Observer
*/
virtual bool readOnly() const = 0;
/**
* Returns the collection of this resource.
*/
virtual Collection rootCollection() const = 0;
protected:
KUrl mCurrentUrl;
QStringList mSupportedMimetypes;
......
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