mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 21:28:07 -06:00
Raise minimum Qt version to 5.14
This commit is contained in:
@@ -479,7 +479,8 @@ Session::Session(QObject *parent)
|
||||
m_storedCategories = map_cast(m_categories);
|
||||
}
|
||||
|
||||
m_tags = List::toSet(m_storedTags.get());
|
||||
const QStringList storedTags = m_storedTags.get();
|
||||
m_tags = {storedTags.cbegin(), storedTags.cend()};
|
||||
|
||||
enqueueRefresh();
|
||||
updateSeedingLimitTimer();
|
||||
|
||||
@@ -1252,7 +1252,7 @@ QVector<int> TorrentImpl::pieceAvailability() const
|
||||
std::vector<int> avail;
|
||||
m_nativeHandle.piece_availability(avail);
|
||||
|
||||
return Vector::fromStdVector(avail);
|
||||
return {avail.cbegin(), avail.cend()};
|
||||
}
|
||||
|
||||
qreal TorrentImpl::distributedCopies() const
|
||||
@@ -1857,9 +1857,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('/', QString::SkipEmptyParts);
|
||||
QVector<QStringRef> oldPathParts = oldFilePath.splitRef('/', Qt::SkipEmptyParts);
|
||||
oldPathParts.removeLast(); // drop file name part
|
||||
QVector<QStringRef> newPathParts = newFilePath.splitRef('/', QString::SkipEmptyParts);
|
||||
QVector<QStringRef> newPathParts = newFilePath.splitRef('/', Qt::SkipEmptyParts);
|
||||
newPathParts.removeLast(); // drop file name part
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
|
||||
@@ -35,44 +35,16 @@
|
||||
#define QBT_APP_64BIT
|
||||
#endif
|
||||
|
||||
const char C_TORRENT_FILE_EXTENSION[] = ".torrent";
|
||||
const int MAX_TORRENT_SIZE = 100 * 1024 * 1024; // 100 MiB
|
||||
inline const char C_TORRENT_FILE_EXTENSION[] = ".torrent";
|
||||
inline const int MAX_TORRENT_SIZE = 100 * 1024 * 1024; // 100 MiB
|
||||
|
||||
template <typename T>
|
||||
constexpr typename std::add_const<T>::type &asConst(T &t) noexcept { return t; }
|
||||
constexpr typename std::add_const_t<T> &asConst(T &t) noexcept { return t; }
|
||||
|
||||
// Forward rvalue as const
|
||||
template <typename T>
|
||||
constexpr typename std::add_const<T>::type asConst(T &&t) noexcept { return std::move(t); }
|
||||
constexpr typename std::add_const_t<T> asConst(T &&t) noexcept { return std::move(t); }
|
||||
|
||||
// Prevent const rvalue arguments
|
||||
template <typename T>
|
||||
void asConst(const T &&) = delete;
|
||||
|
||||
namespace List
|
||||
{
|
||||
// Replacement for the deprecated`QSet<T> QSet::fromList(const QList<T> &list)`
|
||||
template <typename T>
|
||||
QSet<T> toSet(const QList<T> &list)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
return {list.cbegin(), list.cend()};
|
||||
#else
|
||||
return QSet<T>::fromList(list);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
namespace Vector
|
||||
{
|
||||
// Replacement for the deprecated `QVector<T> QVector::fromStdVector(const std::vector<T> &vector)`
|
||||
template <typename T>
|
||||
QVector<T> fromStdVector(const std::vector<T> &vector)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
return {vector.cbegin(), vector.cend()};
|
||||
#else
|
||||
return QVector<T>::fromStdVector(vector);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ bool Connection::acceptsGzipEncoding(QString codings)
|
||||
return false;
|
||||
};
|
||||
|
||||
const QVector<QStringRef> list = codings.remove(' ').remove('\t').splitRef(',', QString::SkipEmptyParts);
|
||||
const QVector<QStringRef> list = codings.remove(' ').remove('\t').splitRef(',', Qt::SkipEmptyParts);
|
||||
if (list.isEmpty())
|
||||
return false;
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ RequestParser::ParseResult RequestParser::doParse(const QByteArray &data)
|
||||
bool RequestParser::parseStartLines(const QString &data)
|
||||
{
|
||||
// we don't handle malformed request which uses `LF` for newline
|
||||
const QVector<QStringRef> lines = data.splitRef(CRLF, QString::SkipEmptyParts);
|
||||
const QVector<QStringRef> lines = data.splitRef(CRLF, Qt::SkipEmptyParts);
|
||||
|
||||
// [rfc7230] 3.2.2. Field Order
|
||||
QStringList requestLines;
|
||||
@@ -276,7 +276,7 @@ bool RequestParser::parsePostMessage(const QByteArray &data)
|
||||
|
||||
// split data by "dash-boundary"
|
||||
const QByteArray dashDelimiter = QByteArray("--") + delimiter + CRLF;
|
||||
QVector<QByteArray> multipart = splitToViews(data, dashDelimiter, QString::SkipEmptyParts);
|
||||
QVector<QByteArray> multipart = splitToViews(data, dashDelimiter, Qt::SkipEmptyParts);
|
||||
if (multipart.isEmpty())
|
||||
{
|
||||
qWarning() << Q_FUNC_INFO << "multipart empty";
|
||||
@@ -299,7 +299,7 @@ bool RequestParser::parsePostMessage(const QByteArray &data)
|
||||
|
||||
bool RequestParser::parseFormData(const QByteArray &data)
|
||||
{
|
||||
const QVector<QByteArray> list = splitToViews(data, EOH, QString::KeepEmptyParts);
|
||||
const QVector<QByteArray> list = splitToViews(data, EOH, Qt::KeepEmptyParts);
|
||||
|
||||
if (list.size() != 2)
|
||||
{
|
||||
@@ -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, QString::SkipEmptyParts);
|
||||
const QVector<QStringRef> headerLines = headers.splitRef(CRLF, Qt::SkipEmptyParts);
|
||||
for (const auto &line : headerLines)
|
||||
{
|
||||
if (line.trimmed().startsWith(HEADER_CONTENT_DISPOSITION, Qt::CaseInsensitive))
|
||||
{
|
||||
// extract out filename & name
|
||||
const QVector<QStringRef> directives = line.split(';', QString::SkipEmptyParts);
|
||||
const QVector<QStringRef> directives = line.split(';', Qt::SkipEmptyParts);
|
||||
|
||||
for (const auto &directive : directives)
|
||||
{
|
||||
|
||||
@@ -456,7 +456,7 @@ void Smtp::authenticate()
|
||||
// AUTH extension is supported, check which
|
||||
// authentication modes are supported by
|
||||
// the server
|
||||
const QStringList auth = m_extensions["AUTH"].toUpper().split(' ', QString::SkipEmptyParts);
|
||||
const QStringList auth = m_extensions["AUTH"].toUpper().split(' ', Qt::SkipEmptyParts);
|
||||
if (auth.contains("CRAM-MD5"))
|
||||
{
|
||||
qDebug() << "Using CRAM-MD5 authentication...";
|
||||
|
||||
@@ -238,7 +238,7 @@ bool AutoDownloadRule::matchesExpression(const QString &articleTitle, const QStr
|
||||
|
||||
// Only match if every wildcard token (separated by spaces) is present in the article name.
|
||||
// Order of wildcard tokens is unimportant (if order is important, they should have used *).
|
||||
const QStringList wildcards {expression.split(whitespace, QString::SplitBehavior::SkipEmptyParts)};
|
||||
const QStringList wildcards {expression.split(whitespace, Qt::SkipEmptyParts)};
|
||||
for (const QString &wildcard : wildcards)
|
||||
{
|
||||
const QRegularExpression reg {cachedRegex(wildcard, false)};
|
||||
|
||||
@@ -516,14 +516,14 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info)
|
||||
QHash<QString, PluginVersion> updateInfo;
|
||||
int numCorrectData = 0;
|
||||
|
||||
const QVector<QByteArray> lines = Utils::ByteArray::splitToViews(info, "\n", QString::SkipEmptyParts);
|
||||
const QVector<QByteArray> lines = Utils::ByteArray::splitToViews(info, "\n", Qt::SkipEmptyParts);
|
||||
for (QByteArray line : lines)
|
||||
{
|
||||
line = line.trimmed();
|
||||
if (line.isEmpty()) continue;
|
||||
if (line.startsWith('#')) continue;
|
||||
|
||||
const QVector<QByteArray> list = Utils::ByteArray::splitToViews(line, ":", QString::SkipEmptyParts);
|
||||
const QVector<QByteArray> list = Utils::ByteArray::splitToViews(line, ":", Qt::SkipEmptyParts);
|
||||
if (list.size() != 2) continue;
|
||||
|
||||
const QString pluginName = list.first().trimmed();
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
#include <QByteArray>
|
||||
#include <QVector>
|
||||
|
||||
QVector<QByteArray> Utils::ByteArray::splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior)
|
||||
QVector<QByteArray> Utils::ByteArray::splitToViews(const QByteArray &in, const QByteArray &sep, const Qt::SplitBehavior behavior)
|
||||
{
|
||||
if (sep.isEmpty())
|
||||
return {in};
|
||||
|
||||
QVector<QByteArray> ret;
|
||||
ret.reserve((behavior == QString::KeepEmptyParts)
|
||||
ret.reserve((behavior == Qt::KeepEmptyParts)
|
||||
? (1 + (in.size() / sep.size()))
|
||||
: (1 + (in.size() / (sep.size() + 1))));
|
||||
int head = 0;
|
||||
@@ -49,7 +49,7 @@ QVector<QByteArray> Utils::ByteArray::splitToViews(const QByteArray &in, const Q
|
||||
|
||||
// omit empty parts
|
||||
const QByteArray part = QByteArray::fromRawData((in.constData() + head), (end - head));
|
||||
if (!part.isEmpty() || (behavior == QString::KeepEmptyParts))
|
||||
if (!part.isEmpty() || (behavior == Qt::KeepEmptyParts))
|
||||
ret += part;
|
||||
|
||||
head = end + sep.size();
|
||||
|
||||
@@ -36,7 +36,7 @@ class QByteArray;
|
||||
namespace Utils::ByteArray
|
||||
{
|
||||
// Mimic QString::splitRef(sep, behavior)
|
||||
QVector<QByteArray> splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior = QString::KeepEmptyParts);
|
||||
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,
|
||||
// we only return a partial view
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace
|
||||
// Software 'Anaconda' installs its own python interpreter
|
||||
// and `python --version` returns a string like this:
|
||||
// "Python 3.4.3 :: Anaconda 2.3.0 (64-bit)"
|
||||
const QVector<QByteArray> outputSplit = Utils::ByteArray::splitToViews(procOutput, " ", QString::SkipEmptyParts);
|
||||
const QVector<QByteArray> outputSplit = Utils::ByteArray::splitToViews(procOutput, " ", Qt::SkipEmptyParts);
|
||||
if (outputSplit.size() <= 1)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ QString Utils::Misc::opensslVersionString()
|
||||
#else
|
||||
static const auto version {QString::fromLatin1(SSLeay_version(SSLEAY_VERSION))};
|
||||
#endif
|
||||
return version.splitRef(' ', QString::SkipEmptyParts)[1].toString();
|
||||
return version.splitRef(' ', Qt::SkipEmptyParts)[1].toString();
|
||||
}
|
||||
|
||||
QString Utils::Misc::zlibVersionString()
|
||||
|
||||
@@ -99,7 +99,7 @@ bool Utils::Password::PBKDF2::verify(const QByteArray &secret, const QString &pa
|
||||
|
||||
bool Utils::Password::PBKDF2::verify(const QByteArray &secret, const QByteArray &password)
|
||||
{
|
||||
const QVector<QByteArray> list = ByteArray::splitToViews(secret, ":", QString::SkipEmptyParts);
|
||||
const QVector<QByteArray> list = ByteArray::splitToViews(secret, ":", Qt::SkipEmptyParts);
|
||||
if (list.size() != 2)
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user