From ec085de33804c01da17b9780f1aa9de02085fb2c Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 22 Jan 2022 11:28:44 -0500 Subject: [PATCH] Add action item to mark all entries in a feed as read Add action to mark all entries in a feed as read --- src/core/FeedsManager.cpp | 15 +++++++++++++++ src/core/FeedsManager.h | 1 + src/modules/windows/feeds/FeedsContentsWidget.cpp | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/src/core/FeedsManager.cpp b/src/core/FeedsManager.cpp index 56cb29be90..7f063c3403 100644 --- a/src/core/FeedsManager.cpp +++ b/src/core/FeedsManager.cpp @@ -66,6 +66,21 @@ void Feed::markEntryAsRead(const QString &identifier) } } +void Feed::markAllEntriesAsRead() +{ + const QDateTime currentDateTime(QDateTime::currentDateTimeUtc()); + + for (int i = 0; i < m_entries.count(); ++i) + { + if (!m_entries[i].lastReadTime.isValid()) + { + m_entries[i].lastReadTime = currentDateTime; + } + } + + emit feedModified(this); +} + void Feed::markEntryAsRemoved(const QString &identifier) { if (!m_removedEntries.contains(identifier)) diff --git a/src/core/FeedsManager.h b/src/core/FeedsManager.h index 17847d8aca..47cbc600f6 100644 --- a/src/core/FeedsManager.h +++ b/src/core/FeedsManager.h @@ -63,6 +63,7 @@ class Feed final : public QObject explicit Feed(const QString &title, const QUrl &url, const QIcon &icon, int updateInterval, QObject *parent = nullptr); void markEntryAsRead(const QString &identifier); + void markAllEntriesAsRead(); void markEntryAsRemoved(const QString &identifier); void setTitle(const QString &title); void setDescription(const QString &description); diff --git a/src/modules/windows/feeds/FeedsContentsWidget.cpp b/src/modules/windows/feeds/FeedsContentsWidget.cpp index f8fced0eb8..4a341207f7 100644 --- a/src/modules/windows/feeds/FeedsContentsWidget.cpp +++ b/src/modules/windows/feeds/FeedsContentsWidget.cpp @@ -394,6 +394,16 @@ void FeedsContentsWidget::showFeedsContextMenu(const QPoint &position) menu.addAction(ThemesManager::createIcon(QLatin1String("view-refresh")), QCoreApplication::translate("actions", "Update"), this, &FeedsContentsWidget::updateFeed); menu.addSeparator(); menu.addAction(ThemesManager::createIcon(QLatin1String("document-open")), QCoreApplication::translate("actions", "Open"), this, &FeedsContentsWidget::openFeed); + menu.addSeparator(); + menu.addAction(tr("Mark All as Read"), this, [&]() + { + if (m_feed) + { + m_feed->markAllEntriesAsRead(); + + updateFeedModel(); + } + }); } menu.addSeparator();