From e0604f713649186507db37be54cc3aaadcd99663 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 23 Jul 2018 12:16:08 +0200 Subject: Search view updates --- components/kube/qml/Kube.qml | 2 +- framework/qml/ConversationView.qml | 6 +- framework/src/domain/maillistmodel.cpp | 42 +++++++++ framework/src/domain/maillistmodel.h | 4 + views/conversation/qml/View.qml | 5 +- views/search/qml/View.qml | 163 ++++++++++++++++++++++++--------- 6 files changed, 172 insertions(+), 50 deletions(-) diff --git a/components/kube/qml/Kube.qml b/components/kube/qml/Kube.qml index 8cbe8691..afc7c83f 100644 --- a/components/kube/qml/Kube.qml +++ b/components/kube/qml/Kube.qml @@ -161,7 +161,7 @@ Controls2.ApplicationWindow { model: Kube.ExtensionModel { id: extensionModel extensionPoint: "views" - sortOrder: ["composer", "conversation", "people"] + sortOrder: ["search", "composer", "conversation", "people"] } Kube.IconButton { id: button diff --git a/framework/qml/ConversationView.qml b/framework/qml/ConversationView.qml index e1e93b66..b052caa2 100644 --- a/framework/qml/ConversationView.qml +++ b/framework/qml/ConversationView.qml @@ -28,7 +28,7 @@ import QtQml 2.2 as QtQml FocusScope { id: root - property variant mail; + property alias model: listView.model property bool hideTrash: true; property bool hideNonTrash: false; property string searchString: "" @@ -83,10 +83,6 @@ FocusScope { //Shrink the listview if the content doesn't fill the full height, so the email appears on top instead of on the bottom. height: Math.min(contentHeight, parent.height) - model: Kube.MailListModel { - mail: root.mail - } - Keys.onPressed: { //Not implemented as a shortcut because we want it only to apply if we have the focus if (event.text == "d") { diff --git a/framework/src/domain/maillistmodel.cpp b/framework/src/domain/maillistmodel.cpp index 152b4f23..d29e851e 100644 --- a/framework/src/domain/maillistmodel.cpp +++ b/framework/src/domain/maillistmodel.cpp @@ -328,6 +328,48 @@ QVariant MailListModel::mail() const return QVariant(); } +void MailListModel::setSingleMail(const QVariant &variant) +{ + using namespace Sink::ApplicationDomain; + auto mail = variant.value(); + if (!mail) { + mCurrentQueryItem.clear(); + setSourceModel(nullptr); + return; + } + if (mCurrentQueryItem == mail->identifier()) { + return; + } + mCurrentQueryItem = mail->identifier(); + Sink::Query query{*mail}; + query.setFlags(Sink::Query::LiveQuery | Sink::Query::UpdateStatus); + 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: " << mail->resourceInstanceIdentifier() << mail->identifier(); + //Latest mail at the bottom + sort(0, Qt::AscendingOrder); + runQuery(query); +} + +QVariant MailListModel::singleMail() const +{ + return {}; +} + void MailListModel::setShowDrafts(bool) { diff --git a/framework/src/domain/maillistmodel.h b/framework/src/domain/maillistmodel.h index 4af13dbd..052e4541 100644 --- a/framework/src/domain/maillistmodel.h +++ b/framework/src/domain/maillistmodel.h @@ -31,6 +31,7 @@ class KUBE_EXPORT MailListModel : public QSortFilterProxyModel Q_OBJECT Q_PROPERTY (QVariant parentFolder READ parentFolder WRITE setParentFolder) Q_PROPERTY (QVariant mail READ mail WRITE setMail) + Q_PROPERTY (QVariant singleMail READ singleMail WRITE setSingleMail) Q_PROPERTY (bool showDrafts READ showDrafts WRITE setShowDrafts) Q_PROPERTY (bool showInbox READ showInbox WRITE setShowInbox) Q_PROPERTY (QString entityId READ entityId WRITE setEntityId) @@ -85,6 +86,9 @@ public: void setMail(const QVariant &mail); QVariant mail() const; + void setSingleMail(const QVariant &mail); + QVariant singleMail() const; + void setFilter(const QString &mail); QString filter() const; diff --git a/views/conversation/qml/View.qml b/views/conversation/qml/View.qml index 7463d5e2..1ca0348f 100644 --- a/views/conversation/qml/View.qml +++ b/views/conversation/qml/View.qml @@ -200,10 +200,13 @@ Kube.View { Layout.fillWidth: true Layout.fillHeight: parent.height activeFocusOnTab: true + model: Kube.MailListModel { + id: mailViewModel + } Kube.Listener { filter: Kube.Messages.mailSelection onMessageReceived: { - mailView.mail = message.mail + mailViewModel.mail = message.mail } } diff --git a/views/search/qml/View.qml b/views/search/qml/View.qml index 74e6cf5b..18098f30 100644 --- a/views/search/qml/View.qml +++ b/views/search/qml/View.qml @@ -20,64 +20,141 @@ import QtQuick 2.7 import QtQuick.Controls 1.3 as Controls1 -import QtQuick.Controls 2.0 as Controls2 +import QtQuick.Controls 2 import QtQuick.Layouts 1.1 import org.kube.framework 1.0 as Kube -FocusScope { - Controls1.SplitView { - anchors.fill: parent - ColumnLayout { - width: Kube.Units.gridUnit * 18 - Layout.minimumWidth: Kube.Units.gridUnit * 10 - Rectangle { - id: filterField - Layout.fillWidth: true - height: Kube.Units.gridUnit * 2 - color: Kube.Colors.darkBackgroundColor +Kube.View { + id: root + property string searchTerm: "" - function clearSearch() { - find.text = "" - mailListView.filter = "" - } - RowLayout { - anchors { - verticalCenter: parent.verticalCenter - } + Rectangle { + id: overlay + + parent: ApplicationWindow.overlay + height: app.height + width: app.width - app.sidebarWidth + x: app.sidebarWidth + y: 0 + + visible: root.searchTerm == "" + + Row { + anchors.centerIn: parent + + spacing: Kube.Units.smallSpacing + + Kube.TextField { + id: searchField + anchors.verticalCenter: parent.verticalCenter + width: Kube.Units.gridUnit * 30 + focus: true + text: root.searchTerm + Keys.onEscapePressed: root.searchTerm = "" + onAccepted: root.searchTerm = text + } - width: parent.width - Kube.Units.smallSpacing - spacing: 0 + Kube.PositiveButton { + anchors.verticalCenter: parent.verticalCenter + text: qsTr("Search") + enabled: searchField.text != "" + onClicked: root.searchTerm = searchField.text + } + } + } - Kube.IconButton { - iconName: Kube.Icons.remove - onClicked: filterField.clearSearch() + RowLayout { + spacing: 0 + Rectangle { + Layout.fillHeight: true + width: Kube.Units.gridUnit * 10 + color: Kube.Colors.darkBackgroundColor + ColumnLayout { + anchors { + left: parent.left + right: parent.right + top: parent.top + margins: Kube.Units.smallSpacing + } + RowLayout { + Kube.CheckBox { + checked: true + } + Kube.Label { + text: qsTr("Mail") + color: Kube.Colors.highlightedTextColor + } + } + RowLayout { + Kube.CheckBox { + checked: false } + Kube.Label { + text: qsTr("Contacts") + color: Kube.Colors.highlightedTextColor + } + } + RowLayout { + Kube.CheckBox { + checked: false + } + Kube.Label { + text: qsTr("Events") + color: Kube.Colors.highlightedTextColor + } + } + } + } + Item { + Layout.fillHeight: true + Layout.fillWidth: true + ColumnLayout { + anchors.fill: parent + spacing: 0 + Rectangle { + id: toolbar + Layout.fillWidth: true + height: searchBar.height + Kube.Units.smallSpacing * 2 + color: Kube.Colors.backgroundColor Kube.TextField { - id: find - Layout.fillWidth: true + id: searchBar + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + text: root.searchTerm + width: parent.width * 0.5 placeholderText: qsTr("Search...") - onTextChanged: mailListView.filter = text - focus: true - Keys.onEscapePressed: filterField.clearSearch() + Keys.onEscapePressed: root.searchTerm = "" + onTextChanged: { + forceActiveFocus() + mailListView.filter = text + } + } + } + + Controls1.SplitView { + Layout.fillHeight: true + Layout.fillWidth: true + Kube.MailListView { + id: mailListView + width: Kube.Units.gridUnit * 18 + Layout.minimumWidth: Kube.Units.gridUnit * 10 + Layout.fillHeight: true + } + Kube.ConversationView { + id: mailView + Layout.minimumWidth: Kube.Units.gridUnit * 5 + Layout.fillWidth: true + Layout.fillHeight: true + activeFocusOnTab: true + model: Kube.MailListModel { + singleMail: mailListView.currentMail + } } } } - Kube.MailListView { - id: mailListView - Layout.fillWidth: true - Layout.fillHeight: true - } - } - Kube.ConversationView { - id: mailView - objectName: "mailView" - Layout.fillWidth: true - Layout.fillHeight: parent.height - activeFocusOnTab: true - mail: mailListView.currentMail } } } -- cgit v1.2.3