From 405b06319df2360cee9e4ae4b08453e435aa3925 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Wed, 14 Oct 2015 12:31:44 +0300 Subject: [PATCH] Move base RSS code to Core. --- src/base/base.pri | 16 ++++++++++++++++ src/{gui => base}/rss/rssarticle.cpp | 2 +- src/{gui => base}/rss/rssarticle.h | 0 src/{gui => base}/rss/rssdownloadrule.cpp | 4 ++-- src/{gui => base}/rss/rssdownloadrule.h | 0 src/{gui => base}/rss/rssdownloadrulelist.cpp | 2 +- src/{gui => base}/rss/rssdownloadrulelist.h | 0 src/{gui => base}/rss/rssfeed.cpp | 19 ++++++++++--------- src/{gui => base}/rss/rssfeed.h | 2 +- src/{gui => base}/rss/rssfile.cpp | 2 +- src/{gui => base}/rss/rssfile.h | 3 +-- src/{gui => base}/rss/rssfolder.cpp | 10 +++++----- src/{gui => base}/rss/rssfolder.h | 3 ++- src/{gui => base}/rss/rssmanager.cpp | 3 ++- src/{gui => base}/rss/rssmanager.h | 0 src/{gui => base}/rss/rssparser.cpp | 12 ++++-------- src/{gui => base}/rss/rssparser.h | 3 ++- src/gui/rss/automatedrssdownloader.cpp | 6 +++--- src/gui/rss/automatedrssdownloader.h | 3 ++- src/gui/rss/feedlistwidget.cpp | 6 +++--- src/gui/rss/feedlistwidget.h | 6 +++--- src/gui/rss/rss.pri | 16 ---------------- src/gui/rss/rss_imp.cpp | 14 +++++++------- src/gui/rss/rss_imp.h | 4 ++-- 24 files changed, 68 insertions(+), 68 deletions(-) rename src/{gui => base}/rss/rssarticle.cpp (100%) rename src/{gui => base}/rss/rssarticle.h (100%) rename src/{gui => base}/rss/rssdownloadrule.cpp (100%) rename src/{gui => base}/rss/rssdownloadrule.h (100%) rename src/{gui => base}/rss/rssdownloadrulelist.cpp (100%) rename src/{gui => base}/rss/rssdownloadrulelist.h (100%) rename src/{gui => base}/rss/rssfeed.cpp (99%) rename src/{gui => base}/rss/rssfeed.h (99%) rename src/{gui => base}/rss/rssfile.cpp (100%) rename src/{gui => base}/rss/rssfile.h (98%) rename src/{gui => base}/rss/rssfolder.cpp (98%) rename src/{gui => base}/rss/rssfolder.h (98%) rename src/{gui => base}/rss/rssmanager.cpp (99%) rename src/{gui => base}/rss/rssmanager.h (100%) rename src/{gui => base}/rss/rssparser.cpp (98%) rename src/{gui => base}/rss/rssparser.h (99%) diff --git a/src/base/base.pri b/src/base/base.pri index 3ce02d04d..ccea8efe1 100644 --- a/src/base/base.pri +++ b/src/base/base.pri @@ -36,6 +36,14 @@ HEADERS += \ $$PWD/bittorrent/private/bandwidthscheduler.h \ $$PWD/bittorrent/private/filterparserthread.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/gzip.h \ $$PWD/utils/misc.h \ @@ -79,6 +87,14 @@ SOURCES += \ $$PWD/bittorrent/private/bandwidthscheduler.cpp \ $$PWD/bittorrent/private/filterparserthread.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/gzip.cpp \ $$PWD/utils/misc.cpp \ diff --git a/src/gui/rss/rssarticle.cpp b/src/base/rss/rssarticle.cpp similarity index 100% rename from src/gui/rss/rssarticle.cpp rename to src/base/rss/rssarticle.cpp index fbc7218bf..34ab247eb 100644 --- a/src/gui/rss/rssarticle.cpp +++ b/src/base/rss/rssarticle.cpp @@ -32,8 +32,8 @@ #include #include -#include "rssarticle.h" #include "rssfeed.h" +#include "rssarticle.h" // public constructor RssArticle::RssArticle(RssFeed* parent, const QString& guid): diff --git a/src/gui/rss/rssarticle.h b/src/base/rss/rssarticle.h similarity index 100% rename from src/gui/rss/rssarticle.h rename to src/base/rss/rssarticle.h diff --git a/src/gui/rss/rssdownloadrule.cpp b/src/base/rss/rssdownloadrule.cpp similarity index 100% rename from src/gui/rss/rssdownloadrule.cpp rename to src/base/rss/rssdownloadrule.cpp index cd37a3a56..132166e06 100644 --- a/src/gui/rss/rssdownloadrule.cpp +++ b/src/base/rss/rssdownloadrule.cpp @@ -32,11 +32,11 @@ #include #include -#include "rssdownloadrule.h" #include "base/preferences.h" +#include "base/utils/fs.h" #include "rssfeed.h" #include "rssarticle.h" -#include "base/utils/fs.h" +#include "rssdownloadrule.h" RssDownloadRule::RssDownloadRule(): m_enabled(false), m_useRegex(false), m_apstate(USE_GLOBAL) { diff --git a/src/gui/rss/rssdownloadrule.h b/src/base/rss/rssdownloadrule.h similarity index 100% rename from src/gui/rss/rssdownloadrule.h rename to src/base/rss/rssdownloadrule.h diff --git a/src/gui/rss/rssdownloadrulelist.cpp b/src/base/rss/rssdownloadrulelist.cpp similarity index 100% rename from src/gui/rss/rssdownloadrulelist.cpp rename to src/base/rss/rssdownloadrulelist.cpp index 12f6a9710..c1d450769 100644 --- a/src/gui/rss/rssdownloadrulelist.cpp +++ b/src/base/rss/rssdownloadrulelist.cpp @@ -32,9 +32,9 @@ #include #include -#include "rssdownloadrulelist.h" #include "base/preferences.h" #include "base/qinisettings.h" +#include "rssdownloadrulelist.h" RssDownloadRuleList::RssDownloadRuleList() { diff --git a/src/gui/rss/rssdownloadrulelist.h b/src/base/rss/rssdownloadrulelist.h similarity index 100% rename from src/gui/rss/rssdownloadrulelist.h rename to src/base/rss/rssdownloadrulelist.h diff --git a/src/gui/rss/rssfeed.cpp b/src/base/rss/rssfeed.cpp similarity index 99% rename from src/gui/rss/rssfeed.cpp rename to src/base/rss/rssfeed.cpp index 7659ecae1..72bcb8993 100644 --- a/src/gui/rss/rssfeed.cpp +++ b/src/base/rss/rssfeed.cpp @@ -29,21 +29,22 @@ */ #include -#include "rssfeed.h" -#include "rssmanager.h" + #include "base/bittorrent/session.h" #include "base/bittorrent/magneturi.h" -#include "rssfolder.h" #include "base/preferences.h" #include "base/qinisettings.h" -#include "rssarticle.h" -#include "rssparser.h" #include "base/utils/misc.h" -#include "rssdownloadrulelist.h" #include "base/net/downloadmanager.h" #include "base/net/downloadhandler.h" #include "base/utils/fs.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) { @@ -227,12 +228,12 @@ QString RssFeed::url() const return m_url; } -QIcon RssFeed::icon() const +QString RssFeed::iconPath() const { 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 diff --git a/src/gui/rss/rssfeed.h b/src/base/rss/rssfeed.h similarity index 99% rename from src/gui/rss/rssfeed.h rename to src/base/rss/rssfeed.h index 81e53a5b2..84e95119f 100644 --- a/src/gui/rss/rssfeed.h +++ b/src/base/rss/rssfeed.h @@ -66,7 +66,7 @@ public: virtual void rename(const QString &alias); virtual QString displayName() const; QString url() const; - virtual QIcon icon() const; + virtual QString iconPath() const; bool hasCustomIcon() const; void setIconPath(const QString &pathHierarchy); RssArticlePtr getItem(const QString &guid) const; diff --git a/src/gui/rss/rssfile.cpp b/src/base/rss/rssfile.cpp similarity index 100% rename from src/gui/rss/rssfile.cpp rename to src/base/rss/rssfile.cpp index f41912484..ac090e0ee 100644 --- a/src/gui/rss/rssfile.cpp +++ b/src/base/rss/rssfile.cpp @@ -28,8 +28,8 @@ * Contact: chris@qbittorrent.org, arnaud@qbittorrent.org */ -#include "rssfile.h" #include "rssfolder.h" +#include "rssfile.h" QStringList RssFile::pathHierarchy() const { QStringList path; diff --git a/src/gui/rss/rssfile.h b/src/base/rss/rssfile.h similarity index 98% rename from src/gui/rss/rssfile.h rename to src/base/rss/rssfile.h index 3d8d95f4e..9b08d00f9 100644 --- a/src/gui/rss/rssfile.h +++ b/src/base/rss/rssfile.h @@ -31,7 +31,6 @@ #ifndef RSSFILE_H #define RSSFILE_H -#include #include #include #include @@ -55,7 +54,7 @@ public: virtual uint unreadCount() const = 0; virtual QString displayName() 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 markAsRead() = 0; virtual RssFolder* parent() const = 0; diff --git a/src/gui/rss/rssfolder.cpp b/src/base/rss/rssfolder.cpp similarity index 98% rename from src/gui/rss/rssfolder.cpp rename to src/base/rss/rssfolder.cpp index 12b16e6df..a76357623 100644 --- a/src/gui/rss/rssfolder.cpp +++ b/src/base/rss/rssfolder.cpp @@ -30,12 +30,12 @@ #include -#include "guiiconprovider.h" -#include "rssfolder.h" -#include "rssarticle.h" +#include "base/iconprovider.h" #include "base/bittorrent/session.h" #include "rssmanager.h" #include "rssfeed.h" +#include "rssarticle.h" +#include "rssfolder.h" RssFolder::RssFolder(RssFolder *parent, const QString &name): m_parent(parent), m_name(name) { } @@ -231,9 +231,9 @@ QString RssFolder::id() const 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) { diff --git a/src/gui/rss/rssfolder.h b/src/base/rss/rssfolder.h similarity index 98% rename from src/gui/rss/rssfolder.h rename to src/base/rss/rssfolder.h index b3210fbac..85e8c7ca0 100644 --- a/src/gui/rss/rssfolder.h +++ b/src/base/rss/rssfolder.h @@ -33,6 +33,7 @@ #include #include + #include "rssfile.h" class RssFolder; @@ -61,7 +62,7 @@ public: QHash getAllFeedsAsHash() const; virtual QString displayName() const; virtual QString id() const; - virtual QIcon icon() const; + virtual QString iconPath() const; bool hasChild(const QString &childId); virtual RssArticleList articleListByDateDesc() const; virtual RssArticleList unreadArticleListByDateDesc() const; diff --git a/src/gui/rss/rssmanager.cpp b/src/base/rss/rssmanager.cpp similarity index 99% rename from src/gui/rss/rssmanager.cpp rename to src/base/rss/rssmanager.cpp index 338c82d17..f00457189 100644 --- a/src/gui/rss/rssmanager.cpp +++ b/src/base/rss/rssmanager.cpp @@ -29,13 +29,14 @@ */ #include -#include "rssmanager.h" + #include "base/preferences.h" #include "base/bittorrent/session.h" #include "rssfeed.h" #include "rssarticle.h" #include "rssdownloadrulelist.h" #include "rssparser.h" +#include "rssmanager.h" static const int MSECS_PER_MIN = 60000; diff --git a/src/gui/rss/rssmanager.h b/src/base/rss/rssmanager.h similarity index 100% rename from src/gui/rss/rssmanager.h rename to src/base/rss/rssmanager.h diff --git a/src/gui/rss/rssparser.cpp b/src/base/rss/rssparser.cpp similarity index 98% rename from src/gui/rss/rssparser.cpp rename to src/base/rss/rssparser.cpp index e09023cea..5929684e4 100644 --- a/src/gui/rss/rssparser.cpp +++ b/src/base/rss/rssparser.cpp @@ -28,15 +28,14 @@ * Contact : chris@qbittorrent.org */ -#include "rssparser.h" -#include "base/utils/fs.h" - #include #include #include #include #include -#include + +#include "base/utils/fs.h" +#include "rssparser.h" struct ParsingJob { QString feedUrl; @@ -343,10 +342,7 @@ void RssParser::parseAtomArticle(QXmlStreamReader& xml, const QString& feedUrl, if (xml.isStartElement()) { if (xml.name() == "title") { - // Workaround for CDATA (QString cannot parse html escapes on it's own) - QTextDocument doc; - doc.setHtml(xml.readElementText()); - article["title"] = doc.toPlainText().trimmed(); + article["title"] = xml.readElementText().trimmed(); } else if (xml.name() == "link") { QString link = ( xml.attributes().isEmpty() ? diff --git a/src/gui/rss/rssparser.h b/src/base/rss/rssparser.h similarity index 99% rename from src/gui/rss/rssparser.h rename to src/base/rss/rssparser.h index bb3b2466f..23608127b 100644 --- a/src/gui/rss/rssparser.h +++ b/src/base/rss/rssparser.h @@ -31,12 +31,13 @@ #ifndef RSSPARSER_H #define RSSPARSER_H -#include "rssarticle.h" #include #include #include #include +#include "rssarticle.h" + struct ParsingJob; class RssParser : public QThread diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index bf5684a57..f087c9bec 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -36,10 +36,10 @@ #include "automatedrssdownloader.h" #include "ui_automatedrssdownloader.h" -#include "rssdownloadrulelist.h" +#include "base/rss/rssdownloadrulelist.h" #include "base/preferences.h" -#include "rssmanager.h" -#include "rssfeed.h" +#include "base/rss/rssmanager.h" +#include "base/rss/rssfeed.h" #include "guiiconprovider.h" #include "autoexpandabledialog.h" #include "base/utils/fs.h" diff --git a/src/gui/rss/automatedrssdownloader.h b/src/gui/rss/automatedrssdownloader.h index b3e409a88..ad7338ed5 100644 --- a/src/gui/rss/automatedrssdownloader.h +++ b/src/gui/rss/automatedrssdownloader.h @@ -35,7 +35,8 @@ #include #include #include -#include "rssdownloadrule.h" + +#include "base/rss/rssdownloadrule.h" QT_BEGIN_NAMESPACE namespace Ui { diff --git a/src/gui/rss/feedlistwidget.cpp b/src/gui/rss/feedlistwidget.cpp index f86ac9864..9c30274f0 100644 --- a/src/gui/rss/feedlistwidget.cpp +++ b/src/gui/rss/feedlistwidget.cpp @@ -28,10 +28,10 @@ * Contact: chris@qbittorrent.org, arnaud@qbittorrent.org */ -#include "feedlistwidget.h" -#include "rssmanager.h" -#include "rssfeed.h" +#include "core/rss/rssmanager.h" +#include "core/rss/rssfeed.h" #include "guiiconprovider.h" +#include "feedlistwidget.h" FeedListWidget::FeedListWidget(QWidget *parent, const RssManagerPtr& rssmanager): QTreeWidget(parent), m_rssManager(rssmanager) { setContextMenuPolicy(Qt::CustomContextMenu); diff --git a/src/gui/rss/feedlistwidget.h b/src/gui/rss/feedlistwidget.h index 89f99eb98..8e69df244 100644 --- a/src/gui/rss/feedlistwidget.h +++ b/src/gui/rss/feedlistwidget.h @@ -39,9 +39,9 @@ #include #include -#include "rssfile.h" -#include "rssfeed.h" -#include "rssmanager.h" +#include "base/rss/rssfile.h" +#include "base/rss/rssfeed.h" +#include "base/rss/rssmanager.h" class FeedListWidget: public QTreeWidget { Q_OBJECT diff --git a/src/gui/rss/rss.pri b/src/gui/rss/rss.pri index e4d91389b..01df487de 100644 --- a/src/gui/rss/rss.pri +++ b/src/gui/rss/rss.pri @@ -3,31 +3,15 @@ INCLUDEPATH += $$PWD HEADERS += $$PWD/rss_imp.h \ $$PWD/rsssettingsdlg.h \ $$PWD/feedlistwidget.h \ - $$PWD/rssmanager.h \ - $$PWD/rssfeed.h \ - $$PWD/rssfolder.h \ - $$PWD/rssfile.h \ - $$PWD/rssarticle.h \ $$PWD/automatedrssdownloader.h \ - $$PWD/rssdownloadrule.h \ - $$PWD/rssdownloadrulelist.h \ $$PWD/cookiesdlg.h \ - $$PWD/rssparser.h \ $$PWD/htmlbrowser.h SOURCES += $$PWD/rss_imp.cpp \ $$PWD/rsssettingsdlg.cpp \ $$PWD/feedlistwidget.cpp \ - $$PWD/rssmanager.cpp \ - $$PWD/rssfeed.cpp \ - $$PWD/rssfolder.cpp \ - $$PWD/rssarticle.cpp \ $$PWD/automatedrssdownloader.cpp \ - $$PWD/rssdownloadrule.cpp \ - $$PWD/rssdownloadrulelist.cpp \ $$PWD/cookiesdlg.cpp \ - $$PWD/rssfile.cpp \ - $$PWD/rssparser.cpp \ $$PWD/htmlbrowser.cpp FORMS += $$PWD/rss.ui \ diff --git a/src/gui/rss/rss_imp.cpp b/src/gui/rss/rss_imp.cpp index 2cda0096c..c5aa670bf 100644 --- a/src/gui/rss/rss_imp.cpp +++ b/src/gui/rss/rss_imp.cpp @@ -44,11 +44,11 @@ #include "cookiesdlg.h" #include "base/preferences.h" #include "rsssettingsdlg.h" -#include "rssmanager.h" -#include "rssfolder.h" -#include "rssarticle.h" -#include "rssparser.h" -#include "rssfeed.h" +#include "base/rss/rssmanager.h" +#include "base/rss/rssfolder.h" +#include "base/rss/rssarticle.h" +#include "base/rss/rssparser.h" +#include "base/rss/rssfeed.h" #include "automatedrssdownloader.h" #include "guiiconprovider.h" #include "autoexpandabledialog.h" @@ -478,7 +478,7 @@ QTreeWidgetItem* RSSImp::createFolderListItem(const RssFilePtr& rssFile) Q_ASSERT(rssFile); QTreeWidgetItem* item = new QTreeWidgetItem; 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; } @@ -680,7 +680,7 @@ void RSSImp::updateFeedInfos(const QString& url, const QString& display_name, ui RssFeedPtr stream = qSharedPointerCast(m_feedList->getRSSItem(item)); item->setText(0, display_name + QString::fromUtf8(" (") + QString::number(nbUnread) + QString(")")); if (!stream->isLoading()) - item->setData(0, Qt::DecorationRole, QVariant(stream->icon())); + item->setData(0, Qt::DecorationRole, QIcon(stream->iconPath())); // Update parent if (item->parent()) updateItemInfos(item->parent()); diff --git a/src/gui/rss/rss_imp.h b/src/gui/rss/rss_imp.h index 5754effd6..966de0006 100644 --- a/src/gui/rss/rss_imp.h +++ b/src/gui/rss/rss_imp.h @@ -35,9 +35,9 @@ #include #include +#include "base/rss/rssfolder.h" +#include "base/rss/rssmanager.h" #include "ui_rss.h" -#include "rssfolder.h" -#include "rssmanager.h" class FeedListWidget;