Commit 348d3fab authored by David Jarvie's avatar David Jarvie

Fix collection compatibility not being updated properly

parent 5c4ccde3
......@@ -162,7 +162,7 @@ KAEvent checkItemChanged(const Akonadi::Item& item, QString& errorMsg)
*/
void setCollectionCompatibility(const Collection& collection, KAlarm::Calendar::Compat compatibility, int version)
{
kDebug() << "->" << compatibility;
kDebug() << collection.id() << "->" << compatibility << version;
Collection col = collection;
CompatibilityAttribute* attr = col.attribute<CompatibilityAttribute>(Collection::AddIfMissing);
attr->setCompatibility(compatibility);
......
......@@ -119,9 +119,10 @@ bool KAlarmResource::readFromFile(const QString& fileName)
{
mCompatibility = compat;
mVersion = version;
const Collection c(collectionId());
if (c.isValid())
KAlarmResourceCommon::setCollectionCompatibility(c, mCompatibility, mVersion);
Collection c;
c.setParentCollection(Collection::root());
c.setRemoteId(mSettings->path());
KAlarmResourceCommon::setCollectionCompatibility(c, mCompatibility, mVersion);
}
return true;
}
......@@ -218,9 +219,10 @@ void KAlarmResource::settingsChanged()
mCurrentHash = calculateHash(filename);
mCompatibility = KAlarm::Calendar::Current;
const Collection c(collectionId());
if (c.isValid())
KAlarmResourceCommon::setCollectionCompatibility(c, mCompatibility, 0);
Collection c;
c.setParentCollection(Collection::root());
c.setRemoteId(mSettings->path());
KAlarmResourceCommon::setCollectionCompatibility(c, mCompatibility, 0);
}
}
mSettings->setUpdateStorageFormat(false);
......
......@@ -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 );
......
......@@ -327,26 +327,13 @@ class SingleFileResource : public SingleFileResourceBase
collectionsRetrieved( list );
}
void retrieveItems( const Akonadi::Collection &collection )
{
mCollectionId = collection.id();
}
bool readOnly() const
{
return mSettings->readOnly();
}
Collection::Id collectionId() const
{
return mCollectionId;
}
protected:
Settings *mSettings;
private:
Collection::Id mCollectionId; //!< the one and only collection for this resource
};
}
......
......@@ -1666,6 +1666,15 @@ void AkonadiModel::setCollectionChanged(const Collection& collection, const QSet
emit collectionStatusChanged(collection, Enabled, static_cast<int>(newEnabled), rowInserted);
}
}
// Check for the backend calendar format changing
if (attributeNames.contains(CompatibilityAttribute::name()))
{
// Update to current KAlarm format if necessary, and if the user agrees
Collection col(collection);
refresh(col);
CalendarMigrator::updateToCurrentFormat(col, false, MainWindow::mainMainWindow());
}
}
/******************************************************************************
......
......@@ -56,6 +56,7 @@ void AkonadiResourceCreator::createResource()
void AkonadiResourceCreator::getAgentType()
{
kDebug() << "Type:" << mDefaultType;
// Use AutoQPointer to guard against crash on application exit while
// the dialogue is still open. It prevents double deletion (both on
// deletion of parent, and on return from this function).
......
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