diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 267b556f6c..6eb1053b22 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -172,6 +172,13 @@ DatabaseWidget::DatabaseWidget(QSharedPointer db, QWidget* parent) connect(m_groupView, SIGNAL(groupSelectionChanged()), SLOT(onGroupChanged())); connect(m_groupView, SIGNAL(groupSelectionChanged()), SIGNAL(groupChanged())); connect(m_groupView, &GroupView::groupFocused, this, [this] { m_previewView->setGroup(currentGroup()); }); + connect(m_entryView, &EntryView::entrySelectionChanged, this, [this](Entry * currentEntry) { + if (currentEntry) { + m_previewView->setEntry(currentEntry); + } else { + m_previewView->setGroup(groupView()->currentGroup()); + } + }); connect(m_entryView, SIGNAL(entryActivated(Entry*,EntryModel::ModelColumn)), SLOT(entryActivationSignalReceived(Entry*,EntryModel::ModelColumn))); connect(m_entryView, SIGNAL(entrySelectionChanged(Entry*)), SLOT(onEntryChanged(Entry*))); @@ -477,6 +484,7 @@ void DatabaseWidget::deleteEntries(QList selectedEntries, bool confirm) auto index = m_entryView->indexFromEntry(selectedEntries.first()); index = m_entryView->indexAbove(index); + // Confirm entry removal before moving forward auto recycleBin = m_db->metadata()->recycleBin(); bool permanent = (recycleBin && recycleBin->findEntryByUuid(selectedEntries.first()->uuid())) @@ -488,22 +496,12 @@ void DatabaseWidget::deleteEntries(QList selectedEntries, bool confirm) GuiTools::deleteEntriesResolveReferences(this, selectedEntries, permanent); - refreshSearch(); - // 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 { - m_previewView->setGroup(groupView()->currentGroup()); - } } void DatabaseWidget::setFocus(Qt::FocusReason reason) @@ -1369,6 +1367,7 @@ void DatabaseWidget::onDatabaseModified() // Only block once, then reset m_blockAutoSave = false; } + refreshSearch(); } QString DatabaseWidget::getCurrentSearch() @@ -1989,7 +1988,6 @@ void DatabaseWidget::emptyRecycleBin() if (result == MessageBox::Empty) { m_db->emptyRecycleBin(); - refreshSearch(); } }