mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-23 14:29:47 -05:00
* Search Group details in addition to entry details; feature parity with KeePass * Remove assertions to prevent crashes in Debug mode when search result is empty
This commit is contained in:
parent
55084499ac
commit
a3fd3205a9
@ -42,9 +42,13 @@ QList<Entry*> EntrySearcher::searchEntries(const QString& searchTerm, const Grou
|
|||||||
const QList<Group*> children = group->children();
|
const QList<Group*> children = group->children();
|
||||||
for (Group* childGroup : children) {
|
for (Group* childGroup : children) {
|
||||||
if (childGroup->searchingEnabled() != Group::Disable) {
|
if (childGroup->searchingEnabled() != Group::Disable) {
|
||||||
|
if (matchGroup(searchTerm, childGroup, caseSensitivity)) {
|
||||||
|
searchResult.append(childGroup->entriesRecursive());
|
||||||
|
} else {
|
||||||
searchResult.append(searchEntries(searchTerm, childGroup, caseSensitivity));
|
searchResult.append(searchEntries(searchTerm, childGroup, caseSensitivity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return searchResult;
|
return searchResult;
|
||||||
}
|
}
|
||||||
@ -69,3 +73,21 @@ bool EntrySearcher::wordMatch(const QString& word, Entry* entry, Qt::CaseSensiti
|
|||||||
entry->url().contains(word, caseSensitivity) ||
|
entry->url().contains(word, caseSensitivity) ||
|
||||||
entry->notes().contains(word, caseSensitivity);
|
entry->notes().contains(word, caseSensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EntrySearcher::matchGroup(const QString& searchTerm, const Group* group, Qt::CaseSensitivity caseSensitivity)
|
||||||
|
{
|
||||||
|
const QStringList wordList = searchTerm.split(QRegExp("\\s"), QString::SkipEmptyParts);
|
||||||
|
for (const QString& word : wordList) {
|
||||||
|
if (!wordMatch(word, group, caseSensitivity)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EntrySearcher::wordMatch(const QString& word, const Group* group, Qt::CaseSensitivity caseSensitivity)
|
||||||
|
{
|
||||||
|
return group->name().contains(word, caseSensitivity) ||
|
||||||
|
group->notes().contains(word, caseSensitivity);
|
||||||
|
}
|
||||||
|
@ -33,6 +33,8 @@ private:
|
|||||||
QList<Entry*> searchEntries(const QString& searchTerm, const Group* group, Qt::CaseSensitivity caseSensitivity);
|
QList<Entry*> searchEntries(const QString& searchTerm, const Group* group, Qt::CaseSensitivity caseSensitivity);
|
||||||
QList<Entry*> matchEntry(const QString& searchTerm, Entry* entry, Qt::CaseSensitivity caseSensitivity);
|
QList<Entry*> matchEntry(const QString& searchTerm, Entry* entry, Qt::CaseSensitivity caseSensitivity);
|
||||||
bool wordMatch(const QString& word, Entry* entry, Qt::CaseSensitivity caseSensitivity);
|
bool wordMatch(const QString& word, Entry* entry, Qt::CaseSensitivity caseSensitivity);
|
||||||
|
bool matchGroup(const QString& searchTerm, const Group* group, Qt::CaseSensitivity caseSensitivity);
|
||||||
|
bool wordMatch(const QString& word, const Group* group, Qt::CaseSensitivity caseSensitivity);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_ENTRYSEARCHER_H
|
#endif // KEEPASSX_ENTRYSEARCHER_H
|
||||||
|
@ -791,7 +791,7 @@ void DatabaseWidget::entryActivationSignalReceived(Entry* entry, EntryModel::Mod
|
|||||||
void DatabaseWidget::switchToEntryEdit()
|
void DatabaseWidget::switchToEntryEdit()
|
||||||
{
|
{
|
||||||
Entry* entry = m_entryView->currentEntry();
|
Entry* entry = m_entryView->currentEntry();
|
||||||
Q_ASSERT(entry);
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -802,7 +802,7 @@ void DatabaseWidget::switchToEntryEdit()
|
|||||||
void DatabaseWidget::switchToGroupEdit()
|
void DatabaseWidget::switchToGroupEdit()
|
||||||
{
|
{
|
||||||
Group* group = m_groupView->currentGroup();
|
Group* group = m_groupView->currentGroup();
|
||||||
Q_ASSERT(group);
|
|
||||||
if (!group) {
|
if (!group) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user