forked from qt-creator/qt-creator
More QRegularExpression and include for Qt 6
Task-number: QTCREATORBUG-24098 Change-Id: Ia537e26efd3f37319c38d906e569b255768371f9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -74,8 +74,8 @@ static int parseVersion(const QString &text)
|
||||
const QRegularExpression rx("([2-9]{1})\\.([0-9]{2})(\\.[1-9]{1})?$");
|
||||
const QRegularExpressionMatch match = rx.match(text);
|
||||
if (match.hasMatch()) {
|
||||
const int major = match.capturedRef(1).toInt() * 100;
|
||||
const int minor = match.capturedRef(2).toInt();
|
||||
const int major = match.captured(1).toInt() * 100;
|
||||
const int minor = match.captured(2).toInt();
|
||||
return major + minor;
|
||||
}
|
||||
return 0;
|
||||
|
@@ -31,6 +31,10 @@
|
||||
#include <QStringList>
|
||||
#include <QPair>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTextCodec;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
|
@@ -49,7 +49,7 @@
|
||||
#include <QLabel>
|
||||
#include <QMap>
|
||||
#include <QMenu>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTextBrowser>
|
||||
@@ -263,7 +263,7 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent)
|
||||
|
||||
QStringList SearchWidget::currentSearchTerms() const
|
||||
{
|
||||
return searchEngine->searchInput().split(QRegExp("\\W+"), Utils::SkipEmptyParts);
|
||||
return searchEngine->searchInput().split(QRegularExpression("\\W+"), Utils::SkipEmptyParts);
|
||||
}
|
||||
|
||||
// #pragma mark -- SearchSideBarItem
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
@@ -96,7 +96,7 @@ QStringList CMakeCommandBuilder::defaultArguments()
|
||||
|
||||
QString CMakeCommandBuilder::setMultiProcessArg(QString args)
|
||||
{
|
||||
QRegExp regExp("\\s*\\-j\\s+\\d+");
|
||||
QRegularExpression regExp("\\s*\\-j\\s+\\d+");
|
||||
args.remove(regExp);
|
||||
args.append(" -- -j 200");
|
||||
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
@@ -84,13 +84,14 @@ QString MakeCommandBuilder::setMultiProcessArg(QString args)
|
||||
|
||||
// jom -j 200
|
||||
if (fileInfo.baseName().compare("jom", Qt::CaseSensitivity::CaseInsensitive) == 0) {
|
||||
QRegExp regExp("\\s*\\-j\\s+\\d+");
|
||||
QRegularExpression regExp("\\s*\\-j\\s+\\d+");
|
||||
args.remove(regExp);
|
||||
args.append(" -j 200");
|
||||
}
|
||||
// make -j200
|
||||
else if ((fileInfo.baseName().compare("make", Qt::CaseSensitivity::CaseInsensitive) == 0) || (fileInfo.baseName().compare("gmake", Qt::CaseSensitivity::CaseInsensitive) == 0)) {
|
||||
QRegExp regExp("\\s*\\-j\\d+");
|
||||
else if ((fileInfo.baseName().compare("make", Qt::CaseSensitivity::CaseInsensitive) == 0)
|
||||
|| (fileInfo.baseName().compare("gmake", Qt::CaseSensitivity::CaseInsensitive) == 0)) {
|
||||
QRegularExpression regExp("\\s*\\-j\\d+");
|
||||
args.remove(regExp);
|
||||
args.append(" -j200");
|
||||
}
|
||||
|
@@ -377,16 +377,17 @@ void PythonBuildSystem::parse()
|
||||
*/
|
||||
static void expandEnvironmentVariables(const QProcessEnvironment &env, QString &string)
|
||||
{
|
||||
static QRegExp candidate(QLatin1String("\\$\\$\\((.+)\\)"));
|
||||
const QRegularExpression candidate("\\$\\$\\((.+)\\)");
|
||||
|
||||
int index = candidate.indexIn(string);
|
||||
QRegularExpressionMatch match;
|
||||
int index = string.indexOf(candidate, 0, &match);
|
||||
while (index != -1) {
|
||||
const QString value = env.value(candidate.cap(1));
|
||||
const QString value = env.value(match.captured(1));
|
||||
|
||||
string.replace(index, candidate.matchedLength(), value);
|
||||
string.replace(index, match.capturedLength(), value);
|
||||
index += value.length();
|
||||
|
||||
index = candidate.indexIn(string, index);
|
||||
index = string.indexOf(candidate, index, &match);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -86,7 +86,7 @@ private:
|
||||
if (match.hasMatch()) {
|
||||
const LinkSpec link(match.capturedStart(2), match.capturedLength(2), match.captured(2));
|
||||
const auto fileName = FilePath::fromString(match.captured(3));
|
||||
const int lineNumber = match.capturedRef(4).toInt();
|
||||
const int lineNumber = match.captured(4).toInt();
|
||||
m_tasks.append({Task::Warning, QString(), fileName, lineNumber, category});
|
||||
return {Status::InProgress, {link}};
|
||||
}
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
if (!match.hasMatch())
|
||||
return false;
|
||||
const QString fileName = match.captured(3);
|
||||
const int lineNumber = match.capturedRef(4).toInt();
|
||||
const int lineNumber = match.captured(4).toInt();
|
||||
Core::EditorManager::openEditorAt(fileName, lineNumber);
|
||||
return true;
|
||||
}
|
||||
|
@@ -44,14 +44,13 @@ using namespace QmakeProjectManager::Internal;
|
||||
const char qt_file_dialog_filter_reg_exp[] =
|
||||
"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
|
||||
|
||||
// taken from qfiledialog.cpp
|
||||
QStringList qt_clean_filter_list(const QString &filter)
|
||||
static QStringList qt_clean_filter_list(const QString &filter)
|
||||
{
|
||||
QRegExp regexp(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
|
||||
const QRegularExpression regexp(qt_file_dialog_filter_reg_exp);
|
||||
const QRegularExpressionMatch match = regexp.match(filter);
|
||||
QString f = filter;
|
||||
int i = regexp.indexIn(f);
|
||||
if (i >= 0)
|
||||
f = regexp.cap(2);
|
||||
if (match.hasMatch())
|
||||
f = match.captured(2);
|
||||
return f.split(QLatin1Char(' '), Utils::SkipEmptyParts);
|
||||
}
|
||||
|
||||
@@ -65,12 +64,16 @@ static bool validateLibraryPath(const Utils::FilePath &filePath,
|
||||
|
||||
const QString fileName = filePath.fileName();
|
||||
|
||||
QStringList filters = qt_clean_filter_list(pathChooser->promptDialogFilter());
|
||||
for (int i = 0; i < filters.count(); i++) {
|
||||
QRegExp regExp(filters.at(i));
|
||||
regExp.setCaseSensitivity(Utils::HostOsInfo::fileNameCaseSensitivity());
|
||||
regExp.setPatternSyntax(QRegExp::Wildcard);
|
||||
if (regExp.exactMatch(fileName))
|
||||
QRegularExpression::PatternOption option =
|
||||
Utils::HostOsInfo::fileNameCaseSensitivity() == Qt::CaseInsensitive
|
||||
? QRegularExpression::CaseInsensitiveOption
|
||||
: QRegularExpression::NoPatternOption;
|
||||
|
||||
const QStringList filters = qt_clean_filter_list(pathChooser->promptDialogFilter());
|
||||
for (const QString &filter : filters) {
|
||||
QString pattern = QRegularExpression::wildcardToRegularExpression(filter);
|
||||
QRegularExpression regExp(pattern, option);
|
||||
if (regExp.match(fileName).hasMatch())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user