Add ability to expire entries from context menus (#8731)

Closes #1972

Add ability to immediately expire an entry from the context menu

---------
Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
Matteson 2025-01-12 04:55:22 -08:00 committed by GitHub
parent 832340e209
commit 29ac4da240
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 154 additions and 22 deletions

View file

@ -374,6 +374,11 @@ void ReportsWidgetHibp::customMenuRequested(QPoint pos)
});
}
// Create the "Expire entry" menu item
const auto expEntry = new QAction(icons()->icon("entry-expire"), tr("Expire Entry(s)…", "", selected.size()), this);
menu->addAction(expEntry);
connect(expEntry, &QAction::triggered, this, &ReportsWidgetHibp::expireSelectedEntries);
// Create the "delete entry" menu item
const auto delEntry = new QAction(icons()->icon("entry-delete"), tr("Delete Entry(s)…", "", selected.size()), this);
menu->addAction(delEntry);
@ -411,7 +416,7 @@ void ReportsWidgetHibp::customMenuRequested(QPoint pos)
menu->popup(m_ui->hibpTableView->viewport()->mapToGlobal(pos));
}
void ReportsWidgetHibp::deleteSelectedEntries()
QList<Entry*> ReportsWidgetHibp::getSelectedEntries()
{
QList<Entry*> selectedEntries;
for (auto index : m_ui->hibpTableView->selectionModel()->selectedRows()) {
@ -421,7 +426,21 @@ void ReportsWidgetHibp::deleteSelectedEntries()
selectedEntries << entry;
}
}
return selectedEntries;
}
void ReportsWidgetHibp::expireSelectedEntries()
{
for (auto entry : getSelectedEntries()) {
entry->expireNow();
}
makeHibpTable();
}
void ReportsWidgetHibp::deleteSelectedEntries()
{
QList<Entry*> selectedEntries = getSelectedEntries();
bool permanent = !m_db->metadata()->recycleBinEnabled();
if (GuiTools::confirmDeleteEntries(this, selectedEntries, permanent)) {
GuiTools::deleteEntriesResolveReferences(this, selectedEntries, permanent);