mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-04 13:07:38 +03:00
Select entry above deleted entry
* Fix #6304 - Don't cause the list view to scroll to the top when deleting any entry in the list.
This commit is contained in:
parent
746276edea
commit
af9eb6d6b1
3 changed files with 24 additions and 3 deletions
|
@ -462,8 +462,16 @@ void DatabaseWidget::deleteSelectedEntries()
|
|||
|
||||
void DatabaseWidget::deleteEntries(QList<Entry*> selectedEntries, bool confirm)
|
||||
{
|
||||
if (selectedEntries.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the index above the first entry for selection after deletion
|
||||
auto index = m_entryView->indexFromEntry(selectedEntries.first());
|
||||
index = m_entryView->indexAbove(index);
|
||||
|
||||
// Confirm entry removal before moving forward
|
||||
auto* recycleBin = m_db->metadata()->recycleBin();
|
||||
auto recycleBin = m_db->metadata()->recycleBin();
|
||||
bool permanent = (recycleBin && recycleBin->findEntryByUuid(selectedEntries.first()->uuid()))
|
||||
|| !m_db->metadata()->recycleBinEnabled();
|
||||
|
||||
|
@ -475,8 +483,15 @@ void DatabaseWidget::deleteEntries(QList<Entry*> selectedEntries, bool confirm)
|
|||
|
||||
refreshSearch();
|
||||
|
||||
m_entryView->setFirstEntryActive();
|
||||
auto* currentEntry = currentSelectedEntry();
|
||||
// Select the row above the deleted entries
|
||||
if (index.isValid()) {
|
||||
m_entryView->setCurrentIndex(index);
|
||||
} else {
|
||||
m_entryView->setFirstEntryActive();
|
||||
}
|
||||
|
||||
// Update the preview widget
|
||||
auto currentEntry = currentSelectedEntry();
|
||||
if (currentEntry) {
|
||||
m_previewView->setEntry(currentEntry);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue