summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/accounts/CreateMaildir.qml19
-rw-r--r--framework/accounts/CMakeLists.txt1
-rw-r--r--framework/accounts/accountsplugin.cpp2
-rw-r--r--framework/accounts/maildircontroller.cpp55
-rw-r--r--framework/accounts/maildircontroller.h44
5 files changed, 113 insertions, 8 deletions
diff --git a/components/accounts/CreateMaildir.qml b/components/accounts/CreateMaildir.qml
index e5d10fd4..99bde452 100644
--- a/components/accounts/CreateMaildir.qml
+++ b/components/accounts/CreateMaildir.qml
@@ -23,14 +23,14 @@ import QtQuick.Controls 2.0 as Controls2
23import org.kde.kirigami 1.0 as Kirigami 23import org.kde.kirigami 1.0 as Kirigami
24import QtQuick.Dialogs 1.0 as Dialogs 24import QtQuick.Dialogs 1.0 as Dialogs
25 25
26import org.kube.accounts.maildir 1.0 as MaildirAccount 26import org.kube.framework.accounts 1.0 as KubeAccounts
27 27
28Item { 28Item {
29 id: root 29 id: root
30 30
31 //Controller 31 //Controller
32 MaildirAccount.MaildirController { 32 KubeAccounts.MaildirController {
33 id: accountsController 33 id: account
34 } 34 }
35 35
36 //Navigation 36 //Navigation
@@ -99,10 +99,10 @@ Item {
99 id: title 99 id: title
100 Layout.fillWidth: true 100 Layout.fillWidth: true
101 101
102 text: accountsController.name 102 text: account.name
103 103
104 onTextChanged: { 104 onTextChanged: {
105 accountsController.name = text 105 account.name = text
106 } 106 }
107 } 107 }
108 108
@@ -119,7 +119,7 @@ Item {
119 119
120 enabled: false 120 enabled: false
121 121
122 text: accountsController.path 122 text: account.path
123 } 123 }
124 124
125 Controls.Button { 125 Controls.Button {
@@ -140,7 +140,7 @@ Item {
140 selectFolder: true 140 selectFolder: true
141 141
142 onAccepted: { 142 onAccepted: {
143 accountsController.path = fileDialog.fileUrl 143 account.path = fileDialog.fileUrl
144 } 144 }
145 } 145 }
146 } 146 }
@@ -175,6 +175,7 @@ Item {
175 text: "Discard" 175 text: "Discard"
176 176
177 onClicked: { 177 onClicked: {
178 //account.clear()
178 popup.close() 179 popup.close()
179 } 180 }
180 } 181 }
@@ -186,8 +187,10 @@ Item {
186 187
187 text: "Save" 188 text: "Save"
188 189
190 enabled: account.createAction.enabled
191
189 onClicked: { 192 onClicked: {
190 accountsController.createAccount() 193 account.createAction.execute()
191 popup.close() 194 popup.close()
192 } 195 }
193 } 196 }
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
2 accountsplugin.cpp 2 accountsplugin.cpp
3 accountfactory.cpp 3 accountfactory.cpp
4 accountsmodel.cpp 4 accountsmodel.cpp
5 maildircontroller.cpp
5) 6)
6 7
7add_library(accountsplugin SHARED ${accountsplugin_SRCS}) 8add_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 @@
20 20
21#include "accountsmodel.h" 21#include "accountsmodel.h"
22#include "accountfactory.h" 22#include "accountfactory.h"
23#include "maildircontroller.h"
23 24
24#include <QtQml> 25#include <QtQml>
25 26
@@ -28,4 +29,5 @@ void AccountsPlugin::registerTypes (const char *uri)
28 Q_ASSERT(uri == QLatin1String("org.kube.framework.accounts")); 29 Q_ASSERT(uri == QLatin1String("org.kube.framework.accounts"));
29 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory"); 30 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory");
30 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel"); 31 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel");
32 qmlRegisterType<MaildirController>(uri, 1, 0, "MaildirController");
31} 33}
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 @@
1/*
2 Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17*/
18
19#include "maildircontroller.h"
20
21#include <sink/store.h>
22
23using namespace Sink;
24using namespace Sink::ApplicationDomain;
25
26MaildirController::MaildirController() : Kube::Controller(),
27 action_create{new Kube::ControllerAction{this, &MaildirController::create}},
28 action_modify{new Kube::ControllerAction{this, &MaildirController::modify}},
29 action_remove{new Kube::ControllerAction{this, &MaildirController::remove}}
30{
31
32}
33
34void MaildirController::create() {
35 auto account = ApplicationDomainType::createEntity<SinkAccount>();
36 account.setProperty("type", "maildir");
37 account.setProperty("name", getName());
38 //account.setProperty("icon", getIcon());
39 Store::create(account).exec().waitForFinished();
40
41 auto resource = ApplicationDomainType::createEntity<SinkResource>();
42 resource.setResourceType("sink.maildir");
43 resource.setAccount(account);
44 resource.setProperty("path", getPath().path());
45
46 Store::create(resource).exec().waitForFinished();
47
48 clear();
49}
50
51void MaildirController::modify() {
52}
53
54void MaildirController::remove() {
55}
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 @@
1/*
2 Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17*/
18
19#pragma once
20
21#include <QObject>
22#include <QString>
23#include <QUrl>
24#include <QByteArray>
25
26#include <domain/controller.h>
27
28class MaildirController : public Kube::Controller
29{
30 Q_OBJECT
31
32 //Interface properties
33 KUBE_CONTROLLER_PROPERTY(QString, Name, name)
34 KUBE_CONTROLLER_PROPERTY(QString, Icon, icon)
35 KUBE_CONTROLLER_PROPERTY(QUrl, Path, path)
36
37 //Actions
38 KUBE_CONTROLLER_ACTION(create)
39 KUBE_CONTROLLER_ACTION(modify)
40 KUBE_CONTROLLER_ACTION(remove)
41
42public:
43 explicit MaildirController();
44};