TextEditor: Fix regular expression to wildcard workaround

The used functionality turned out to do not what was expected.
Fix this by a simpler but more correct way.
This silences lots of warnings while running QC when using the
minimum supported Qt version.

Change-Id: I7c659c3cf6c1c090e992822f91bb644eec651ec9
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2020-03-26 10:09:54 +01:00
parent a4be1e8b66
commit 223281222d

View File

@@ -112,8 +112,16 @@ bool StorageSettings::removeTrailingWhitespace(const QString &fileName) const
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
= QRegularExpression::wildcardToRegularExpression(pattern);
#else
= QRegExp(pattern, Utils::HostOsInfo::fileNameCaseSensitivity(),
QRegExp::Wildcard).pattern();
= pattern;
// handle at least the most likely appearing
wildcardRegExp.replace('.', "\\.");
wildcardRegExp.replace('$', "\\$");
wildcardRegExp.replace('(', "\\(").replace(')', "\\)");
wildcardRegExp.replace('[', "\\[").replace(']', "\\]");
wildcardRegExp.replace('{', "\\{").replace('}', "\\}");
wildcardRegExp.replace('+', "\\+");
wildcardRegExp.replace('*', ".*");
wildcardRegExp.replace('?', '.');
#endif
QRegularExpression patternRegExp(wildcardRegExp);
QRegularExpressionMatch patternMatch = patternRegExp.match(fileName);