Skip to content

Commit

Permalink
refactor: Replace depracated QRegExp with QRegularExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
pktiuk committed Apr 9, 2024
1 parent d20f9be commit ea3666c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
13 changes: 7 additions & 6 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#include <QDirIterator>
#include <QLibraryInfo>
#include <QReadWriteLock>
#include <QRegExp>
#include <QRegularExpression>

#ifdef Q_OS_WIN
#include <QStandardPaths>
#endif
Expand Down Expand Up @@ -90,9 +91,9 @@ QStringList parseArgumentsString(QString tempString)
{
bool inside = (!tempString.isEmpty() && tempString.at(0) == QChar('"'));
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList tempList = tempString.split(QRegExp("\""), Qt::SkipEmptyParts);
QStringList tempList = tempString.split(QRegularExpression("\""), Qt::SkipEmptyParts);
#else
QStringList tempList = tempString.split(QRegExp("\""), QString::SkipEmptyParts);
QStringList tempList = tempString.split(QRegularExpression("\""), QString::SkipEmptyParts);
#endif
QStringList finalList = QStringList();
QStringListIterator iter(tempList);
Expand All @@ -105,9 +106,9 @@ QStringList parseArgumentsString(QString tempString)
finalList.append(temp);
else
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
finalList.append(temp.split(QRegExp("\\s+"), Qt::SkipEmptyParts));
finalList.append(temp.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts));
#else
finalList.append(temp.split(QRegExp("\\s+"), QString::SkipEmptyParts));
finalList.append(temp.split(QRegularExpression("\\s+"), QString::SkipEmptyParts));
#endif
inside = !inside;
}
Expand Down Expand Up @@ -179,7 +180,7 @@ QIcon loadIcon(QString name)
QDirIterator it(":images/", QDirIterator::Subdirectories);
QString fallback_location = "";
// search also for variants with underscore like document_save.png for document-save
QRegExp regex = QRegExp(".*" + name.replace(QChar('-'), "[_-]") + "\\.(svg|png)");
QRegularExpression regex = QRegularExpression(".*" + name.replace(QChar('-'), "[_-]") + "\\.(svg|png)");
while (it.hasNext())
{
QString value = it.next();
Expand Down
4 changes: 2 additions & 2 deletions src/gamecontroller/gamecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <cmath>

#include <QDebug>
#include <QRegExp>
#include <QRegularExpression>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>

Expand Down Expand Up @@ -91,7 +91,7 @@ QString GameController::getSerialString() const
if (controller != nullptr)
{
const char *serial = SDL_GameControllerGetSerial(controller);
temp = QString(serial).remove(QRegExp("[^A-Za-z0-9]"));
temp = QString(serial).remove(QRegularExpression("[^A-Za-z0-9]"));
}
#endif
return temp;
Expand Down
4 changes: 2 additions & 2 deletions src/globalvariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ const int GlobalVariables::InputDevice::RAISEDDEADZONE = 20000;
const int GlobalVariables::InputDevice::DEFAULTKEYREPEATDELAY = 660; // 660 ms
const int GlobalVariables::InputDevice::DEFAULTKEYREPEATRATE = 40; // 40 ms. 25 times per second

// QRegExp GlobalVariables::InputDevice::emptyGUID("^[0]+$");
QRegExp GlobalVariables::InputDevice::emptyUniqueID("^[0]+$");
// QRegularExpression GlobalVariables::InputDevice::emptyGUID("^[0]+$");
QRegularExpression GlobalVariables::InputDevice::emptyUniqueID("^[0]+$");

// ---- JOYAXIS ---- //

Expand Down
6 changes: 3 additions & 3 deletions src/globalvariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <QList>
#include <QObject>
#include <QRegExp>
#include <QRegularExpression>

namespace GlobalVariables {
class JoyButton
Expand Down Expand Up @@ -107,8 +107,8 @@ class InputDevice
static const int DEFAULTKEYREPEATDELAY;
static const int DEFAULTKEYREPEATRATE;

// static QRegExp emptyGUID;
static QRegExp emptyUniqueID;
// static QRegularExpression emptyGUID;
static QRegularExpression emptyUniqueID;
};

class JoyAxis
Expand Down
2 changes: 1 addition & 1 deletion src/joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ QString Joystick::getSerialString() const
if (m_joyhandle != nullptr)
{
const char *serial = SDL_JoystickGetSerial(m_joyhandle);
temp = QString(serial).remove(QRegExp("[^A-Za-z0-9]"));
temp = QString(serial).remove(QRegularExpression("[^A-Za-z0-9]"));
}
#endif

Expand Down

0 comments on commit ea3666c

Please sign in to comment.