diff options
author | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-01-05 17:46:56 +0100 |
---|---|---|
committer | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-01-05 17:46:56 +0100 |
commit | d0716c36927275fbfe0a0a9ab8e1726cbddb35c0 (patch) | |
tree | 9c23ee9fe73c2c28e2dd0ff76335b0da502b1f99 | |
parent | aba4edffe5a0e98ed92bb0177e89f6936c7eeb1f (diff) | |
download | kube-d0716c36927275fbfe0a0a9ab8e1726cbddb35c0.tar.gz kube-d0716c36927275fbfe0a0a9ab8e1726cbddb35c0.zip |
add remove, modify and load to maildircontroller
-rw-r--r-- | framework/accounts/maildircontroller.cpp | 59 | ||||
-rw-r--r-- | framework/accounts/maildircontroller.h | 7 |
2 files changed, 48 insertions, 18 deletions
diff --git a/framework/accounts/maildircontroller.cpp b/framework/accounts/maildircontroller.cpp index daafccb6..481d43d8 100644 --- a/framework/accounts/maildircontroller.cpp +++ b/framework/accounts/maildircontroller.cpp | |||
@@ -1,20 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net> | 2 | * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net> |
3 | 3 | * | |
4 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 6 | * the Free Software Foundation; either version 2 of the License, or |
7 | (at your option) any later version. | 7 | * (at your option) any later version. |
8 | 8 | * | |
9 | This program is distributed in the hope that it will be useful, | 9 | * This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. | 12 | * GNU General Public License for more details. |
13 | 13 | * | |
14 | You should have received a copy of the GNU General Public License along | 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., | 15 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include "maildircontroller.h" | 19 | #include "maildircontroller.h" |
20 | 20 | ||
@@ -44,12 +44,35 @@ void MaildirController::create() { | |||
44 | resource.setProperty("path", getPath().path()); | 44 | resource.setProperty("path", getPath().path()); |
45 | 45 | ||
46 | Store::create(resource).exec().waitForFinished(); | 46 | Store::create(resource).exec().waitForFinished(); |
47 | |||
48 | clear(); | ||
49 | } | 47 | } |
50 | 48 | ||
51 | void MaildirController::modify() { | 49 | void MaildirController::modify() { |
50 | SinkResource resource(m_resourceId); | ||
51 | resource.setProperty("path", getPath().path()); | ||
52 | Store::modify(resource).exec(); | ||
52 | } | 53 | } |
53 | 54 | ||
54 | void MaildirController::remove() { | 55 | void MaildirController::remove() { |
56 | SinkAccount account(m_accountId); | ||
57 | Store::remove(account).exec(); | ||
58 | |||
59 | clear(); | ||
60 | } | ||
61 | |||
62 | void MaildirController::load(const QByteArray &id) { | ||
63 | |||
64 | m_accountId = id; | ||
65 | clear(); | ||
66 | |||
67 | Store::fetchOne<SinkAccount>(Query().filter(m_accountId)) | ||
68 | .syncThen<void, SinkAccount>([this](const SinkAccount &account) { | ||
69 | setIcon(account.getIcon()); | ||
70 | setName(account.getName()); | ||
71 | }).exec(); | ||
72 | |||
73 | Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(m_accountId).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage)) | ||
74 | .syncThen<void, SinkResource>([this](const SinkResource &resource) { | ||
75 | m_resourceId = resource.identifier(); | ||
76 | setPath(resource.getProperty("path").toString()); | ||
77 | }).exec(); | ||
55 | } | 78 | } |
diff --git a/framework/accounts/maildircontroller.h b/framework/accounts/maildircontroller.h index da2a3a62..5965f118 100644 --- a/framework/accounts/maildircontroller.h +++ b/framework/accounts/maildircontroller.h | |||
@@ -41,4 +41,11 @@ class MaildirController : public Kube::Controller | |||
41 | 41 | ||
42 | public: | 42 | public: |
43 | explicit MaildirController(); | 43 | explicit MaildirController(); |
44 | |||
45 | public slots: | ||
46 | void load(const QByteArray &id); | ||
47 | |||
48 | private: | ||
49 | QByteArray m_accountId; | ||
50 | QByteArray m_resourceId; | ||
44 | }; | 51 | }; |