Commit 9b6147d5 authored by David Jarvie's avatar David Jarvie
Browse files

Rename AkonadiModel and CollectionSearch

parent 0970d673
......@@ -97,16 +97,16 @@ set(kalarm_bin_SRCS ${kalarm_bin_SRCS}
resources/resourcetype.cpp
resources/resource.cpp
resources/resources.cpp
resources/akonadiresource.cpp
resources/resourcedatamodelbase.cpp
resources/resourcemodel.cpp
resources/resourceselectdialog.cpp
resources/eventmodel.cpp
kalarmmigrateapplication.cpp
akonadimodel.cpp
akonadiresourcecreator.cpp
collectionsearch.cpp
resources/akonadidatamodel.cpp
resources/akonadiresource.cpp
resources/akonadiresourcecreator.cpp
resources/akonadiresourcemigrator.cpp
kalarmmigrateapplication.cpp
akonadicollectionsearch.cpp
eventid.cpp
)
......
/*
* collectionsearch.cpp - Search Akonadi Collections
* akonadicollectionsearch.cpp - Search Akonadi Collections
* Program: kalarm
* Copyright © 2014,2019 David Jarvie <djarvie@kde.org>
*
......@@ -18,7 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "collectionsearch.h"
#include "akonadicollectionsearch.h"
#include "kalarm_debug.h"
......@@ -46,7 +46,7 @@ using namespace Akonadi;
* notify all Items with that GID.
* - Otherwise, it will Q_EMIT the signal collections() to notify all Collections.
*/
CollectionSearch::CollectionSearch(const QString& mimeType, const QString& gid, const QString& uid, bool remove)
AkonadiCollectionSearch::AkonadiCollectionSearch(const QString& mimeType, const QString& gid, const QString& uid, bool remove)
: mMimeType(mimeType)
, mGid(gid)
, mUid(uid)
......@@ -60,7 +60,7 @@ CollectionSearch::CollectionSearch(const QString& mimeType, const QString& gid,
CollectionFetchJob* job = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive);
job->fetchScope().setResource(agent.identifier());
mCollectionJobs << job;
connect(job, &CollectionFetchJob::result, this, &CollectionSearch::collectionFetchResult);
connect(job, &CollectionFetchJob::result, this, &AkonadiCollectionSearch::collectionFetchResult);
}
}
......@@ -68,18 +68,18 @@ CollectionSearch::CollectionSearch(const QString& mimeType, const QString& gid,
{
// There are no resources containing the mime type, so ensure that a
// signal is emitted after construction.
QTimer::singleShot(0, this, &CollectionSearch::finish);
QTimer::singleShot(0, this, &AkonadiCollectionSearch::finish);
}
}
/******************************************************************************
* Called when a CollectionFetchJob has completed.
*/
void CollectionSearch::collectionFetchResult(KJob* j)
void AkonadiCollectionSearch::collectionFetchResult(KJob* j)
{
CollectionFetchJob* job = qobject_cast<CollectionFetchJob*>(j);
if (j->error())
qCCritical(KALARM_LOG) << "CollectionSearch::collectionFetchResult: CollectionFetchJob" << job->fetchScope().resource()<< "error: " << j->errorString();
qCCritical(KALARM_LOG) << "AkonadiCollectionSearch::collectionFetchResult: CollectionFetchJob" << job->fetchScope().resource()<< "error: " << j->errorString();
else
{
const Collection::List collections = job->collections();
......@@ -108,7 +108,7 @@ void CollectionSearch::collectionFetchResult(KJob* j)
continue;
}
mItemFetchJobs[ijob] = c.id();
connect(ijob, &ItemFetchJob::result, this, &CollectionSearch::itemFetchResult);
connect(ijob, &ItemFetchJob::result, this, &AkonadiCollectionSearch::itemFetchResult);
}
}
}
......@@ -125,15 +125,15 @@ void CollectionSearch::collectionFetchResult(KJob* j)
/******************************************************************************
* Called when an ItemFetchJob has completed.
*/
void CollectionSearch::itemFetchResult(KJob* j)
void AkonadiCollectionSearch::itemFetchResult(KJob* j)
{
ItemFetchJob* job = qobject_cast<ItemFetchJob*>(j);
if (j->error())
{
if (!mUid.isEmpty())
qCDebug(KALARM_LOG) << "CollectionSearch::itemFetchResult: ItemFetchJob: collection" << mItemFetchJobs[job] << "UID" << mUid << "error: " << j->errorString();
qCDebug(KALARM_LOG) << "AkonadiCollectionSearch::itemFetchResult: ItemFetchJob: collection" << mItemFetchJobs[job] << "UID" << mUid << "error: " << j->errorString();
else
qCDebug(KALARM_LOG) << "CollectionSearch::itemFetchResult: ItemFetchJob: collection" << mItemFetchJobs[job] << "GID" << mGid << "error: " << j->errorString();
qCDebug(KALARM_LOG) << "AkonadiCollectionSearch::itemFetchResult: ItemFetchJob: collection" << mItemFetchJobs[job] << "GID" << mGid << "error: " << j->errorString();
}
else
{
......@@ -155,7 +155,7 @@ void CollectionSearch::itemFetchResult(KJob* j)
continue;
ItemDeleteJob* djob = new ItemDeleteJob(item, this);
mItemDeleteJobs[djob] = mItemFetchJobs[job];
connect(djob, &ItemDeleteJob::result, this, &CollectionSearch::itemDeleteResult);
connect(djob, &ItemDeleteJob::result, this, &AkonadiCollectionSearch::itemDeleteResult);
}
}
else
......@@ -170,15 +170,15 @@ void CollectionSearch::itemFetchResult(KJob* j)
/******************************************************************************
* Called when an ItemDeleteJob has completed.
*/
void CollectionSearch::itemDeleteResult(KJob* j)
void AkonadiCollectionSearch::itemDeleteResult(KJob* j)
{
ItemDeleteJob* job = static_cast<ItemDeleteJob*>(j);
if (j->error())
{
if (!mUid.isEmpty())
qCDebug(KALARM_LOG) << "CollectionSearch::itemDeleteResult: ItemDeleteJob: resource" << mItemDeleteJobs[job] << "UID" << mUid << "error: " << j->errorString();
qCDebug(KALARM_LOG) << "AkonadiCollectionSearch::itemDeleteResult: ItemDeleteJob: resource" << mItemDeleteJobs[job] << "UID" << mUid << "error: " << j->errorString();
else
qCDebug(KALARM_LOG) << "CollectionSearch::itemDeleteResult: ItemDeleteJob: resource" << mItemDeleteJobs[job] << "GID" << mGid << "error: " << j->errorString();
qCDebug(KALARM_LOG) << "AkonadiCollectionSearch::itemDeleteResult: ItemDeleteJob: resource" << mItemDeleteJobs[job] << "GID" << mGid << "error: " << j->errorString();
}
else
++mDeleteCount;
......@@ -191,7 +191,7 @@ void CollectionSearch::itemDeleteResult(KJob* j)
/******************************************************************************
* Notify the result of the search/delete operation, and delete this instance.
*/
void CollectionSearch::finish()
void AkonadiCollectionSearch::finish()
{
if (mDelete)
Q_EMIT deleted(mDeleteCount);
......
/*
* collectionsearch.h - Search Akonadi Collections
* akonadicollectionsearch.h - Search Akonadi Collections
* Program: kalarm
* Copyright © 2014,2019 David Jarvie <djarvie@kde.org>
*
......@@ -18,8 +18,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef COLLECTIONSEARCH_H
#define COLLECTIONSEARCH_H
#ifndef AKONADICOLLECTIONSEARCH_H
#define AKONADICOLLECTIONSEARCH_H
#include <AkonadiCore/Collection>
......@@ -38,7 +38,7 @@ class ItemDeleteJob;
}
/*=============================================================================
= Class: CollectionSearch
= Class: AkonadiCollectionSearch
= Fetches a list of all Akonadi collections which handle a specified mime type,
= and then optionally fetches or deletes all Items from them with a given GID
= or UID.
......@@ -47,11 +47,11 @@ class ItemDeleteJob;
= Instances must therefore be created on the heap by operator new(), not on the
= stack.
=============================================================================*/
class CollectionSearch : public QObject
class AkonadiCollectionSearch : public QObject
{
Q_OBJECT
public:
explicit CollectionSearch(const QString& mimeType, const QString& gid = QString(), const QString& uid = QString(), bool remove = false);
explicit AkonadiCollectionSearch(const QString& mimeType, const QString& gid = QString(), const QString& uid = QString(), bool remove = false);
Q_SIGNALS:
// Signal emitted if action is to fetch all collections for the mime type
......@@ -80,6 +80,6 @@ class CollectionSearch : public QObject
bool mDelete;
};
#endif // COLLECTIONSEARCH_H
#endif // AKONADICOLLECTIONSEARCH_H
// vim: et sw=4:
......@@ -20,12 +20,12 @@
#include "alarmcalendar.h"
#include "akonadimodel.h"
#include "kalarm.h"
#include "functions.h"
#include "kalarmapp.h"
#include "mainwindow.h"
#include "preferences.h"
#include "resources/akonadidatamodel.h"
#include "resources/resources.h"
#include "lib/filedialog.h"
#include "lib/messagebox.h"
......@@ -72,7 +72,7 @@ bool AlarmCalendar::initialiseCalendars()
QDir dir;
dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
QString displayCal = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + displayCalendarName;
AkonadiModel::instance();
AkonadiDataModel::instance();
Preferences::setBackend(Preferences::Akonadi);
Preferences::self()->save();
mResourcesCalendar = new AlarmCalendar();
......@@ -689,7 +689,7 @@ bool AlarmCalendar::importAlarms(QWidget* parent, Resource* resourceptr)
default:
continue;
}
res = Resources::destination<AkonadiModel>(type);
res = Resources::destination<AkonadiDataModel>(type);
}
Event::Ptr newev(new Event(*event));
......@@ -948,7 +948,7 @@ bool AlarmCalendar::addEvent(KAEvent& evnt, QWidget* promptParent, bool useEvent
res = resource;
else
{
res = Resources::destination<AkonadiModel>(type, promptParent, noPrompt, cancelled);
res = Resources::destination<AkonadiDataModel>(type, promptParent, noPrompt, cancelled);
if (!res.isValid())
{
const char* typeStr = (type == CalEvent::ACTIVE) ? "Active alarm" : (type == CalEvent::ARCHIVED) ? "Archived alarm" : "alarm Template";
......@@ -958,7 +958,7 @@ bool AlarmCalendar::addEvent(KAEvent& evnt, QWidget* promptParent, bool useEvent
if (res.isValid())
{
// Don't add event to mEventMap yet - its Akonadi item id is not yet known.
// It will be added once it is inserted into AkonadiModel.
// It will be added once it is inserted into AkonadiDataModel.
ok = res.addEvent(*event);
remove = ok; // if success, delete the local event instance on exit
if (ok && type == CalEvent::ACTIVE && !event->enabled())
......
......@@ -20,8 +20,8 @@
#include "alarmlistdelegate.h"
#include "akonadimodel.h"
#include "functions.h"
#include "resources/resourcedatamodelbase.h"
#include "resources/eventmodel.h"
#include "kalarm_debug.h"
......
......@@ -22,7 +22,6 @@
#include "editdlg_p.h"
#include "editdlgtypes.h"
#include "akonadimodel.h"
#include "alarmcalendar.h"
#include "alarmtimewidget.h"
#include "deferdlg.h"
......@@ -33,6 +32,7 @@
#include "preferences.h"
#include "recurrenceedit.h"
#include "reminder.h"
#include "resources/akonadidatamodel.h"
#include "resources/resources.h"
#include "lib/autoqpointer.h"
#include "lib/buttongroup.h"
......@@ -1162,7 +1162,7 @@ bool EditAlarmDlg::validate()
bool cancelled = false;
CalEvent::Type type = mTemplate ? CalEvent::TEMPLATE : CalEvent::ACTIVE;
if (!mResource.isWritable(type))
mResource = Resources::destination<AkonadiModel>(type, this, false, &cancelled);
mResource = Resources::destination<AkonadiDataModel>(type, this, false, &cancelled);
if (!mResource.isValid())
{
if (!cancelled)
......
......@@ -21,10 +21,9 @@
#include "functions.h"
#include "functions_p.h"
#include "akonadimodel.h"
#include "akonadicollectionsearch.h"
#include "alarmcalendar.h"
#include "alarmtime.h"
#include "collectionsearch.h"
#include "editdlg.h"
#include "kalarmapp.h"
#include "kamail.h"
......@@ -33,6 +32,7 @@
#include "preferences.h"
#include "templatelistview.h"
#include "templatemenuaction.h"
#include "resources/akonadidatamodel.h"
#include "resources/resources.h"
#include "resources/eventmodel.h"
#include "lib/autoqpointer.h"
......@@ -258,7 +258,7 @@ UpdateResult addEvents(QVector<KAEvent>& events, QWidget* msgParent, bool allowK
status.status = UPDATE_FAILED;
else
{
Resource resource = Resources::destination<AkonadiModel>(CalEvent::ACTIVE, msgParent);
Resource resource = Resources::destination<AkonadiDataModel>(CalEvent::ACTIVE, msgParent);
if (!resource.isValid())
{
qCDebug(KALARM_LOG) << "KAlarm::addEvents: No calendar";
......@@ -591,7 +591,7 @@ UpdateResult reactivateEvents(QVector<KAEvent>& events, QVector<EventId>& inelig
if (resourceptr)
resource = *resourceptr;
if (!resource.isValid())
resource = Resources::destination<AkonadiModel>(CalEvent::ACTIVE, msgParent);
resource = Resources::destination<AkonadiDataModel>(CalEvent::ACTIVE, msgParent);
if (!resource.isValid())
{
qCDebug(KALARM_LOG) << "KAlarm::reactivateEvents: No calendar";
......@@ -746,7 +746,7 @@ QVector<KAEvent> getSortedActiveEvents(QObject* parent, AlarmListModel** model)
model = &mdl;
if (!*model)
{
*model = AlarmListModel::create<AkonadiModel>(parent);
*model = AlarmListModel::create<AkonadiDataModel>(parent);
(*model)->setEventTypeFilter(CalEvent::ACTIVE);
(*model)->sort(AlarmListModel::TimeColumn);
}
......@@ -1590,7 +1590,7 @@ KAlarm::UpdateResult sendToKOrganizer(const KAEvent& event)
KAlarm::UpdateResult deleteFromKOrganizer(const QString& eventID)
{
const QString newID = uidKOrganizer(eventID);
new CollectionSearch(KORG_MIME_TYPE, QString(), newID, true); // this auto-deletes when complete
new AkonadiCollectionSearch(KORG_MIME_TYPE, QString(), newID, true); // this auto-deletes when complete
// Ignore errors
return KAlarm::UpdateResult(KAlarm::UPDATE_OK);
}
......
......@@ -20,7 +20,6 @@
#include "kalarmapp.h"
#include "akonadimodel.h"
#include "alarmcalendar.h"
#include "alarmtime.h"
#include "commandoptions.h"
......@@ -35,6 +34,7 @@
#include "prefdlg.h"
#include "startdaytimer.h"
#include "traywindow.h"
#include "resources/akonadidatamodel.h"
#include "resources/resources.h"
#include "resources/eventmodel.h"
#include "lib/desktop.h"
......@@ -140,8 +140,8 @@ KAlarmApp::KAlarmApp(int& argc, char** argv)
this, &KAlarmApp::purgeNewArchivedDefault);
connect(Resources::instance(), &Resources::resourcesCreated,
this, &KAlarmApp::checkWritableCalendar);
connect(AkonadiModel::instance(), &AkonadiModel::migrationCompleted,
this, &KAlarmApp::checkWritableCalendar);
connect(AkonadiDataModel::instance(), &AkonadiDataModel::migrationCompleted,
this, &KAlarmApp::checkWritableCalendar);
KConfigGroup config(KSharedConfig::openConfig(), "General");
mNoSystemTray = config.readEntry("NoSystemTray", false);
......@@ -1146,7 +1146,7 @@ void KAlarmApp::checkWritableCalendar()
MessageWin::redisplayAlarms();
}
if (!treeFetched
|| !AkonadiModel::instance()->isMigrationComplete())
|| !AkonadiDataModel::instance()->isMigrationComplete())
return;
static bool done = false;
if (done)
......@@ -2398,10 +2398,10 @@ bool KAlarmApp::waitUntilPopulated(ResourceId id, int timeout)
// Use AutoQPointer to guard against crash on application exit while
// the event loop is still running. It prevents double deletion (both
// on deletion of parent, and on return from this function).
AutoQPointer<QEventLoop> loop = new QEventLoop(AlarmListModel::all<AkonadiModel>());
AutoQPointer<QEventLoop> loop = new QEventLoop(AlarmListModel::all<AkonadiDataModel>());
//TODO: The choice of parent object for QEventLoop can prevent EntityTreeModel signals
// from activating connected slots in AkonadiModel, which prevents resources from
// being informed that collections have loaded. Need to find a better parent
// from activating connected slots in AkonadiDataModel, which prevents resources
// from being informed that collections have loaded. Need to find a better parent
// object - Qt item models seem to work, but what else?
// These don't work: Resources::instance(), qApp(), theApp(), MainWindow::mainMainWindow(), AlarmCalendar::resources(), QStandardItemModel.
// These do work: CollectionControlModel::instance(), AlarmListModel::all().
......
......@@ -20,7 +20,6 @@
#include "mainwindow.h"
#include "akonadimodel.h"
#include "alarmcalendar.h"
#include "alarmlistdelegate.h"
#include "alarmlistview.h"
......@@ -37,6 +36,7 @@
#include "templatepickdlg.h"
#include "traywindow.h"
#include "wakedlg.h"
#include "resources/akonadidatamodel.h"
#include "resources/resources.h"
#include "resources/eventmodel.h"
#include "lib/autoqpointer.h"
......@@ -160,7 +160,7 @@ MainWindow::MainWindow(bool restored)
mSplitter->setStretchFactor(1, 1);
// Create the alarm list widget
mListFilterModel = AlarmListModel::create<AkonadiModel>(this);
mListFilterModel = AlarmListModel::create<AkonadiDataModel>(this);
mListFilterModel->setEventTypeFilter(mShowArchived ? CalEvent::ACTIVE | CalEvent::ARCHIVED : CalEvent::ACTIVE);
mListView = new AlarmListView(WINDOW_NAME, mSplitter);
mListView->setModel(mListFilterModel);
......@@ -618,7 +618,7 @@ void MainWindow::enableTemplateMenuItem(bool enable)
void MainWindow::refresh()
{
qCDebug(KALARM_LOG) << "MainWindow::refresh";
AkonadiModel::instance()->reload();
AkonadiDataModel::instance()->reload();
}
/******************************************************************************
......
......@@ -20,9 +20,9 @@
#include "newalarmaction.h"
#include "akonadimodel.h"
#include "functions.h"
#include "templatemenuaction.h"
#include "resources/akonadidatamodel.h"
#include "resources/resources.h"
#include "resources/eventmodel.h"
#include "lib/shellprocess.h"
......@@ -83,7 +83,7 @@ NewAlarmAction::NewAlarmAction(bool templates, const QString& label, QObject* pa
mTemplateAction = new TemplateMenuAction(QIcon::fromTheme(TEMPLATE_ICON), i18nc("@action", "New Alarm From &Template"), parent);
menu()->addAction(mTemplateAction);
connect(Resources::instance(), &Resources::settingsChanged, this, &NewAlarmAction::slotCalendarStatusChanged);
connect(TemplateListModel::all<AkonadiModel>(), &EventListModel::haveEventsStatus, this, &NewAlarmAction::slotCalendarStatusChanged);
connect(TemplateListModel::all<AkonadiDataModel>(), &EventListModel::haveEventsStatus, this, &NewAlarmAction::slotCalendarStatusChanged);
slotCalendarStatusChanged(); // initialise action states
}
setDelayed(false);
......@@ -171,7 +171,7 @@ void NewAlarmAction::slotCalendarStatusChanged()
{
// Find whether there are any writable active alarm calendars
bool active = !Resources::enabledResources(CalEvent::ACTIVE, true).isEmpty();
bool haveEvents = TemplateListModel::all<AkonadiModel>()->haveEvents();
bool haveEvents = TemplateListModel::all<AkonadiDataModel>()->haveEvents();
mTemplateAction->setEnabled(active && haveEvents);
setEnabled(active);
}
......
/*
* akonadimodel.h - KAlarm calendar file access using Akonadi
* akonadidatamodel.h - KAlarm calendar file access using Akonadi
* Program: kalarm
* Copyright © 2010-2019 David Jarvie <djarvie@kde.org>
*
......@@ -18,8 +18,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef AKONADIMODEL_H
#define AKONADIMODEL_H
#ifndef AKONADIDATAMODEL_H
#define AKONADIDATAMODEL_H
#include "resources/resourcedatamodelbase.h"
#include "resources/akonadiresource.h"
......@@ -43,15 +43,15 @@ class KJob;
using namespace KAlarmCal;
class AkonadiModel : public Akonadi::EntityTreeModel, public ResourceDataModelBase
class AkonadiDataModel : public Akonadi::EntityTreeModel, public ResourceDataModelBase
{
Q_OBJECT
public:
enum Change { Enabled, ReadOnly, AlarmTypes };
static AkonadiModel* instance();
static AkonadiDataModel* instance();
~AkonadiModel() override;
~AkonadiDataModel() override;
static Akonadi::ChangeRecorder* monitor();
......@@ -152,7 +152,7 @@ class AkonadiModel : public Akonadi::EntityTreeModel, public ResourceDataModelBa
CalEvent::Type alarmType;
};
AkonadiModel(Akonadi::ChangeRecorder*, QObject* parent);
AkonadiDataModel(Akonadi::ChangeRecorder*, QObject* parent);
void initResourceMigrator();
Resource& updateResource(const Akonadi::Collection&) const;
......@@ -168,7 +168,7 @@ class AkonadiModel : public Akonadi::EntityTreeModel, public ResourceDataModelBa
QList<KAEvent> events(ResourceId) const;
void getChildEvents(const QModelIndex& parent, QList<KAEvent>&) const;
static AkonadiModel* mInstance;
static AkonadiDataModel* mInstance;
static int mTimeHourPos; // position of hour within time string, or -1 if leading zeroes included
Akonadi::ChangeRecorder* mMonitor;
......@@ -187,6 +187,6 @@ class AkonadiModel : public Akonadi::EntityTreeModel, public ResourceDataModelBa
QQueue<KAEvent> mPendingEventChanges; // changed events with changedEvent() signal pending
};
#endif // AKONADIMODEL_H
#endif // AKONADIDATAMODEL_H
// vim: et sw=4:
......@@ -21,7 +21,7 @@
#include "akonadiresource.h"
#include "resources.h"
#include "akonadimodel.h"
#include "akonadidatamodel.h"
#include "akonadiresourcemigrator.h"
#include "lib/autoqpointer.h"
#include "kalarm_debug.h"
......@@ -105,7 +105,7 @@ AkonadiResource::AkonadiResource(const Collection& collection)
// If the collection doesn't belong to a resource, it can't be used.
mValid = AgentManager::self()->instance(mCollection.resource()).isValid();
connect(AkonadiModel::monitor(), &Monitor::collectionRemoved, this, &AkonadiResource::slotCollectionRemoved);
connect(AkonadiDataModel::monitor(), &Monitor::collectionRemoved, this, &AkonadiResource::slotCollectionRemoved);
}
}
......@@ -222,7 +222,7 @@ void AkonadiResource::setEnabled(CalEvent::Types types)
bool AkonadiResource::readOnly() const
{
AkonadiModel::instance()->refresh(mCollection); // update with latest data
AkonadiDataModel::instance()->refresh(mCollection); // update with latest data
return (mCollection.rights() & WritableRights) != WritableRights;
}
......@@ -230,7 +230,7 @@ int AkonadiResource::writableStatus(CalEvent::Type type) const
{
if (!mValid)
return -1;
AkonadiModel::instance()->refresh(mCollection); // update with latest data
AkonadiDataModel::instance()->refresh(mCollection); // update with latest data
if ((type == CalEvent::EMPTY && !enabledTypes())
|| (type != CalEvent::EMPTY && !isEnabled(type)))
return -1;
......@@ -335,7 +335,7 @@ KACalendar::Compat AkonadiResource::compatibilityVersion(QString& versionString)
versionString.clear();
if (!mValid)
return KACalendar::Incompatible;
AkonadiModel::instance()->refresh(mCollection); // update with latest data
AkonadiDataModel::instance()->refresh(mCollection); // update with latest data
if (!mCollection.hasAttribute<CompatibilityAttribute>())
return KACalendar::Incompatible;
const CompatibilityAttribute* attr = mCollection.attribute<CompatibilityAttribute>();
......@@ -400,7 +400,7 @@ void AkonadiResource::slotCollectionRemoved(const Collection& collection)
if (collection.id() == id())
{
qCDebug(KALARM_LOG) << "AkonadiResource::slotCollectionRemoved:" << id();
disconnect(AkonadiModel::monitor(), nullptr, this, nullptr);
disconnect(AkonadiDataModel::monitor(), nullptr, this, nullptr);
ResourceType::removeResource(collection.id());
}
}
......@@ -416,8 +416,8 @@ bool AkonadiResource::isPopulated() const
{
if (!ResourceType::isPopulated())
{
const QModelIndex ix = AkonadiModel::instance()->resourceIndex(mCollection.id());
if (!ix.data(AkonadiModel::IsPopulatedRole).toBool())
const QModelIndex ix = AkonadiDataModel::instance()->resourceIndex(mCollection.id());
if (!ix.data(AkonadiDataModel::IsPopulatedRole).toBool())
return false;
setLoaded(true);
}
......@@ -462,7 +462,7 @@ bool AkonadiResource::addEvent(const KAEvent& event)
bool AkonadiResource::updateEvent(const KAEvent& event)
{
qCDebug(KALARM_LOG) << "AkonadiResource::updateEvent:" << event.id();
Item item = AkonadiModel::instance()->itemForEvent(event.id());
Item item = AkonadiDataModel::instance()->itemForEvent(event.id());
if (!item.isValid())
return false;
if (!KAlarmCal::setItemPayload(item, event, mCollection.contentMimeTypes()))
......@@ -485,7 +485,7 @@ bool AkonadiResource::deleteEvent(const KAEvent& event)
qCDebug(KALARM_LOG) << "AkonadiResource::deleteEvent: Collection being deleted";
return true; // the event's collection is being deleted
}
const Item item = AkonadiModel::instance()->itemForEvent(event.id());
const Item item = AkonadiDataModel::instance()->itemForEvent(event.id());
if (!item.isValid())
return false;
ItemDeleteJob* job = new ItemDeleteJob(item);
......@@ -500,7 +500,7 @@ bool AkonadiResource::deleteEvent(const KAEvent& event)
*/
void AkonadiResource::handleCommandErrorChange(const KAEvent& event)
{
Item item = AkonadiModel::instance()->itemForEvent(event.id());
Item item = AkonadiDataModel::instance()->itemForEvent(event.id());
if (item.isValid())
{
const KAEvent::CmdErrType err = event.commandError();
......@@ -569,7 +569,7 @@ KAEvent AkonadiResource::event(Resource& resource, const Akonadi::Item& item)
*/
Resource AkonadiResource::destination(CalEvent::Type type, QWidget* promptParent, bool noPrompt, bool* cancelled)
{
return Resources::destination<AkonadiModel>(type, promptParent, noPrompt, cancelled);
return Resources::destination<AkonadiDataModel>(type, promptParent, noPrompt, cancelled);
}
/******************************************************************************
......@@ -722,7 +722,7 @@ void AkonadiResource::notifyCollectionChanged(Resource& res, const Collection& c
// Create a new temporary 'Resource' object, because the one passed
// to this method can get overwritten with an old version of its
// CompatibilityAttribute before AkonadiResourceMigration finishes,
// due to AkonadiModel still containing an out of date value.
// due to AkonadiDataModel still containing an out of date value.
qCDebug(KALARM_LOG) << "AkonadiResource::setCollectionChanged:" << collection.id() << ": compatibility ->" << collection.attribute<CompatibilityAttribute>()->compatibility();
// Note that the AkonadiResource will be deleted once no more
// QSharedPointers reference it.
......@@ -795,7 +795,7 @@ void AkonadiResource::queueItemModifyJob(const Item& item)
{
Item newItem = item;
Item current = item;
if (AkonadiModel::instance()->refresh(current)) // fetch the up-to-date item
if (AkonadiDataModel::instance()->refresh(current)) // fetch the up-to-date item
newItem.setRevision(current.revision());
mItemModifyJobQueue[item.id()] = Item(); // mark the queued item as now executing
ItemModifyJob* job = new ItemModifyJob(newItem);
......@@ -842,7 +842,7 @@ void AkonadiResource::itemJobDone(KJob* j)
if (itemId >= 0 && jobClass == "Akonadi::ItemModifyJob")
{
// Execute the next queued job for this item
const Item current = AkonadiModel::instance()->itemById(itemId); // fetch the up-to-date item
const Item current = AkonadiDataModel::instance()->itemById(itemId); // fetch the up-to-date item
checkQueuedItemModifyJob(current);
}
Resources::notifyResourceMessage(this, MessageType::Error, errMsg, j->errorString());
......@@ -915,7 +915,7 @@ void AkonadiResource::checkQueuedItemModifyJob(const Item& item)