mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 11:40:33 +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(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
|
||||
m_rssManager->refresh();
|
||||
|
@ -129,9 +129,12 @@ void RssDownloadRule::setSavePath(const QString &save_path)
|
||||
QStringList RssDownloadRule::findMatchingArticles(const RssFeed *feed) const
|
||||
{
|
||||
QStringList ret;
|
||||
foreach(const RssArticle &art, feed->articleList()) {
|
||||
if(matches(art.title()))
|
||||
ret << art.title();
|
||||
const QHash<QString, RssArticle>& feed_articles = feed->articleListNoCopy();
|
||||
QHash<QString, RssArticle>::const_iterator artIt;
|
||||
for(artIt = feed_articles.begin(); artIt != feed_articles.end(); artIt++) {
|
||||
const QString title = artIt.value().title();
|
||||
if(matches(title))
|
||||
ret << title;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ void RssDownloadRuleList::drop()
|
||||
RssDownloadRule RssDownloadRuleList::findMatchingRule(const QString &feed_url, const QString &article_title) const
|
||||
{
|
||||
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) {
|
||||
RssDownloadRule rule = m_rules[rule_name];
|
||||
const RssDownloadRule &rule = m_rules[rule_name];
|
||||
if(rule.isEnabled() && rule.matches(article_title)) return rule;
|
||||
}
|
||||
return RssDownloadRule();
|
||||
@ -172,9 +172,10 @@ void RssDownloadRuleList::renameRule(const QString &old_name, const QString &new
|
||||
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)
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
void saveRule(const RssDownloadRule &rule);
|
||||
void removeRule(const QString &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 bool isEmpty() const { return m_rules.isEmpty(); }
|
||||
bool serialize(const QString& path);
|
||||
@ -67,7 +67,6 @@ private:
|
||||
void loadRulesFromVariantHash(const QVariantHash& l);
|
||||
QVariantHash toVariantHash() const;
|
||||
void saveRulesToStorage();
|
||||
inline QStringList feedRules(const QString &feed_url) const { return m_feedRules[feed_url]; }
|
||||
|
||||
private:
|
||||
QHash<QString, RssDownloadRule> m_rules;
|
||||
|
@ -162,7 +162,7 @@ RssArticle& RssFeed::getItem(const QString &id) {
|
||||
return m_articles[id];
|
||||
}
|
||||
|
||||
unsigned int RssFeed::getNbNews() const{
|
||||
uint RssFeed::count() const{
|
||||
return m_articles.size();
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ void RssFeed::markAsRead() {
|
||||
RssManager::instance()->forwardFeedInfosChanged(m_url, displayName(), 0);
|
||||
}
|
||||
|
||||
unsigned int RssFeed::unreadCount() const{
|
||||
uint RssFeed::unreadCount() const{
|
||||
uint nbUnread=0;
|
||||
foreach(const RssArticle &item, m_articles.values()) {
|
||||
if(!item.isRead())
|
||||
|
@ -60,10 +60,11 @@ public:
|
||||
bool hasCustomIcon() const;
|
||||
void setIconPath(const QString &pathHierarchy);
|
||||
RssArticle& getItem(const QString &name);
|
||||
unsigned int getNbNews() const;
|
||||
uint count() const;
|
||||
void markAsRead();
|
||||
unsigned int unreadCount() const;
|
||||
uint unreadCount() const;
|
||||
QList<RssArticle> articleList() const;
|
||||
const QHash<QString, RssArticle>& articleListNoCopy() const { return m_articles; }
|
||||
QList<RssArticle> unreadArticleList() const;
|
||||
|
||||
signals:
|
||||
|
Loading…
Reference in New Issue
Block a user