mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 21:52:32 -06:00
Merge pull request #15181 from glassez/qt5
Raise minimum Qt version to 5.15.2
This commit is contained in:
@@ -32,18 +32,18 @@
|
||||
|
||||
using namespace BitTorrent;
|
||||
|
||||
PeerAddress PeerAddress::parse(const QString &address)
|
||||
PeerAddress PeerAddress::parse(const QStringView address)
|
||||
{
|
||||
QVector<QStringRef> ipPort;
|
||||
QList<QStringView> ipPort;
|
||||
|
||||
if (address.startsWith('[') && address.contains("]:"))
|
||||
if (address.startsWith(u'[') && address.contains(QLatin1String("]:")))
|
||||
{ // IPv6
|
||||
ipPort = address.splitRef("]:");
|
||||
ipPort = address.split(QString::fromLatin1("]:"));
|
||||
ipPort[0] = ipPort[0].mid(1); // chop '['
|
||||
}
|
||||
else if (address.contains(':'))
|
||||
else if (address.contains(u':'))
|
||||
{ // IPv4
|
||||
ipPort = address.splitRef(':');
|
||||
ipPort = address.split(u':');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace BitTorrent
|
||||
QHostAddress ip;
|
||||
ushort port = 0;
|
||||
|
||||
static PeerAddress parse(const QString &address);
|
||||
static PeerAddress parse(QStringView address);
|
||||
QString toString() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1590,7 +1590,7 @@ void Session::populateAdditionalTrackers()
|
||||
m_additionalTrackerList.clear();
|
||||
|
||||
const QString trackers = additionalTrackers();
|
||||
for (QStringRef tracker : asConst(trackers.splitRef('\n')))
|
||||
for (QStringView tracker : asConst(QStringView(trackers).split(u'\n')))
|
||||
{
|
||||
tracker = tracker.trimmed();
|
||||
if (!tracker.isEmpty())
|
||||
|
||||
@@ -1868,9 +1868,9 @@ void TorrentImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p)
|
||||
if (m_oldPath[p->index].isEmpty())
|
||||
m_oldPath.remove(p->index);
|
||||
|
||||
QVector<QStringRef> oldPathParts = oldFilePath.splitRef('/', Qt::SkipEmptyParts);
|
||||
QList<QStringView> oldPathParts = QStringView(oldFilePath).split('/', Qt::SkipEmptyParts);
|
||||
oldPathParts.removeLast(); // drop file name part
|
||||
QVector<QStringRef> newPathParts = newFilePath.splitRef('/', Qt::SkipEmptyParts);
|
||||
QList<QStringView> newPathParts = QStringView(newFilePath).split('/', Qt::SkipEmptyParts);
|
||||
newPathParts.removeLast(); // drop file name part
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
@@ -1889,7 +1889,7 @@ void TorrentImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p)
|
||||
|
||||
for (int i = (oldPathParts.size() - 1); i >= pathIdx; --i)
|
||||
{
|
||||
QDir().rmdir(savePath() + Utils::String::join(oldPathParts, QLatin1String("/")));
|
||||
QDir().rmdir(savePath() + Utils::String::join(oldPathParts, QString::fromLatin1("/")));
|
||||
oldPathParts.removeLast();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace
|
||||
{
|
||||
if (QDir::isAbsolutePath(filePath)) continue;
|
||||
|
||||
const auto filePathElements = filePath.splitRef('/');
|
||||
const auto filePathElements = QStringView(filePath).split(u'/');
|
||||
// if at least one file has no root folder, no common root folder exists
|
||||
if (filePathElements.count() <= 1) return {};
|
||||
|
||||
|
||||
@@ -137,9 +137,9 @@ bool Connection::acceptsGzipEncoding(QString codings)
|
||||
{
|
||||
// [rfc7231] 5.3.4. Accept-Encoding
|
||||
|
||||
const auto isCodingAvailable = [](const QVector<QStringRef> &list, const QString &encoding) -> bool
|
||||
const auto isCodingAvailable = [](const QList<QStringView> &list, const QStringView encoding) -> bool
|
||||
{
|
||||
for (const QStringRef &str : list)
|
||||
for (const QStringView &str : list)
|
||||
{
|
||||
if (!str.startsWith(encoding))
|
||||
continue;
|
||||
@@ -149,7 +149,7 @@ bool Connection::acceptsGzipEncoding(QString codings)
|
||||
return true;
|
||||
|
||||
// [rfc7231] 5.3.1. Quality Values
|
||||
const QStringRef substr = str.mid(encoding.size() + 3); // ex. skip over "gzip;q="
|
||||
const QStringView substr = str.mid(encoding.size() + 3); // ex. skip over "gzip;q="
|
||||
|
||||
bool ok = false;
|
||||
const double qvalue = substr.toDouble(&ok);
|
||||
@@ -161,15 +161,15 @@ bool Connection::acceptsGzipEncoding(QString codings)
|
||||
return false;
|
||||
};
|
||||
|
||||
const QVector<QStringRef> list = codings.remove(' ').remove('\t').splitRef(',', Qt::SkipEmptyParts);
|
||||
const QList<QStringView> list = QStringView(codings.remove(' ').remove('\t')).split(u',', Qt::SkipEmptyParts);
|
||||
if (list.isEmpty())
|
||||
return false;
|
||||
|
||||
const bool canGzip = isCodingAvailable(list, QLatin1String("gzip"));
|
||||
const bool canGzip = isCodingAvailable(list, QString::fromLatin1("gzip"));
|
||||
if (canGzip)
|
||||
return true;
|
||||
|
||||
const bool canAny = isCodingAvailable(list, QLatin1String("*"));
|
||||
const bool canAny = isCodingAvailable(list, QString::fromLatin1("*"));
|
||||
if (canAny)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace
|
||||
return in;
|
||||
}
|
||||
|
||||
bool parseHeaderLine(const QString &line, HeaderMap &out)
|
||||
bool parseHeaderLine(const QStringView line, HeaderMap &out)
|
||||
{
|
||||
// [rfc7230] 3.2. Header Fields
|
||||
const int i = line.indexOf(':');
|
||||
@@ -67,8 +67,8 @@ namespace
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString name = line.leftRef(i).trimmed().toString().toLower();
|
||||
const QString value = line.midRef(i + 1).trimmed().toString();
|
||||
const QString name = line.left(i).trimmed().toString().toLower();
|
||||
const QString value = line.mid(i + 1).trimmed().toString();
|
||||
out[name] = value;
|
||||
|
||||
return true;
|
||||
@@ -145,10 +145,10 @@ RequestParser::ParseResult RequestParser::doParse(const QByteArray &data)
|
||||
return {ParseStatus::BadRequest, Request(), 0}; // TODO: SHOULD respond "501 Not Implemented"
|
||||
}
|
||||
|
||||
bool RequestParser::parseStartLines(const QString &data)
|
||||
bool RequestParser::parseStartLines(const QStringView data)
|
||||
{
|
||||
// we don't handle malformed request which uses `LF` for newline
|
||||
const QVector<QStringRef> lines = data.splitRef(CRLF, Qt::SkipEmptyParts);
|
||||
const QList<QStringView> lines = data.split(QString::fromLatin1(CRLF), Qt::SkipEmptyParts);
|
||||
|
||||
// [rfc7230] 3.2.2. Field Order
|
||||
QStringList requestLines;
|
||||
@@ -267,7 +267,7 @@ bool RequestParser::parsePostMessage(const QByteArray &data)
|
||||
return false;
|
||||
}
|
||||
|
||||
const QByteArray delimiter = Utils::String::unquote(contentType.midRef(idx + boundaryFieldName.size())).toLatin1();
|
||||
const QByteArray delimiter = Utils::String::unquote(QStringView(contentType).mid(idx + boundaryFieldName.size())).toLatin1();
|
||||
if (delimiter.isEmpty())
|
||||
{
|
||||
qWarning() << Q_FUNC_INFO << "boundary delimiter field empty!";
|
||||
@@ -311,13 +311,13 @@ bool RequestParser::parseFormData(const QByteArray &data)
|
||||
const QByteArray payload = viewWithoutEndingWith(list[1], CRLF);
|
||||
|
||||
HeaderMap headersMap;
|
||||
const QVector<QStringRef> headerLines = headers.splitRef(CRLF, Qt::SkipEmptyParts);
|
||||
const QList<QStringView> headerLines = QStringView(headers).split(QString::fromLatin1(CRLF), Qt::SkipEmptyParts);
|
||||
for (const auto &line : headerLines)
|
||||
{
|
||||
if (line.trimmed().startsWith(HEADER_CONTENT_DISPOSITION, Qt::CaseInsensitive))
|
||||
if (line.trimmed().startsWith(QString::fromLatin1(HEADER_CONTENT_DISPOSITION), Qt::CaseInsensitive))
|
||||
{
|
||||
// extract out filename & name
|
||||
const QVector<QStringRef> directives = line.split(';', Qt::SkipEmptyParts);
|
||||
const QList<QStringView> directives = line.split(u';', Qt::SkipEmptyParts);
|
||||
|
||||
for (const auto &directive : directives)
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Http
|
||||
RequestParser();
|
||||
|
||||
ParseResult doParse(const QByteArray &data);
|
||||
bool parseStartLines(const QString &data);
|
||||
bool parseStartLines(QStringView data);
|
||||
bool parseRequestLine(const QString &line);
|
||||
|
||||
bool parsePostMessage(const QByteArray &data);
|
||||
|
||||
@@ -122,12 +122,7 @@ Smtp::Smtp(QObject *parent)
|
||||
|
||||
connect(m_socket, &QIODevice::readyRead, this, &Smtp::readyRead);
|
||||
connect(m_socket, &QAbstractSocket::disconnected, this, &QObject::deleteLater);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
connect(m_socket, &QAbstractSocket::errorOccurred, this, &Smtp::error);
|
||||
#else
|
||||
connect(m_socket, qOverload<QAbstractSocket::SocketError>(&QAbstractSocket::error)
|
||||
, this, &Smtp::error);
|
||||
#endif
|
||||
|
||||
// Test hmacMD5 function (http://www.faqs.org/rfcs/rfc2202.html)
|
||||
Q_ASSERT(hmacMD5("Jefe", "what do ya want for nothing?").toHex()
|
||||
|
||||
@@ -325,7 +325,7 @@ bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitl
|
||||
|
||||
if (episode.endsWith('-'))
|
||||
{ // Infinite range
|
||||
const int episodeOurs {episode.leftRef(episode.size() - 1).toInt()};
|
||||
const int episodeOurs {QStringView(episode).left(episode.size() - 1).toInt()};
|
||||
if (((seasonTheirs == seasonOurs) && (episodeTheirs >= episodeOurs)) || (seasonTheirs > seasonOurs))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void SearchDownloadHandler::downloadProcessFinished(int exitcode)
|
||||
if ((exitcode == 0) && (m_downloadProcess->exitStatus() == QProcess::NormalExit))
|
||||
{
|
||||
const QString line = QString::fromUtf8(m_downloadProcess->readAllStandardOutput()).trimmed();
|
||||
const QVector<QStringRef> parts = line.splitRef(' ');
|
||||
const QList<QStringView> parts = QStringView(line).split(u' ');
|
||||
if (parts.size() == 2)
|
||||
path = parts[0].toString();
|
||||
}
|
||||
|
||||
@@ -163,9 +163,9 @@ void SearchHandler::processFailed()
|
||||
// Parse one line of search results list
|
||||
// Line is in the following form:
|
||||
// file url | file name | file size | nb seeds | nb leechers | Search engine url
|
||||
bool SearchHandler::parseSearchResult(const QString &line, SearchResult &searchResult)
|
||||
bool SearchHandler::parseSearchResult(const QStringView line, SearchResult &searchResult)
|
||||
{
|
||||
const QVector<QStringRef> parts = line.splitRef('|');
|
||||
const QList<QStringView> parts = line.split(u'|');
|
||||
const int nbFields = parts.size();
|
||||
|
||||
if (nbFields < (NB_PLUGIN_COLUMNS - 1)) return false; // -1 because desc_link is optional
|
||||
|
||||
@@ -78,7 +78,7 @@ private:
|
||||
void readSearchOutput();
|
||||
void processFailed();
|
||||
void processFinished(int exitcode);
|
||||
bool parseSearchResult(const QString &line, SearchResult &searchResult);
|
||||
bool parseSearchResult(QStringView line, SearchResult &searchResult);
|
||||
|
||||
const QString m_pattern;
|
||||
const QString m_category;
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <Qt>
|
||||
#include <QtContainerFwd>
|
||||
|
||||
class QByteArray;
|
||||
|
||||
namespace Utils::ByteArray
|
||||
{
|
||||
// Mimic QString::splitRef(sep, behavior)
|
||||
// Mimic QStringView(in).split(sep, behavior)
|
||||
QVector<QByteArray> splitToViews(const QByteArray &in, const QByteArray &sep, const Qt::SplitBehavior behavior = Qt::KeepEmptyParts);
|
||||
|
||||
// Mimic QByteArray::mid(pos, len) but instead of returning a full-copy,
|
||||
|
||||
@@ -60,16 +60,16 @@ int Utils::Compare::naturalCompare(const QString &left, const QString &right, co
|
||||
{
|
||||
// Both are digits, compare the numbers
|
||||
|
||||
const auto numberView = [](const QString &str, int &pos) -> QStringRef
|
||||
const auto numberView = [](const QStringView str, int &pos) -> QStringView
|
||||
{
|
||||
const int start = pos;
|
||||
while ((pos < str.size()) && str[pos].isDigit())
|
||||
++pos;
|
||||
return str.midRef(start, (pos - start));
|
||||
return str.mid(start, (pos - start));
|
||||
};
|
||||
|
||||
const QStringRef numViewL = numberView(left, posL);
|
||||
const QStringRef numViewR = numberView(right, posR);
|
||||
const QStringView numViewL = numberView(left, posL);
|
||||
const QStringView numViewR = numberView(right, posR);
|
||||
|
||||
if (numViewL.length() != numViewR.length())
|
||||
return (numViewL.length() - numViewR.length());
|
||||
|
||||
@@ -498,7 +498,7 @@ QString Utils::Misc::opensslVersionString()
|
||||
#else
|
||||
static const auto version {QString::fromLatin1(SSLeay_version(SSLEAY_VERSION))};
|
||||
#endif
|
||||
return version.splitRef(' ', Qt::SkipEmptyParts)[1].toString();
|
||||
return QStringView(version).split(u' ', Qt::SkipEmptyParts)[1].toString();
|
||||
}
|
||||
|
||||
QString Utils::Misc::zlibVersionString()
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
// to send numbers instead of strings with suffixes
|
||||
QString Utils::String::fromDouble(const double n, const int precision)
|
||||
{
|
||||
/* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9
|
||||
/* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f', 1) == 99.9
|
||||
** but QString::number(0.9999*100.0, 'f' ,1) == 100.0 The problem manifests when
|
||||
** the number has more digits after the decimal than we want AND the digit after
|
||||
** our 'wanted' is >= 5. In this case our last digit gets rounded up. So for each
|
||||
@@ -99,7 +99,7 @@ std::optional<double> Utils::String::parseDouble(const QString &string)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
QString Utils::String::join(const QVector<QStringRef> &strings, const QString &separator)
|
||||
QString Utils::String::join(const QList<QStringView> &strings, const QStringView separator)
|
||||
{
|
||||
if (strings.empty())
|
||||
return {};
|
||||
|
||||
@@ -37,8 +37,6 @@
|
||||
#include <Qt>
|
||||
#include <QtContainerFwd>
|
||||
|
||||
class QStringRef;
|
||||
|
||||
namespace Utils::String
|
||||
{
|
||||
QString wildcardToRegexPattern(const QString &pattern);
|
||||
@@ -61,7 +59,7 @@ namespace Utils::String
|
||||
std::optional<int> parseInt(const QString &string);
|
||||
std::optional<double> parseDouble(const QString &string);
|
||||
|
||||
QString join(const QVector<QStringRef> &strings, const QString &separator);
|
||||
QString join(const QList<QStringView> &strings, QStringView separator);
|
||||
|
||||
QString fromDouble(double n, int precision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user