fix(search-interface):文件搜索接口适配新国标字体
This commit is contained in:
parent
9d6f19d4af
commit
11707a54a6
|
@ -26,6 +26,7 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QTextBoundaryFinder>
|
||||||
#include "index-status-recorder.h"
|
#include "index-status-recorder.h"
|
||||||
#include "dir-watcher.h"
|
#include "dir-watcher.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -178,10 +179,17 @@ Xapian::Query FileSearchWorker::creatQueryForFileSearch() {
|
||||||
for (QString &keyword : m_searchController->getKeyword()) {
|
for (QString &keyword : m_searchController->getKeyword()) {
|
||||||
if (!keyword.isEmpty()) {
|
if (!keyword.isEmpty()) {
|
||||||
std::vector<Xapian::Query> queryOfKeyword;
|
std::vector<Xapian::Query> queryOfKeyword;
|
||||||
for(auto &c : keyword) {
|
QString inputKeyWord = keyword.toLower();
|
||||||
queryOfKeyword.emplace_back(Xapian::Query(QUrl::toPercentEncoding(c).toStdString()));
|
QTextBoundaryFinder bf(QTextBoundaryFinder::Grapheme, inputKeyWord.toLower());
|
||||||
|
int start = 0;
|
||||||
|
for(; bf.position() != -1; bf.toNextBoundary()) {
|
||||||
|
int end = bf.position();
|
||||||
|
if(bf.boundaryReasons() & QTextBoundaryFinder::EndOfItem) {
|
||||||
|
queryOfKeyword.emplace_back(QUrl::toPercentEncoding(inputKeyWord.toLower().mid(start, end - start)).toStdString());
|
||||||
}
|
}
|
||||||
queries.emplace_back(Xapian::Query(Xapian::Query::OP_PHRASE, queryOfKeyword.begin(), queryOfKeyword.end()));
|
start = end;
|
||||||
|
}
|
||||||
|
queries.emplace_back(Xapian::Query::OP_PHRASE, queryOfKeyword.begin(), queryOfKeyword.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue