mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 06:08:48 +03:00
Match on each word in the completer
This commit is contained in:
parent
90ce4f23ab
commit
9c8850a46c
1 changed files with 12 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
||||||
// Class for showing a limited amount of completions at a time
|
// Class for showing a limited amount of completions at a time
|
||||||
|
|
||||||
#include <QAbstractProxyModel>
|
#include <QAbstractProxyModel>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "CompletionModelRoles.h"
|
#include "CompletionModelRoles.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
@ -136,6 +137,7 @@ public:
|
||||||
: QAbstractProxyModel(parent)
|
: QAbstractProxyModel(parent)
|
||||||
{
|
{
|
||||||
setSourceModel(model);
|
setSourceModel(model);
|
||||||
|
QRegularExpression splitPoints("\\s+|-");
|
||||||
|
|
||||||
for (int i = 0; i < sourceModel()->rowCount(); i++) {
|
for (int i = 0; i < sourceModel()->rowCount(); i++) {
|
||||||
if (i < 7)
|
if (i < 7)
|
||||||
|
@ -148,14 +150,23 @@ public:
|
||||||
.toLower();
|
.toLower();
|
||||||
trie_.insert(string1.toUcs4(), i);
|
trie_.insert(string1.toUcs4(), i);
|
||||||
|
|
||||||
|
for (const auto &e : string1.split(splitPoints, Qt::SkipEmptyParts)) {
|
||||||
|
trie_.insert(e.toUcs4(), i);
|
||||||
|
}
|
||||||
|
|
||||||
auto string2 =
|
auto string2 =
|
||||||
sourceModel()
|
sourceModel()
|
||||||
->data(sourceModel()->index(i, 0), CompletionModel::SearchRole2)
|
->data(sourceModel()->index(i, 0), CompletionModel::SearchRole2)
|
||||||
.toString()
|
.toString()
|
||||||
.toLower();
|
.toLower();
|
||||||
|
|
||||||
if (!string2.isEmpty())
|
if (!string2.isEmpty()) {
|
||||||
trie_.insert(string2.toUcs4(), i);
|
trie_.insert(string2.toUcs4(), i);
|
||||||
|
for (const auto &e :
|
||||||
|
string2.split(splitPoints, Qt::SkipEmptyParts)) {
|
||||||
|
trie_.insert(e.toUcs4(), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
|
|
Loading…
Reference in a new issue