Fix EntryView and PreviewView to automatically update when the model changes

This commit is contained in:
Aetf 2021-10-12 16:29:25 -04:00 committed by Jonathan White
parent a31c5ba006
commit 8b6d0e4b12

View File

@ -172,6 +172,13 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> 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*)));
@ -488,22 +495,12 @@ void DatabaseWidget::deleteEntries(QList<Entry*> 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 +1366,7 @@ void DatabaseWidget::onDatabaseModified()
// Only block once, then reset
m_blockAutoSave = false;
}
refreshSearch();
}
QString DatabaseWidget::getCurrentSearch()
@ -1989,7 +1987,6 @@ void DatabaseWidget::emptyRecycleBin()
if (result == MessageBox::Empty) {
m_db->emptyRecycleBin();
refreshSearch();
}
}