Skip to content

Commit

Permalink
Follow project coding style. Issue #2192.
Browse files Browse the repository at this point in the history
--HG--
branch : magao-dev
  • Loading branch information
magao committed Jan 8, 2017
1 parent 33ada71 commit 70ce123
Show file tree
Hide file tree
Showing 8 changed files with 632 additions and 634 deletions.
4 changes: 2 additions & 2 deletions src/base/rss/rssdownloadrule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool DownloadRule::matches(const QString &articleTitle) const
pos = reg.indexIn(articleTitle);
if (pos != -1) {
int epTheirs = reg.cap(1).toInt();
if (epOursFirst <= epTheirs && epOursLast >= epTheirs)
if ((epOursFirst <= epTheirs) && (epOursLast >= epTheirs))
return true;
}
}
Expand Down Expand Up @@ -300,7 +300,7 @@ QStringList DownloadRule::findMatchingArticles(const FeedPtr &feed) const

ArticleHash::ConstIterator artIt = feedArticles.begin();
ArticleHash::ConstIterator artItend = feedArticles.end();
for ( ; artIt != artItend ; ++artIt) {
for (; artIt != artItend; ++artIt) {
const QString title = artIt.value()->title();
if (matches(title))
ret << title;
Expand Down
28 changes: 11 additions & 17 deletions src/base/rss/rssfeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Feed::Feed(const QString &url, Manager *manager)

// Download the RSS Feed icon
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(iconUrl(), true);
connect(handler, SIGNAL(downloadFinished(QString, QString)), this, SLOT(handleIconDownloadFinished(QString, QString)));
connect(handler, SIGNAL(downloadFinished(QString,QString)), this, SLOT(handleIconDownloadFinished(QString,QString)));

// Load old RSS articles
loadItemsFromDisk();
Expand All @@ -104,9 +104,8 @@ void Feed::saveItemsToDisk()

ArticleHash::ConstIterator it = m_articles.begin();
ArticleHash::ConstIterator itend = m_articles.end();
for ( ; it != itend; ++it) {
for (; it != itend; ++it)
oldItems << it.value()->toHash();
}
qDebug("Saving %d old items for feed %s", oldItems.size(), qPrintable(displayName()));
QHash<QString, QVariant> allOldItems = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash();
allOldItems[m_url] = oldItems;
Expand Down Expand Up @@ -155,20 +154,18 @@ void Feed::addArticle(const ArticlePtr &article)
}

// Check if article was inserted at the end of the list and will break max_articles limit
if (Preferences::instance()->isRssDownloadingEnabled()) {
if (Preferences::instance()->isRssDownloadingEnabled())
if ((lbIndex < maxArticles) && !article->isRead())
downloadArticleTorrentIfMatching(article);
}
}
else {
// m_articles.contains(article->guid())
// Try to download skipped articles
if (Preferences::instance()->isRssDownloadingEnabled()) {
ArticlePtr skipped = m_articles.value(article->guid(), ArticlePtr());
if (skipped) {
if (skipped)
if (!skipped->isRead())
downloadArticleTorrentIfMatching(skipped);
}
}
}
}
Expand All @@ -182,8 +179,8 @@ bool Feed::refresh()
m_loading = true;
// Download the RSS again
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(m_url);
connect(handler, SIGNAL(downloadFinished(QString, QByteArray)), this, SLOT(handleRssDownloadFinished(QString, QByteArray)));
connect(handler, SIGNAL(downloadFailed(QString, QString)), this, SLOT(handleRssDownloadFailed(QString, QString)));
connect(handler, SIGNAL(downloadFinished(QString,QByteArray)), this, SLOT(handleRssDownloadFinished(QString,QByteArray)));
connect(handler, SIGNAL(downloadFailed(QString,QString)), this, SLOT(handleRssDownloadFailed(QString,QString)));
return true;
}

Expand Down Expand Up @@ -260,7 +257,7 @@ bool Feed::hasCustomIcon() const
void Feed::setIconPath(const QString &path)
{
QString nativePath = Utils::Fs::fromNativePath(path);
if (nativePath == m_icon || nativePath.isEmpty() || !QFile::exists(nativePath)) return;
if ((nativePath == m_icon) || nativePath.isEmpty() || !QFile::exists(nativePath)) return;

if (!m_icon.startsWith(":/") && QFile::exists(m_icon))
Utils::Fs::forceRemove(m_icon);
Expand All @@ -282,9 +279,8 @@ void Feed::markAsRead()
{
ArticleHash::ConstIterator it = m_articles.begin();
ArticleHash::ConstIterator itend = m_articles.end();
for ( ; it != itend; ++it) {
for (; it != itend; ++it)
it.value()->markAsRead();
}
m_unreadCount = 0;
m_manager->forwardFeedInfosChanged(m_url, displayName(), 0);
}
Expand All @@ -310,10 +306,9 @@ ArticleList Feed::unreadArticleListByDateDesc() const

ArticleList::ConstIterator it = m_articlesByDate.begin();
ArticleList::ConstIterator itend = m_articlesByDate.end();
for ( ; it != itend; ++it) {
for (; it != itend; ++it)
if (!(*it)->isRead())
unreadNews << *it;
}
return unreadNews;
}

Expand Down Expand Up @@ -407,10 +402,9 @@ void Feed::downloadArticleTorrentIfMatching(const ArticlePtr &article)
void Feed::recheckRssItemsForDownload()
{
Q_ASSERT(Preferences::instance()->isRssDownloadingEnabled());
foreach (const ArticlePtr &article, m_articlesByDate) {
foreach (const ArticlePtr &article, m_articlesByDate)
if (!article->isRead())
downloadArticleTorrentIfMatching(article);
}
}

void Feed::handleNewArticle(const QVariantHash &articleData)
Expand All @@ -426,7 +420,7 @@ void Feed::handleNewArticle(const QVariantHash &articleData)
m_manager->forwardFeedInfosChanged(m_url, displayName(), m_unreadCount);
// FIXME: We should forward the information here but this would seriously decrease
// performance with current design.
//m_manager->forwardFeedContentChanged(m_url);
// m_manager->forwardFeedContentChanged(m_url);
}

void Feed::handleParsingFinished(const QString &error)
Expand Down
2 changes: 1 addition & 1 deletion src/base/rss/rssfeed.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace Rss
Q_OBJECT

public:
Feed(const QString &url, Manager *manager);
Feed(const QString &url, Manager * manager);
~Feed();

bool refresh();
Expand Down
Loading

0 comments on commit 70ce123

Please sign in to comment.