Skip to content
Snippets Groups Projects
Commit 9c8850a4 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Match on each word in the completer

parent 90ce4f23
No related branches found
No related tags found
No related merge requests found
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment