• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

akregator

  • sources
  • kde-4.14
  • kdepim
  • akregator
  • src
articlematcher.h
Go to the documentation of this file.
1 /*
2  * articlematcher.h
3  *
4  * Copyright (c) 2004, 2005 Frerich Raabe <raabe@kde.org>
5  * 2005 Frank Osterfeld <osterfeld@kde.org>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 #ifndef AKREGATOR_ARTICLEMATCHER_H
29 #define AKREGATOR_ARTICLEMATCHER_H
30 
31 #include "akregator_export.h"
32 #include <QList>
33 #include <QString>
34 #include <QVariant>
35 
36 class KConfigGroup;
37 
38 namespace Akregator {
39 
40 class Article;
41 
42 namespace Filters {
43 
44 class AbstractMatcher;
45 class Criterion;
46 
50 class AKREGATORPART_EXPORT AbstractMatcher
51 {
52  public:
53  virtual ~AbstractMatcher();
54 
55  virtual bool matches(const Article& article) const = 0;
56 
57  virtual void writeConfig(KConfigGroup* config) const = 0;
58  virtual void readConfig(KConfigGroup* config) = 0;
59 
60  virtual bool operator==(const AbstractMatcher&) const = 0;
61  virtual bool operator!=(const AbstractMatcher &other) const = 0;
62 
63  protected:
64  AbstractMatcher();
65 
66  private:
67  Q_DISABLE_COPY( AbstractMatcher )
68 
69 };
70 
71 
75 class AKREGATORPART_EXPORT ArticleMatcher : public AbstractMatcher
76 {
77  public:
78 
79  enum Association {
80  None, LogicalAnd, LogicalOr
81  };
82 
83  ArticleMatcher();
84  ArticleMatcher( const QList<Criterion> &criteria, Association assoc );
85 
86  ~ArticleMatcher();
87 
88  bool matches(const Article &article) const;
89  bool operator==(const AbstractMatcher &other) const;
90  bool operator!=(const AbstractMatcher &other) const;
91 
92  void writeConfig(KConfigGroup* config) const;
93  void readConfig(KConfigGroup* config);
94 
95  private:
96 
97  static Association stringToAssociation(const QString& assocStr);
98  static QString associationToString(Association association);
99 
100  bool anyCriterionMatches( const Article &a ) const;
101  bool allCriteriaMatch( const Article &a ) const;
102 
103  QList<Criterion> m_criteria;
104  Association m_association;
105 };
106 
110 class AKREGATORPART_EXPORT Criterion
111 {
112  public:
113 
114  enum Subject {
115  Title, Description, Link, Status, KeepFlag, Author
116  };
117 
118  static QString subjectToString(Subject subj);
119  static Subject stringToSubject(const QString& subjStr);
120 
121  enum Predicate {
122  Contains = 0x01,
123  Equals = 0x02,
124  Matches = 0x03,
125  Negation = 0x80
126  };
127 
128  static QString predicateToString(Predicate pred);
129  static Predicate stringToPredicate(const QString& predStr);
130 
131  Criterion();
132  Criterion( Subject subject, Predicate predicate, const QVariant &object );
133  virtual ~Criterion(){}
134  bool satisfiedBy( const Article &article ) const;
135 
136  virtual void writeConfig(KConfigGroup* config) const;
137  virtual void readConfig(KConfigGroup* config);
138 
139  Subject subject() const;
140  Predicate predicate() const;
141  QVariant object() const;
142  bool operator==(const Criterion& other) const
143  { return m_subject == other.m_subject && m_predicate == other.m_predicate && m_object == other.m_object; }
144 
145  private:
146  Subject m_subject;
147  Predicate m_predicate;
148  QVariant m_object;
149 };
150 
151 } // namespace Filters
152 } // namespace Akregator
153 
154 #endif // AKREGATOR_ARTICLEMATCHER_H
Akregator::Filters::Criterion::operator==
bool operator==(const Criterion &other) const
Definition: articlematcher.h:142
Akregator::Filters::AbstractMatcher
Abstract base class for matchers, a matcher just takes an article and checks whether the article matc...
Definition: articlematcher.h:50
Status
Status
Definition: akregatorstorageexporter.cpp:63
Akregator::Filters::Criterion::Subject
Subject
Definition: articlematcher.h:114
Akregator::Filters::Criterion::~Criterion
virtual ~Criterion()
Definition: articlematcher.h:133
QString
QList
Definition: article.h:41
Akregator::Filters::Criterion
Criterion for ArticleMatcher.
Definition: articlematcher.h:110
Akregator::Filters::Criterion::Predicate
Predicate
Definition: articlematcher.h:121
Akregator::Filters::ArticleMatcher
a powerful matcher supporting multiple criterions, which can be combined via logical OR or AND ...
Definition: articlematcher.h:75
Akregator::Filters::Criterion::Title
Definition: articlematcher.h:115
Akregator::Filters::ArticleMatcher::None
Definition: articlematcher.h:80
akregator_export.h
Akregator::Filters::ArticleMatcher::Association
Association
Definition: articlematcher.h:79
Akregator::Article
A proxy class for Syndication::ItemPtr with some additional methods to assist sorting.
Definition: article.h:63
AKREGATORPART_EXPORT
#define AKREGATORPART_EXPORT
Definition: akregator_export.h:48
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal