28 #ifndef ARTICLEFILTER_H
29 #define ARTICLEFILTER_H
32 #include <tqvaluelist.h>
33 #include <tqvariant.h>
44 class AbstractMatcher;
66 const TQString&
name()
const;
67 void setName(
const TQString& name);
74 AbstractAction* action()
const;
75 void setAction(
const AbstractAction& action);
80 void writeConfig(TDEConfig* config)
const;
81 void readConfig(TDEConfig* config);
84 class ArticleFilterPrivate;
85 ArticleFilterPrivate* d;
89 class ArticleFilterList :
public TQValueList<ArticleFilter>
93 void writeConfig(TDEConfig* config)
const;
94 void readConfig(TDEConfig* config);
108 virtual bool matches(
const Article& article)
const = 0;
110 virtual void writeConfig(TDEConfig* config)
const = 0;
111 virtual void readConfig(TDEConfig* config) = 0;
122 TagMatcher(
const TQString& tagID);
123 TagMatcher(
const TagMatcher& other);
125 virtual ~TagMatcher();
128 virtual bool matches(
const Article& article)
const;
130 virtual TagMatcher* clone()
const;
132 virtual void writeConfig(TDEConfig* config)
const;
133 virtual void readConfig(TDEConfig* config);
135 TagMatcher& operator=(
const TagMatcher& other);
141 class TagMatcherPrivate;
142 TagMatcherPrivate* d;
149 virtual ~AbstractAction() {}
152 virtual void exec(Article& article) = 0;
154 virtual void writeConfig(TDEConfig* config)
const = 0;
155 virtual void readConfig(TDEConfig* config) = 0;
157 virtual AbstractAction* clone()
const = 0;
158 virtual bool operator==(
const AbstractAction& other) = 0;
161 class DeleteAction :
public AbstractAction
164 virtual void exec(Article& article);
166 virtual void writeConfig(TDEConfig* config)
const;
167 virtual void readConfig(TDEConfig* config);
169 virtual DeleteAction* clone()
const {
return new DeleteAction; }
170 virtual bool operator==(
const AbstractAction& other);
173 class SetStatusAction :
public AbstractAction
176 SetStatusAction(
int status=0);
178 virtual void exec(Article& article);
181 void setStatus(
int status);
183 virtual void writeConfig(TDEConfig* config)
const;
184 virtual void readConfig(TDEConfig* config);
186 virtual SetStatusAction* clone()
const {
return new SetStatusAction(*
this); }
187 virtual bool operator==(
const AbstractAction& other);
193 class AssignTagAction :
public AbstractAction
197 AssignTagAction(
const TQString& tagID=TQString());
198 virtual void exec(Article& article);
200 const TQString& tagID()
const;
201 void setTagID(
const TQString& tagID);
203 virtual void writeConfig(TDEConfig* config)
const;
204 virtual void readConfig(TDEConfig* config);
206 virtual AssignTagAction* clone()
const {
return new AssignTagAction(*
this); }
207 virtual bool operator==(
const AbstractAction& other);
221 None, LogicalAnd, LogicalOr
225 ArticleMatcher(
const TQValueList<Criterion> &criteria, Association assoc);
238 virtual bool matches(
const Article &article)
const;
243 virtual void writeConfig(TDEConfig* config)
const;
244 virtual void readConfig(TDEConfig* config);
248 static Association stringToAssociation(
const TQString& assocStr);
249 static TQString associationToString(Association association);
251 bool anyCriterionMatches(
const Article &a )
const;
252 bool allCriteriaMatch(
const Article &a )
const;
254 TQValueList<Criterion> m_criteria;
255 Association m_association;
266 Title, Description, Author, Link, Status, KeepFlag
269 static TQString subjectToString(Subject subj);
270 static Subject stringToSubject(
const TQString& subjStr);
279 static TQString predicateToString(Predicate pred);
280 static Predicate stringToPredicate(
const TQString& predStr);
283 Criterion( Subject subject, Predicate predicate,
const TQVariant &
object );
285 bool satisfiedBy(
const Article &article )
const;
287 virtual void writeConfig(TDEConfig* config)
const;
288 virtual void readConfig(TDEConfig* config);
290 Subject subject()
const;
291 Predicate predicate()
const;
292 TQVariant object()
const;
293 bool operator==(
const Criterion& other)
const
294 {
return m_subject == other.m_subject && m_predicate == other.m_predicate && m_object == other.m_object; }
298 Predicate m_predicate;
Abstract base class for matchers, a matcher just takes an article and checks whether the article matc...
virtual ArticleMatcher * clone() const
returns a copy of the matcher
virtual AbstractMatcher * clone() const =0
returns a copy of the matcher
const TQString & name() const
name of the filter, for display in filter list
an article filter, basically a matcher and an action.
Criterion for ArticleMatcher.
a powerful matcher supporting multiple criterions, which can be combined via logical OR or AND ...
virtual bool matchesAll() const
returns whether the matcher matches all articles anyway (empty criteria list), so there is no need to...
void applyTo(Article &article) const
checks whether an article matches the matcher, and executes the action if so
A proxy class for RSS::Article with some additional methods to assist sorting.