From 3d71264041523f4ab6ba03b1b6714fb449ebec05 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 8 Jan 2016 10:08:00 +0100 Subject: [PATCH] Some const - no time. --- src/core/feeddownloader.cpp | 17 +++++++++++++++-- src/core/feeddownloader.h | 16 ++++++++-------- src/core/feedsmodel.cpp | 4 ++-- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp index 22d331a31..fef8b0086 100755 --- a/src/core/feeddownloader.cpp +++ b/src/core/feeddownloader.cpp @@ -45,7 +45,7 @@ void FeedDownloader::updateFeeds(const QList &feeds) { int updated_messages = feeds.at(i)->update(); if (updated_messages > 0) { - results.m_updatedFeeds.append(QPair(feeds.at(i)->title(), updated_messages)); + results.updatedFeeds().append(QPair(feeds.at(i)->title(), updated_messages)); } qDebug("Made progress in feed updates: %d/%d (id of feed is %d).", i + 1, total, feeds.at(i)->id()); @@ -62,7 +62,12 @@ void FeedDownloader::updateFeeds(const QList &feeds) { } -QString FeedDownloadResults::getOverview(int how_many_feeds) { +FeedDownloadResults::FeedDownloadResults() : m_updatedFeeds(QList >()) { +} + + + +QString FeedDownloadResults::overview(int how_many_feeds) { qSort(m_updatedFeeds.begin(), m_updatedFeeds.end(), FeedDownloadResults::lessThan); QStringList result; @@ -79,3 +84,11 @@ QString FeedDownloadResults::getOverview(int how_many_feeds) { return res_str; } + +bool FeedDownloadResults::lessThan(const QPair &lhs, const QPair &rhs) { + return lhs.second > rhs.second; +} + +QList > &FeedDownloadResults::updatedFeeds() { + return m_updatedFeeds; +} diff --git a/src/core/feeddownloader.h b/src/core/feeddownloader.h index 88f8992b7..105103a19 100755 --- a/src/core/feeddownloader.h +++ b/src/core/feeddownloader.h @@ -26,16 +26,16 @@ class Feed; // Represents results of batch feed updates. -struct FeedDownloadResults { - explicit FeedDownloadResults() : m_updatedFeeds(QList >()) { - } +class FeedDownloadResults { + public: + explicit FeedDownloadResults(); - QString getOverview(int how_many_feeds); + QList > &updatedFeeds(); + QString overview(int how_many_feeds); - static bool lessThan(const QPair &lhs, const QPair &rhs) { - return lhs.second > rhs.second; - } + static bool lessThan(const QPair &lhs, const QPair &rhs); + private: // QString represents title if the feed, int represents count of newly downloaded messages. QList > m_updatedFeeds; }; @@ -69,7 +69,7 @@ class FeedDownloader : public QObject { // "Current" number indicates count of processed feeds // and "total" number indicates total number of feeds // which were in the initial queue. - void progress(Feed *feed, int current, int total); + void progress(const Feed *feed, int current, int total); }; #endif // FEEDDOWNLOADER_H diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 4e383ae22..85ad2f5a9 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -172,9 +172,9 @@ void FeedsModel::onFeedUpdatesFinished(FeedDownloadResults results) { qApp->feedUpdateLock()->unlock(); qApp->mainForm()->statusBar()->clearProgressFeeds(); - if (!results.m_updatedFeeds.isEmpty()) { + if (!results.updatedFeeds().isEmpty()) { // Now, inform about results via GUI message/notification. - qApp->showGuiMessage(tr("New messages downloaded"), results.getOverview(10), QSystemTrayIcon::NoIcon, + qApp->showGuiMessage(tr("New messages downloaded"), results.overview(10), QSystemTrayIcon::NoIcon, 0, false, qApp->icons()->fromTheme(QSL("item-update-all"))); }