From 7e89a13476e4257c8f0c912a37ecd6bc303cf7f7 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 6 Jan 2019 13:46:22 +0200 Subject: [PATCH] Refactoring. Fixing static analyzers warnings. --HG-- branch : develop --- src/libs/vmisc/vtablesearch.cpp | 25 +++++++++++-------------- src/libs/vmisc/vtablesearch.h | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/libs/vmisc/vtablesearch.cpp b/src/libs/vmisc/vtablesearch.cpp index 82df0700e..a60eff722 100644 --- a/src/libs/vmisc/vtablesearch.cpp +++ b/src/libs/vmisc/vtablesearch.cpp @@ -93,38 +93,35 @@ void VTableSearch::ShowNext(int newIndex) } } -QList VTableSearch::FindTableItems(QString term) +//--------------------------------------------------------------------------------------------------------------------- +QList VTableSearch::FindTableItems(const QString& term) { if (term.isEmpty()) { return QList(); } - if (term.startsWith("/")) + if (term.startsWith(QChar('/'))) { - QRegularExpression qre("^/(?[^/]+)/(?.+)$"); + QRegularExpression qre(QStringLiteral("^/(?[^/]+)/(?.+)$")); QScopedPointer match(new QRegularExpressionMatch()); if (!term.contains(qre, match.data())) { return QList(); } - auto searchType = match->capturedRef("searchType"); - auto searchString = match->capturedRef("searchString"); - if (searchType == "r") + auto searchType = match->capturedRef(QStringLiteral("searchType")); + auto searchString = match->capturedRef(QStringLiteral("searchString")); + if (searchType == QChar('r')) { QString reSearchString = ".*" % searchString % ".*"; return table->findItems(reSearchString, Qt::MatchRegExp); } - else - { - return QList(); - } - } - else - { - return table->findItems(term, Qt::MatchContains); + + return QList(); } + + return table->findItems(term, Qt::MatchContains); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/vtablesearch.h b/src/libs/vmisc/vtablesearch.h index 18c1eba6d..bec54fee2 100644 --- a/src/libs/vmisc/vtablesearch.h +++ b/src/libs/vmisc/vtablesearch.h @@ -60,7 +60,7 @@ private: void Clear(); void ShowNext(int newIndex); - QList FindTableItems(QString term); + QList FindTableItems(const QString& term); }; #endif // VTABLESEARCH_H