From 42d34555397dd62399233fac1fbfa216c255ef68 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 21 Jan 2016 11:46:46 +0100 Subject: Akonadi2 -> Sink --- framework/CMakeLists.txt | 4 +- framework/mail/CMakeLists.txt | 4 +- framework/mail/actions/akonadiactions.cpp | 75 ------------------------------- framework/mail/actions/akonadiactions.h | 40 ----------------- framework/mail/actions/sinkactions.cpp | 75 +++++++++++++++++++++++++++++++ framework/mail/actions/sinkactions.h | 40 +++++++++++++++++ framework/mail/folderlistcontroller.cpp | 2 +- framework/mail/folderlistmodel.cpp | 12 ++--- framework/mail/maillistcontroller.cpp | 10 ++--- framework/mail/maillistmodel.cpp | 16 +++---- framework/mail/maillistmodel.h | 4 +- framework/mail/singlemailcontroller.cpp | 2 +- framework/settings/CMakeLists.txt | 6 +-- framework/settings/qmldir | 4 +- framework/settings/resourcelistmodel.cpp | 8 ++-- framework/settings/settingsplugin.cpp | 2 +- 16 files changed, 152 insertions(+), 152 deletions(-) delete mode 100644 framework/mail/actions/akonadiactions.cpp delete mode 100644 framework/mail/actions/akonadiactions.h create mode 100644 framework/mail/actions/sinkactions.cpp create mode 100644 framework/mail/actions/sinkactions.h (limited to 'framework') diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index 0b2b505d..8b0a7ca1 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -18,7 +18,7 @@ find_package(Qt5 COMPONENTS REQUIRED Core Qml) find_package(KF5Otp "5.1.42" CONFIG REQUIRED) find_package(KF5Mime "4.87.0" CONFIG REQUIRED) -find_package(Akonadi2Common CONFIG REQUIRED) +find_package(SinkCommon CONFIG REQUIRED) find_package(KF5Async) find_package(KF5Libkleo) @@ -35,7 +35,7 @@ include_directories(SYSTEM /work/install/include/KF5/KCoreAddons) enable_testing() -set(AKONADI2_RESOURCE_PLUGINS_PATH ${QT_PLUGIN_INSTALL_DIR}/akonadi2/resources) +set(SINK_RESOURCE_PLUGINS_PATH ${QT_PLUGIN_INSTALL_DIR}/sink/resources) add_subdirectory(mail) add_subdirectory(actions) diff --git a/framework/mail/CMakeLists.txt b/framework/mail/CMakeLists.txt index 9a32cc83..0a0e0ac6 100644 --- a/framework/mail/CMakeLists.txt +++ b/framework/mail/CMakeLists.txt @@ -5,7 +5,7 @@ set(mailplugin_SRCS singlemailcontroller.cpp folderlistmodel.cpp folderlistcontroller.cpp - actions/akonadiactions.cpp + actions/sinkactions.cpp objecttreesource.cpp stringhtmlwriter.cpp ) @@ -14,7 +14,7 @@ add_library(mailplugin SHARED ${mailplugin_SRCS}) qt5_use_modules(mailplugin Core Quick Qml) -target_link_libraries(mailplugin actionplugin KF5::akonadi2common KF5::Otp actionplugin) +target_link_libraries(mailplugin actionplugin Sink KF5::Otp) install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) diff --git a/framework/mail/actions/akonadiactions.cpp b/framework/mail/actions/akonadiactions.cpp deleted file mode 100644 index d0a51deb..00000000 --- a/framework/mail/actions/akonadiactions.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (c) 2016 Christian Mollekopf - - 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 - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#include "akonadiactions.h" - -#include - -#include - -using namespace Kube; - -ActionHandlerHelper::ActionHandlerHelper(const QByteArray &actionId, const std::function &isReady, const std::function &handler) - : ActionHandler(nullptr), - isReadyFunction(isReady), - handlerFunction(handler) -{ - setActionId(actionId); -} - -bool ActionHandlerHelper::isActionReady(Context *context) -{ - return isReadyFunction(context); -} - -void ActionHandlerHelper::execute(Context *context) -{ - handlerFunction(context); -} - -static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read", - [](Context *context) -> bool { - return context->property("mail").isValid(); - }, - [](Context *context) { - auto mail = context->property("mail").value(); - if (!mail) { - qWarning() << "Failed to get the mail mail: " << context->property("mail"); - return; - } - mail->setProperty("unread", false); - qDebug() << "Mark as read " << mail->identifier(); - Akonadi2::Store::modify(*mail).exec(); - } -); - -static ActionHandlerHelper deleteHandler("org.kde.kube.actions.delete", - [](Context *context) -> bool { - return context->property("mail").isValid(); - }, - [](Context *context) { - auto mail = context->property("mail").value(); - if (!mail) { - qWarning() << "Failed to get the mail mail: " << context->property("mail"); - return; - } - mail->setProperty("unread", false); - qDebug() << "Remove " << mail->identifier(); - Akonadi2::Store::remove(*mail).exec(); - } -); diff --git a/framework/mail/actions/akonadiactions.h b/framework/mail/actions/akonadiactions.h deleted file mode 100644 index a583ebf8..00000000 --- a/framework/mail/actions/akonadiactions.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (c) 2016 Christian Mollekopf - - 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 - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ -#pragma once - -#include -#include - -namespace Kube { -class Context; - -class ActionHandlerHelper : public ActionHandler -{ - Q_OBJECT -public: - ActionHandlerHelper(const QByteArray &actionId, const std::function &, const std::function &); - - bool isActionReady(Context *context) Q_DECL_OVERRIDE; - void execute(Context *context) Q_DECL_OVERRIDE; -private: - const std::function isReadyFunction; - const std::function handlerFunction; -}; - -} diff --git a/framework/mail/actions/sinkactions.cpp b/framework/mail/actions/sinkactions.cpp new file mode 100644 index 00000000..8918f996 --- /dev/null +++ b/framework/mail/actions/sinkactions.cpp @@ -0,0 +1,75 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + 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 + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#include "sinkactions.h" + +#include + +#include + +using namespace Kube; + +ActionHandlerHelper::ActionHandlerHelper(const QByteArray &actionId, const std::function &isReady, const std::function &handler) + : ActionHandler(nullptr), + isReadyFunction(isReady), + handlerFunction(handler) +{ + setActionId(actionId); +} + +bool ActionHandlerHelper::isActionReady(Context *context) +{ + return isReadyFunction(context); +} + +void ActionHandlerHelper::execute(Context *context) +{ + handlerFunction(context); +} + +static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read", + [](Context *context) -> bool { + return context->property("mail").isValid(); + }, + [](Context *context) { + auto mail = context->property("mail").value(); + if (!mail) { + qWarning() << "Failed to get the mail mail: " << context->property("mail"); + return; + } + mail->setProperty("unread", false); + qDebug() << "Mark as read " << mail->identifier(); + Sink::Store::modify(*mail).exec(); + } +); + +static ActionHandlerHelper deleteHandler("org.kde.kube.actions.delete", + [](Context *context) -> bool { + return context->property("mail").isValid(); + }, + [](Context *context) { + auto mail = context->property("mail").value(); + if (!mail) { + qWarning() << "Failed to get the mail mail: " << context->property("mail"); + return; + } + mail->setProperty("unread", false); + qDebug() << "Remove " << mail->identifier(); + Sink::Store::remove(*mail).exec(); + } +); diff --git a/framework/mail/actions/sinkactions.h b/framework/mail/actions/sinkactions.h new file mode 100644 index 00000000..a583ebf8 --- /dev/null +++ b/framework/mail/actions/sinkactions.h @@ -0,0 +1,40 @@ +/* + Copyright (c) 2016 Christian Mollekopf + + 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 + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ +#pragma once + +#include +#include + +namespace Kube { +class Context; + +class ActionHandlerHelper : public ActionHandler +{ + Q_OBJECT +public: + ActionHandlerHelper(const QByteArray &actionId, const std::function &, const std::function &); + + bool isActionReady(Context *context) Q_DECL_OVERRIDE; + void execute(Context *context) Q_DECL_OVERRIDE; +private: + const std::function isReadyFunction; + const std::function handlerFunction; +}; + +} diff --git a/framework/mail/folderlistcontroller.cpp b/framework/mail/folderlistcontroller.cpp index 3b1cf9f8..46a6f648 100644 --- a/framework/mail/folderlistcontroller.cpp +++ b/framework/mail/folderlistcontroller.cpp @@ -52,7 +52,7 @@ FolderListModel* FolderListController::model() const void FolderListController::loadFolders(const QString &id) { - //load foldermodel from akonadi + //load foldermodel from sink } diff --git a/framework/mail/folderlistmodel.cpp b/framework/mail/folderlistmodel.cpp index 204dfdbf..645ecc30 100644 --- a/framework/mail/folderlistmodel.cpp +++ b/framework/mail/folderlistmodel.cpp @@ -19,17 +19,17 @@ */ #include "folderlistmodel.h" -#include -#include +#include +#include FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() { - Akonadi2::Query query; + Sink::Query query; query.syncOnDemand = false; query.processAll = false; query.liveQuery = true; query.requestedProperties << "name" << "icon"; - mModel = Akonadi2::Store::loadModel(query); + mModel = Sink::Store::loadModel(query); setSourceModel(mModel.data()); } @@ -59,9 +59,9 @@ QVariant FolderListModel::data(const QModelIndex &idx, int role) const case Icon: return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); case Id: - return srcIdx.data(Akonadi2::Store::DomainObjectBaseRole).value()->identifier(); + return srcIdx.data(Sink::Store::DomainObjectBaseRole).value()->identifier(); case DomainObject: - return srcIdx.data(Akonadi2::Store::DomainObjectRole); + return srcIdx.data(Sink::Store::DomainObjectRole); } return QIdentityProxyModel::data(idx, role); } diff --git a/framework/mail/maillistcontroller.cpp b/framework/mail/maillistcontroller.cpp index ed353b70..b342b1ec 100644 --- a/framework/mail/maillistcontroller.cpp +++ b/framework/mail/maillistcontroller.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include "maillistmodel.h" @@ -38,7 +38,7 @@ MailListModel *MailListController::model() const void MailListController::loadAllMail() { - Akonadi2::Query query; + Sink::Query query; query.syncOnDemand = false; query.processAll = false; query.liveQuery = true; @@ -48,7 +48,7 @@ void MailListController::loadAllMail() void MailListController::loadMailFolder(const QString &folderId) { - Akonadi2::Query query; + Sink::Query query; query.syncOnDemand = false; query.processAll = false; query.liveQuery = true; @@ -59,7 +59,7 @@ void MailListController::loadMailFolder(const QString &folderId) void MailListController::loadUnreadMail() { - Akonadi2::Query query; + Sink::Query query; query.syncOnDemand = false; query.processAll = false; query.liveQuery = true; @@ -70,7 +70,7 @@ void MailListController::loadUnreadMail() void MailListController::loadImportantMail() { - Akonadi2::Query query; + Sink::Query query; query.syncOnDemand = false; query.processAll = false; query.liveQuery = true; diff --git a/framework/mail/maillistmodel.cpp b/framework/mail/maillistmodel.cpp index 2314e155..e43351b0 100644 --- a/framework/mail/maillistmodel.cpp +++ b/framework/mail/maillistmodel.cpp @@ -74,9 +74,9 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const case Important: return srcIdx.sibling(srcIdx.row(), 5).data(Qt::DisplayRole).toString(); case Id: - return srcIdx.data(Akonadi2::Store::DomainObjectBaseRole).value()->identifier(); + return srcIdx.data(Sink::Store::DomainObjectBaseRole).value()->identifier(); case DomainObject: - return srcIdx.data(Akonadi2::Store::DomainObjectRole); + return srcIdx.data(Sink::Store::DomainObjectRole); case MimeMessage: { auto filename = srcIdx.sibling(srcIdx.row(), 6).data(Qt::DisplayRole).toString(); QFile file(filename); @@ -123,20 +123,20 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const return QIdentityProxyModel::data(idx, role); } -void MailListModel::runQuery(const Akonadi2::Query &query) +void MailListModel::runQuery(const Sink::Query &query) { - m_model = Akonadi2::Store::loadModel(query); + m_model = Sink::Store::loadModel(query); setSourceModel(m_model.data()); } void MailListModel::setParentFolder(const QVariant &parentFolder) { - auto folder = parentFolder.value(); + auto folder = parentFolder.value(); if (!folder) { qWarning() << "No folder: " << parentFolder; return; } - Akonadi2::Query query; + Sink::Query query; query.syncOnDemand = false; query.processAll = false; query.liveQuery = true; @@ -154,12 +154,12 @@ QVariant MailListModel::parentFolder() const void MailListModel::setMail(const QVariant &variant) { - auto mail = variant.value(); + auto mail = variant.value(); if (!mail) { qWarning() << "No mail: " << mail; return; } - Akonadi2::Query query; + Sink::Query query; query.syncOnDemand = false; query.processAll = false; query.liveQuery = false; diff --git a/framework/mail/maillistmodel.h b/framework/mail/maillistmodel.h index 1d56e6b8..6593a59c 100644 --- a/framework/mail/maillistmodel.h +++ b/framework/mail/maillistmodel.h @@ -20,7 +20,7 @@ #pragma once -#include +#include #include #include @@ -53,7 +53,7 @@ public: QHash roleNames() const; - void runQuery(const Akonadi2::Query &query); + void runQuery(const Sink::Query &query); void setParentFolder(const QVariant &parentFolder); QVariant parentFolder() const; diff --git a/framework/mail/singlemailcontroller.cpp b/framework/mail/singlemailcontroller.cpp index 5f7a6d93..d0ab9f3c 100644 --- a/framework/mail/singlemailcontroller.cpp +++ b/framework/mail/singlemailcontroller.cpp @@ -38,7 +38,7 @@ MailListModel* SingleMailController::model() const void SingleMailController::loadMail(const QString &id) { - Akonadi2::Query query; + Sink::Query query; query.syncOnDemand = false; query.processAll = false; query.liveQuery = false; diff --git a/framework/settings/CMakeLists.txt b/framework/settings/CMakeLists.txt index 5d61851f..017820b6 100644 --- a/framework/settings/CMakeLists.txt +++ b/framework/settings/CMakeLists.txt @@ -9,7 +9,7 @@ add_library(settingsplugin SHARED ${settingsplugin_SRCS}) qt5_use_modules(settingsplugin Core Quick Qml) -target_link_libraries(settingsplugin KF5::akonadi2common) +target_link_libraries(settingsplugin KF5::sinkcommon) -install(TARGETS settingsplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/akonadi2/settings) -install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/akonadi2/settings) \ No newline at end of file +install(TARGETS settingsplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/sink/settings) +install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/sink/settings) \ No newline at end of file diff --git a/framework/settings/qmldir b/framework/settings/qmldir index 4db161bc..1740f29a 100644 --- a/framework/settings/qmldir +++ b/framework/settings/qmldir @@ -1,3 +1,3 @@ -module org.kde.akonadi2.settings +module org.kde.sink.settings -plugin settingsplugin \ No newline at end of file +plugin settingsplugin diff --git a/framework/settings/resourcelistmodel.cpp b/framework/settings/resourcelistmodel.cpp index ebeaac32..ae1ffc15 100644 --- a/framework/settings/resourcelistmodel.cpp +++ b/framework/settings/resourcelistmodel.cpp @@ -1,15 +1,15 @@ #include "resourcelistmodel.h" -#include +#include ResourceListModel::ResourceListModel(QObject *parent) : QIdentityProxyModel() { - Akonadi2::Query query; + Sink::Query query; query.syncOnDemand = false; query.processAll = false; query.liveQuery = true; query.requestedProperties << "type"; - m_model = Akonadi2::Store::loadModel(query); + m_model = Sink::Store::loadModel(query); } ResourceListModel::~ResourceListModel() @@ -32,7 +32,7 @@ QVariant ResourceListModel::data(const QModelIndex& index, int role) const auto srcIdx = mapToSource(index); switch (role) { case Id: - return srcIdx.data(Akonadi2::Store::DomainObjectBaseRole).value()->identifier(); + return srcIdx.data(Sink::Store::DomainObjectBaseRole).value()->identifier(); case Type: return srcIdx.sibling(srcIdx.row(), 0).data(Qt::DisplayRole).toString(); } diff --git a/framework/settings/settingsplugin.cpp b/framework/settings/settingsplugin.cpp index 6c2951e7..ca670583 100644 --- a/framework/settings/settingsplugin.cpp +++ b/framework/settings/settingsplugin.cpp @@ -8,7 +8,7 @@ void SettingsPlugin::registerTypes (const char *uri) { - Q_ASSERT(uri == QLatin1String("org.kde.akonadi2.settings")); + Q_ASSERT(uri == QLatin1String("org.kde.sink.settings")); qmlRegisterType(); qmlRegisterType(uri, 1, 0, "Resources"); -- cgit v1.2.3