Some const - no time.
This commit is contained in:
		
							parent
							
								
									f73d0eeb8c
								
							
						
					
					
						commit
						3d71264041
					
				
					 3 changed files with 25 additions and 12 deletions
				
			
		|  | @ -45,7 +45,7 @@ void FeedDownloader::updateFeeds(const QList<Feed*> &feeds) { | ||||||
|     int updated_messages = feeds.at(i)->update(); |     int updated_messages = feeds.at(i)->update(); | ||||||
| 
 | 
 | ||||||
|     if (updated_messages > 0) { |     if (updated_messages > 0) { | ||||||
|       results.m_updatedFeeds.append(QPair<QString,int>(feeds.at(i)->title(), updated_messages)); |       results.updatedFeeds().append(QPair<QString,int>(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()); |     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<Feed*> &feeds) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| QString FeedDownloadResults::getOverview(int how_many_feeds) { | FeedDownloadResults::FeedDownloadResults() : m_updatedFeeds(QList<QPair<QString,int> >()) { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | QString FeedDownloadResults::overview(int how_many_feeds) { | ||||||
|   qSort(m_updatedFeeds.begin(), m_updatedFeeds.end(), FeedDownloadResults::lessThan); |   qSort(m_updatedFeeds.begin(), m_updatedFeeds.end(), FeedDownloadResults::lessThan); | ||||||
| 
 | 
 | ||||||
|   QStringList result; |   QStringList result; | ||||||
|  | @ -79,3 +84,11 @@ QString FeedDownloadResults::getOverview(int how_many_feeds) { | ||||||
| 
 | 
 | ||||||
|   return res_str; |   return res_str; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | bool FeedDownloadResults::lessThan(const QPair<QString, int> &lhs, const QPair<QString, int> &rhs) { | ||||||
|  |   return lhs.second > rhs.second; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | QList<QPair<QString,int> > &FeedDownloadResults::updatedFeeds() { | ||||||
|  |   return m_updatedFeeds; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -26,16 +26,16 @@ | ||||||
| class Feed; | class Feed; | ||||||
| 
 | 
 | ||||||
| // Represents results of batch feed updates.
 | // Represents results of batch feed updates.
 | ||||||
| struct FeedDownloadResults { | class FeedDownloadResults { | ||||||
|     explicit FeedDownloadResults() : m_updatedFeeds(QList<QPair<QString,int> >()) { |   public: | ||||||
|     } |     explicit FeedDownloadResults(); | ||||||
| 
 | 
 | ||||||
|     QString getOverview(int how_many_feeds); |     QList<QPair<QString,int> > &updatedFeeds(); | ||||||
|  |     QString overview(int how_many_feeds); | ||||||
| 
 | 
 | ||||||
|     static bool lessThan(const QPair<QString,int> &lhs, const QPair<QString,int> &rhs) { |     static bool lessThan(const QPair<QString,int> &lhs, const QPair<QString,int> &rhs); | ||||||
|       return lhs.second > rhs.second; |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|  |   private: | ||||||
|     // QString represents title if the feed, int represents count of newly downloaded messages.
 |     // QString represents title if the feed, int represents count of newly downloaded messages.
 | ||||||
|     QList<QPair<QString,int> > m_updatedFeeds; |     QList<QPair<QString,int> > m_updatedFeeds; | ||||||
| }; | }; | ||||||
|  | @ -69,7 +69,7 @@ class FeedDownloader : public QObject { | ||||||
|     // "Current" number indicates count of processed feeds
 |     // "Current" number indicates count of processed feeds
 | ||||||
|     // and "total" number indicates total number of feeds
 |     // and "total" number indicates total number of feeds
 | ||||||
|     // which were in the initial queue.
 |     // 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
 | #endif // FEEDDOWNLOADER_H
 | ||||||
|  |  | ||||||
|  | @ -172,9 +172,9 @@ void FeedsModel::onFeedUpdatesFinished(FeedDownloadResults results) { | ||||||
|   qApp->feedUpdateLock()->unlock(); |   qApp->feedUpdateLock()->unlock(); | ||||||
|   qApp->mainForm()->statusBar()->clearProgressFeeds(); |   qApp->mainForm()->statusBar()->clearProgressFeeds(); | ||||||
| 
 | 
 | ||||||
|   if (!results.m_updatedFeeds.isEmpty()) { |   if (!results.updatedFeeds().isEmpty()) { | ||||||
|     // Now, inform about results via GUI message/notification.
 |     // 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"))); |                          0, false, qApp->icons()->fromTheme(QSL("item-update-all"))); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue