mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-27 00:09:53 -05: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
@ -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 {
|
||||
|
@ -289,6 +289,11 @@ Entry* EntryView::entryFromIndex(const QModelIndex& index)
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex EntryView::indexFromEntry(Entry* entry)
|
||||
{
|
||||
return m_sortModel->mapFromSource(m_model->indexFromEntry(entry));
|
||||
}
|
||||
|
||||
int EntryView::currentEntryIndex()
|
||||
{
|
||||
QModelIndexList list = selectionModel()->selectedRows();
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
Entry* currentEntry();
|
||||
void setCurrentEntry(Entry* entry);
|
||||
Entry* entryFromIndex(const QModelIndex& index);
|
||||
QModelIndex indexFromEntry(Entry* entry);
|
||||
int currentEntryIndex();
|
||||
bool inSearchMode();
|
||||
bool isSorted();
|
||||
|
Loading…
Reference in New Issue
Block a user