diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2020-11-24 13:40:23 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2020-11-25 19:05:12 +0100 |
commit | 9c8850a46c8f8f16bb476fcd7d3d529e82796048 (patch) | |
tree | 2f9531d556f12709bc1f48b5d56be1e6dda764bb /src | |
parent | Fix index out of range on backspace in completer (diff) | |
download | nheko-9c8850a46c8f8f16bb476fcd7d3d529e82796048.tar.xz |
Match on each word in the completer
Diffstat (limited to 'src')
-rw-r--r-- | src/CompletionProxyModel.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/CompletionProxyModel.h b/src/CompletionProxyModel.h index 91f937a4..f4ec6a96 100644 --- a/src/CompletionProxyModel.h +++ b/src/CompletionProxyModel.h @@ -3,6 +3,7 @@ // Class for showing a limited amount of completions at a time #include <QAbstractProxyModel> +#include <QRegularExpression> #include "CompletionModelRoles.h" #include "Logging.h" @@ -136,6 +137,7 @@ public: : QAbstractProxyModel(parent) { setSourceModel(model); + QRegularExpression splitPoints("\\s+|-"); for (int i = 0; i < sourceModel()->rowCount(); i++) { if (i < 7) @@ -148,14 +150,23 @@ public: .toLower(); trie_.insert(string1.toUcs4(), i); + for (const auto &e : string1.split(splitPoints, Qt::SkipEmptyParts)) { + trie_.insert(e.toUcs4(), i); + } + auto string2 = sourceModel() ->data(sourceModel()->index(i, 0), CompletionModel::SearchRole2) .toString() .toLower(); - if (!string2.isEmpty()) + if (!string2.isEmpty()) { trie_.insert(string2.toUcs4(), i); + for (const auto &e : + string2.split(splitPoints, Qt::SkipEmptyParts)) { + trie_.insert(e.toUcs4(), i); + } + } } connect( |