2010-10-16 17:39:03 +00:00
|
|
|
/*
|
|
|
|
* Bittorrent Client using Qt4 and libtorrent.
|
|
|
|
* Copyright (C) 2010 Christophe Dumez, Arnaud Demaiziere
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*
|
|
|
|
* Contact: chris@qbittorrent.org, arnaud@qbittorrent.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RSSFEED_H
|
|
|
|
#define RSSFEED_H
|
|
|
|
|
|
|
|
#include <QHash>
|
2012-02-19 18:53:10 +02:00
|
|
|
#include <QSharedPointer>
|
2012-08-18 18:06:29 +03:00
|
|
|
#include <QVariantHash>
|
2012-02-20 21:20:42 +02:00
|
|
|
#include <QXmlStreamReader>
|
2010-10-16 17:39:03 +00:00
|
|
|
|
|
|
|
#include "rssfile.h"
|
|
|
|
|
2012-02-19 18:53:10 +02:00
|
|
|
class RssFeed;
|
2010-10-16 17:39:03 +00:00
|
|
|
class RssManager;
|
|
|
|
|
2012-02-19 16:38:41 +02:00
|
|
|
typedef QHash<QString, RssArticlePtr> RssArticleHash;
|
2012-02-19 18:53:10 +02:00
|
|
|
typedef QSharedPointer<RssFeed> RssFeedPtr;
|
2012-02-20 20:49:31 +02:00
|
|
|
typedef QList<RssFeedPtr> RssFeedList;
|
2012-02-19 16:38:41 +02:00
|
|
|
|
2012-08-19 11:46:50 +03:00
|
|
|
bool rssArticleDateRecentThan(const RssArticlePtr& left, const RssArticlePtr& right);
|
|
|
|
|
2012-02-19 18:53:10 +02:00
|
|
|
class RssFeed: public QObject, public RssFile {
|
2010-10-16 17:39:03 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-02-19 18:53:10 +02:00
|
|
|
RssFeed(RssManager* manager, RssFolder* m_parent, const QString &url);
|
2012-02-19 15:13:39 +02:00
|
|
|
virtual ~RssFeed();
|
2012-02-20 19:28:11 +02:00
|
|
|
virtual RssFolder* parent() const { return m_parent; }
|
|
|
|
virtual void setParent(RssFolder* parent) { m_parent = parent; }
|
2012-08-19 15:12:08 +03:00
|
|
|
bool refresh();
|
2012-02-20 19:28:11 +02:00
|
|
|
virtual QString id() const { return m_url; }
|
|
|
|
virtual void removeAllSettings();
|
2012-02-19 20:36:01 +02:00
|
|
|
virtual void saveItemsToDisk();
|
2010-10-16 17:39:03 +00:00
|
|
|
void setLoading(bool val);
|
2011-01-27 17:18:56 +00:00
|
|
|
bool isLoading() const;
|
|
|
|
QString title() const;
|
2012-02-20 19:28:11 +02:00
|
|
|
virtual void rename(const QString &alias);
|
|
|
|
virtual QString displayName() const;
|
2011-01-27 17:18:56 +00:00
|
|
|
QString url() const;
|
|
|
|
QString icon() const;
|
2010-10-16 17:39:03 +00:00
|
|
|
bool hasCustomIcon() const;
|
2011-01-27 17:18:56 +00:00
|
|
|
void setIconPath(const QString &pathHierarchy);
|
2012-02-19 16:38:41 +02:00
|
|
|
RssArticlePtr getItem(const QString &guid) const;
|
2011-01-29 14:10:08 +00:00
|
|
|
uint count() const;
|
2012-02-20 19:28:11 +02:00
|
|
|
virtual void markAsRead();
|
|
|
|
virtual uint unreadCount() const;
|
2012-08-19 11:46:50 +03:00
|
|
|
virtual RssArticleList articleListByDateDesc() const;
|
2012-02-19 16:38:41 +02:00
|
|
|
const RssArticleHash& articleHash() const { return m_articles; }
|
2012-08-19 11:46:50 +03:00
|
|
|
virtual RssArticleList unreadArticleListByDateDesc() const;
|
2012-08-18 22:25:21 +03:00
|
|
|
void decrementUnreadCount();
|
2011-01-27 17:18:56 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleFinishedDownload(const QString& url, const QString &file_path);
|
|
|
|
void handleDownloadFailure(const QString &url, const QString& error);
|
2012-08-18 18:06:29 +03:00
|
|
|
void handleFeedTitle(const QString& feedUrl, const QString& title);
|
|
|
|
void handleNewArticle(const QString& feedUrl, const QVariantHash& article);
|
|
|
|
void handleFeedParsingFinished(const QString& feedUrl, const QString& error);
|
2011-01-25 18:46:38 +00:00
|
|
|
|
2010-10-16 17:39:03 +00:00
|
|
|
private:
|
2011-01-27 17:18:56 +00:00
|
|
|
QString iconUrl() const;
|
2011-09-26 20:25:59 +03:00
|
|
|
void loadItemsFromDisk();
|
2012-08-19 11:46:50 +03:00
|
|
|
void addArticle(const RssArticlePtr& article);
|
2011-01-25 18:46:38 +00:00
|
|
|
|
|
|
|
private:
|
2012-02-19 18:53:10 +02:00
|
|
|
RssManager* m_manager;
|
2012-02-19 16:38:41 +02:00
|
|
|
RssArticleHash m_articles;
|
2012-08-19 11:46:50 +03:00
|
|
|
RssArticleList m_articlesByDate; // Articles sorted by date (more recent first)
|
|
|
|
RssFolder* m_parent;
|
2011-01-27 17:18:56 +00:00
|
|
|
QString m_title;
|
|
|
|
QString m_url;
|
|
|
|
QString m_alias;
|
|
|
|
QString m_icon;
|
|
|
|
QString m_iconUrl;
|
2012-08-18 22:25:21 +03:00
|
|
|
uint m_unreadCount;
|
2012-08-18 21:26:22 +03:00
|
|
|
bool m_dirty;
|
2012-08-18 18:06:29 +03:00
|
|
|
bool m_inErrorState;
|
2011-01-27 17:18:56 +00:00
|
|
|
bool m_loading;
|
2011-01-25 18:46:38 +00:00
|
|
|
|
2010-10-16 17:39:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // RSSFEED_H
|