forked from qt-creator/qt-creator
Perforce: Remove QRegExp use
Task-number: QTCREATORBUG-24098 Change-Id: Id234cc2206afd3e1372c25749e73d7c31c7ebd7f Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -66,6 +66,7 @@
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
|
||||||
@@ -783,7 +784,7 @@ void PerforcePluginPrivate::startSubmitProject()
|
|||||||
QStringList filesLines = filesResult.stdOut.split(QLatin1Char('\n'));
|
QStringList filesLines = filesResult.stdOut.split(QLatin1Char('\n'));
|
||||||
QStringList depotFileNames;
|
QStringList depotFileNames;
|
||||||
foreach (const QString &line, filesLines) {
|
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()) {
|
if (depotFileNames.isEmpty()) {
|
||||||
VcsOutputWindow::appendWarning(tr("Project has no files"));
|
VcsOutputWindow::appendWarning(tr("Project has no files"));
|
||||||
@@ -1635,9 +1636,9 @@ QString PerforcePluginPrivate::clientFilePath(const QString &serverFilePath)
|
|||||||
if (response.error)
|
if (response.error)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QRegExp r(QLatin1String("\\.\\.\\.\\sclientFile\\s(.+)\n"));
|
const QRegularExpression r("\\.\\.\\.\\sclientFile\\s(.+?)\n");
|
||||||
r.setMinimal(true);
|
const QRegularExpressionMatch match = r.match(response.stdOut);
|
||||||
return r.indexIn(response.stdOut) != -1 ? r.cap(1).trimmed() : QString();
|
return match.hasMatch() ? match.captured(1).trimmed() : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PerforcePluginPrivate::pendingChangesData()
|
QString PerforcePluginPrivate::pendingChangesData()
|
||||||
@@ -1650,10 +1651,10 @@ QString PerforcePluginPrivate::pendingChangesData()
|
|||||||
if (userResponse.error)
|
if (userResponse.error)
|
||||||
return QString();
|
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());
|
QTC_ASSERT(r.isValid(), return QString());
|
||||||
r.setMinimal(true);
|
const QRegularExpressionMatch match = r.match(userResponse.stdOut);
|
||||||
const QString user = r.indexIn(userResponse.stdOut) != -1 ? r.cap(1).trimmed() : QString();
|
const QString user = match.hasMatch() ? match.captured(1).trimmed() : QString();
|
||||||
if (user.isEmpty())
|
if (user.isEmpty())
|
||||||
return QString();
|
return QString();
|
||||||
args.clear();
|
args.clear();
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#include <vcsbase/submitfilemodel.h>
|
#include <vcsbase/submitfilemodel.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace Perforce {
|
namespace Perforce {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -69,10 +71,9 @@ bool PerforceSubmitEditor::setFileContents(const QByteArray &contents)
|
|||||||
|
|
||||||
bool PerforceSubmitEditor::parseText(QString text)
|
bool PerforceSubmitEditor::parseText(QString text)
|
||||||
{
|
{
|
||||||
QRegExp formField(QLatin1String("^\\S+:"));
|
QRegularExpression formField(QLatin1String("^\\S+:"));
|
||||||
const QString newLine = QString(QLatin1Char('\n'));
|
const QString newLine = QString(QLatin1Char('\n'));
|
||||||
|
|
||||||
int match;
|
|
||||||
int matchLen;
|
int matchLen;
|
||||||
QTextStream stream(&text, QIODevice::ReadOnly);
|
QTextStream stream(&text, QIODevice::ReadOnly);
|
||||||
QString line;
|
QString line;
|
||||||
@@ -80,14 +81,14 @@ bool PerforceSubmitEditor::parseText(QString text)
|
|||||||
QString value;
|
QString value;
|
||||||
line = stream.readLine();
|
line = stream.readLine();
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
match = formField.indexIn(line);
|
const QRegularExpressionMatch match = formField.match(line);
|
||||||
if (match == 0) {
|
if (match.hasMatch()) {
|
||||||
matchLen = formField.matchedLength();
|
matchLen = match.capturedLength();
|
||||||
key = line.left(matchLen-1);
|
key = line.left(matchLen-1);
|
||||||
value = line.mid(matchLen) + newLine;
|
value = line.mid(matchLen) + newLine;
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
line = stream.readLine();
|
line = stream.readLine();
|
||||||
if (formField.indexIn(line) != -1)
|
if (line.indexOf(formField) != -1)
|
||||||
break;
|
break;
|
||||||
value += line + newLine;
|
value += line + newLine;
|
||||||
}
|
}
|
||||||
@@ -116,7 +117,7 @@ void PerforceSubmitEditor::updateFields()
|
|||||||
lines.removeFirst(); // that is the line break after 'Description:'
|
lines.removeFirst(); // that is the line break after 'Description:'
|
||||||
lines.removeLast(); // that is the empty line at the end
|
lines.removeLast(); // that is the empty line at the end
|
||||||
|
|
||||||
const QRegExp leadingTabPattern = QRegExp(QLatin1String("^\\t"));
|
const QRegularExpression leadingTabPattern("^\\t");
|
||||||
QTC_CHECK(leadingTabPattern.isValid());
|
QTC_CHECK(leadingTabPattern.isValid());
|
||||||
|
|
||||||
lines.replaceInStrings(leadingTabPattern, QString());
|
lines.replaceInStrings(leadingTabPattern, QString());
|
||||||
@@ -144,7 +145,7 @@ void PerforceSubmitEditor::updateEntries()
|
|||||||
while (!lines.empty() && lines.last().isEmpty())
|
while (!lines.empty() && lines.last().isEmpty())
|
||||||
lines.removeLast();
|
lines.removeLast();
|
||||||
// Description
|
// Description
|
||||||
lines.replaceInStrings(QRegExp(QLatin1String("^")), tab);
|
lines.replaceInStrings(QRegularExpression("^"), tab);
|
||||||
m_entries.insert(QLatin1String("Description"), newLine + lines.join(newLine) + QLatin1String("\n\n"));
|
m_entries.insert(QLatin1String("Description"), newLine + lines.join(newLine) + QLatin1String("\n\n"));
|
||||||
QString files = newLine;
|
QString files = newLine;
|
||||||
// Re-build the file spec '<tab>file#add' from the user data
|
// Re-build the file spec '<tab>file#add' from the user data
|
||||||
|
Reference in New Issue
Block a user