mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 09:55:55 +00:00
Rss code clean up
This commit is contained in:
parent
87174ef3a4
commit
74c32a0ecd
@ -648,7 +648,7 @@ RSSImp::RSSImp(QWidget *parent) : QWidget(parent) {
|
|||||||
connect(m_feedList, SIGNAL(overwriteAttempt(QString)), this, SLOT(displayOverwriteError(QString)));
|
connect(m_feedList, SIGNAL(overwriteAttempt(QString)), this, SLOT(displayOverwriteError(QString)));
|
||||||
|
|
||||||
connect(listArticles, SIGNAL(itemSelectionChanged()), this, SLOT(refreshTextBrowser()));
|
connect(listArticles, SIGNAL(itemSelectionChanged()), this, SLOT(refreshTextBrowser()));
|
||||||
connect(listArticles, SIGNAL(itemDoubleClicked(QListWidgetItem *, int)), this, SLOT(downloadTorrent()));
|
connect(listArticles, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(downloadTorrent()));
|
||||||
|
|
||||||
// Refresh all feeds
|
// Refresh all feeds
|
||||||
m_rssManager->refresh();
|
m_rssManager->refresh();
|
||||||
|
@ -129,9 +129,12 @@ void RssDownloadRule::setSavePath(const QString &save_path)
|
|||||||
QStringList RssDownloadRule::findMatchingArticles(const RssFeed *feed) const
|
QStringList RssDownloadRule::findMatchingArticles(const RssFeed *feed) const
|
||||||
{
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
foreach(const RssArticle &art, feed->articleList()) {
|
const QHash<QString, RssArticle>& feed_articles = feed->articleListNoCopy();
|
||||||
if(matches(art.title()))
|
QHash<QString, RssArticle>::const_iterator artIt;
|
||||||
ret << art.title();
|
for(artIt = feed_articles.begin(); artIt != feed_articles.end(); artIt++) {
|
||||||
|
const QString title = artIt.value().title();
|
||||||
|
if(matches(title))
|
||||||
|
ret << title;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,9 @@ void RssDownloadRuleList::drop()
|
|||||||
RssDownloadRule RssDownloadRuleList::findMatchingRule(const QString &feed_url, const QString &article_title) const
|
RssDownloadRule RssDownloadRuleList::findMatchingRule(const QString &feed_url, const QString &article_title) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(RssSettings().isRssDownloadingEnabled());
|
Q_ASSERT(RssSettings().isRssDownloadingEnabled());
|
||||||
QStringList rule_names = feedRules(feed_url);
|
const QStringList rule_names = m_feedRules.value(feed_url);
|
||||||
foreach(const QString &rule_name, rule_names) {
|
foreach(const QString &rule_name, rule_names) {
|
||||||
RssDownloadRule rule = m_rules[rule_name];
|
const RssDownloadRule &rule = m_rules[rule_name];
|
||||||
if(rule.isEnabled() && rule.matches(article_title)) return rule;
|
if(rule.isEnabled() && rule.matches(article_title)) return rule;
|
||||||
}
|
}
|
||||||
return RssDownloadRule();
|
return RssDownloadRule();
|
||||||
@ -172,9 +172,10 @@ void RssDownloadRuleList::renameRule(const QString &old_name, const QString &new
|
|||||||
saveRulesToStorage();
|
saveRulesToStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
RssDownloadRule RssDownloadRuleList::getRule(const QString &name) const
|
const RssDownloadRule RssDownloadRuleList::getRule(const QString &name) const
|
||||||
{
|
{
|
||||||
return m_rules.value(name);
|
Q_ASSERT(m_rules.contains(name));
|
||||||
|
return m_rules[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RssDownloadRuleList::serialize(const QString& path)
|
bool RssDownloadRuleList::serialize(const QString& path)
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
void saveRule(const RssDownloadRule &rule);
|
void saveRule(const RssDownloadRule &rule);
|
||||||
void removeRule(const QString &name);
|
void removeRule(const QString &name);
|
||||||
void renameRule(const QString &old_name, const QString &new_name);
|
void renameRule(const QString &old_name, const QString &new_name);
|
||||||
RssDownloadRule getRule(const QString &name) const;
|
const RssDownloadRule getRule(const QString &name) const;
|
||||||
inline QStringList ruleNames() const { return m_rules.keys(); }
|
inline QStringList ruleNames() const { return m_rules.keys(); }
|
||||||
inline bool isEmpty() const { return m_rules.isEmpty(); }
|
inline bool isEmpty() const { return m_rules.isEmpty(); }
|
||||||
bool serialize(const QString& path);
|
bool serialize(const QString& path);
|
||||||
@ -67,7 +67,6 @@ private:
|
|||||||
void loadRulesFromVariantHash(const QVariantHash& l);
|
void loadRulesFromVariantHash(const QVariantHash& l);
|
||||||
QVariantHash toVariantHash() const;
|
QVariantHash toVariantHash() const;
|
||||||
void saveRulesToStorage();
|
void saveRulesToStorage();
|
||||||
inline QStringList feedRules(const QString &feed_url) const { return m_feedRules[feed_url]; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QString, RssDownloadRule> m_rules;
|
QHash<QString, RssDownloadRule> m_rules;
|
||||||
|
@ -162,7 +162,7 @@ RssArticle& RssFeed::getItem(const QString &id) {
|
|||||||
return m_articles[id];
|
return m_articles[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int RssFeed::getNbNews() const{
|
uint RssFeed::count() const{
|
||||||
return m_articles.size();
|
return m_articles.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ void RssFeed::markAsRead() {
|
|||||||
RssManager::instance()->forwardFeedInfosChanged(m_url, displayName(), 0);
|
RssManager::instance()->forwardFeedInfosChanged(m_url, displayName(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int RssFeed::unreadCount() const{
|
uint RssFeed::unreadCount() const{
|
||||||
uint nbUnread=0;
|
uint nbUnread=0;
|
||||||
foreach(const RssArticle &item, m_articles.values()) {
|
foreach(const RssArticle &item, m_articles.values()) {
|
||||||
if(!item.isRead())
|
if(!item.isRead())
|
||||||
|
@ -60,10 +60,11 @@ public:
|
|||||||
bool hasCustomIcon() const;
|
bool hasCustomIcon() const;
|
||||||
void setIconPath(const QString &pathHierarchy);
|
void setIconPath(const QString &pathHierarchy);
|
||||||
RssArticle& getItem(const QString &name);
|
RssArticle& getItem(const QString &name);
|
||||||
unsigned int getNbNews() const;
|
uint count() const;
|
||||||
void markAsRead();
|
void markAsRead();
|
||||||
unsigned int unreadCount() const;
|
uint unreadCount() const;
|
||||||
QList<RssArticle> articleList() const;
|
QList<RssArticle> articleList() const;
|
||||||
|
const QHash<QString, RssArticle>& articleListNoCopy() const { return m_articles; }
|
||||||
QList<RssArticle> unreadArticleList() const;
|
QList<RssArticle> unreadArticleList() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user