akregator/src

feed.h
1 /*
2  This file is part of Akregator.
3 
4  Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
5  2005 Frank Osterfeld <frank.osterfeld at kdemail.net>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of TQt, and distribute the resulting executable,
23  without including the source code for TQt in the source distribution.
24 */
25 
26 #ifndef AKREGATORFEED_H
27 #define AKREGATORFEED_H
28 
29 #include "treenode.h"
30 #include "librss/librss.h"
31 
32 class TQDomElement;
33 class TQPixmap;
34 class TQString;
35 class TQStringList;
36 class KURL;
37 
38 
39 namespace KPIM {
40  class ProgressItem;
41 }
42 
43 // needed for slot fetchCompleted()
44 using RSS::Document;
45 using RSS::Loader;
46 using RSS::Status;
47 
48 namespace Akregator
49 {
50  class Article;
51  class FetchQueue;
52  class Folder;
53  class TreeNodeVisitor;
54 
55  namespace Backend
56  {
57  class FeedStorage;
58  }
62  class Feed : public TreeNode
63  {
64  friend class Article;
65 
66  Q_OBJECT
67 
68  public:
76  enum ArchiveMode { globalDefault, keepAllArticles, disableArchiving, limitArticleNumber, limitArticleAge };
77 
78  // class methods
82  static ArchiveMode stringToArchiveMode(const TQString& str);
83 
85  static TQString archiveModeToString(ArchiveMode mode);
86 
88  static Feed* fromOPML(TQDomElement e);
89 
91  Feed();
92 
93  virtual ~Feed();
94 
95  virtual bool accept(TreeNodeVisitor* visitor);
96 
98  virtual TQDomElement toOPML( TQDomElement parent, TQDomDocument document ) const;
99 
104  bool useCustomFetchInterval() const;
105 
110  void setCustomFetchIntervalEnabled(bool enabled);
111 
112  // FIXME is it -1 or 0 to disable interval fetching?
115  int fetchInterval() const;
116 
119  void setFetchInterval(int interval);
120 
122  ArchiveMode archiveMode() const;
123 
125  void setArchiveMode(ArchiveMode archiveMode);
126 
129  int maxArticleAge() const;
130 
133  void setMaxArticleAge(int maxArticleAge);
134 
135 
137  int maxArticleNumber() const;
138 
140  void setMaxArticleNumber(int maxArticleNumber);
141 
143  bool markImmediatelyAsRead() const;
144 
145  void setMarkImmediatelyAsRead(bool enabled);
146 
147  void setUseNotification(bool enabled);
148 
149  bool useNotification() const;
150 
152  void setLoadLinkedWebsite(bool enabled);
153 
154  bool loadLinkedWebsite() const;
155 
157  const TQPixmap& favicon() const;
158 
160  void setFavicon(const TQPixmap& p);
161 
163  const TQPixmap& image() const;
164 
166  const TQString& xmlUrl() const;
168  void setXmlUrl(const TQString& s);
169 
171  const TQString& htmlUrl() const;
173  void setHtmlUrl(const TQString& s);
174 
176  const TQString& description() const;
177 
179  void setDescription(const TQString& s);
180 
181  virtual TQValueList<Article> articles(const TQString& tag=TQString());
182 
184  virtual Article findArticle(const TQString& guid) const;
185 
186  virtual TQStringList tags() const;
187 
189  bool fetchErrorOccurred();
190 
192  virtual int unread() const;
193 
197  virtual int totalCount() const;
198 
200  bool isArticlesLoaded() const;
201 
203  virtual bool isGroup() const { return false; }
204 
208  virtual TreeNode* next();
209 
211  void loadFavicon();
212 
214  void loadImage();
215 
216  public slots:
218  void fetch(bool followDiscovery=false);
219 
220  void slotAbortFetch();
221 
223  virtual void slotDeleteExpiredArticles();
224 
226  virtual void slotMarkAllArticlesAsRead();
227 
229  virtual void slotAddToFetchQueue(FetchQueue* queue, bool intervalFetchOnly=false);
230 
231  signals:
233  void fetchStarted(Feed*);
235  void fetched(Feed *);
237  void fetchError(Feed *);
239  void fetchDiscovery(Feed *);
241  void fetchAborted(Feed *);
242 
243  protected:
245  void loadArticles();
246 
247  void recalcUnreadCount();
248 
249  virtual void doArticleNotification();
250 
252  void setUnread(int unread);
253 
254 
255  private slots:
256 
257  void fetchCompleted(Loader *loader, Document doc, Status status);
258  void slotImageFetched(const TQPixmap& image);
259 
260  private:
261 
265  void setArticleDeleted(Article& a);
266 
271  void setArticleChanged(Article& a, int oldStatus=-1);
272 
273  void enforceLimitArticleNumber();
274 
275  void appendArticles(const RSS::Document &d);
277  void appendArticle(const Article& a);
278 
280  bool isExpired(const Article& a) const;
281 
283  bool usesExpiryByAge() const;
284 
286  void tryFetch();
287 
288  class FeedPrivate;
289  FeedPrivate* d;
290  };
291 }
292 
293 #endif
virtual bool isGroup() const
returns if this node is a feed group (false here)
Definition: feed.h:203
ArchiveMode
the archiving modes:
Definition: feed.h:76
Definition: feed.h:39
represents a feed
Definition: feed.h:62
A proxy class for RSS::Article with some additional methods to assist sorting.
Definition: article.h:57
Abstract base class for all kind of elements in the feed tree, like feeds and feed groups (and search...
Definition: treenode.h:51