summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-02 00:19:01 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-02 00:31:49 +0100
commit1ef70a4c8c2bb9fd70d5bc73614b09177b6b970c (patch)
tree57503402891c5d02720a06b2bdebb26ba551d9d7
parent8cf790d6bc91e5e9c06651ffe4a193b625207f0d (diff)
downloadkube-1ef70a4c8c2bb9fd70d5bc73614b09177b6b970c.tar.gz
kube-1ef70a4c8c2bb9fd70d5bc73614b09177b6b970c.zip
Foldercontroller
-rw-r--r--components/mail/contents/ui/main.qml21
-rw-r--r--components/package/contents/ui/AccountSwitcher.qml11
-rw-r--r--framework/domain/CMakeLists.txt1
-rw-r--r--framework/domain/controller.h8
-rw-r--r--framework/domain/foldercontroller.cpp50
-rw-r--r--framework/domain/foldercontroller.h33
-rw-r--r--framework/domain/mailcontroller.h7
-rw-r--r--framework/domain/mailplugin.cpp2
8 files changed, 108 insertions, 25 deletions
diff --git a/components/mail/contents/ui/main.qml b/components/mail/contents/ui/main.qml
index 423d8f34..bf3b4954 100644
--- a/components/mail/contents/ui/main.qml
+++ b/components/mail/contents/ui/main.qml
@@ -49,23 +49,11 @@ Controls2.ApplicationWindow {
49 isDraft: mailListView.isDraft 49 isDraft: mailListView.isDraft
50 } 50 }
51 51
52 KubeAction.Context {
53 id: folderListContext
54 property variant folder
55 folder: folderListView.currentFolder
56 }
57
58 KubeAction.Action { 52 KubeAction.Action {
59 id: replyAction 53 id: replyAction
60 actionId: "org.kde.kube.actions.reply" 54 actionId: "org.kde.kube.actions.reply"
61 context: maillistcontext 55 context: maillistcontext
62 } 56 }
63
64 KubeAction.Action {
65 id: syncAction
66 actionId: "org.kde.kube.actions.synchronize"
67 context: folderListContext
68 }
69 //END Actions 57 //END Actions
70 58
71 //BEGIN ActionHandler 59 //BEGIN ActionHandler
@@ -103,12 +91,17 @@ Controls2.ApplicationWindow {
103 mail: mailListView.currentMail 91 mail: mailListView.currentMail
104 } 92 }
105 93
94 KubeFramework.FolderController {
95 id: folderController
96 folder: folderListView.currentFolder
97 }
98
106 99
107 //BEGIN Shortcuts 100 //BEGIN Shortcuts
108 Shortcut { 101 Shortcut {
109 sequence: StandardKey.Refresh 102 sequence: StandardKey.Refresh
110 onActivated: syncAction.execute() 103 onActivated: folderController.synchronizeAction.execute()
111 enabled: syncAction.ready 104 enabled: folderController.synchronizeAction.enabled
112 } 105 }
113 Shortcut { 106 Shortcut {
114 sequence: StandardKey.Delete 107 sequence: StandardKey.Delete
diff --git a/components/package/contents/ui/AccountSwitcher.qml b/components/package/contents/ui/AccountSwitcher.qml
index 78ec38cb..a29a290d 100644
--- a/components/package/contents/ui/AccountSwitcher.qml
+++ b/components/package/contents/ui/AccountSwitcher.qml
@@ -28,6 +28,10 @@ import org.kube.components 1.0 as KubeComponents
28Controls2.Button { 28Controls2.Button {
29 id: accountSwitcher 29 id: accountSwitcher
30 30
31 KubeFramework.FolderController {
32 id: folderController
33 }
34
31 Layout.fillWidth: true 35 Layout.fillWidth: true
32 height: parent.height 36 height: parent.height
33 37
@@ -87,7 +91,6 @@ Controls2.Button {
87 } 91 }
88 92
89 Controls2.Button { 93 Controls2.Button {
90
91 anchors { 94 anchors {
92 verticalCenter: parent.verticalCenter 95 verticalCenter: parent.verticalCenter
93 left: parent.left 96 left: parent.left
@@ -95,10 +98,10 @@ Controls2.Button {
95 98
96 //iconName: "view-refresh" 99 //iconName: "view-refresh"
97 text: "Sync" 100 text: "Sync"
98 enabled: syncAction.ready 101 enabled: folderController.synchronizeAction.enabled
99
100 onClicked: { 102 onClicked: {
101 syncAction.execute() 103 folderController.synchronizeAction.execute()
104 popup.close()
102 } 105 }
103 } 106 }
104 } 107 }
diff --git a/framework/domain/CMakeLists.txt b/framework/domain/CMakeLists.txt
index 8f343928..70a86d01 100644
--- a/framework/domain/CMakeLists.txt
+++ b/framework/domain/CMakeLists.txt
@@ -25,6 +25,7 @@ set(mailplugin_SRCS
25 controller.cpp 25 controller.cpp
26 outboxcontroller.cpp 26 outboxcontroller.cpp
27 mailcontroller.cpp 27 mailcontroller.cpp
28 foldercontroller.cpp
28) 29)
29find_package(KF5 REQUIRED COMPONENTS Package) 30find_package(KF5 REQUIRED COMPONENTS Package)
30 31
diff --git a/framework/domain/controller.h b/framework/domain/controller.h
index c152a588..77baa606 100644
--- a/framework/domain/controller.h
+++ b/framework/domain/controller.h
@@ -35,6 +35,14 @@
35 void clear##NAME() { setProperty(NAME::name, QVariant{}); } \ 35 void clear##NAME() { setProperty(NAME::name, QVariant{}); } \
36 TYPE get##NAME() const { return m##NAME; } \ 36 TYPE get##NAME() const { return m##NAME; } \
37 37
38
39#define KUBE_CONTROLLER_ACTION(NAME) \
40 Q_PROPERTY (Kube::ControllerAction* NAME##Action READ NAME##Action CONSTANT) \
41 private: QScopedPointer<Kube::ControllerAction> action_##NAME; \
42 public: Kube::ControllerAction* NAME##Action() const { Q_ASSERT(action_##NAME); return action_##NAME.data(); } \
43 private slots: void NAME(); \
44
45
38namespace Kube { 46namespace Kube {
39 47
40class ControllerAction : public QObject { 48class ControllerAction : public QObject {
diff --git a/framework/domain/foldercontroller.cpp b/framework/domain/foldercontroller.cpp
new file mode 100644
index 00000000..45fb86a6
--- /dev/null
+++ b/framework/domain/foldercontroller.cpp
@@ -0,0 +1,50 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#include "foldercontroller.h"
20
21#include <sink/store.h>
22#include <sink/log.h>
23
24SINK_DEBUG_AREA("foldercontroller");
25
26FolderController::FolderController()
27 : Kube::Controller(),
28 action_synchronize{new Kube::ControllerAction}
29{
30 QObject::connect(synchronizeAction(), &Kube::ControllerAction::triggered, this, &FolderController::synchronize);
31}
32
33void FolderController::synchronize()
34{
35 using namespace Sink;
36 using namespace Sink::ApplicationDomain;
37 auto job = [&] {
38 if (auto folder = getFolder()) {
39 SinkLog() << "Synchronizing folder " << folder->resourceInstanceIdentifier() << folder->identifier();
40 auto scope = SyncScope().resourceFilter(folder->resourceInstanceIdentifier()).filter<Mail::Folder>(QVariant::fromValue(folder->identifier()));
41 scope.setType<ApplicationDomain::Mail>();
42 return Store::synchronize(scope);
43 } else {
44 SinkLog() << "Synchronizing all";
45 return Store::synchronize(SyncScope());
46 }
47 }();
48 run(job);
49}
50
diff --git a/framework/domain/foldercontroller.h b/framework/domain/foldercontroller.h
new file mode 100644
index 00000000..24d6929c
--- /dev/null
+++ b/framework/domain/foldercontroller.h
@@ -0,0 +1,33 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#pragma once
20
21#include <QObject>
22#include "controller.h"
23#include "sink/applicationdomaintype.h"
24
25class FolderController : public Kube::Controller
26{
27 Q_OBJECT
28 KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Folder::Ptr, Folder, folder)
29 KUBE_CONTROLLER_ACTION(synchronize)
30
31public:
32 explicit FolderController();
33};
diff --git a/framework/domain/mailcontroller.h b/framework/domain/mailcontroller.h
index 66cb7b4b..6c41f433 100644
--- a/framework/domain/mailcontroller.h
+++ b/framework/domain/mailcontroller.h
@@ -22,13 +22,6 @@
22#include "controller.h" 22#include "controller.h"
23#include "sink/applicationdomaintype.h" 23#include "sink/applicationdomaintype.h"
24 24
25#define KUBE_CONTROLLER_ACTION(NAME) \
26 Q_PROPERTY (Kube::ControllerAction* NAME##Action READ NAME##Action CONSTANT) \
27 private: QScopedPointer<Kube::ControllerAction> action_##NAME; \
28 public: Kube::ControllerAction* NAME##Action() const { Q_ASSERT(action_##NAME); return action_##NAME.data(); } \
29 private slots: void NAME(); \
30
31
32class MailController : public Kube::Controller 25class MailController : public Kube::Controller
33{ 26{
34 Q_OBJECT 27 Q_OBJECT
diff --git a/framework/domain/mailplugin.cpp b/framework/domain/mailplugin.cpp
index eeb1aeb1..e63f3ad1 100644
--- a/framework/domain/mailplugin.cpp
+++ b/framework/domain/mailplugin.cpp
@@ -31,6 +31,7 @@
31#include "outboxmodel.h" 31#include "outboxmodel.h"
32#include "outboxcontroller.h" 32#include "outboxcontroller.h"
33#include "mailcontroller.h" 33#include "mailcontroller.h"
34#include "foldercontroller.h"
34 35
35#include <QtQml> 36#include <QtQml>
36 37
@@ -49,4 +50,5 @@ void MailPlugin::registerTypes (const char *uri)
49 qmlRegisterType<OutboxController>(uri, 1, 0, "OutboxController"); 50 qmlRegisterType<OutboxController>(uri, 1, 0, "OutboxController");
50 qmlRegisterType<OutboxModel>(uri, 1, 0, "OutboxModel"); 51 qmlRegisterType<OutboxModel>(uri, 1, 0, "OutboxModel");
51 qmlRegisterType<MailController>(uri, 1, 0, "MailController"); 52 qmlRegisterType<MailController>(uri, 1, 0, "MailController");
53 qmlRegisterType<FolderController>(uri, 1, 0, "FolderController");
52} 54}