summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--accounts/maildir/package/contents/ui/MaildirAccountSettings.qml28
-rw-r--r--components/package/contents/ui/FolderListView.qml202
-rw-r--r--components/package/contents/ui/Settings.qml2
-rw-r--r--framework/domain/CMakeLists.txt1
-rw-r--r--framework/domain/accountsmodel.cpp65
-rw-r--r--framework/domain/accountsmodel.h48
-rw-r--r--framework/domain/folderlistmodel.cpp34
-rw-r--r--framework/domain/folderlistmodel.h10
-rw-r--r--framework/domain/mailplugin.cpp2
9 files changed, 338 insertions, 54 deletions
diff --git a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml
index 61828f34..3b2dbd35 100644
--- a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml
+++ b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml
@@ -28,7 +28,8 @@ import org.kube.accounts.maildir 1.0 as MaildirAccount
28Rectangle { 28Rectangle {
29 id: root 29 id: root
30 property string accountId 30 property string accountId
31 property string accountName: "Maildir" 31 property string accountName
32 property string icon
32 33
33 color: ColorPalette.background 34 color: ColorPalette.background
34 35
@@ -40,7 +41,22 @@ Rectangle {
40 Text { 41 Text {
41 Layout.columnSpan: 2 42 Layout.columnSpan: 2
42 Layout.fillWidth: true 43 Layout.fillWidth: true
43 text: "Account: " + accountName 44 text: "General:"
45 }
46
47 Label { text: "Account Name" }
48 TextField {
49 id: name
50 placeholderText: accountName
51 Layout.fillWidth: true
52 text: accountSettings.name
53 onTextChanged: { accountSettings.name = text; }
54 }
55
56 Text {
57 Layout.columnSpan: 2
58 Layout.fillWidth: true
59 text: "Maildir:"
44 } 60 }
45 61
46 Label { text: "Path" } 62 Label { text: "Path" }
@@ -133,11 +149,19 @@ Rectangle {
133 property string password; 149 property string password;
134 } 150 }
135 151
152 KubeSettings.Settings {
153 id: accountSettings
154 identifier: "account." + accountId
155 property string name;
156 property string icon: root.icon;
157 }
158
136 Button { 159 Button {
137 text: "Save" 160 text: "Save"
138 onClicked: { 161 onClicked: {
139 transportSettings.save(); 162 transportSettings.save();
140 maildirSettings.save(); 163 maildirSettings.save();
164 accountSettings.save();
141 } 165 }
142 } 166 }
143 Button { 167 Button {
diff --git a/components/package/contents/ui/FolderListView.qml b/components/package/contents/ui/FolderListView.qml
index fafc1623..f660846d 100644
--- a/components/package/contents/ui/FolderListView.qml
+++ b/components/package/contents/ui/FolderListView.qml
@@ -46,72 +46,174 @@ Item {
46 } 46 }
47 } 47 }
48 48
49 TreeView { 49 Rectangle {
50 id: treeView
51 anchors { 50 anchors {
52 top: searchBox.bottom 51 top: searchBox.bottom
53 left: parent.left 52 left: parent.left
54 right: parent.right 53 right: parent.right
55 bottom: parent.bottom 54 bottom: parent.bottom
56 } 55 }
57 TableViewColumn { 56 color: "white"
58 title: "Name" 57 ScrollView {
59 role: "name" 58 anchors.fill: parent
60 width: treeView.width - 5 59 ListView {
61 } 60 id: listView
62 model: KubeFramework.FolderListModel { id: folderListModel } 61 anchors.fill: parent
63 onCurrentIndexChanged: { 62 delegate: accountDelegate
64 model.fetchMore(currentIndex) 63 model: KubeFramework.AccountsModel { id: accountsModel }
65 root.currentFolder = model.data(currentIndex, KubeFramework.FolderListModel.DomainObject)
66 }
67 backgroundVisible: false
68 headerVisible: false
69 style: TreeViewStyle {
70 activateItemOnSingleClick: true
71 rowDelegate: Rectangle {
72 height: Unit.size * 10
73 color: "transparent"
74 } 64 }
75 itemDelegate: Rectangle { 65 }
76 radius: 5 66 }
77 border.width: 1 67
78 border.color: "lightgrey" 68 Component {
79 color: styleData.selected ? colorPalette.highlight : colorPalette.button 69 id: accountDelegate
70
71 Item {
72 id: wrapper
73
74 property var accountId: model.accountId
75
76 width: listView.width
77 height: 30
78
79 Rectangle {
80 id: headerView
81 anchors.left: parent.left
82 anchors.right: parent.right
83 anchors.top: parent.top
84
85 height: 30
86
87 color: "#333"
88 border.color: Qt.lighter(color, 1.2)
80 PlasmaCore.IconItem { 89 PlasmaCore.IconItem {
81 id: iconItem 90 id: iconItem
82 anchors { 91 anchors.left: parent.left
83 verticalCenter: parent.verticalCenter 92 anchors.verticalCenter: parent.verticalCenter
84 left: parent.left 93 anchors.leftMargin: 4
85 leftMargin: Unit.size * 3
86 }
87 source: model.icon 94 source: model.icon
88 } 95 }
89 Label { 96 Text {
90 anchors { 97 anchors.left: iconItem.right
91 verticalCenter: parent.verticalCenter 98 anchors.verticalCenter: parent.verticalCenter
92 left: iconItem.right 99 anchors.leftMargin: 4
93 leftMargin: Unit.size * 3 100
101 font.pixelSize: parent.height-4
102 color: '#fff'
103
104 text: name
105 }
106 }
107
108 MouseArea {
109 anchors.fill: parent
110 onClicked: {
111 if (parent.state != "expanded") {
112 parent.state = "expanded";
113 } else {
114 parent.state = ""
94 } 115 }
95 renderType: Text.NativeRendering
96 text: styleData.value
97 font.pixelSize: 16
98 font.bold: true
99 color: styleData.selected ? colorPalette.highlightedText : colorPalette.text
100 } 116 }
101 } 117 }
102 branchDelegate: Item { 118
103 width: 16 119 Item {
104 height: 16 120 id: folderView
105 Text { 121
106 visible: styleData.column === 0 && styleData.hasChildren 122 anchors.top: headerView.bottom
107 text: styleData.isExpanded ? "\u25bc" : "\u25b6" 123 anchors.left: parent.left
108 color: !control.activeFocus || styleData.selected ? styleData.textColor : "#666" 124 anchors.right: parent.right
109 font.pointSize: 10 125 anchors.bottom: parent.bottom
110 renderType: Text.NativeRendering 126
111 anchors.centerIn: parent 127 opacity: 0
112 anchors.verticalCenterOffset: styleData.isExpanded ? 2 : 0 128 visible: false
129
130 Rectangle {
131 anchors.fill: parent
132 TreeView {
133 anchors.fill: parent
134 id: treeView
135 TableViewColumn {
136 title: "Name"
137 role: "name"
138 width: treeView.width - 5
139 }
140 model: KubeFramework.FolderListModel { id: folderListModel; accountId: wrapper.accountId }
141 onCurrentIndexChanged: {
142 model.fetchMore(currentIndex)
143 root.currentFolder = model.data(currentIndex, KubeFramework.FolderListModel.DomainObject)
144 }
145 backgroundVisible: false
146 headerVisible: false
147 style: TreeViewStyle {
148 activateItemOnSingleClick: true
149 rowDelegate: Rectangle {
150 height: Unit.size * 10
151 color: "transparent"
152 }
153 itemDelegate: Rectangle {
154 radius: 5
155 border.width: 1
156 border.color: "lightgrey"
157 color: styleData.selected ? colorPalette.highlight : colorPalette.button
158 PlasmaCore.IconItem {
159 id: iconItem
160 anchors {
161 verticalCenter: parent.verticalCenter
162 left: parent.left
163 leftMargin: Unit.size * 3
164 }
165 source: model.icon
166 }
167 Label {
168 anchors {
169 verticalCenter: parent.verticalCenter
170 left: iconItem.right
171 leftMargin: Unit.size * 3
172 }
173 renderType: Text.NativeRendering
174 text: styleData.value
175 font.pixelSize: 16
176 font.bold: true
177 color: styleData.selected ? colorPalette.highlightedText : colorPalette.text
178 }
179 }
180 branchDelegate: Item {
181 width: 16
182 height: 16
183 Text {
184 visible: styleData.column === 0 && styleData.hasChildren
185 text: styleData.isExpanded ? "\u25bc" : "\u25b6"
186 color: !control.activeFocus || styleData.selected ? styleData.textColor : "#666"
187 font.pointSize: 10
188 renderType: Text.NativeRendering
189 anchors.centerIn: parent
190 anchors.verticalCenterOffset: styleData.isExpanded ? 2 : 0
191 }
192 }
193 }
194 }
113 } 195 }
114 } 196 }
197
198 states: [
199 State {
200 name: "expanded"
201
202 PropertyChanges { target: wrapper; height: listView.height - accountsModel.rowCount() * 30 }
203 PropertyChanges { target: folderView; opacity: 1; visible: true }
204 PropertyChanges { target: wrapper.ListView.view; contentY: wrapper.y; interactive: false }
205 }
206 ]
207
208 transitions: [
209 Transition {
210 NumberAnimation {
211 duration: 150;
212 properties: "height,width,anchors.rightMargin,anchors.topMargin,opacity,contentY"
213 }
214 }
215 ]
115 } 216 }
116 } 217 }
218
117} 219}
diff --git a/components/package/contents/ui/Settings.qml b/components/package/contents/ui/Settings.qml
index d96ccfb0..c17109a0 100644
--- a/components/package/contents/ui/Settings.qml
+++ b/components/package/contents/ui/Settings.qml
@@ -102,6 +102,8 @@ Rectangle {
102 console.warn("Loading module is ", accountFactory.accountId); 102 console.warn("Loading module is ", accountFactory.accountId);
103 accountDetails.source = accountFactory.uiPath 103 accountDetails.source = accountFactory.uiPath
104 accountDetails.item.accountId = accountFactory.accountId 104 accountDetails.item.accountId = accountFactory.accountId
105 accountDetails.item.icon = accountFactory.icon
106 accountDetails.item.accountName = accountFactory.name
105 listView.currentIndex = model.index 107 listView.currentIndex = model.index
106 } 108 }
107 } 109 }
diff --git a/framework/domain/CMakeLists.txt b/framework/domain/CMakeLists.txt
index 7560219f..435db5cf 100644
--- a/framework/domain/CMakeLists.txt
+++ b/framework/domain/CMakeLists.txt
@@ -14,6 +14,7 @@ set(mailplugin_SRCS
14 retriever.cpp 14 retriever.cpp
15 accountfactory.cpp 15 accountfactory.cpp
16 accountscontroller.cpp 16 accountscontroller.cpp
17 accountsmodel.cpp
17) 18)
18add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data") 19add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data")
19 20
diff --git a/framework/domain/accountsmodel.cpp b/framework/domain/accountsmodel.cpp
new file mode 100644
index 00000000..96306464
--- /dev/null
+++ b/framework/domain/accountsmodel.cpp
@@ -0,0 +1,65 @@
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 "accountsmodel.h"
20
21#include <settings/settings.h>
22
23#include <QVariant>
24
25AccountsModel::AccountsModel(QObject *parent) : QAbstractListModel()
26{
27 Kube::Settings settings("accounts");
28 mAccounts = settings.property("accounts").toStringList();
29}
30
31AccountsModel::~AccountsModel()
32{
33
34}
35
36QHash< int, QByteArray > AccountsModel::roleNames() const
37{
38 QHash<int, QByteArray> roles;
39
40 roles[Name] = "name";
41 roles[Icon] = "icon";
42 roles[AccountId] = "accountId";
43
44 return roles;
45}
46
47QVariant AccountsModel::data(const QModelIndex &idx, int role) const
48{
49 const auto identifier = mAccounts.at(idx.row());
50 Kube::Account accountSettings(identifier.toLatin1());
51 switch (role) {
52 case Name:
53 return accountSettings.property("name").toString();
54 case Icon:
55 return accountSettings.property("icon").toString();
56 case AccountId:
57 return identifier;
58 }
59 return QVariant();
60}
61
62int AccountsModel::rowCount(const QModelIndex &idx) const
63{
64 return mAccounts.size();
65}
diff --git a/framework/domain/accountsmodel.h b/framework/domain/accountsmodel.h
new file mode 100644
index 00000000..a50c2e4a
--- /dev/null
+++ b/framework/domain/accountsmodel.h
@@ -0,0 +1,48 @@
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
20#pragma once
21
22#include <QObject>
23#include <QAbstractListModel>
24#include <QSharedPointer>
25#include <QStringList>
26
27class AccountsModel : public QAbstractListModel
28{
29 Q_OBJECT
30
31public:
32 AccountsModel(QObject *parent = Q_NULLPTR);
33 ~AccountsModel();
34
35 int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
36 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
37
38 enum Roles {
39 Name = Qt::UserRole + 1,
40 Icon,
41 AccountId
42 };
43 Q_ENUMS(Roles)
44
45 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
46private:
47 QStringList mAccounts;
48};
diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp
index ce6fb4fd..f212e336 100644
--- a/framework/domain/folderlistmodel.cpp
+++ b/framework/domain/folderlistmodel.cpp
@@ -20,6 +20,7 @@
20 20
21#include "folderlistmodel.h" 21#include "folderlistmodel.h"
22#include <sink/store.h> 22#include <sink/store.h>
23#include <settings/settings.h>
23 24
24FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() 25FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel()
25{ 26{
@@ -27,8 +28,7 @@ FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel()
27 query.liveQuery = true; 28 query.liveQuery = true;
28 query.requestedProperties << "name" << "icon" << "parent"; 29 query.requestedProperties << "name" << "icon" << "parent";
29 query.parentProperty = "parent"; 30 query.parentProperty = "parent";
30 mModel = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); 31 runQuery(query);
31 setSourceModel(mModel.data());
32} 32}
33 33
34FolderListModel::~FolderListModel() 34FolderListModel::~FolderListModel()
@@ -63,3 +63,33 @@ QVariant FolderListModel::data(const QModelIndex &idx, int role) const
63 } 63 }
64 return QIdentityProxyModel::data(idx, role); 64 return QIdentityProxyModel::data(idx, role);
65} 65}
66
67void FolderListModel::runQuery(const Sink::Query &query)
68{
69 mModel = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query);
70 setSourceModel(mModel.data());
71}
72
73void FolderListModel::setAccountId(const QVariant &accountId)
74{
75 const auto account = accountId.toString();
76 Kube::Account accountSettings(account.toUtf8());
77 //FIXME maildirResource is obviously not good. We need a way to find resources that belong to the account and provide folders.
78 const auto resourceId = accountSettings.property("maildirResource").toString();
79 qDebug() << "Running query for account " << account;
80 qDebug() << "Found resources " << resourceId;
81
82 Sink::Query query;
83 query.liveQuery = true;
84 query.requestedProperties << "name" << "icon" << "parent";
85 query.parentProperty = "parent";
86 query.resources << resourceId.toUtf8();
87
88 runQuery(query);
89}
90
91QVariant FolderListModel::accountId() const
92{
93 return QVariant();
94}
95
diff --git a/framework/domain/folderlistmodel.h b/framework/domain/folderlistmodel.h
index 7844e59a..d30393db 100644
--- a/framework/domain/folderlistmodel.h
+++ b/framework/domain/folderlistmodel.h
@@ -25,10 +25,16 @@
25#include <QSharedPointer> 25#include <QSharedPointer>
26#include <QStringList> 26#include <QStringList>
27 27
28namespace Sink {
29 class Query;
30}
31
28class FolderListModel : public QIdentityProxyModel 32class FolderListModel : public QIdentityProxyModel
29{ 33{
30 Q_OBJECT 34 Q_OBJECT
31 35
36 Q_PROPERTY (QVariant accountId READ accountId WRITE setAccountId)
37
32public: 38public:
33 FolderListModel(QObject *parent = Q_NULLPTR); 39 FolderListModel(QObject *parent = Q_NULLPTR);
34 ~FolderListModel(); 40 ~FolderListModel();
@@ -45,6 +51,10 @@ public:
45 51
46 QHash<int, QByteArray> roleNames() const; 52 QHash<int, QByteArray> roleNames() const;
47 53
54 void setAccountId(const QVariant &accountId);
55 QVariant accountId() const;
56
48private: 57private:
58 void runQuery(const Sink::Query &query);
49 QSharedPointer<QAbstractItemModel> mModel; 59 QSharedPointer<QAbstractItemModel> mModel;
50}; 60};
diff --git a/framework/domain/mailplugin.cpp b/framework/domain/mailplugin.cpp
index c19818ec..9f06fd5f 100644
--- a/framework/domain/mailplugin.cpp
+++ b/framework/domain/mailplugin.cpp
@@ -27,6 +27,7 @@
27#include "retriever.h" 27#include "retriever.h"
28#include "accountfactory.h" 28#include "accountfactory.h"
29#include "accountscontroller.h" 29#include "accountscontroller.h"
30#include "accountsmodel.h"
30 31
31#include <QtQml> 32#include <QtQml>
32 33
@@ -41,4 +42,5 @@ void MailPlugin::registerTypes (const char *uri)
41 qmlRegisterType<Retriever>(uri, 1, 0, "Retriever"); 42 qmlRegisterType<Retriever>(uri, 1, 0, "Retriever");
42 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory"); 43 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory");
43 qmlRegisterType<AccountsController>(uri, 1, 0, "AccountsController"); 44 qmlRegisterType<AccountsController>(uri, 1, 0, "AccountsController");
45 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel");
44} 46}