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 --- framework/qml/ConversationView.qml | 6 +---- framework/src/domain/maillistmodel.cpp | 42 ++++++++++++++++++++++++++++++++++ framework/src/domain/maillistmodel.h | 4 ++++ 3 files changed, 47 insertions(+), 5 deletions(-) (limited to 'framework') 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; -- cgit v1.2.3