From 670235e37e529bf86d334aed3f2663fcc79a605d Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 26 Oct 2020 12:13:01 +0100 Subject: [PATCH] Labels are now available in msg filtering. --- src/librssguard/core/message.cpp | 16 ++++++++++------ src/librssguard/core/message.h | 3 +++ src/librssguard/services/abstract/label.h | 5 ++++- src/librssguard/services/abstract/rootitem.h | 2 ++ src/rssguard/main.cpp | 3 +++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/librssguard/core/message.cpp b/src/librssguard/core/message.cpp index 64b322f36..a9c601f41 100644 --- a/src/librssguard/core/message.cpp +++ b/src/librssguard/core/message.cpp @@ -165,31 +165,31 @@ bool MessageObject::isDuplicateWithAttribute(int attribute_check) const { // Now we construct the query according to parameter. if ((attrs& DuplicationAttributeCheck::SameTitle) == DuplicationAttributeCheck::SameTitle) { where_clauses.append(QSL("title = :title")); - bind_values.append({":title", title()}); + bind_values.append({ ":title", title() }); } if ((attrs& DuplicationAttributeCheck::SameUrl) == DuplicationAttributeCheck::SameUrl) { where_clauses.append(QSL("url = :url")); - bind_values.append({":url", url()}); + bind_values.append({ ":url", url() }); } if ((attrs& DuplicationAttributeCheck::SameAuthor) == DuplicationAttributeCheck::SameAuthor) { where_clauses.append(QSL("author = :author")); - bind_values.append({":author", author()}); + bind_values.append({ ":author", author() }); } if ((attrs& DuplicationAttributeCheck::SameDateCreated) == DuplicationAttributeCheck::SameDateCreated) { where_clauses.append(QSL("date_created = :date_created")); - bind_values.append({":date_created", created().toMSecsSinceEpoch()}); + bind_values.append({ ":date_created", created().toMSecsSinceEpoch() }); } where_clauses.append(QSL("account_id = :account_id")); - bind_values.append({":account_id", accountId()}); + bind_values.append({ ":account_id", accountId() }); if ((attrs& DuplicationAttributeCheck::AllFeedsSameAccount) != DuplicationAttributeCheck::AllFeedsSameAccount) { // Limit to current feed. where_clauses.append(QSL("feed = :feed")); - bind_values.append({":feed", feedCustomId()}); + bind_values.append({ ":feed", feedCustomId() }); } QString full_query = QSL("SELECT COUNT(*) FROM Messages WHERE ") + where_clauses.join(QSL(" AND ")) + QSL(";"); @@ -289,3 +289,7 @@ QString MessageObject::feedCustomId() const { int MessageObject::accountId() const { return m_accountId; } + +QList MessageObject::assignedLabels() const { + return m_message->m_assignedLabels; +} diff --git a/src/librssguard/core/message.h b/src/librssguard/core/message.h index b078bb897..0854d4146 100644 --- a/src/librssguard/core/message.h +++ b/src/librssguard/core/message.h @@ -118,6 +118,7 @@ inline DuplicationAttributeCheck operator&(DuplicationAttributeCheck lhs, Duplic class MessageObject : public QObject { Q_OBJECT + Q_PROPERTY(QList assignedLabels READ assignedLabels) Q_PROPERTY(QString feedCustomId READ feedCustomId) Q_PROPERTY(int accountId READ accountId) Q_PROPERTY(QString title READ title WRITE setTitle) @@ -138,6 +139,8 @@ class MessageObject : public QObject { // value casted to int. Q_INVOKABLE bool isDuplicateWithAttribute(int attribute_check) const; + QList assignedLabels() const; + // Generic Message's properties bindings. QString feedCustomId() const; int accountId() const; diff --git a/src/librssguard/services/abstract/label.h b/src/librssguard/services/abstract/label.h index 777a48b0a..a5e3fb919 100755 --- a/src/librssguard/services/abstract/label.h +++ b/src/librssguard/services/abstract/label.h @@ -7,9 +7,12 @@ #include -class Label : public RootItem { +class RSSGUARD_DLLSPEC Label : public RootItem { Q_OBJECT + Q_PROPERTY(QString customId READ customId) + Q_PROPERTY(QColor color READ color) + public: explicit Label(const QString& name, const QColor& color, RootItem* parent_item = nullptr); explicit Label(RootItem* parent_item = nullptr); diff --git a/src/librssguard/services/abstract/rootitem.h b/src/librssguard/services/abstract/rootitem.h index 5e3aab119..4935089c5 100644 --- a/src/librssguard/services/abstract/rootitem.h +++ b/src/librssguard/services/abstract/rootitem.h @@ -21,6 +21,8 @@ class QAction; class RSSGUARD_DLLSPEC RootItem : public QObject { Q_OBJECT + Q_PROPERTY(QString title READ title) + public: enum class ReadStatus { Unread = 0, diff --git a/src/rssguard/main.cpp b/src/rssguard/main.cpp index 1963c35e1..78ee4c473 100755 --- a/src/rssguard/main.cpp +++ b/src/rssguard/main.cpp @@ -6,6 +6,7 @@ #include "gui/feedmessageviewer.h" #include "gui/feedsview.h" #include "miscellaneous/application.h" +#include "services/abstract/label.h" #if defined (Q_OS_MACOS) extern void disableWindowTabbing(); @@ -58,6 +59,8 @@ int main(int argc, char* argv[]) { // Register needed metatypes. qRegisterMetaType>("QList"); qRegisterMetaType>("QList"); + qRegisterMetaType>("QList"); + qRegisterMetaType("Label*"); // Add an extra path for non-system icon themes and set current icon theme // and skin.