summaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-07-22 14:54:08 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-07-23 14:47:26 +0000
commit36caa1f292ddfd45b877d331e6d68f813563d259 (patch)
tree28b703a7c0beb14466ebc1e2682d3f76837aadbe /src/app
parent7401a6bc4e53d920fd7ced3249c735fd232d191c (diff)
downloadqbs-36caa1f292ddfd45b877d331e6d68f813563d259.tar.gz
Replace QRegExp by QRegularExpression
Change-Id: I6c86565b8464efd0b7aec61c12879d3b95a5871c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/app')
-rw-r--r--src/app/qbs-create-project/createproject.cpp8
-rw-r--r--src/app/qbs-create-project/createproject.h6
-rw-r--r--src/app/qbs/status.cpp36
3 files changed, 27 insertions, 23 deletions
diff --git a/src/app/qbs-create-project/createproject.cpp b/src/app/qbs-create-project/createproject.cpp
index 26147b484..20338be98 100644
--- a/src/app/qbs-create-project/createproject.cpp
+++ b/src/app/qbs-create-project/createproject.cpp
@@ -62,9 +62,9 @@ void ProjectCreator::run(const QString &topLevelDir, ProjectStructure projectStr
{
m_projectStructure = projectStructure;
for (const QString &s : whiteList)
- m_whiteList.push_back(QRegExp(s, Qt::CaseSensitive, QRegExp::Wildcard));
+ m_whiteList.push_back(QRegularExpression(QRegularExpression::wildcardToRegularExpression(s)));
for (const QString &s : blackList)
- m_blackList.push_back(QRegExp(s, Qt::CaseSensitive, QRegExp::Wildcard));
+ m_blackList.push_back(QRegularExpression(QRegularExpression::wildcardToRegularExpression(s)));
m_topLevelProject.dirPath = topLevelDir;
setupProject(&m_topLevelProject);
serializeProject(m_topLevelProject);
@@ -162,7 +162,9 @@ void ProjectCreator::addGroups(QTextStream &stream, const QDir &baseDir,
bool ProjectCreator::isSourceFile(const QString &fileName)
{
- const auto isMatch = [fileName](const QRegExp &rex) { return rex.exactMatch(fileName); };
+ const auto isMatch = [fileName](const QRegularExpression &rex) {
+ return rex.match(fileName).hasMatch();
+ };
return !std::any_of(m_blackList.cbegin(), m_blackList.cend(), isMatch)
&& (m_whiteList.empty()
|| std::any_of(m_whiteList.cbegin(), m_whiteList.cend(), isMatch));
diff --git a/src/app/qbs-create-project/createproject.h b/src/app/qbs-create-project/createproject.h
index efc217b68..ac7d53e1a 100644
--- a/src/app/qbs-create-project/createproject.h
+++ b/src/app/qbs-create-project/createproject.h
@@ -42,7 +42,7 @@
#include <QtCore/qflags.h>
#include <QtCore/qhash.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qstringlist.h>
#include <memory>
@@ -83,8 +83,8 @@ private:
};
Project m_topLevelProject;
ProjectStructure m_projectStructure = ProjectStructure::Flat;
- QList<QRegExp> m_whiteList;
- QList<QRegExp> m_blackList;
+ QList<QRegularExpression> m_whiteList;
+ QList<QRegularExpression> m_blackList;
};
#endif // QBS_CREATEPROJECT_H
diff --git a/src/app/qbs/status.cpp b/src/app/qbs/status.cpp
index 01d3451fe..a5e0c8228 100644
--- a/src/app/qbs/status.cpp
+++ b/src/app/qbs/status.cpp
@@ -47,20 +47,20 @@
#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qstring.h>
-#include <QtCore/qregexp.h>
namespace qbs {
-static QList<QRegExp> createIgnoreList(const QString &projectRootPath)
+static QList<QRegularExpression> createIgnoreList(const QString &projectRootPath)
{
- QList<QRegExp> ignoreRegularExpressionList {
- QRegExp(projectRootPath + QLatin1String("/build.*")),
- QRegExp(QStringLiteral("*.qbs"), Qt::CaseSensitive, QRegExp::Wildcard),
- QRegExp(QStringLiteral("*.pro"), Qt::CaseSensitive, QRegExp::Wildcard),
- QRegExp(QStringLiteral("*Makefile"), Qt::CaseSensitive, QRegExp::Wildcard),
- QRegExp(QStringLiteral("*.so*"), Qt::CaseSensitive, QRegExp::Wildcard),
- QRegExp(QStringLiteral("*.o"), Qt::CaseSensitive, QRegExp::Wildcard)
+ QList<QRegularExpression> ignoreRegularExpressionList {
+ QRegularExpression(QRegularExpression::anchoredPattern(projectRootPath + QLatin1String("/build.*"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.qbs"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.pro"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*Makefile"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.so*"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.o")))
};
QString ignoreFilePath = projectRootPath + QLatin1String("/.qbsignore");
@@ -71,11 +71,12 @@ static QList<QRegExp> createIgnoreList(const QString &projectRootPath)
for (const QByteArray &btoken : ignoreTokenList) {
const QString token = QString::fromLatin1(btoken);
if (token.startsWith(QLatin1String("/")))
- ignoreRegularExpressionList.push_back(QRegExp(projectRootPath
- + token + QLatin1String(".*"),
- Qt::CaseSensitive, QRegExp::RegExp2));
+ ignoreRegularExpressionList.push_back(
+ QRegularExpression(QRegularExpression::anchoredPattern(
+ projectRootPath + token + QLatin1String(".*"))));
else if (!token.isEmpty())
- ignoreRegularExpressionList.push_back(QRegExp(token, Qt::CaseSensitive, QRegExp::RegExp2));
+ ignoreRegularExpressionList.push_back(
+ QRegularExpression(QRegularExpression::anchoredPattern(token)));
}
}
@@ -83,7 +84,8 @@ static QList<QRegExp> createIgnoreList(const QString &projectRootPath)
return ignoreRegularExpressionList;
}
-static QStringList allFilesInDirectoryRecursive(const QDir &rootDirecory, const QList<QRegExp> &ignoreRegularExpressionList)
+static QStringList allFilesInDirectoryRecursive(
+ const QDir &rootDirecory, const QList<QRegularExpression> &ignoreRegularExpressionList)
{
QStringList fileList;
@@ -91,8 +93,8 @@ static QStringList allFilesInDirectoryRecursive(const QDir &rootDirecory, const
for (const QFileInfo &fileInfo : fileInfos) {
QString absoluteFilePath = fileInfo.absoluteFilePath();
bool inIgnoreList = false;
- for (const QRegExp &ignoreRegularExpression : ignoreRegularExpressionList) {
- if (ignoreRegularExpression.exactMatch(absoluteFilePath)) {
+ for (const QRegularExpression &ignoreRegularExpression : ignoreRegularExpressionList) {
+ if (ignoreRegularExpression.match(absoluteFilePath).hasMatch()) {
inIgnoreList = true;
break;
}
@@ -112,7 +114,7 @@ static QStringList allFilesInDirectoryRecursive(const QDir &rootDirecory, const
static QStringList allFilesInProject(const QString &projectRootPath)
{
- QList<QRegExp> ignoreRegularExpressionList = createIgnoreList(projectRootPath);
+ QList<QRegularExpression> ignoreRegularExpressionList = createIgnoreList(projectRootPath);
return allFilesInDirectoryRecursive(QDir(projectRootPath), ignoreRegularExpressionList);
}