From a5f38b6541fbab0bdf31d5a804ec644af09a6b1b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 10 Jan 2018 12:27:56 +0100 Subject: The Inbox crusher as a first experimental view. The extension itself is not really usable yet, but serves as a showcase. --- CMakeLists.txt | 2 + framework/qml/ModelIndexRetriever.qml | 9 ++- framework/qmldir | 1 + framework/src/domain/maillistmodel.cpp | 40 +++++++++++++ framework/src/domain/maillistmodel.h | 5 ++ views/CMakeLists.txt | 3 + views/inboxcrusher/metadata.json | 4 ++ views/inboxcrusher/qml/View.qml | 102 +++++++++++++++++++++++++++++++++ 8 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 views/inboxcrusher/metadata.json create mode 100644 views/inboxcrusher/qml/View.qml 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) cmake_policy(SET CMP0053 NEW) cmake_policy(SET CMP0063 NEW) +option(EXPERIMENTAL_VIEWS "Install experimental views" OFF) + include(CPack) include(FeatureSummary) 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 Repeater { id: root property var currentData + property int currentIndex: 0 + onCurrentIndexChanged: { + currentData = itemAt(currentIndex).currentData + } Item { - id: delegate property var currentData: model onCurrentDataChanged: { - root.currentData = model + if (index == root.currentIndex) { + root.currentData = model + } } visible: false } 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 ConversationListView 1.0 ConversationListView.qml FolderListView 1.0 FolderListView.qml MailListView 1.0 MailListView.qml +MailViewer 1.0 MailViewer.qml InlineAccountSwitcher 1.0 InlineAccountSwitcher.qml NewAccountDialog 1.0 NewAccountDialog.qml 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 { return false; } + +void MailListModel::setShowInbox(bool) +{ + using namespace Sink::ApplicationDomain; + + Sink::Query folderQuery{}; + folderQuery.containsFilter(Sink::ApplicationDomain::SpecialPurpose::Mail::inbox); + folderQuery.request(); + folderQuery.request(); + + Sink::Query query; + query.setFlags(Sink::Query::LiveQuery); + query.filter(folderQuery); + query.sort(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + query.request(); + mFetchMails = true; + mFetchedMails.clear(); + qDebug() << "Running mail query for drafts: "; + //Latest mail at the top + sort(0, Qt::DescendingOrder); + runQuery(query); +} + +bool MailListModel::showInbox() const +{ + return false; +} 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 Q_PROPERTY (QVariant parentFolder READ parentFolder WRITE setParentFolder) Q_PROPERTY (QVariant mail READ mail WRITE setMail) Q_PROPERTY (bool showDrafts READ showDrafts WRITE setShowDrafts) + Q_PROPERTY (bool showInbox READ showInbox WRITE setShowInbox) + Q_PROPERTY (QString filter READ filter WRITE setFilter) Q_PROPERTY (bool isThreaded READ isThreaded NOTIFY isThreadedChanged) @@ -91,6 +93,9 @@ public: void setShowDrafts(bool); bool showDrafts() const; + void setShowInbox(bool); + bool showInbox() const; + signals: void isThreadedChanged(); 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) install_view(people) install_view(log) install_view(accounts) +if (${EXPERIMENTAL_VIEWS}) + install_view(inboxcrusher) +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 @@ +{ + "icon": "document-edit-inverted", + "tooltip": "Crush your inbox!" +} 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 @@ +/* + * Copyright (C) 2017 Christian Mollekopf, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.4 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import org.kube.framework 1.0 as Kube + +FocusScope { + id: root + property variant currentMail: null + + Keys.onRightPressed: { + modelIndexRetriever.currentIndex = modelIndexRetriever.currentIndex + 1 + } + Keys.onLeftPressed: { + if (modelIndexRetriever.currentIndex > 0) { + modelIndexRetriever.currentIndex = modelIndexRetriever.currentIndex - 1 + } + } + Kube.ModelIndexRetriever { + id: modelIndexRetriever + model: Kube.MailListModel { + showInbox: true + } + currentIndex: 0 + onCurrentDataChanged: { + root.currentMail = currentData.mail + } + } + Column { + anchors.fill: parent + spacing: Kube.Units.smallSpacing + Repeater { + anchors { + left: parent.left + right: parent.right + } + model: Kube.MailListModel { + mail: root.currentMail + } + Kube.MailViewer { + anchors { + left: parent.left + right: parent.right + } + message: model.mimeMessage + subject: model.subject + sender: model.sender + senderName: model.senderName + to: model.to + cc: model.cc + bcc: model.bcc + date: model.date + unread: model.unread + trash: model.trash + draft: model.draft + sent: model.sent + incomplete: model.incomplete + current: true + } + } + Row { + spacing: Kube.Units.smallSpacing + anchors { + horizontalCenter: parent.horizontalCenter + } + height: Kube.Units.gridUnit + Kube.Button { + focus: true + text: qsTr("Delete!") + onClicked: { + } + } + Kube.Button { + text: qsTr("Reply!") + onClicked: { + } + } + Kube.Button { + text: qsTr("Flag!") + onClicked: { + } + } + } + } +} -- cgit v1.2.3