From a9b086954e17d6f2d64ac94b225577cb0e416f4f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 22 Feb 2018 15:22:22 +0100 Subject: Use the new changes regarding aggregated properties. This fixes marking partially unread threads as read. --- framework/qml/MailListView.qml | 18 ++++++++++-------- framework/src/domain/maillistmodel.cpp | 29 +++++++++-------------------- framework/src/domain/maillistmodel.h | 7 ------- tests/teststore.cpp | 1 + views/conversation/main.qml | 5 +++++ 5 files changed, 25 insertions(+), 35 deletions(-) diff --git a/framework/qml/MailListView.qml b/framework/qml/MailListView.qml index 69b7d871..35c90618 100644 --- a/framework/qml/MailListView.qml +++ b/framework/qml/MailListView.qml @@ -35,9 +35,6 @@ FocusScope { property bool showFilter: false property string filter: null - onCurrentMailChanged: { - Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": currentMail}) - } onParentFolderChanged: { currentMail = null filterField.clearSearch() @@ -130,11 +127,16 @@ FocusScope { onCurrentItemChanged: { if (currentItem) { - root.currentMail = currentItem.currentData.mail; - root.isDraft = currentItem.currentData.draft; - root.isTrash = currentItem.currentData.trash; - root.isImportant = currentItem.currentData.important; - root.isUnread = currentItem.currentData.unread; + var currentData = currentItem.currentData; + root.currentMail = currentData.mail; + root.isDraft = currentData.draft; + root.isTrash = currentData.trash; + root.isImportant = currentData.important; + root.isUnread = currentData.unread; + + if (currentData.mail && currentData.unread) { + Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": currentData.mail}) + } } } diff --git a/framework/src/domain/maillistmodel.cpp b/framework/src/domain/maillistmodel.cpp index 0c22b2c8..a1e137b3 100644 --- a/framework/src/domain/maillistmodel.cpp +++ b/framework/src/domain/maillistmodel.cpp @@ -139,14 +139,14 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const case Date: return mail->getDate(); case Unread: - if (mIsThreaded) { - return mail->getProperty("unreadCollected").toList().contains(true); + if (mail->isAggregate()) { + return mail->getCollectedProperty().contains(true); } else { - return mail->getUnread(); + return mail->getImportant(); } case Important: - if (mIsThreaded) { - return mail->getProperty("importantCollected").toList().contains(true); + if (mail->isAggregate()) { + return mail->getCollectedProperty().contains(true); } else { return mail->getImportant(); } @@ -166,11 +166,7 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const } return mail->getMimeMessage(); case ThreadSize: - if (mIsThreaded) { - return mail->getProperty("count").toInt(); - } else { - return 1; - } + return mail->count(); case Mail: return QVariant::fromValue(mail); case Incomplete: @@ -224,11 +220,6 @@ void MailListModel::runQuery(const Sink::Query &query) } } -bool MailListModel::isThreaded() const -{ - return mIsThreaded; -} - void MailListModel::setParentFolder(const QVariant &parentFolder) { using namespace Sink::ApplicationDomain; @@ -242,16 +233,14 @@ void MailListModel::setParentFolder(const QVariant &parentFolder) return; } mCurrentQueryItem = folder->identifier(); + bool isThreaded = true; if (folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::drafts) || folder->getSpecialPurpose().contains(Sink::ApplicationDomain::SpecialPurpose::Mail::sent)) { - mIsThreaded = false; - } else { - mIsThreaded = true; + isThreaded = false; } - emit isThreadedChanged(); Sink::Query query = [&] { - if (mIsThreaded) { + if (isThreaded) { return Sink::StandardQueries::threadLeaders(*folder); } else { Sink::Query query; diff --git a/framework/src/domain/maillistmodel.h b/framework/src/domain/maillistmodel.h index 27e8d036..f83656b9 100644 --- a/framework/src/domain/maillistmodel.h +++ b/framework/src/domain/maillistmodel.h @@ -35,7 +35,6 @@ class MailListModel : public QSortFilterProxyModel Q_PROPERTY (bool showInbox READ showInbox WRITE setShowInbox) Q_PROPERTY (QString filter READ filter WRITE setFilter) - Q_PROPERTY (bool isThreaded READ isThreaded NOTIFY isThreadedChanged) public: enum Status { @@ -53,8 +52,6 @@ public: bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE; - bool isThreaded() const; - enum Roles { Subject = Qt::UserRole + 1, Sender, @@ -96,9 +93,6 @@ public: void setShowInbox(bool); bool showInbox() const; -signals: - void isThreadedChanged(); - private: void fetchMail(Sink::ApplicationDomain::Mail::Ptr mail); @@ -106,6 +100,5 @@ private: bool mFetchMails = false; QSet mFetchedMails; QByteArray mCurrentQueryItem; - bool mIsThreaded = true; Sink::Query mQuery; }; diff --git a/tests/teststore.cpp b/tests/teststore.cpp index 07310640..6dbe5622 100644 --- a/tests/teststore.cpp +++ b/tests/teststore.cpp @@ -91,6 +91,7 @@ static void createMail(const QVariantMap &object, const QByteArray &folder = {}) auto mail = ApplicationDomainType::createEntity(object["resource"].toByteArray()); mail.setMimeMessage(msg->encodedContent(true)); + mail.setUnread(object["unread"].toBool()); if (!folder.isEmpty()) { mail.setFolder(folder); } diff --git a/views/conversation/main.qml b/views/conversation/main.qml index 2f80abff..9e17a0b6 100644 --- a/views/conversation/main.qml +++ b/views/conversation/main.qml @@ -63,6 +63,7 @@ ApplicationWindow { to: ["to@example.org"], cc: ["cc@example.org"], bcc: ["bcc@example.org"], + unread: true }, { resource: "resource1", @@ -71,6 +72,7 @@ ApplicationWindow { subject: "subject2", body: "body2", to: ["to@example.org"], + unread: true }, { resource: "resource1", @@ -79,6 +81,7 @@ ApplicationWindow { subject: "subject3", body: "body3\n\n\n\nfoo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe End", to: ["to@example.org"], + unread: true }, { resource: "resource1", @@ -87,6 +90,7 @@ ApplicationWindow { subject: "subject4", body: "body4", to: ["to@example.org"], + unread: false }, { resource: "resource1", @@ -94,6 +98,7 @@ ApplicationWindow { subject: "UTF-8 Madness Umlauts:öüä Snowflake:❆ Heart:♥", body: "UTF-8 Madness Umlauts:öüä Snowflake:❆ Heart:♥", to: ["öüä@example.org"], + unread: true }, ] }], -- cgit v1.2.3