Skip to content

Commit

Permalink
Fix EntryView and PreviewView to automatically update when the model …
Browse files Browse the repository at this point in the history
…changes
  • Loading branch information
Aetf committed Oct 12, 2021
1 parent b6716bd commit 684d565
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*)));
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1369,6 +1366,7 @@ void DatabaseWidget::onDatabaseModified()
// Only block once, then reset
m_blockAutoSave = false;
}
refreshSearch();
}

QString DatabaseWidget::getCurrentSearch()
Expand Down Expand Up @@ -1989,7 +1987,6 @@ void DatabaseWidget::emptyRecycleBin()

if (result == MessageBox::Empty) {
m_db->emptyRecycleBin();
refreshSearch();
}
}

Expand Down

0 comments on commit 684d565

Please sign in to comment.