forked from qt-creator/qt-creator
Help: Remove usage of deprecated API
This follows the same outline as qttools 256bbc4f139036a780a63b80af8bb461a77d333a Change-Id: Iffe1f7a8d11ef9d20ec567fd222ee5279b56c765 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
46e2c354ba
commit
6235ae0bc0
@@ -164,28 +164,7 @@ void SearchWidget::showEvent(QShowEvent *event)
|
|||||||
|
|
||||||
void SearchWidget::search() const
|
void SearchWidget::search() const
|
||||||
{
|
{
|
||||||
static const QStringList charsToEscapeList({
|
searchEngine->search(searchEngine->queryWidget()->searchInput());
|
||||||
"\\", "+", "-", "!", "(", ")", ":", "^", "[", "]", "{", "}", "~"
|
|
||||||
});
|
|
||||||
|
|
||||||
static const QString escapeChar("\\");
|
|
||||||
static const QRegExp regExp("[\\+\\-\\!\\(\\)\\^\\[\\]\\{\\}~:]");
|
|
||||||
|
|
||||||
QList<QHelpSearchQuery> escapedQueries;
|
|
||||||
const QList<QHelpSearchQuery> queries = searchEngine->queryWidget()->query();
|
|
||||||
foreach (const QHelpSearchQuery &query, queries) {
|
|
||||||
QHelpSearchQuery escapedQuery;
|
|
||||||
escapedQuery.fieldName = query.fieldName;
|
|
||||||
foreach (QString word, query.wordList) {
|
|
||||||
if (word.contains(regExp)) {
|
|
||||||
foreach (const QString &charToEscape, charsToEscapeList)
|
|
||||||
word.replace(charToEscape, escapeChar + charToEscape);
|
|
||||||
}
|
|
||||||
escapedQuery.wordList.append(word);
|
|
||||||
}
|
|
||||||
escapedQueries.append(escapedQuery);
|
|
||||||
}
|
|
||||||
searchEngine->search(escapedQueries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchWidget::searchingStarted()
|
void SearchWidget::searchingStarted()
|
||||||
@@ -286,24 +265,7 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent)
|
|||||||
|
|
||||||
QStringList SearchWidget::currentSearchTerms() const
|
QStringList SearchWidget::currentSearchTerms() const
|
||||||
{
|
{
|
||||||
QList<QHelpSearchQuery> queryList = searchEngine->query();
|
return searchEngine->searchInput().split(QRegExp("\\W+"), QString::SkipEmptyParts);
|
||||||
|
|
||||||
QStringList terms;
|
|
||||||
foreach (const QHelpSearchQuery &query, queryList) {
|
|
||||||
switch (query.fieldName) {
|
|
||||||
case QHelpSearchQuery::ALL:
|
|
||||||
case QHelpSearchQuery::PHRASE:
|
|
||||||
case QHelpSearchQuery::DEFAULT:
|
|
||||||
case QHelpSearchQuery::ATLEAST: {
|
|
||||||
foreach (QString term, query.wordList)
|
|
||||||
terms.append(term.remove(QLatin1Char('"')));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return terms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// #pragma mark -- SearchSideBarItem
|
// #pragma mark -- SearchSideBarItem
|
||||||
|
|||||||
Reference in New Issue
Block a user