implemented #745

This commit is contained in:
Martin Rotter 2022-12-03 09:42:26 +01:00
parent f77ed37c89
commit 6877044a57
4 changed files with 23 additions and 14 deletions

View File

@ -391,7 +391,7 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
<< " stored in DB.";
if (updated_messages.first > 0) {
m_results.appendUpdatedFeed({feed->title(), updated_messages.first});
m_results.appendUpdatedFeed({feed, updated_messages.first});
}
}
catch (const FeedFetchException& feed_ex) {
@ -500,7 +500,7 @@ QString FeedDownloadResults::overview(int how_many_feeds) const {
QStringList result;
for (int i = 0, number_items_output = qMin(how_many_feeds, m_updatedFeeds.size()); i < number_items_output; i++) {
result.append(m_updatedFeeds.at(i).first + QSL(": ") + QString::number(m_updatedFeeds.at(i).second));
result.append(m_updatedFeeds.at(i).first->title() + QSL(": ") + QString::number(m_updatedFeeds.at(i).second));
}
QString res_str = result.join(QSL("\n"));
@ -512,14 +512,14 @@ QString FeedDownloadResults::overview(int how_many_feeds) const {
return res_str;
}
void FeedDownloadResults::appendUpdatedFeed(const QPair<QString, int>& feed) {
void FeedDownloadResults::appendUpdatedFeed(const QPair<Feed*, int>& feed) {
m_updatedFeeds.append(feed);
}
void FeedDownloadResults::sort() {
std::sort(m_updatedFeeds.begin(),
m_updatedFeeds.end(),
[](const QPair<QString, int>& lhs, const QPair<QString, int>& rhs) {
[](const QPair<Feed*, int>& lhs, const QPair<Feed*, int>& rhs) {
return lhs.second > rhs.second;
});
}
@ -528,6 +528,6 @@ void FeedDownloadResults::clear() {
m_updatedFeeds.clear();
}
QList<QPair<QString, int>> FeedDownloadResults::updatedFeeds() const {
QList<QPair<Feed*, int>> FeedDownloadResults::updatedFeeds() const {
return m_updatedFeeds;
}

View File

@ -18,16 +18,16 @@ class QMutex;
// Represents results of batch feed updates.
class FeedDownloadResults {
public:
QList<QPair<QString, int>> updatedFeeds() const;
QList<QPair<Feed*, int>> updatedFeeds() const;
QString overview(int how_many_feeds) const;
void appendUpdatedFeed(const QPair<QString, int>& feed);
void appendUpdatedFeed(const QPair<Feed*, int>& feed);
void sort();
void clear();
private:
// QString represents title if the feed, int represents count of newly downloaded messages.
QList<QPair<QString, int>> m_updatedFeeds;
QList<QPair<Feed*, int>> m_updatedFeeds;
};
// This class offers means to "update" feeds and "special" categories.

View File

@ -890,7 +890,12 @@ void Application::onFeedUpdatesProgress(const Feed* feed, int current, int total
}
void Application::onFeedUpdatesFinished(const FeedDownloadResults& results) {
if (!results.updatedFeeds().isEmpty()) {
auto fds = results.updatedFeeds();
bool some_unquiet_feed = boolinq::from(fds).any([](const QPair<Feed*, int>& fd) {
return !fd.first->isQuiet();
});
if (some_unquiet_feed) {
// Now, inform about results via GUI message/notification.
qApp->showGuiMessage(Notification::Event::NewUnreadArticlesFetched,
{tr("Unread articles fetched"), results.overview(10), QSystemTrayIcon::MessageIcon::NoIcon});

View File

@ -336,11 +336,15 @@ void FeedReader::executeNextAutoUpdate() {
// Request update for given feeds.
updateFeeds(feeds_for_update);
// NOTE: OSD/bubble informing about performing of scheduled update can be shown now.
qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted,
{tr("Starting auto-download of some feeds' articles"),
tr("I will auto-download new articles for %n feed(s).", nullptr, feeds_for_update.size()),
QSystemTrayIcon::MessageIcon::Information});
if (boolinq::from(feeds_for_update).any([](const Feed* fd) {
return !fd->isQuiet();
})) {
// NOTE: OSD/bubble informing about performing of scheduled update can be shown now.
qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted,
{tr("Starting auto-download of some feeds' articles"),
tr("I will auto-download new articles for %n feed(s).", nullptr, feeds_for_update.size()),
QSystemTrayIcon::MessageIcon::Information});
}
}
}