DolphinQt: Migrate QRegExp over to QRegularExpression
Qt 5.0 introduced QRegularExpression to replace QRegExp. In Qt 6.0, QRegExp is removed entirely in favor of it.
This commit is contained in:
parent
765a1b3c09
commit
46ca371ef3
|
@ -11,6 +11,7 @@
|
|||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QScrollBar>
|
||||
#include <QStringListModel>
|
||||
#include <QTextCursor>
|
||||
|
@ -161,7 +162,7 @@ void GameConfigEdit::AddBoolOption(QMenu* menu, const QString& name, const QStri
|
|||
void GameConfigEdit::SetOption(const QString& section, const QString& key, const QString& value)
|
||||
{
|
||||
auto section_cursor =
|
||||
m_edit->document()->find(QRegExp(QStringLiteral("^\\[%1\\]").arg(section)), 0);
|
||||
m_edit->document()->find(QRegularExpression(QStringLiteral("^\\[%1\\]").arg(section)), 0);
|
||||
|
||||
// Check if the section this belongs in can be found
|
||||
if (section_cursor.isNull())
|
||||
|
@ -170,8 +171,8 @@ void GameConfigEdit::SetOption(const QString& section, const QString& key, const
|
|||
}
|
||||
else
|
||||
{
|
||||
auto value_cursor =
|
||||
m_edit->document()->find(QRegExp(QStringLiteral("^%1 = .*").arg(key)), section_cursor);
|
||||
auto value_cursor = m_edit->document()->find(
|
||||
QRegularExpression(QStringLiteral("^%1 = .*").arg(key)), section_cursor);
|
||||
|
||||
const QString new_line = QStringLiteral("%1 = %2").arg(key).arg(value);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QPushButton>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
|
||||
|
@ -51,8 +51,8 @@ QString GetExpressionForControl(const QString& control_name,
|
|||
|
||||
if (quote == Quote::On)
|
||||
{
|
||||
QRegExp reg(QStringLiteral("[a-zA-Z]+"));
|
||||
if (!reg.exactMatch(expr))
|
||||
const QRegularExpression reg(QStringLiteral("[a-zA-Z]+"));
|
||||
if (!reg.match(expr).hasMatch())
|
||||
expr = QStringLiteral("`%1`").arg(expr);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QPixmap>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
|
||||
|
@ -96,7 +97,8 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
|||
const int disc_nr = game.GetDiscNumber() + 1;
|
||||
if (disc_nr > 1)
|
||||
{
|
||||
if (!name.contains(QRegExp(QStringLiteral("disc ?%1").arg(disc_nr), Qt::CaseInsensitive)))
|
||||
if (!name.contains(QRegularExpression(QStringLiteral("disc ?%1").arg(disc_nr),
|
||||
QRegularExpression::CaseInsensitiveOption)))
|
||||
{
|
||||
name.append(tr(" (Disc %1)").arg(disc_nr));
|
||||
}
|
||||
|
@ -107,11 +109,14 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
|||
{
|
||||
constexpr int MAX_NUMBER_LENGTH = 10;
|
||||
|
||||
QRegExp rx(QStringLiteral("\\d+"));
|
||||
const QRegularExpression rx(QStringLiteral("\\d+"));
|
||||
QRegularExpressionMatch match;
|
||||
int pos = 0;
|
||||
while ((pos = rx.indexIn(name, pos)) != -1)
|
||||
while ((match = rx.match(name, pos)).hasMatch())
|
||||
{
|
||||
name.replace(pos, rx.matchedLength(), rx.cap().rightJustified(MAX_NUMBER_LENGTH));
|
||||
pos = match.capturedStart();
|
||||
name.replace(pos, match.capturedLength(),
|
||||
match.captured().rightJustified(MAX_NUMBER_LENGTH));
|
||||
pos += MAX_NUMBER_LENGTH;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue