From aba4edffe5a0e98ed92bb0177e89f6936c7eeb1f Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Thu, 5 Jan 2017 15:58:47 +0100 Subject: maildir controller based on the new kubecontroller + adjusted create-maildir-ui --- framework/accounts/CMakeLists.txt | 1 + framework/accounts/accountsplugin.cpp | 2 ++ framework/accounts/maildircontroller.cpp | 55 ++++++++++++++++++++++++++++++++ framework/accounts/maildircontroller.h | 44 +++++++++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 framework/accounts/maildircontroller.cpp create mode 100644 framework/accounts/maildircontroller.h (limited to 'framework/accounts') diff --git a/framework/accounts/CMakeLists.txt b/framework/accounts/CMakeLists.txt index bccafd77..609b26d4 100644 --- a/framework/accounts/CMakeLists.txt +++ b/framework/accounts/CMakeLists.txt @@ -2,6 +2,7 @@ set(accountsplugin_SRCS accountsplugin.cpp accountfactory.cpp accountsmodel.cpp + maildircontroller.cpp ) add_library(accountsplugin SHARED ${accountsplugin_SRCS}) diff --git a/framework/accounts/accountsplugin.cpp b/framework/accounts/accountsplugin.cpp index e980d5f3..51316b52 100644 --- a/framework/accounts/accountsplugin.cpp +++ b/framework/accounts/accountsplugin.cpp @@ -20,6 +20,7 @@ #include "accountsmodel.h" #include "accountfactory.h" +#include "maildircontroller.h" #include @@ -28,4 +29,5 @@ void AccountsPlugin::registerTypes (const char *uri) Q_ASSERT(uri == QLatin1String("org.kube.framework.accounts")); qmlRegisterType(uri, 1, 0, "AccountFactory"); qmlRegisterType(uri, 1, 0, "AccountsModel"); + qmlRegisterType(uri, 1, 0, "MaildirController"); } diff --git a/framework/accounts/maildircontroller.cpp b/framework/accounts/maildircontroller.cpp new file mode 100644 index 00000000..daafccb6 --- /dev/null +++ b/framework/accounts/maildircontroller.cpp @@ -0,0 +1,55 @@ +/* + Copyright (C) 2017 Michael Bohlender, + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "maildircontroller.h" + +#include + +using namespace Sink; +using namespace Sink::ApplicationDomain; + +MaildirController::MaildirController() : Kube::Controller(), + action_create{new Kube::ControllerAction{this, &MaildirController::create}}, + action_modify{new Kube::ControllerAction{this, &MaildirController::modify}}, + action_remove{new Kube::ControllerAction{this, &MaildirController::remove}} +{ + +} + +void MaildirController::create() { + auto account = ApplicationDomainType::createEntity(); + account.setProperty("type", "maildir"); + account.setProperty("name", getName()); + //account.setProperty("icon", getIcon()); + Store::create(account).exec().waitForFinished(); + + auto resource = ApplicationDomainType::createEntity(); + resource.setResourceType("sink.maildir"); + resource.setAccount(account); + resource.setProperty("path", getPath().path()); + + Store::create(resource).exec().waitForFinished(); + + clear(); +} + +void MaildirController::modify() { +} + +void MaildirController::remove() { +} diff --git a/framework/accounts/maildircontroller.h b/framework/accounts/maildircontroller.h new file mode 100644 index 00000000..da2a3a62 --- /dev/null +++ b/framework/accounts/maildircontroller.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2017 Michael Bohlender, + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#pragma once + +#include +#include +#include +#include + +#include + +class MaildirController : public Kube::Controller +{ + Q_OBJECT + + //Interface properties + KUBE_CONTROLLER_PROPERTY(QString, Name, name) + KUBE_CONTROLLER_PROPERTY(QString, Icon, icon) + KUBE_CONTROLLER_PROPERTY(QUrl, Path, path) + + //Actions + KUBE_CONTROLLER_ACTION(create) + KUBE_CONTROLLER_ACTION(modify) + KUBE_CONTROLLER_ACTION(remove) + +public: + explicit MaildirController(); +}; -- cgit v1.2.3