From 5fa8608e9877eab40336a60ed8ed979aaf3cfbd0 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 5 Oct 2016 22:42:53 +0200 Subject: Adapted to new API --- framework/domain/accountfactory.cpp | 2 +- framework/domain/actions/sinkactions.cpp | 16 +++++++-------- framework/domain/folderlistmodel.cpp | 4 ++-- framework/domain/maillistmodel.cpp | 2 +- framework/domain/settings/accountsettings.cpp | 28 +++++++++++++-------------- 5 files changed, 26 insertions(+), 26 deletions(-) (limited to 'framework') diff --git a/framework/domain/accountfactory.cpp b/framework/domain/accountfactory.cpp index 6261eaf1..182a0a1d 100644 --- a/framework/domain/accountfactory.cpp +++ b/framework/domain/accountfactory.cpp @@ -43,7 +43,7 @@ QString AccountFactory::name() const void AccountFactory::setAccountId(const QString &accountId) { mAccountId = accountId; - Sink::Store::fetchOne(Sink::Query::IdentityFilter(accountId.toUtf8())) + Sink::Store::fetchOne(Sink::Query().filter(accountId.toUtf8())) .syncThen([this](const Sink::ApplicationDomain::SinkAccount &account) { mAccountType = account.getProperty("type").toByteArray(); loadPackage(); diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index e79e79c9..cc8d324e 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp @@ -85,7 +85,7 @@ static ActionHandlerHelper synchronizeHandler("org.kde.kube.actions.synchronize" [](Context *context) { if (auto folder = context->property("folder").value()) { SinkLog() << "Synchronizing resource " << folder->resourceInstanceIdentifier(); - Store::synchronize(Query::ResourceFilter(folder->resourceInstanceIdentifier())).exec(); + Store::synchronize(Query().resourceFilter(folder->resourceInstanceIdentifier())).exec(); } else { SinkLog() << "Synchronizing all"; Store::synchronize(Query()).exec(); @@ -106,7 +106,7 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", Query query; query.containsFilter(ApplicationDomain::ResourceCapabilities::Mail::transport); - query.filter(ApplicationDomain::SinkAccount(accountId)); + query.filter(accountId); Store::fetchAll(query) .then>([=](const QList &resources) -> KAsync::Job { if (!resources.isEmpty()) { @@ -129,7 +129,7 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", return !accountId.isEmpty() && message; }, ActionHandlerHelper::JobHandler([](Context *context) -> KAsync::Job { - SinkWarning() << "executing save as draft"; + SinkLog() << "Executing the save-as-draft action"; const auto accountId = context->property("accountId").value(); const auto message = context->property("message").value(); auto existingMail = context->property("existingMail").value(); @@ -140,18 +140,18 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", if (existingMail.identifier().isEmpty()) { Query query; - query.containsFilter(ApplicationDomain::ResourceCapabilities::Mail::drafts); - query.filter(ApplicationDomain::SinkAccount(accountId)); + query.containsFilter(ApplicationDomain::ResourceCapabilities::Mail::drafts); + query.filter(accountId); return Store::fetchOne(query) .then([=](const SinkResource &resource) -> KAsync::Job { Mail mail(resource.identifier()); - mail.setProperty("draft", true); - mail.setBlobProperty("mimeMessage", message->encodedContent()); + mail.setDraft(true); + mail.setMimeMessage(message->encodedContent()); return Store::create(mail); }); } else { SinkWarning() << "Modifying an existing mail" << existingMail.identifier(); - existingMail.setBlobProperty("mimeMessage", message->encodedContent()); + existingMail.setMimeMessage(message->encodedContent()); return Store::modify(existingMail); } }) diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp index e852288f..7cf5ad5d 100644 --- a/framework/domain/folderlistmodel.cpp +++ b/framework/domain/folderlistmodel.cpp @@ -29,7 +29,7 @@ FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() { Query query; query.liveQuery = true; - query.requestedProperties << "name" << "icon" << "parent"; + query.request().request().request(); query.parentProperty = "parent"; runQuery(query); } @@ -79,7 +79,7 @@ void FolderListModel::setAccountId(const QVariant &accountId) //Get all folders of an account auto query = Query(); - query.filter(SinkAccount(account)); + query.resourceFilter(account); query.liveQuery = true; query.request() .request() diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp index e3f555c4..9afb6408 100644 --- a/framework/domain/maillistmodel.cpp +++ b/framework/domain/maillistmodel.cpp @@ -107,7 +107,7 @@ void MailListModel::setParentFolder(const QVariant &parentFolder) } Sink::Query query; query.liveQuery = true; - query.resources << folder->resourceInstanceIdentifier(); + query.resourceFilter(folder->resourceInstanceIdentifier()); query.sort(); query.limit = 100; query.request(); diff --git a/framework/domain/settings/accountsettings.cpp b/framework/domain/settings/accountsettings.cpp index 635aef6e..ea798a73 100644 --- a/framework/domain/settings/accountsettings.cpp +++ b/framework/domain/settings/accountsettings.cpp @@ -134,9 +134,9 @@ void AccountSettings::saveAccount() qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; Q_ASSERT(!mAccountIdentifier.isEmpty()); SinkAccount account(mAccountIdentifier); - account.setProperty("type", "imap"); - account.setProperty("name", mName); - account.setProperty("icon", mIcon); + account.setAccountType("imap"); + account.setName(mName); + account.setIcon(mIcon); Q_ASSERT(!account.identifier().isEmpty()); Store::modify(account) .onError([](const KAsync::Error &error) { @@ -148,17 +148,17 @@ void AccountSettings::saveAccount() void AccountSettings::loadAccount() { Q_ASSERT(!mAccountIdentifier.isEmpty()); - Store::fetchOne(Query::IdentityFilter(mAccountIdentifier)) + Store::fetchOne(Query().filter(mAccountIdentifier)) .syncThen([this](const SinkAccount &account) { - mIcon = account.getProperty("icon").toString(); - mName = account.getProperty("name").toString(); + mIcon = account.getIcon(); + mName = account.getName(); emit changed(); }).exec(); } void AccountSettings::loadImapResource() { - Store::fetchOne(Query().filter(SinkAccount(mAccountIdentifier)).containsFilter(ResourceCapabilities::Mail::storage)) + Store::fetchOne(Query().filter(mAccountIdentifier).containsFilter(ResourceCapabilities::Mail::storage)) .syncThen([this](const SinkResource &resource) { mImapIdentifier = resource.identifier(); mImapServer = resource.getProperty("server").toString(); @@ -172,7 +172,7 @@ void AccountSettings::loadImapResource() void AccountSettings::loadMaildirResource() { - Store::fetchOne(Query().filter(SinkAccount(mAccountIdentifier)).containsFilter(ResourceCapabilities::Mail::storage)) + Store::fetchOne(Query().filter(mAccountIdentifier).containsFilter(ResourceCapabilities::Mail::storage)) .syncThen([this](const SinkResource &resource) { mMaildirIdentifier = resource.identifier(); auto path = resource.getProperty("path").toString(); @@ -187,7 +187,7 @@ void AccountSettings::loadMaildirResource() void AccountSettings::loadMailtransportResource() { - Store::fetchOne(Query().filter(SinkAccount(mAccountIdentifier)).containsFilter(ResourceCapabilities::Mail::transport)) + Store::fetchOne(Query().filter(mAccountIdentifier).containsFilter(ResourceCapabilities::Mail::transport)) .syncThen([this](const SinkResource &resource) { mMailtransportIdentifier = resource.identifier(); mSmtpServer = resource.getProperty("server").toString(); @@ -202,7 +202,7 @@ void AccountSettings::loadMailtransportResource() void AccountSettings::loadIdentity() { //FIXME this assumes that we only ever have one identity per account - Store::fetchOne(Query().filter(SinkAccount(mAccountIdentifier))) + Store::fetchOne(Query().filter(mAccountIdentifier)) .syncThen([this](const Identity &identity) { mIdentityIdentifier = identity.identifier(); mUsername = identity.getProperty("username").toString(); @@ -283,7 +283,7 @@ void AccountSettings::saveIdentity() } else { auto identity = ApplicationDomainType::createEntity(); mIdentityIdentifier = identity.identifier(); - identity.setProperty("account", mAccountIdentifier); + identity.setAccount(mAccountIdentifier); identity.setProperty("username", mUsername); identity.setProperty("address", mEmailAddress); Store::create(identity) @@ -299,7 +299,7 @@ void AccountSettings::removeResource(const QByteArray &identifier) if (identifier.isEmpty()) { qWarning() << "We're missing an identifier"; } else { - SinkResource resource("", identifier, 0, QSharedPointer::create()); + SinkResource resource(identifier); Store::remove(resource) .onError([](const KAsync::Error &error) { qWarning() << "Error while removing resource: " << error.errorMessage; @@ -313,7 +313,7 @@ void AccountSettings::removeAccount() if (mAccountIdentifier.isEmpty()) { qWarning() << "We're missing an identifier"; } else { - SinkAccount account("", mAccountIdentifier, 0, QSharedPointer::create()); + SinkAccount account(mAccountIdentifier); Store::remove(account) .onError([](const KAsync::Error &error) { qWarning() << "Error while removing account: " << error.errorMessage; @@ -327,7 +327,7 @@ void AccountSettings::removeIdentity() if (mIdentityIdentifier.isEmpty()) { qWarning() << "We're missing an identifier"; } else { - Identity identity("", mIdentityIdentifier, 0, QSharedPointer::create()); + Identity identity(mIdentityIdentifier); Store::remove(identity) .onError([](const KAsync::Error &error) { qWarning() << "Error while removing identity: " << error.errorMessage; -- cgit v1.2.3