Follow project coding style. Issue #2192.

--HG--
branch : magao-dev
This commit is contained in:
Tim Delaney
2017-01-08 11:46:01 +11:00
parent 33ada71e4b
commit 70ce12372d
8 changed files with 628 additions and 630 deletions

View File

@@ -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();
@@ -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;
@@ -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);
}
}
}
}
@@ -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;
}
@@ -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);
@@ -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);
}
@@ -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;
}
@@ -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)
@@ -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)