Skip to content

Commit

Permalink
Prevent expired entries search if no results returned
Browse files Browse the repository at this point in the history
* Fixes keepassxreboot#8626
* Also remove old feature to set the title of a new entry to the current search text. This only made sense before advanced searching was made available.
  • Loading branch information
droidmonkey committed Oct 29, 2022
1 parent c5eaee8 commit ceb2cd2
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,6 @@ void DatabaseWidget::createEntry()

m_newEntry.reset(new Entry());

if (isSearchActive()) {
m_newEntry->setTitle(getCurrentSearch());
endSearch();
}
m_newEntry->setUuid(QUuid::createUuid());
m_newEntry->setUsername(m_db->metadata()->defaultUserName());
m_newParent = m_groupView->currentGroup();
Expand Down Expand Up @@ -1414,25 +1410,33 @@ void DatabaseWidget::search(const QString& searchtext)
return;
}

emit searchModeAboutToActivate();

Group* searchGroup = m_searchLimitGroup ? currentGroup() : m_db->rootGroup();

QList<Entry*> searchResult = m_entrySearcher->search(searchtext, searchGroup);
auto searchGroup = m_db->rootGroup();
if (m_searchLimitGroup && m_nextSearchLabelText.isEmpty()) {
searchGroup = currentGroup();
}

m_entryView->displaySearch(searchResult);
m_lastSearchText = searchtext;
auto results = m_entrySearcher->search(searchtext, searchGroup);

// Display a label detailing our search results
if (!m_nextSearchLabelText.isEmpty()) {
// Custom searches don't display if there are no results
if (results.isEmpty()) {
endSearch();
return;
}
m_searchingLabel->setText(m_nextSearchLabelText);
m_nextSearchLabelText.clear();
} else if (!searchResult.isEmpty()) {
m_searchingLabel->setText(tr("Search Results (%1)").arg(searchResult.size()));
} else if (!results.isEmpty()) {
m_searchingLabel->setText(tr("Search Results (%1)").arg(results.size()));
} else {
m_searchingLabel->setText(tr("No Results"));
}

emit searchModeAboutToActivate();

m_entryView->displaySearch(results);
m_lastSearchText = searchtext;

m_searchingLabel->setVisible(true);
#ifdef WITH_XC_KEESHARE
m_shareLabel->setVisible(false);
Expand Down

0 comments on commit ceb2cd2

Please sign in to comment.