aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/perforce
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-06-23 16:02:54 +0200
committerhjk <hjk@qt.io>2020-06-24 08:38:27 +0000
commit8b3e0d71225be469ac9a6e4867e09b28d2db7530 (patch)
tree42dee9c4c973567a398057b94208d59616b1cfa7 /src/plugins/perforce
parent15ab47cb3c19158d8e62943595e46f7d171c5366 (diff)
Perforce: Remove QRegExp use
Task-number: QTCREATORBUG-24098 Change-Id: Id234cc2206afd3e1372c25749e73d7c31c7ebd7f Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/perforce')
-rw-r--r--src/plugins/perforce/perforceplugin.cpp15
-rw-r--r--src/plugins/perforce/perforcesubmiteditor.cpp17
2 files changed, 17 insertions, 15 deletions
diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp
index a04394e90d..6bb0b5d55b 100644
--- a/src/plugins/perforce/perforceplugin.cpp
+++ b/src/plugins/perforce/perforceplugin.cpp
@@ -66,6 +66,7 @@
#include <QMainWindow>
#include <QMenu>
#include <QMessageBox>
+#include <QRegularExpression>
#include <QSettings>
#include <QTextCodec>
@@ -783,7 +784,7 @@ void PerforcePluginPrivate::startSubmitProject()
QStringList filesLines = filesResult.stdOut.split(QLatin1Char('\n'));
QStringList depotFileNames;
foreach (const QString &line, filesLines) {
- depotFileNames.append(line.left(line.lastIndexOf(QRegExp(QLatin1String("#[0-9]+\\s-\\s")))));
+ depotFileNames.append(line.left(line.lastIndexOf(QRegularExpression("#[0-9]+\\s-\\s"))));
}
if (depotFileNames.isEmpty()) {
VcsOutputWindow::appendWarning(tr("Project has no files"));
@@ -1635,9 +1636,9 @@ QString PerforcePluginPrivate::clientFilePath(const QString &serverFilePath)
if (response.error)
return QString();
- QRegExp r(QLatin1String("\\.\\.\\.\\sclientFile\\s(.+)\n"));
- r.setMinimal(true);
- return r.indexIn(response.stdOut) != -1 ? r.cap(1).trimmed() : QString();
+ const QRegularExpression r("\\.\\.\\.\\sclientFile\\s(.+?)\n");
+ const QRegularExpressionMatch match = r.match(response.stdOut);
+ return match.hasMatch() ? match.captured(1).trimmed() : QString();
}
QString PerforcePluginPrivate::pendingChangesData()
@@ -1650,10 +1651,10 @@ QString PerforcePluginPrivate::pendingChangesData()
if (userResponse.error)
return QString();
- QRegExp r(QLatin1String("User\\sname:\\s(\\S+)\\s*\n"));
+ const QRegularExpression r("User\\sname:\\s(\\S+?)\\s*?\n");
QTC_ASSERT(r.isValid(), return QString());
- r.setMinimal(true);
- const QString user = r.indexIn(userResponse.stdOut) != -1 ? r.cap(1).trimmed() : QString();
+ const QRegularExpressionMatch match = r.match(userResponse.stdOut);
+ const QString user = match.hasMatch() ? match.captured(1).trimmed() : QString();
if (user.isEmpty())
return QString();
args.clear();
diff --git a/src/plugins/perforce/perforcesubmiteditor.cpp b/src/plugins/perforce/perforcesubmiteditor.cpp
index 596a9c32e0..115be50ad6 100644
--- a/src/plugins/perforce/perforcesubmiteditor.cpp
+++ b/src/plugins/perforce/perforcesubmiteditor.cpp
@@ -31,6 +31,8 @@
#include <vcsbase/submitfilemodel.h>
#include <utils/qtcassert.h>
+#include <QRegularExpression>
+
namespace Perforce {
namespace Internal {
@@ -69,10 +71,9 @@ bool PerforceSubmitEditor::setFileContents(const QByteArray &contents)
bool PerforceSubmitEditor::parseText(QString text)
{
- QRegExp formField(QLatin1String("^\\S+:"));
+ QRegularExpression formField(QLatin1String("^\\S+:"));
const QString newLine = QString(QLatin1Char('\n'));
- int match;
int matchLen;
QTextStream stream(&text, QIODevice::ReadOnly);
QString line;
@@ -80,14 +81,14 @@ bool PerforceSubmitEditor::parseText(QString text)
QString value;
line = stream.readLine();
while (!stream.atEnd()) {
- match = formField.indexIn(line);
- if (match == 0) {
- matchLen = formField.matchedLength();
+ const QRegularExpressionMatch match = formField.match(line);
+ if (match.hasMatch()) {
+ matchLen = match.capturedLength();
key = line.left(matchLen-1);
value = line.mid(matchLen) + newLine;
while (!stream.atEnd()) {
line = stream.readLine();
- if (formField.indexIn(line) != -1)
+ if (line.indexOf(formField) != -1)
break;
value += line + newLine;
}
@@ -116,7 +117,7 @@ void PerforceSubmitEditor::updateFields()
lines.removeFirst(); // that is the line break after 'Description:'
lines.removeLast(); // that is the empty line at the end
- const QRegExp leadingTabPattern = QRegExp(QLatin1String("^\\t"));
+ const QRegularExpression leadingTabPattern("^\\t");
QTC_CHECK(leadingTabPattern.isValid());
lines.replaceInStrings(leadingTabPattern, QString());
@@ -144,7 +145,7 @@ void PerforceSubmitEditor::updateEntries()
while (!lines.empty() && lines.last().isEmpty())
lines.removeLast();
// Description
- lines.replaceInStrings(QRegExp(QLatin1String("^")), tab);
+ lines.replaceInStrings(QRegularExpression("^"), tab);
m_entries.insert(QLatin1String("Description"), newLine + lines.join(newLine) + QLatin1String("\n\n"));
QString files = newLine;
// Re-build the file spec '<tab>file#add' from the user data