Debian Codegraph @

src/librssguard/services/abstract/feed.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef FEED_H
4 #define FEED_H
5
6 #include "core/message.h"
7 #include "core/messagefilter.h"
8 #include "services/abstract/feedrtlbehavior.h"
9 #include "services/abstract/rootitem.h"
10
11 #include <QPointer>
12 #include <QVariant>
13
14 // Base class for "feed" nodes.
15 class RSSGUARD_DLLSPEC Feed : public RootItem {
16 Q_OBJECT
17
18 public:
19 struct ArticleIgnoreLimit {
20 // Ignoring articles.
21 bool m_avoidOldArticles = false;
22 bool m_addAnyArticlesToDb = false;
23 QDateTime m_dtToAvoid = QDateTime();
24 int m_hoursToAvoid = 0;
25
26 // Limitting articles.
27 bool m_customizeLimitting = false;
28 int m_keepCountOfArticles = 0;
29 bool m_doNotRemoveStarred = true;
30 bool m_doNotRemoveUnread = true;
31 bool m_moveToBinDontPurge = false;
32
33 static ArticleIgnoreLimit fromSettings();
34 };
35
36 // Specifies the auto-download strategy for the feed.
37 enum class AutoUpdateType {
38 DontAutoUpdate = 0,
39 DefaultAutoUpdate = 1,
40 SpecificAutoUpdate = 2
41 };
42
43 // Specifies the actual "status" of the feed.
44 // For example if it has new messages, error
45 // occurred, and so on.
46 enum class Status {
47 Normal = 0,
48 NewMessages = 1,
49 NetworkError = 2,
50 AuthError = 3,
51 ParsingError = 4,
52 OtherError = 5,
53 Fetching = 6
54 };
55
56 Q_ENUM(Status)
57
58 explicit Feed(RootItem* parent = nullptr);
59 explicit Feed(const Feed& other);
60 explicit Feed(const QString& title, const QString& custom_id, const QIcon& icon, RootItem* parent = nullptr);
61
62 virtual QList<Message> undeletedMessages() const;
63 virtual QString additionalTooltip() const;
64 virtual Qt::ItemFlags additionalFlags() const;
65 virtual bool markAsReadUnread(ReadStatus status);
66 virtual bool cleanMessages(bool clean_read_only);
67 virtual int countOfAllMessages() const;
68 virtual int countOfUnreadMessages() const;
69 virtual QVariantHash customDatabaseData() const;
70 virtual void setCustomDatabaseData(const QVariantHash& data);
71 virtual bool canBeEdited() const;
72 virtual bool isFetching() const;
73 virtual QVariant data(int column, int role) const;
74
75 void setCountOfAllMessages(int count_all_messages);
76 void setCountOfUnreadMessages(int count_unread_messages);
77
78 int autoUpdateInterval() const;
79 void setAutoUpdateInterval(int auto_update_interval);
80
81 AutoUpdateType autoUpdateType() const;
82 void setAutoUpdateType(AutoUpdateType auto_update_type);
83
84 Status status() const;
85 QString statusString() const;
86 void setStatus(Feed::Status status, const QString& status_text = {});
87
88 QString source() const;
89 void setSource(const QString& source);
90
91 bool openArticlesDirectly() const;
92 void setOpenArticlesDirectly(bool opn);
93
94 bool isSwitchedOff() const;
95 void setIsSwitchedOff(bool switched_off);
96
97 bool isQuiet() const;
98 void setIsQuiet(bool quiet);
99
100 void appendMessageFilter(MessageFilter* filter);
101 QList<QPointer<MessageFilter>> messageFilters() const;
102 void setMessageFilters(const QList<QPointer<MessageFilter>>& messageFilters);
103 void removeMessageFilter(MessageFilter* filter);
104
105 QDateTime lastUpdated() const;
106 void setLastUpdated(const QDateTime& last_updated);
107
108 RtlBehavior rtlBehavior() const;
109 void setRtlBehavior(RtlBehavior rtl);
110
111 bool removeUnwantedArticles(QSqlDatabase& db);
112
113 ArticleIgnoreLimit& articleIgnoreLimit();
114 const ArticleIgnoreLimit& articleIgnoreLimit() const;
115 void setArticleIgnoreLimit(const ArticleIgnoreLimit& ignore_limit);
116
117 public slots:
118 virtual void updateCounts(bool including_total_count);
119
120 protected:
121 QString getAutoUpdateStatusDescription() const;
122 QString getStatusDescription() const;
123
124 private:
125 QString m_source;
126 Status m_status;
127 QString m_statusString;
128 AutoUpdateType m_autoUpdateType;
129 int m_autoUpdateInterval{}; // In seconds.
130 QDateTime m_lastUpdated;
131 bool m_isSwitchedOff;
132 bool m_isQuiet;
133 bool m_openArticlesDirectly;
134 RtlBehavior m_rtlBehavior;
135
136 // NOTE: These are used to filter out older articles
137 // than needed. Either absolute value is given (date/time)
138 // or relative value given in minutes.
139 // Amount
140 ArticleIgnoreLimit m_articleIgnoreLimit;
141
142 int m_totalCount{};
143 int m_unreadCount{};
144 QList<QPointer<MessageFilter>> m_messageFilters;
145 };
146
147 Q_DECLARE_METATYPE(Feed::AutoUpdateType)
148 Q_DECLARE_METATYPE(Feed::Status)
149 Q_DECLARE_METATYPE(Feed::ArticleIgnoreLimit)
150
151 #endif // FEED_H