diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-10 12:27:56 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-10 12:42:13 +0100 |
commit | a5f38b6541fbab0bdf31d5a804ec644af09a6b1b (patch) | |
tree | 9e5bec0ec777f09d4ebe1761feb5a4cfb5a5d240 | |
parent | 6d726bb10386b3d7f5481d41b735ec06cb2163ad (diff) | |
download | kube-a5f38b6541fbab0bdf31d5a804ec644af09a6b1b.tar.gz kube-a5f38b6541fbab0bdf31d5a804ec644af09a6b1b.zip |
The Inbox crusher as a first experimental view.
The extension itself is not really usable yet, but serves as a showcase.
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | framework/qml/ModelIndexRetriever.qml | 9 | ||||
-rw-r--r-- | framework/qmldir | 1 | ||||
-rw-r--r-- | framework/src/domain/maillistmodel.cpp | 40 | ||||
-rw-r--r-- | framework/src/domain/maillistmodel.h | 5 | ||||
-rw-r--r-- | views/CMakeLists.txt | 3 | ||||
-rw-r--r-- | views/inboxcrusher/metadata.json | 4 | ||||
-rw-r--r-- | views/inboxcrusher/qml/View.qml | 102 |
8 files changed, 164 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 48120389..7cc67c1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -10,6 +10,8 @@ cmake_policy(SET CMP0048 NEW) | |||
10 | cmake_policy(SET CMP0053 NEW) | 10 | cmake_policy(SET CMP0053 NEW) |
11 | cmake_policy(SET CMP0063 NEW) | 11 | cmake_policy(SET CMP0063 NEW) |
12 | 12 | ||
13 | option(EXPERIMENTAL_VIEWS "Install experimental views" OFF) | ||
14 | |||
13 | include(CPack) | 15 | include(CPack) |
14 | include(FeatureSummary) | 16 | include(FeatureSummary) |
15 | find_package(PkgConfig REQUIRED) | 17 | find_package(PkgConfig REQUIRED) |
diff --git a/framework/qml/ModelIndexRetriever.qml b/framework/qml/ModelIndexRetriever.qml index fa3fb64b..d01ceb71 100644 --- a/framework/qml/ModelIndexRetriever.qml +++ b/framework/qml/ModelIndexRetriever.qml | |||
@@ -21,11 +21,16 @@ import QtQuick 2.4 | |||
21 | Repeater { | 21 | Repeater { |
22 | id: root | 22 | id: root |
23 | property var currentData | 23 | property var currentData |
24 | property int currentIndex: 0 | ||
25 | onCurrentIndexChanged: { | ||
26 | currentData = itemAt(currentIndex).currentData | ||
27 | } | ||
24 | Item { | 28 | Item { |
25 | id: delegate | ||
26 | property var currentData: model | 29 | property var currentData: model |
27 | onCurrentDataChanged: { | 30 | onCurrentDataChanged: { |
28 | root.currentData = model | 31 | if (index == root.currentIndex) { |
32 | root.currentData = model | ||
33 | } | ||
29 | } | 34 | } |
30 | visible: false | 35 | visible: false |
31 | } | 36 | } |
diff --git a/framework/qmldir b/framework/qmldir index 748b77f7..b94abc28 100644 --- a/framework/qmldir +++ b/framework/qmldir | |||
@@ -4,6 +4,7 @@ ConversationView 1.0 ConversationView.qml | |||
4 | ConversationListView 1.0 ConversationListView.qml | 4 | ConversationListView 1.0 ConversationListView.qml |
5 | FolderListView 1.0 FolderListView.qml | 5 | FolderListView 1.0 FolderListView.qml |
6 | MailListView 1.0 MailListView.qml | 6 | MailListView 1.0 MailListView.qml |
7 | MailViewer 1.0 MailViewer.qml | ||
7 | InlineAccountSwitcher 1.0 InlineAccountSwitcher.qml | 8 | InlineAccountSwitcher 1.0 InlineAccountSwitcher.qml |
8 | NewAccountDialog 1.0 NewAccountDialog.qml | 9 | NewAccountDialog 1.0 NewAccountDialog.qml |
9 | EditAccount 1.0 EditAccount.qml | 10 | EditAccount 1.0 EditAccount.qml |
diff --git a/framework/src/domain/maillistmodel.cpp b/framework/src/domain/maillistmodel.cpp index 83fd37ff..4b70a10a 100644 --- a/framework/src/domain/maillistmodel.cpp +++ b/framework/src/domain/maillistmodel.cpp | |||
@@ -339,3 +339,43 @@ bool MailListModel::showDrafts() const | |||
339 | { | 339 | { |
340 | return false; | 340 | return false; |
341 | } | 341 | } |
342 | |||
343 | void MailListModel::setShowInbox(bool) | ||
344 | { | ||
345 | using namespace Sink::ApplicationDomain; | ||
346 | |||
347 | Sink::Query folderQuery{}; | ||
348 | folderQuery.containsFilter<Sink::ApplicationDomain::Folder::SpecialPurpose>(Sink::ApplicationDomain::SpecialPurpose::Mail::inbox); | ||
349 | folderQuery.request<Sink::ApplicationDomain::Folder::SpecialPurpose>(); | ||
350 | folderQuery.request<Sink::ApplicationDomain::Folder::Name>(); | ||
351 | |||
352 | Sink::Query query; | ||
353 | query.setFlags(Sink::Query::LiveQuery); | ||
354 | query.filter<Sink::ApplicationDomain::Mail::Folder>(folderQuery); | ||
355 | query.sort<Mail::Date>(); | ||
356 | query.request<Mail::Subject>(); | ||
357 | query.request<Mail::Sender>(); | ||
358 | query.request<Mail::To>(); | ||
359 | query.request<Mail::Cc>(); | ||
360 | query.request<Mail::Bcc>(); | ||
361 | query.request<Mail::Date>(); | ||
362 | query.request<Mail::Unread>(); | ||
363 | query.request<Mail::Important>(); | ||
364 | query.request<Mail::Draft>(); | ||
365 | query.request<Mail::Folder>(); | ||
366 | query.request<Mail::Sent>(); | ||
367 | query.request<Mail::Trash>(); | ||
368 | query.request<Mail::MimeMessage>(); | ||
369 | query.request<Mail::FullPayloadAvailable>(); | ||
370 | mFetchMails = true; | ||
371 | mFetchedMails.clear(); | ||
372 | qDebug() << "Running mail query for drafts: "; | ||
373 | //Latest mail at the top | ||
374 | sort(0, Qt::DescendingOrder); | ||
375 | runQuery(query); | ||
376 | } | ||
377 | |||
378 | bool MailListModel::showInbox() const | ||
379 | { | ||
380 | return false; | ||
381 | } | ||
diff --git a/framework/src/domain/maillistmodel.h b/framework/src/domain/maillistmodel.h index 5f593700..ce0399f7 100644 --- a/framework/src/domain/maillistmodel.h +++ b/framework/src/domain/maillistmodel.h | |||
@@ -32,6 +32,8 @@ class MailListModel : public QSortFilterProxyModel | |||
32 | Q_PROPERTY (QVariant parentFolder READ parentFolder WRITE setParentFolder) | 32 | Q_PROPERTY (QVariant parentFolder READ parentFolder WRITE setParentFolder) |
33 | Q_PROPERTY (QVariant mail READ mail WRITE setMail) | 33 | Q_PROPERTY (QVariant mail READ mail WRITE setMail) |
34 | Q_PROPERTY (bool showDrafts READ showDrafts WRITE setShowDrafts) | 34 | Q_PROPERTY (bool showDrafts READ showDrafts WRITE setShowDrafts) |
35 | Q_PROPERTY (bool showInbox READ showInbox WRITE setShowInbox) | ||
36 | |||
35 | Q_PROPERTY (QString filter READ filter WRITE setFilter) | 37 | Q_PROPERTY (QString filter READ filter WRITE setFilter) |
36 | Q_PROPERTY (bool isThreaded READ isThreaded NOTIFY isThreadedChanged) | 38 | Q_PROPERTY (bool isThreaded READ isThreaded NOTIFY isThreadedChanged) |
37 | 39 | ||
@@ -91,6 +93,9 @@ public: | |||
91 | void setShowDrafts(bool); | 93 | void setShowDrafts(bool); |
92 | bool showDrafts() const; | 94 | bool showDrafts() const; |
93 | 95 | ||
96 | void setShowInbox(bool); | ||
97 | bool showInbox() const; | ||
98 | |||
94 | signals: | 99 | signals: |
95 | void isThreadedChanged(); | 100 | void isThreadedChanged(); |
96 | 101 | ||
diff --git a/views/CMakeLists.txt b/views/CMakeLists.txt index 4004e310..5b19620d 100644 --- a/views/CMakeLists.txt +++ b/views/CMakeLists.txt | |||
@@ -9,3 +9,6 @@ install_view(conversation) | |||
9 | install_view(people) | 9 | install_view(people) |
10 | install_view(log) | 10 | install_view(log) |
11 | install_view(accounts) | 11 | install_view(accounts) |
12 | if (${EXPERIMENTAL_VIEWS}) | ||
13 | install_view(inboxcrusher) | ||
14 | endif() | ||
diff --git a/views/inboxcrusher/metadata.json b/views/inboxcrusher/metadata.json new file mode 100644 index 00000000..a5cdb8d5 --- /dev/null +++ b/views/inboxcrusher/metadata.json | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | "icon": "document-edit-inverted", | ||
3 | "tooltip": "Crush your inbox!" | ||
4 | } | ||
diff --git a/views/inboxcrusher/qml/View.qml b/views/inboxcrusher/qml/View.qml new file mode 100644 index 00000000..7059a8eb --- /dev/null +++ b/views/inboxcrusher/qml/View.qml | |||
@@ -0,0 +1,102 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | ||
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 | import QtQuick 2.4 | ||
20 | import QtQuick.Layouts 1.1 | ||
21 | import QtQuick.Controls 2.0 | ||
22 | import org.kube.framework 1.0 as Kube | ||
23 | |||
24 | FocusScope { | ||
25 | id: root | ||
26 | property variant currentMail: null | ||
27 | |||
28 | Keys.onRightPressed: { | ||
29 | modelIndexRetriever.currentIndex = modelIndexRetriever.currentIndex + 1 | ||
30 | } | ||
31 | Keys.onLeftPressed: { | ||
32 | if (modelIndexRetriever.currentIndex > 0) { | ||
33 | modelIndexRetriever.currentIndex = modelIndexRetriever.currentIndex - 1 | ||
34 | } | ||
35 | } | ||
36 | Kube.ModelIndexRetriever { | ||
37 | id: modelIndexRetriever | ||
38 | model: Kube.MailListModel { | ||
39 | showInbox: true | ||
40 | } | ||
41 | currentIndex: 0 | ||
42 | onCurrentDataChanged: { | ||
43 | root.currentMail = currentData.mail | ||
44 | } | ||
45 | } | ||
46 | Column { | ||
47 | anchors.fill: parent | ||
48 | spacing: Kube.Units.smallSpacing | ||
49 | Repeater { | ||
50 | anchors { | ||
51 | left: parent.left | ||
52 | right: parent.right | ||
53 | } | ||
54 | model: Kube.MailListModel { | ||
55 | mail: root.currentMail | ||
56 | } | ||
57 | Kube.MailViewer { | ||
58 | anchors { | ||
59 | left: parent.left | ||
60 | right: parent.right | ||
61 | } | ||
62 | message: model.mimeMessage | ||
63 | subject: model.subject | ||
64 | sender: model.sender | ||
65 | senderName: model.senderName | ||
66 | to: model.to | ||
67 | cc: model.cc | ||
68 | bcc: model.bcc | ||
69 | date: model.date | ||
70 | unread: model.unread | ||
71 | trash: model.trash | ||
72 | draft: model.draft | ||
73 | sent: model.sent | ||
74 | incomplete: model.incomplete | ||
75 | current: true | ||
76 | } | ||
77 | } | ||
78 | Row { | ||
79 | spacing: Kube.Units.smallSpacing | ||
80 | anchors { | ||
81 | horizontalCenter: parent.horizontalCenter | ||
82 | } | ||
83 | height: Kube.Units.gridUnit | ||
84 | Kube.Button { | ||
85 | focus: true | ||
86 | text: qsTr("Delete!") | ||
87 | onClicked: { | ||
88 | } | ||
89 | } | ||
90 | Kube.Button { | ||
91 | text: qsTr("Reply!") | ||
92 | onClicked: { | ||
93 | } | ||
94 | } | ||
95 | Kube.Button { | ||
96 | text: qsTr("Flag!") | ||
97 | onClicked: { | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | } | ||