mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-12 07:48:04 +00:00
Merge pull request #6176 from magao/issue873
Improve UI responsiveness during RSS downloading. Closes #873, #1089, #1235, #5423
This commit is contained in:
commit
179b686e42
@ -361,6 +361,14 @@ void Feed::handleFeedTitle(const QString &title)
|
|||||||
void Feed::downloadArticleTorrentIfMatching(const ArticlePtr &article)
|
void Feed::downloadArticleTorrentIfMatching(const ArticlePtr &article)
|
||||||
{
|
{
|
||||||
Q_ASSERT(Preferences::instance()->isRssDownloadingEnabled());
|
Q_ASSERT(Preferences::instance()->isRssDownloadingEnabled());
|
||||||
|
qDebug().nospace() << Q_FUNC_INFO << " Deferring matching of " << article->title() << " from " << displayName() << " RSS feed";
|
||||||
|
m_manager->downloadArticleTorrentIfMatching(m_url, article);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Feed::deferredDownloadArticleTorrentIfMatching(const ArticlePtr &article)
|
||||||
|
{
|
||||||
|
qDebug().nospace() << Q_FUNC_INFO << " Matching of " << article->title() << " from " << displayName() << " RSS feed";
|
||||||
|
|
||||||
DownloadRuleList *rules = m_manager->downloadRules();
|
DownloadRuleList *rules = m_manager->downloadRules();
|
||||||
DownloadRulePtr matchingRule = rules->findMatchingRule(m_url, article->title());
|
DownloadRulePtr matchingRule = rules->findMatchingRule(m_url, article->title());
|
||||||
if (!matchingRule) return;
|
if (!matchingRule) return;
|
||||||
|
@ -98,10 +98,13 @@ namespace Rss
|
|||||||
void handleArticleRead();
|
void handleArticleRead();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class Manager;
|
||||||
|
|
||||||
QString iconUrl() const;
|
QString iconUrl() const;
|
||||||
void loadItemsFromDisk();
|
void loadItemsFromDisk();
|
||||||
void addArticle(const ArticlePtr &article);
|
void addArticle(const ArticlePtr &article);
|
||||||
void downloadArticleTorrentIfMatching(const ArticlePtr &article);
|
void downloadArticleTorrentIfMatching(const ArticlePtr &article);
|
||||||
|
void deferredDownloadArticleTorrentIfMatching(const ArticlePtr &article);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Manager *m_manager;
|
Manager *m_manager;
|
||||||
|
@ -54,6 +54,10 @@ Manager::Manager(QObject *parent)
|
|||||||
connect(&m_refreshTimer, SIGNAL(timeout()), SLOT(refresh()));
|
connect(&m_refreshTimer, SIGNAL(timeout()), SLOT(refresh()));
|
||||||
m_refreshInterval = Preferences::instance()->getRSSRefreshInterval();
|
m_refreshInterval = Preferences::instance()->getRSSRefreshInterval();
|
||||||
m_refreshTimer.start(m_refreshInterval * MSECS_PER_MIN);
|
m_refreshTimer.start(m_refreshInterval * MSECS_PER_MIN);
|
||||||
|
|
||||||
|
m_deferredDownloadTimer.setInterval(1);
|
||||||
|
m_deferredDownloadTimer.setSingleShot(true);
|
||||||
|
connect(&m_deferredDownloadTimer, SIGNAL(timeout()), SLOT(downloadNextArticleTorrentIfMatching()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::~Manager()
|
Manager::~Manager()
|
||||||
@ -72,7 +76,7 @@ void Manager::updateRefreshInterval(uint val)
|
|||||||
{
|
{
|
||||||
if (m_refreshInterval != val) {
|
if (m_refreshInterval != val) {
|
||||||
m_refreshInterval = val;
|
m_refreshInterval = val;
|
||||||
m_refreshTimer.start(m_refreshInterval*60000);
|
m_refreshTimer.start(m_refreshInterval * 60000);
|
||||||
qDebug("New RSS refresh interval is now every %dmin", m_refreshInterval);
|
qDebug("New RSS refresh interval is now every %dmin", m_refreshInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +85,7 @@ void Manager::loadStreamList()
|
|||||||
{
|
{
|
||||||
const Preferences *const pref = Preferences::instance();
|
const Preferences *const pref = Preferences::instance();
|
||||||
const QStringList streamsUrl = pref->getRssFeedsUrls();
|
const QStringList streamsUrl = pref->getRssFeedsUrls();
|
||||||
const QStringList aliases = pref->getRssFeedsAliases();
|
const QStringList aliases = pref->getRssFeedsAliases();
|
||||||
if (streamsUrl.size() != aliases.size()) {
|
if (streamsUrl.size() != aliases.size()) {
|
||||||
Logger::instance()->addMessage("Corrupted RSS list, not loading it.", Log::WARNING);
|
Logger::instance()->addMessage("Corrupted RSS list, not loading it.", Log::WARNING);
|
||||||
return;
|
return;
|
||||||
@ -188,3 +192,27 @@ void Manager::refresh()
|
|||||||
{
|
{
|
||||||
m_rootFolder->refresh();
|
m_rootFolder->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Manager::downloadArticleTorrentIfMatching(const QString &url, const ArticlePtr &article)
|
||||||
|
{
|
||||||
|
m_deferredDownloads.append(qMakePair(url, article));
|
||||||
|
m_deferredDownloadTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::downloadNextArticleTorrentIfMatching()
|
||||||
|
{
|
||||||
|
if (m_deferredDownloads.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Schedule to process the next article (if any)
|
||||||
|
m_deferredDownloadTimer.start();
|
||||||
|
|
||||||
|
QPair<QString, ArticlePtr> urlArticle(m_deferredDownloads.takeFirst());
|
||||||
|
FeedList streams = m_rootFolder->getAllFeeds();
|
||||||
|
foreach (const FeedPtr &stream, streams) {
|
||||||
|
if (stream->url() == urlArticle.first) {
|
||||||
|
stream->deferredDownloadArticleTorrentIfMatching(urlArticle.second);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -32,19 +32,23 @@
|
|||||||
#ifndef RSSMANAGER_H
|
#ifndef RSSMANAGER_H
|
||||||
#define RSSMANAGER_H
|
#define RSSMANAGER_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QPair>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
namespace Rss
|
namespace Rss
|
||||||
{
|
{
|
||||||
|
class Article;
|
||||||
class DownloadRuleList;
|
class DownloadRuleList;
|
||||||
class File;
|
class File;
|
||||||
class Folder;
|
class Folder;
|
||||||
class Feed;
|
class Feed;
|
||||||
class Manager;
|
class Manager;
|
||||||
|
|
||||||
|
typedef QSharedPointer<Article> ArticlePtr;
|
||||||
typedef QSharedPointer<File> FilePtr;
|
typedef QSharedPointer<File> FilePtr;
|
||||||
typedef QSharedPointer<Folder> FolderPtr;
|
typedef QSharedPointer<Folder> FolderPtr;
|
||||||
typedef QSharedPointer<Feed> FeedPtr;
|
typedef QSharedPointer<Feed> FeedPtr;
|
||||||
@ -62,6 +66,7 @@ namespace Rss
|
|||||||
DownloadRuleList *downloadRules() const;
|
DownloadRuleList *downloadRules() const;
|
||||||
FolderPtr rootFolder() const;
|
FolderPtr rootFolder() const;
|
||||||
QThread *workingThread() const;
|
QThread *workingThread() const;
|
||||||
|
void downloadArticleTorrentIfMatching(const QString &url, const ArticlePtr &article);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void refresh();
|
void refresh();
|
||||||
@ -78,12 +83,17 @@ namespace Rss
|
|||||||
void feedInfosChanged(const QString &url, const QString &displayName, uint unreadCount);
|
void feedInfosChanged(const QString &url, const QString &displayName, uint unreadCount);
|
||||||
void feedIconChanged(const QString &url, const QString &iconPath);
|
void feedIconChanged(const QString &url, const QString &iconPath);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void downloadNextArticleTorrentIfMatching();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer m_refreshTimer;
|
QTimer m_refreshTimer;
|
||||||
uint m_refreshInterval;
|
uint m_refreshInterval;
|
||||||
DownloadRuleList *m_downloadRules;
|
DownloadRuleList *m_downloadRules;
|
||||||
FolderPtr m_rootFolder;
|
FolderPtr m_rootFolder;
|
||||||
QThread *m_workingThread;
|
QThread *m_workingThread;
|
||||||
|
QTimer m_deferredDownloadTimer;
|
||||||
|
QList<QPair<QString, ArticlePtr>> m_deferredDownloads;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user