mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 08:48:07 -06:00
Revert "Use QRegularExpression instead of deprecated QRegExp"
Related to #14611
This reverts commit 3b748178c2.
This commit is contained in:
@@ -213,8 +213,10 @@ QRegularExpression AutoDownloadRule::cachedRegex(const QString &expression, cons
|
||||
QRegularExpression ®ex = m_dataPtr->cachedRegexes[expression];
|
||||
if (regex.pattern().isEmpty())
|
||||
{
|
||||
const QString pattern = (isRegex ? expression : Utils::String::wildcardToRegexPattern(expression));
|
||||
regex = QRegularExpression {pattern, QRegularExpression::CaseInsensitiveOption};
|
||||
regex = QRegularExpression
|
||||
{
|
||||
(isRegex ? expression : Utils::String::wildcardToRegex(expression))
|
||||
, QRegularExpression::CaseInsensitiveOption};
|
||||
}
|
||||
|
||||
return regex;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <QGlobalStatic>
|
||||
#include <QHash>
|
||||
#include <QMetaObject>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegExp>
|
||||
#include <QStringList>
|
||||
#include <QVariant>
|
||||
#include <QXmlStreamEntityResolver>
|
||||
@@ -391,13 +391,12 @@ namespace
|
||||
int nmin = 8;
|
||||
int nsec = 9;
|
||||
// Also accept obsolete form "Weekday, DD-Mon-YY HH:MM:SS ±hhmm"
|
||||
QRegularExpression rx {"^(?:([A-Z][a-z]+),\\s*)?(\\d{1,2})(\\s+|-)([^-\\s]+)(\\s+|-)(\\d{2,4})\\s+(\\d\\d):(\\d\\d)(?::(\\d\\d))?\\s+(\\S+)$"};
|
||||
QRegularExpressionMatch rxMatch;
|
||||
QRegExp rx("^(?:([A-Z][a-z]+),\\s*)?(\\d{1,2})(\\s+|-)([^-\\s]+)(\\s+|-)(\\d{2,4})\\s+(\\d\\d):(\\d\\d)(?::(\\d\\d))?\\s+(\\S+)$");
|
||||
QStringList parts;
|
||||
if (str.indexOf(rx, 0, &rxMatch) == 0)
|
||||
if (!str.indexOf(rx))
|
||||
{
|
||||
// Check that if date has '-' separators, both separators are '-'.
|
||||
parts = rxMatch.capturedTexts();
|
||||
parts = rx.capturedTexts();
|
||||
const bool h1 = (parts[3] == QLatin1String("-"));
|
||||
const bool h2 = (parts[5] == QLatin1String("-"));
|
||||
if (h1 != h2)
|
||||
@@ -406,10 +405,9 @@ namespace
|
||||
else
|
||||
{
|
||||
// Check for the obsolete form "Wdy Mon DD HH:MM:SS YYYY"
|
||||
rx = QRegularExpression {"^([A-Z][a-z]+)\\s+(\\S+)\\s+(\\d\\d)\\s+(\\d\\d):(\\d\\d):(\\d\\d)\\s+(\\d\\d\\d\\d)$"};
|
||||
if (str.indexOf(rx, 0, &rxMatch) != 0)
|
||||
rx = QRegExp("^([A-Z][a-z]+)\\s+(\\S+)\\s+(\\d\\d)\\s+(\\d\\d):(\\d\\d):(\\d\\d)\\s+(\\d\\d\\d\\d)$");
|
||||
if (str.indexOf(rx))
|
||||
return QDateTime::currentDateTime();
|
||||
|
||||
nyear = 7;
|
||||
nmonth = 2;
|
||||
nday = 3;
|
||||
@@ -417,7 +415,7 @@ namespace
|
||||
nhour = 4;
|
||||
nmin = 5;
|
||||
nsec = 6;
|
||||
parts = rxMatch.capturedTexts();
|
||||
parts = rx.capturedTexts();
|
||||
}
|
||||
|
||||
bool ok[4];
|
||||
@@ -465,11 +463,11 @@ namespace
|
||||
bool negOffset = false;
|
||||
if (parts.count() > 10)
|
||||
{
|
||||
rx = QRegularExpression {"^([+-])(\\d\\d)(\\d\\d)$"};
|
||||
if (parts[10].indexOf(rx, 0, &rxMatch) == 0)
|
||||
rx = QRegExp("^([+-])(\\d\\d)(\\d\\d)$");
|
||||
if (!parts[10].indexOf(rx))
|
||||
{
|
||||
// It's a UTC offset ±hhmm
|
||||
parts = rxMatch.capturedTexts();
|
||||
parts = rx.capturedTexts();
|
||||
offset = parts[2].toInt(&ok[0]) * 3600;
|
||||
const int offsetMin = parts[3].toInt(&ok[1]);
|
||||
if (!ok[0] || !ok[1] || offsetMin > 59)
|
||||
|
||||
@@ -33,15 +33,10 @@
|
||||
|
||||
#include <QCollator>
|
||||
#include <QLocale>
|
||||
#include <QRegExp>
|
||||
#include <QtGlobal>
|
||||
#include <QVector>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
#include <QRegularExpression>
|
||||
#else
|
||||
#include <QRegExp>
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MACOS) || defined(__MINGW32__)
|
||||
#define QBT_USES_QTHREADSTORAGE
|
||||
#include <QThreadStorage>
|
||||
@@ -186,21 +181,14 @@ QString Utils::String::fromDouble(const double n, const int precision)
|
||||
return QLocale::system().toString(std::floor(n * prec) / prec, 'f', precision);
|
||||
}
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
QString Utils::String::wildcardToRegexPattern(const QString &pattern)
|
||||
{
|
||||
return QRegularExpression::wildcardToRegularExpression(pattern, QRegularExpression::UnanchoredWildcardConversion);
|
||||
}
|
||||
#else
|
||||
// This is marked as internal in QRegExp.cpp, but is exported. The alternative would be to
|
||||
// copy the code from QRegExp::wc2rx().
|
||||
QString qt_regexp_toCanonical(const QString &pattern, QRegExp::PatternSyntax patternSyntax);
|
||||
|
||||
QString Utils::String::wildcardToRegexPattern(const QString &pattern)
|
||||
QString Utils::String::wildcardToRegex(const QString &pattern)
|
||||
{
|
||||
return qt_regexp_toCanonical(pattern, QRegExp::Wildcard);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::optional<bool> Utils::String::parseBool(const QString &string)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Utils::String
|
||||
return (naturalCompare(left, right, caseSensitivity) < 0);
|
||||
}
|
||||
|
||||
QString wildcardToRegexPattern(const QString &pattern);
|
||||
QString wildcardToRegex(const QString &pattern);
|
||||
|
||||
template <typename T>
|
||||
T unquote(const T &str, const QString "es = QChar('"'))
|
||||
|
||||
Reference in New Issue
Block a user