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 d3f2c39
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 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 @@ -477,6 +484,7 @@ void DatabaseWidget::deleteEntries(QList<Entry*> 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()))
Expand All @@ -488,22 +496,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 +1367,7 @@ void DatabaseWidget::onDatabaseModified()
// Only block once, then reset
m_blockAutoSave = false;
}
refreshSearch();
}

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

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

Expand Down

0 comments on commit d3f2c39

Please sign in to comment.