Refactoring. Fixing static analyzers warnings.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-01-06 13:46:22 +02:00
parent ba08ed4d1d
commit 7e89a13476
2 changed files with 12 additions and 15 deletions

View File

@ -93,39 +93,36 @@ void VTableSearch::ShowNext(int newIndex)
}
}
QList<QTableWidgetItem *> VTableSearch::FindTableItems(QString term)
//---------------------------------------------------------------------------------------------------------------------
QList<QTableWidgetItem *> VTableSearch::FindTableItems(const QString& term)
{
if (term.isEmpty())
{
return QList<QTableWidgetItem *>();
}
if (term.startsWith("/"))
if (term.startsWith(QChar('/')))
{
QRegularExpression qre("^/(?<searchType>[^/]+)/(?<searchString>.+)$");
QRegularExpression qre(QStringLiteral("^/(?<searchType>[^/]+)/(?<searchString>.+)$"));
QScopedPointer<QRegularExpressionMatch> match(new QRegularExpressionMatch());
if (!term.contains(qre, match.data()))
{
return QList<QTableWidgetItem *>();
}
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<QTableWidgetItem *>();
}
}
else
{
return table->findItems(term, Qt::MatchContains);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VTableSearch::Find(const QString &term)

View File

@ -60,7 +60,7 @@ private:
void Clear();
void ShowNext(int newIndex);
QList<QTableWidgetItem *> FindTableItems(QString term);
QList<QTableWidgetItem *> FindTableItems(const QString& term);
};
#endif // VTABLESEARCH_H