implemented #745
This commit is contained in:
parent
f77ed37c89
commit
6877044a57
@ -391,7 +391,7 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
|
|||||||
<< " stored in DB.";
|
<< " stored in DB.";
|
||||||
|
|
||||||
if (updated_messages.first > 0) {
|
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) {
|
catch (const FeedFetchException& feed_ex) {
|
||||||
@ -500,7 +500,7 @@ QString FeedDownloadResults::overview(int how_many_feeds) const {
|
|||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
||||||
for (int i = 0, number_items_output = qMin(how_many_feeds, m_updatedFeeds.size()); i < number_items_output; i++) {
|
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"));
|
QString res_str = result.join(QSL("\n"));
|
||||||
@ -512,14 +512,14 @@ QString FeedDownloadResults::overview(int how_many_feeds) const {
|
|||||||
return res_str;
|
return res_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedDownloadResults::appendUpdatedFeed(const QPair<QString, int>& feed) {
|
void FeedDownloadResults::appendUpdatedFeed(const QPair<Feed*, int>& feed) {
|
||||||
m_updatedFeeds.append(feed);
|
m_updatedFeeds.append(feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedDownloadResults::sort() {
|
void FeedDownloadResults::sort() {
|
||||||
std::sort(m_updatedFeeds.begin(),
|
std::sort(m_updatedFeeds.begin(),
|
||||||
m_updatedFeeds.end(),
|
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;
|
return lhs.second > rhs.second;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -528,6 +528,6 @@ void FeedDownloadResults::clear() {
|
|||||||
m_updatedFeeds.clear();
|
m_updatedFeeds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QPair<QString, int>> FeedDownloadResults::updatedFeeds() const {
|
QList<QPair<Feed*, int>> FeedDownloadResults::updatedFeeds() const {
|
||||||
return m_updatedFeeds;
|
return m_updatedFeeds;
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,16 @@ class QMutex;
|
|||||||
// Represents results of batch feed updates.
|
// Represents results of batch feed updates.
|
||||||
class FeedDownloadResults {
|
class FeedDownloadResults {
|
||||||
public:
|
public:
|
||||||
QList<QPair<QString, int>> updatedFeeds() const;
|
QList<QPair<Feed*, int>> updatedFeeds() const;
|
||||||
QString overview(int how_many_feeds) 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 sort();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
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<Feed*, int>> m_updatedFeeds;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class offers means to "update" feeds and "special" categories.
|
// This class offers means to "update" feeds and "special" categories.
|
||||||
|
@ -890,7 +890,12 @@ void Application::onFeedUpdatesProgress(const Feed* feed, int current, int total
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Application::onFeedUpdatesFinished(const FeedDownloadResults& results) {
|
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.
|
// Now, inform about results via GUI message/notification.
|
||||||
qApp->showGuiMessage(Notification::Event::NewUnreadArticlesFetched,
|
qApp->showGuiMessage(Notification::Event::NewUnreadArticlesFetched,
|
||||||
{tr("Unread articles fetched"), results.overview(10), QSystemTrayIcon::MessageIcon::NoIcon});
|
{tr("Unread articles fetched"), results.overview(10), QSystemTrayIcon::MessageIcon::NoIcon});
|
||||||
|
@ -336,6 +336,9 @@ void FeedReader::executeNextAutoUpdate() {
|
|||||||
// Request update for given feeds.
|
// Request update for given feeds.
|
||||||
updateFeeds(feeds_for_update);
|
updateFeeds(feeds_for_update);
|
||||||
|
|
||||||
|
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.
|
// NOTE: OSD/bubble informing about performing of scheduled update can be shown now.
|
||||||
qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted,
|
qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted,
|
||||||
{tr("Starting auto-download of some feeds' articles"),
|
{tr("Starting auto-download of some feeds' articles"),
|
||||||
@ -343,6 +346,7 @@ void FeedReader::executeNextAutoUpdate() {
|
|||||||
QSystemTrayIcon::MessageIcon::Information});
|
QSystemTrayIcon::MessageIcon::Information});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<MessageFilter*> FeedReader::messageFilters() const {
|
QList<MessageFilter*> FeedReader::messageFilters() const {
|
||||||
return m_messageFilters;
|
return m_messageFilters;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user