Browse Source

Move base RSS code to Core.

adaptive-webui-19844
Vladimir Golovnev (Glassez) 9 years ago committed by Vladimir Golovnev (qlassez)
parent
commit
405b06319d
  1. 16
      src/base/base.pri
  2. 2
      src/base/rss/rssarticle.cpp
  3. 0
      src/base/rss/rssarticle.h
  4. 4
      src/base/rss/rssdownloadrule.cpp
  5. 0
      src/base/rss/rssdownloadrule.h
  6. 2
      src/base/rss/rssdownloadrulelist.cpp
  7. 0
      src/base/rss/rssdownloadrulelist.h
  8. 19
      src/base/rss/rssfeed.cpp
  9. 2
      src/base/rss/rssfeed.h
  10. 2
      src/base/rss/rssfile.cpp
  11. 3
      src/base/rss/rssfile.h
  12. 10
      src/base/rss/rssfolder.cpp
  13. 3
      src/base/rss/rssfolder.h
  14. 3
      src/base/rss/rssmanager.cpp
  15. 0
      src/base/rss/rssmanager.h
  16. 12
      src/base/rss/rssparser.cpp
  17. 3
      src/base/rss/rssparser.h
  18. 6
      src/gui/rss/automatedrssdownloader.cpp
  19. 3
      src/gui/rss/automatedrssdownloader.h
  20. 6
      src/gui/rss/feedlistwidget.cpp
  21. 6
      src/gui/rss/feedlistwidget.h
  22. 16
      src/gui/rss/rss.pri
  23. 14
      src/gui/rss/rss_imp.cpp
  24. 4
      src/gui/rss/rss_imp.h

16
src/base/base.pri

@ -36,6 +36,14 @@ HEADERS += \
$$PWD/bittorrent/private/bandwidthscheduler.h \ $$PWD/bittorrent/private/bandwidthscheduler.h \
$$PWD/bittorrent/private/filterparserthread.h \ $$PWD/bittorrent/private/filterparserthread.h \
$$PWD/bittorrent/private/statistics.h \ $$PWD/bittorrent/private/statistics.h \
$$PWD/rss/rssmanager.h \
$$PWD/rss/rssfeed.h \
$$PWD/rss/rssfolder.h \
$$PWD/rss/rssfile.h \
$$PWD/rss/rssarticle.h \
$$PWD/rss/rssdownloadrule.h \
$$PWD/rss/rssdownloadrulelist.h \
$$PWD/rss/rssparser.h \
$$PWD/utils/fs.h \ $$PWD/utils/fs.h \
$$PWD/utils/gzip.h \ $$PWD/utils/gzip.h \
$$PWD/utils/misc.h \ $$PWD/utils/misc.h \
@ -79,6 +87,14 @@ SOURCES += \
$$PWD/bittorrent/private/bandwidthscheduler.cpp \ $$PWD/bittorrent/private/bandwidthscheduler.cpp \
$$PWD/bittorrent/private/filterparserthread.cpp \ $$PWD/bittorrent/private/filterparserthread.cpp \
$$PWD/bittorrent/private/statistics.cpp \ $$PWD/bittorrent/private/statistics.cpp \
$$PWD/rss/rssmanager.cpp \
$$PWD/rss/rssfeed.cpp \
$$PWD/rss/rssfolder.cpp \
$$PWD/rss/rssarticle.cpp \
$$PWD/rss/rssdownloadrule.cpp \
$$PWD/rss/rssdownloadrulelist.cpp \
$$PWD/rss/rssfile.cpp \
$$PWD/rss/rssparser.cpp \
$$PWD/utils/fs.cpp \ $$PWD/utils/fs.cpp \
$$PWD/utils/gzip.cpp \ $$PWD/utils/gzip.cpp \
$$PWD/utils/misc.cpp \ $$PWD/utils/misc.cpp \

2
src/gui/rss/rssarticle.cpp → src/base/rss/rssarticle.cpp

@ -32,8 +32,8 @@
#include <QDebug> #include <QDebug>
#include <iostream> #include <iostream>
#include "rssarticle.h"
#include "rssfeed.h" #include "rssfeed.h"
#include "rssarticle.h"
// public constructor // public constructor
RssArticle::RssArticle(RssFeed* parent, const QString& guid): RssArticle::RssArticle(RssFeed* parent, const QString& guid):

0
src/gui/rss/rssarticle.h → src/base/rss/rssarticle.h

4
src/gui/rss/rssdownloadrule.cpp → src/base/rss/rssdownloadrule.cpp

@ -32,11 +32,11 @@
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include "rssdownloadrule.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "base/utils/fs.h"
#include "rssfeed.h" #include "rssfeed.h"
#include "rssarticle.h" #include "rssarticle.h"
#include "base/utils/fs.h" #include "rssdownloadrule.h"
RssDownloadRule::RssDownloadRule(): m_enabled(false), m_useRegex(false), m_apstate(USE_GLOBAL) RssDownloadRule::RssDownloadRule(): m_enabled(false), m_useRegex(false), m_apstate(USE_GLOBAL)
{ {

0
src/gui/rss/rssdownloadrule.h → src/base/rss/rssdownloadrule.h

2
src/gui/rss/rssdownloadrulelist.cpp → src/base/rss/rssdownloadrulelist.cpp

@ -32,9 +32,9 @@
#include <QDataStream> #include <QDataStream>
#include <QDebug> #include <QDebug>
#include "rssdownloadrulelist.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "base/qinisettings.h" #include "base/qinisettings.h"
#include "rssdownloadrulelist.h"
RssDownloadRuleList::RssDownloadRuleList() RssDownloadRuleList::RssDownloadRuleList()
{ {

0
src/gui/rss/rssdownloadrulelist.h → src/base/rss/rssdownloadrulelist.h

19
src/gui/rss/rssfeed.cpp → src/base/rss/rssfeed.cpp

@ -29,21 +29,22 @@
*/ */
#include <QDebug> #include <QDebug>
#include "rssfeed.h"
#include "rssmanager.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/magneturi.h" #include "base/bittorrent/magneturi.h"
#include "rssfolder.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "base/qinisettings.h" #include "base/qinisettings.h"
#include "rssarticle.h"
#include "rssparser.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "rssdownloadrulelist.h"
#include "base/net/downloadmanager.h" #include "base/net/downloadmanager.h"
#include "base/net/downloadhandler.h" #include "base/net/downloadhandler.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/logger.h" #include "base/logger.h"
#include "rssdownloadrulelist.h"
#include "rssarticle.h"
#include "rssparser.h"
#include "rssfolder.h"
#include "rssmanager.h"
#include "rssfeed.h"
bool rssArticleDateRecentThan(const RssArticlePtr& left, const RssArticlePtr& right) bool rssArticleDateRecentThan(const RssArticlePtr& left, const RssArticlePtr& right)
{ {
@ -227,12 +228,12 @@ QString RssFeed::url() const
return m_url; return m_url;
} }
QIcon RssFeed::icon() const QString RssFeed::iconPath() const
{ {
if (m_inErrorState) if (m_inErrorState)
return QIcon(":/icons/oxygen/unavailable.png"); return QLatin1String(":/icons/oxygen/unavailable.png");
return QIcon(m_icon); return m_icon;
} }
bool RssFeed::hasCustomIcon() const bool RssFeed::hasCustomIcon() const

2
src/gui/rss/rssfeed.h → src/base/rss/rssfeed.h

@ -66,7 +66,7 @@ public:
virtual void rename(const QString &alias); virtual void rename(const QString &alias);
virtual QString displayName() const; virtual QString displayName() const;
QString url() const; QString url() const;
virtual QIcon icon() const; virtual QString iconPath() const;
bool hasCustomIcon() const; bool hasCustomIcon() const;
void setIconPath(const QString &pathHierarchy); void setIconPath(const QString &pathHierarchy);
RssArticlePtr getItem(const QString &guid) const; RssArticlePtr getItem(const QString &guid) const;

2
src/gui/rss/rssfile.cpp → src/base/rss/rssfile.cpp

@ -28,8 +28,8 @@
* Contact: chris@qbittorrent.org, arnaud@qbittorrent.org * Contact: chris@qbittorrent.org, arnaud@qbittorrent.org
*/ */
#include "rssfile.h"
#include "rssfolder.h" #include "rssfolder.h"
#include "rssfile.h"
QStringList RssFile::pathHierarchy() const { QStringList RssFile::pathHierarchy() const {
QStringList path; QStringList path;

3
src/gui/rss/rssfile.h → src/base/rss/rssfile.h

@ -31,7 +31,6 @@
#ifndef RSSFILE_H #ifndef RSSFILE_H
#define RSSFILE_H #define RSSFILE_H
#include <QIcon>
#include <QList> #include <QList>
#include <QStringList> #include <QStringList>
#include <QSharedPointer> #include <QSharedPointer>
@ -55,7 +54,7 @@ public:
virtual uint unreadCount() const = 0; virtual uint unreadCount() const = 0;
virtual QString displayName() const = 0; virtual QString displayName() const = 0;
virtual QString id() const = 0; virtual QString id() const = 0;
virtual QIcon icon() const = 0; virtual QString iconPath() const = 0;
virtual void rename(const QString &new_name) = 0; virtual void rename(const QString &new_name) = 0;
virtual void markAsRead() = 0; virtual void markAsRead() = 0;
virtual RssFolder* parent() const = 0; virtual RssFolder* parent() const = 0;

10
src/gui/rss/rssfolder.cpp → src/base/rss/rssfolder.cpp

@ -30,12 +30,12 @@
#include <QDebug> #include <QDebug>
#include "guiiconprovider.h" #include "base/iconprovider.h"
#include "rssfolder.h"
#include "rssarticle.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "rssmanager.h" #include "rssmanager.h"
#include "rssfeed.h" #include "rssfeed.h"
#include "rssarticle.h"
#include "rssfolder.h"
RssFolder::RssFolder(RssFolder *parent, const QString &name): m_parent(parent), m_name(name) { RssFolder::RssFolder(RssFolder *parent, const QString &name): m_parent(parent), m_name(name) {
} }
@ -231,9 +231,9 @@ QString RssFolder::id() const
return m_name; return m_name;
} }
QIcon RssFolder::icon() const QString RssFolder::iconPath() const
{ {
return GuiIconProvider::instance()->getIcon("inode-directory"); return IconProvider::instance()->getIconPath("inode-directory");
} }
bool RssFolder::hasChild(const QString &childId) { bool RssFolder::hasChild(const QString &childId) {

3
src/gui/rss/rssfolder.h → src/base/rss/rssfolder.h

@ -33,6 +33,7 @@
#include <QHash> #include <QHash>
#include <QSharedPointer> #include <QSharedPointer>
#include "rssfile.h" #include "rssfile.h"
class RssFolder; class RssFolder;
@ -61,7 +62,7 @@ public:
QHash<QString, RssFeedPtr> getAllFeedsAsHash() const; QHash<QString, RssFeedPtr> getAllFeedsAsHash() const;
virtual QString displayName() const; virtual QString displayName() const;
virtual QString id() const; virtual QString id() const;
virtual QIcon icon() const; virtual QString iconPath() const;
bool hasChild(const QString &childId); bool hasChild(const QString &childId);
virtual RssArticleList articleListByDateDesc() const; virtual RssArticleList articleListByDateDesc() const;
virtual RssArticleList unreadArticleListByDateDesc() const; virtual RssArticleList unreadArticleListByDateDesc() const;

3
src/gui/rss/rssmanager.cpp → src/base/rss/rssmanager.cpp

@ -29,13 +29,14 @@
*/ */
#include <QDebug> #include <QDebug>
#include "rssmanager.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "rssfeed.h" #include "rssfeed.h"
#include "rssarticle.h" #include "rssarticle.h"
#include "rssdownloadrulelist.h" #include "rssdownloadrulelist.h"
#include "rssparser.h" #include "rssparser.h"
#include "rssmanager.h"
static const int MSECS_PER_MIN = 60000; static const int MSECS_PER_MIN = 60000;

0
src/gui/rss/rssmanager.h → src/base/rss/rssmanager.h

12
src/gui/rss/rssparser.cpp → src/base/rss/rssparser.cpp

@ -28,15 +28,14 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#include "rssparser.h"
#include "base/utils/fs.h"
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QRegExp> #include <QRegExp>
#include <QStringList> #include <QStringList>
#include <QVariant> #include <QVariant>
#include <QTextDocument>
#include "base/utils/fs.h"
#include "rssparser.h"
struct ParsingJob { struct ParsingJob {
QString feedUrl; QString feedUrl;
@ -343,10 +342,7 @@ void RssParser::parseAtomArticle(QXmlStreamReader& xml, const QString& feedUrl,
if (xml.isStartElement()) { if (xml.isStartElement()) {
if (xml.name() == "title") { if (xml.name() == "title") {
// Workaround for CDATA (QString cannot parse html escapes on it's own) article["title"] = xml.readElementText().trimmed();
QTextDocument doc;
doc.setHtml(xml.readElementText());
article["title"] = doc.toPlainText().trimmed();
} }
else if (xml.name() == "link") { else if (xml.name() == "link") {
QString link = ( xml.attributes().isEmpty() ? QString link = ( xml.attributes().isEmpty() ?

3
src/gui/rss/rssparser.h → src/base/rss/rssparser.h

@ -31,12 +31,13 @@
#ifndef RSSPARSER_H #ifndef RSSPARSER_H
#define RSSPARSER_H #define RSSPARSER_H
#include "rssarticle.h"
#include <QMutex> #include <QMutex>
#include <QQueue> #include <QQueue>
#include <QThread> #include <QThread>
#include <QWaitCondition> #include <QWaitCondition>
#include "rssarticle.h"
struct ParsingJob; struct ParsingJob;
class RssParser : public QThread class RssParser : public QThread

6
src/gui/rss/automatedrssdownloader.cpp

@ -36,10 +36,10 @@
#include "automatedrssdownloader.h" #include "automatedrssdownloader.h"
#include "ui_automatedrssdownloader.h" #include "ui_automatedrssdownloader.h"
#include "rssdownloadrulelist.h" #include "base/rss/rssdownloadrulelist.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "rssmanager.h" #include "base/rss/rssmanager.h"
#include "rssfeed.h" #include "base/rss/rssfeed.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "autoexpandabledialog.h" #include "autoexpandabledialog.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"

3
src/gui/rss/automatedrssdownloader.h

@ -35,7 +35,8 @@
#include <QWeakPointer> #include <QWeakPointer>
#include <QShortcut> #include <QShortcut>
#include <QRegExpValidator> #include <QRegExpValidator>
#include "rssdownloadrule.h"
#include "base/rss/rssdownloadrule.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { namespace Ui {

6
src/gui/rss/feedlistwidget.cpp

@ -28,10 +28,10 @@
* Contact: chris@qbittorrent.org, arnaud@qbittorrent.org * Contact: chris@qbittorrent.org, arnaud@qbittorrent.org
*/ */
#include "feedlistwidget.h" #include "core/rss/rssmanager.h"
#include "rssmanager.h" #include "core/rss/rssfeed.h"
#include "rssfeed.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "feedlistwidget.h"
FeedListWidget::FeedListWidget(QWidget *parent, const RssManagerPtr& rssmanager): QTreeWidget(parent), m_rssManager(rssmanager) { FeedListWidget::FeedListWidget(QWidget *parent, const RssManagerPtr& rssmanager): QTreeWidget(parent), m_rssManager(rssmanager) {
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);

6
src/gui/rss/feedlistwidget.h

@ -39,9 +39,9 @@
#include <QHash> #include <QHash>
#include <QUrl> #include <QUrl>
#include "rssfile.h" #include "base/rss/rssfile.h"
#include "rssfeed.h" #include "base/rss/rssfeed.h"
#include "rssmanager.h" #include "base/rss/rssmanager.h"
class FeedListWidget: public QTreeWidget { class FeedListWidget: public QTreeWidget {
Q_OBJECT Q_OBJECT

16
src/gui/rss/rss.pri

@ -3,31 +3,15 @@ INCLUDEPATH += $$PWD
HEADERS += $$PWD/rss_imp.h \ HEADERS += $$PWD/rss_imp.h \
$$PWD/rsssettingsdlg.h \ $$PWD/rsssettingsdlg.h \
$$PWD/feedlistwidget.h \ $$PWD/feedlistwidget.h \
$$PWD/rssmanager.h \
$$PWD/rssfeed.h \
$$PWD/rssfolder.h \
$$PWD/rssfile.h \
$$PWD/rssarticle.h \
$$PWD/automatedrssdownloader.h \ $$PWD/automatedrssdownloader.h \
$$PWD/rssdownloadrule.h \
$$PWD/rssdownloadrulelist.h \
$$PWD/cookiesdlg.h \ $$PWD/cookiesdlg.h \
$$PWD/rssparser.h \
$$PWD/htmlbrowser.h $$PWD/htmlbrowser.h
SOURCES += $$PWD/rss_imp.cpp \ SOURCES += $$PWD/rss_imp.cpp \
$$PWD/rsssettingsdlg.cpp \ $$PWD/rsssettingsdlg.cpp \
$$PWD/feedlistwidget.cpp \ $$PWD/feedlistwidget.cpp \
$$PWD/rssmanager.cpp \
$$PWD/rssfeed.cpp \
$$PWD/rssfolder.cpp \
$$PWD/rssarticle.cpp \
$$PWD/automatedrssdownloader.cpp \ $$PWD/automatedrssdownloader.cpp \
$$PWD/rssdownloadrule.cpp \
$$PWD/rssdownloadrulelist.cpp \
$$PWD/cookiesdlg.cpp \ $$PWD/cookiesdlg.cpp \
$$PWD/rssfile.cpp \
$$PWD/rssparser.cpp \
$$PWD/htmlbrowser.cpp $$PWD/htmlbrowser.cpp
FORMS += $$PWD/rss.ui \ FORMS += $$PWD/rss.ui \

14
src/gui/rss/rss_imp.cpp

@ -44,11 +44,11 @@
#include "cookiesdlg.h" #include "cookiesdlg.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "rsssettingsdlg.h" #include "rsssettingsdlg.h"
#include "rssmanager.h" #include "base/rss/rssmanager.h"
#include "rssfolder.h" #include "base/rss/rssfolder.h"
#include "rssarticle.h" #include "base/rss/rssarticle.h"
#include "rssparser.h" #include "base/rss/rssparser.h"
#include "rssfeed.h" #include "base/rss/rssfeed.h"
#include "automatedrssdownloader.h" #include "automatedrssdownloader.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "autoexpandabledialog.h" #include "autoexpandabledialog.h"
@ -478,7 +478,7 @@ QTreeWidgetItem* RSSImp::createFolderListItem(const RssFilePtr& rssFile)
Q_ASSERT(rssFile); Q_ASSERT(rssFile);
QTreeWidgetItem* item = new QTreeWidgetItem; QTreeWidgetItem* item = new QTreeWidgetItem;
item->setData(0, Qt::DisplayRole, QVariant(rssFile->displayName() + QString::fromUtf8(" (") + QString::number(rssFile->unreadCount()) + QString(")"))); item->setData(0, Qt::DisplayRole, QVariant(rssFile->displayName() + QString::fromUtf8(" (") + QString::number(rssFile->unreadCount()) + QString(")")));
item->setData(0, Qt::DecorationRole, rssFile->icon()); item->setData(0, Qt::DecorationRole, QIcon(rssFile->iconPath()));
return item; return item;
} }
@ -680,7 +680,7 @@ void RSSImp::updateFeedInfos(const QString& url, const QString& display_name, ui
RssFeedPtr stream = qSharedPointerCast<RssFeed>(m_feedList->getRSSItem(item)); RssFeedPtr stream = qSharedPointerCast<RssFeed>(m_feedList->getRSSItem(item));
item->setText(0, display_name + QString::fromUtf8(" (") + QString::number(nbUnread) + QString(")")); item->setText(0, display_name + QString::fromUtf8(" (") + QString::number(nbUnread) + QString(")"));
if (!stream->isLoading()) if (!stream->isLoading())
item->setData(0, Qt::DecorationRole, QVariant(stream->icon())); item->setData(0, Qt::DecorationRole, QIcon(stream->iconPath()));
// Update parent // Update parent
if (item->parent()) if (item->parent())
updateItemInfos(item->parent()); updateItemInfos(item->parent());

4
src/gui/rss/rss_imp.h

@ -35,9 +35,9 @@
#include <QPointer> #include <QPointer>
#include <QShortcut> #include <QShortcut>
#include "base/rss/rssfolder.h"
#include "base/rss/rssmanager.h"
#include "ui_rss.h" #include "ui_rss.h"
#include "rssfolder.h"
#include "rssmanager.h"
class FeedListWidget; class FeedListWidget;

Loading…
Cancel
Save