Labels are now available in msg filtering.

This commit is contained in:
Martin Rotter 2020-10-26 12:13:01 +01:00
parent 7f49c2883b
commit 670235e37e
5 changed files with 22 additions and 7 deletions

View File

@ -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<Label*> MessageObject::assignedLabels() const {
return m_message->m_assignedLabels;
}

View File

@ -118,6 +118,7 @@ inline DuplicationAttributeCheck operator&(DuplicationAttributeCheck lhs, Duplic
class MessageObject : public QObject {
Q_OBJECT
Q_PROPERTY(QList<Label*> 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<Label*> assignedLabels() const;
// Generic Message's properties bindings.
QString feedCustomId() const;
int accountId() const;

View File

@ -7,9 +7,12 @@
#include <QColor>
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);

View File

@ -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,

View File

@ -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<Message>>("QList<Message>");
qRegisterMetaType<QList<RootItem*>>("QList<RootItem*>");
qRegisterMetaType<QList<Label*>>("QList<Label*>");
qRegisterMetaType<Label*>("Label*");
// Add an extra path for non-system icon themes and set current icon theme
// and skin.