Skip to content

Commit

Permalink
Add action item to mark all entries in a feed as read
Browse files Browse the repository at this point in the history
Add action to mark all entries in a feed as read
  • Loading branch information
rjframe authored Jan 22, 2022
1 parent a3d65b6 commit ec085de
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/FeedsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions src/core/FeedsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/modules/windows/feeds/FeedsContentsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ec085de

Please sign in to comment.