mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-10 00:46:48 -06:00
Use proper return type
`count()`, `length()`, `size()`, `indexOf()` and `lastIndexOf()` were returning `int` in Qt5. In Qt6 they return `qsizetype`. PR #23317.
This commit is contained in:
parent
01ac8c012c
commit
eed0e56d1a
@ -543,7 +543,7 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo
|
|||||||
|
|
||||||
const auto replaceVariables = [torrent](QString str) -> QString
|
const auto replaceVariables = [torrent](QString str) -> QString
|
||||||
{
|
{
|
||||||
for (int i = (str.length() - 2); i >= 0; --i)
|
for (qsizetype i = (str.length() - 2); i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (str[i] != u'%')
|
if (str[i] != u'%')
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -356,7 +356,7 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)
|
|||||||
{
|
{
|
||||||
QBtCommandLineParameters result {QProcessEnvironment::systemEnvironment()};
|
QBtCommandLineParameters result {QProcessEnvironment::systemEnvironment()};
|
||||||
|
|
||||||
for (int i = 1; i < args.count(); ++i)
|
for (qsizetype i = 1; i < args.count(); ++i)
|
||||||
{
|
{
|
||||||
const QString &arg = args[i];
|
const QString &arg = args[i];
|
||||||
|
|
||||||
|
|||||||
@ -170,8 +170,8 @@ namespace
|
|||||||
|
|
||||||
std::pair<QString, QString> joinColumns(const QList<Column> &columns)
|
std::pair<QString, QString> joinColumns(const QList<Column> &columns)
|
||||||
{
|
{
|
||||||
int namesSize = columns.size();
|
qsizetype namesSize = columns.size();
|
||||||
int valuesSize = columns.size();
|
qsizetype valuesSize = columns.size();
|
||||||
for (const Column &column : columns)
|
for (const Column &column : columns)
|
||||||
{
|
{
|
||||||
namesSize += column.name.size() + 2;
|
namesSize += column.name.size() + 2;
|
||||||
|
|||||||
@ -273,12 +273,12 @@ QString PeerInfo::connectionType() const
|
|||||||
|
|
||||||
qreal PeerInfo::calcRelevance(const QBitArray &allPieces) const
|
qreal PeerInfo::calcRelevance(const QBitArray &allPieces) const
|
||||||
{
|
{
|
||||||
const int localMissing = allPieces.count(false);
|
const qsizetype localMissing = allPieces.count(false);
|
||||||
if (localMissing <= 0)
|
if (localMissing <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const QBitArray peerPieces = pieces();
|
const QBitArray peerPieces = pieces();
|
||||||
const int remoteHaves = (peerPieces & (~allPieces)).count(true);
|
const qsizetype remoteHaves = (peerPieces & (~allPieces)).count(true);
|
||||||
return static_cast<qreal>(remoteHaves) / localMissing;
|
return static_cast<qreal>(remoteHaves) / localMissing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -404,7 +404,7 @@ bool Session::isValidCategoryName(const QString &name)
|
|||||||
|
|
||||||
QString Session::subcategoryName(const QString &category)
|
QString Session::subcategoryName(const QString &category)
|
||||||
{
|
{
|
||||||
const int sepIndex = category.lastIndexOf(u'/');
|
const qsizetype sepIndex = category.lastIndexOf(u'/');
|
||||||
if (sepIndex >= 0)
|
if (sepIndex >= 0)
|
||||||
return category.sliced(sepIndex + 1);
|
return category.sliced(sepIndex + 1);
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ QString Session::subcategoryName(const QString &category)
|
|||||||
|
|
||||||
QString Session::parentCategoryName(const QString &category)
|
QString Session::parentCategoryName(const QString &category)
|
||||||
{
|
{
|
||||||
const int sepIndex = category.lastIndexOf(u'/');
|
const qsizetype sepIndex = category.lastIndexOf(u'/');
|
||||||
if (sepIndex >= 0)
|
if (sepIndex >= 0)
|
||||||
return category.first(sepIndex);
|
return category.first(sepIndex);
|
||||||
|
|
||||||
@ -2843,7 +2843,7 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
|||||||
|
|
||||||
if (!filePriorities.isEmpty())
|
if (!filePriorities.isEmpty())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < filePriorities.size(); ++i)
|
for (qsizetype i = 0; i < filePriorities.size(); ++i)
|
||||||
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(filePriorities[i]);
|
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(filePriorities[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2944,7 +2944,7 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
|||||||
{
|
{
|
||||||
const TorrentInfo torrentInfo {*p.ti};
|
const TorrentInfo torrentInfo {*p.ti};
|
||||||
const auto nativeIndexes = torrentInfo.nativeIndexes();
|
const auto nativeIndexes = torrentInfo.nativeIndexes();
|
||||||
for (int i = 0; i < result.fileNames.size(); ++i)
|
for (qsizetype i = 0; i < result.fileNames.size(); ++i)
|
||||||
p.renamed_files[nativeIndexes[i]] = result.fileNames[i].toString().toStdString();
|
p.renamed_files[nativeIndexes[i]] = result.fileNames[i].toString().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4146,7 +4146,7 @@ void SessionImpl::applyFilenameFilter(const PathList &files, QList<DownloadPrior
|
|||||||
};
|
};
|
||||||
|
|
||||||
priorities.resize(files.count(), DownloadPriority::Normal);
|
priorities.resize(files.count(), DownloadPriority::Normal);
|
||||||
for (int i = 0; i < priorities.size(); ++i)
|
for (qsizetype i = 0; i < priorities.size(); ++i)
|
||||||
{
|
{
|
||||||
if (priorities[i] == BitTorrent::DownloadPriority::Ignored)
|
if (priorities[i] == BitTorrent::DownloadPriority::Ignored)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -57,9 +57,10 @@ namespace
|
|||||||
// == 20 (SHA-1 length in bytes) * 1.6 (the efficiency of Base32 encoding)
|
// == 20 (SHA-1 length in bytes) * 1.6 (the efficiency of Base32 encoding)
|
||||||
const int V1_HEX_SIZE = SHA1Hash::length() * 2;
|
const int V1_HEX_SIZE = SHA1Hash::length() * 2;
|
||||||
const int V1_BASE32_SIZE = SHA1Hash::length() * 1.6;
|
const int V1_BASE32_SIZE = SHA1Hash::length() * 1.6;
|
||||||
|
const qsizetype strSize = string.size();
|
||||||
|
|
||||||
return ((((string.size() == V1_HEX_SIZE)) && !string.contains(QRegularExpression(u"[^0-9A-Fa-f]"_s)))
|
return (((strSize == V1_HEX_SIZE) && !string.contains(QRegularExpression(u"[^0-9A-Fa-f]"_s)))
|
||||||
|| ((string.size() == V1_BASE32_SIZE) && !string.contains(QRegularExpression(u"[^2-7A-Za-z]"_s))));
|
|| ((strSize == V1_BASE32_SIZE) && !string.contains(QRegularExpression(u"[^2-7A-Za-z]"_s))));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isV2Hash(const QString &string)
|
bool isV2Hash(const QString &string)
|
||||||
|
|||||||
@ -1403,7 +1403,7 @@ QList<qreal> TorrentImpl::filesProgress() const
|
|||||||
if (!hasMetadata())
|
if (!hasMetadata())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
const int count = m_filesProgress.size();
|
const qsizetype count = m_filesProgress.size();
|
||||||
Q_ASSERT(count == filesCount());
|
Q_ASSERT(count == filesCount());
|
||||||
if (count != filesCount()) [[unlikely]]
|
if (count != filesCount()) [[unlikely]]
|
||||||
return {};
|
return {};
|
||||||
@ -1710,7 +1710,7 @@ void TorrentImpl::applyFirstLastPiecePriority(const bool enabled)
|
|||||||
|
|
||||||
// Updating file priorities is an async operation in libtorrent, when we just updated it and immediately query it
|
// Updating file priorities is an async operation in libtorrent, when we just updated it and immediately query it
|
||||||
// we might get the old/wrong values, so we rely on `updatedFilePrio` in this case.
|
// we might get the old/wrong values, so we rely on `updatedFilePrio` in this case.
|
||||||
for (int fileIndex = 0; fileIndex < m_filePriorities.size(); ++fileIndex)
|
for (qsizetype fileIndex = 0; fileIndex < m_filePriorities.size(); ++fileIndex)
|
||||||
{
|
{
|
||||||
const DownloadPriority filePrio = m_filePriorities[fileIndex];
|
const DownloadPriority filePrio = m_filePriorities[fileIndex];
|
||||||
if (filePrio <= DownloadPriority::Ignored)
|
if (filePrio <= DownloadPriority::Ignored)
|
||||||
@ -1808,7 +1808,7 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi
|
|||||||
m_filesProgress.resize(filesCount());
|
m_filesProgress.resize(filesCount());
|
||||||
updateProgress();
|
updateProgress();
|
||||||
|
|
||||||
for (int i = 0; i < fileNames.size(); ++i)
|
for (qsizetype i = 0; i < fileNames.size(); ++i)
|
||||||
{
|
{
|
||||||
const auto nativeIndex = nativeIndexes.at(i);
|
const auto nativeIndex = nativeIndexes.at(i);
|
||||||
|
|
||||||
@ -1822,7 +1822,7 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_session->applyFilenameFilter(m_filePaths, m_filePriorities);
|
m_session->applyFilenameFilter(m_filePaths, m_filePriorities);
|
||||||
for (int i = 0; i < m_filePriorities.size(); ++i)
|
for (qsizetype i = 0; i < m_filePriorities.size(); ++i)
|
||||||
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(m_filePriorities[i]);
|
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(m_filePriorities[i]);
|
||||||
|
|
||||||
p.save_path = savePath.toString().toStdString();
|
p.save_path = savePath.toString().toStdString();
|
||||||
@ -2152,7 +2152,7 @@ void TorrentImpl::handleSaveResumeData(lt::add_torrent_params params)
|
|||||||
|
|
||||||
const auto nativeIndexes = metadata.nativeIndexes();
|
const auto nativeIndexes = metadata.nativeIndexes();
|
||||||
m_indexMap.reserve(filePaths.size());
|
m_indexMap.reserve(filePaths.size());
|
||||||
for (int i = 0; i < filePaths.size(); ++i)
|
for (qsizetype i = 0; i < filePaths.size(); ++i)
|
||||||
{
|
{
|
||||||
const auto nativeIndex = nativeIndexes.at(i);
|
const auto nativeIndex = nativeIndexes.at(i);
|
||||||
m_indexMap[nativeIndex] = i;
|
m_indexMap[nativeIndex] = i;
|
||||||
@ -2931,7 +2931,7 @@ void TorrentImpl::prioritizeFiles(const QList<DownloadPriority> &priorities)
|
|||||||
// Reset 'm_hasSeedStatus' if needed in order to react again to
|
// Reset 'm_hasSeedStatus' if needed in order to react again to
|
||||||
// "torrent finished" event and e.g. show tray notifications
|
// "torrent finished" event and e.g. show tray notifications
|
||||||
const QList<DownloadPriority> oldPriorities = filePriorities();
|
const QList<DownloadPriority> oldPriorities = filePriorities();
|
||||||
for (int i = 0; i < oldPriorities.size(); ++i)
|
for (qsizetype i = 0; i < oldPriorities.size(); ++i)
|
||||||
{
|
{
|
||||||
if ((oldPriorities[i] == DownloadPriority::Ignored)
|
if ((oldPriorities[i] == DownloadPriority::Ignored)
|
||||||
&& (priorities[i] > DownloadPriority::Ignored)
|
&& (priorities[i] > DownloadPriority::Ignored)
|
||||||
@ -2945,7 +2945,7 @@ void TorrentImpl::prioritizeFiles(const QList<DownloadPriority> &priorities)
|
|||||||
const int internalFilesCount = m_torrentInfo.nativeInfo()->files().num_files(); // including .pad files
|
const int internalFilesCount = m_torrentInfo.nativeInfo()->files().num_files(); // including .pad files
|
||||||
auto nativePriorities = std::vector<lt::download_priority_t>(internalFilesCount, LT::toNative(DownloadPriority::Normal));
|
auto nativePriorities = std::vector<lt::download_priority_t>(internalFilesCount, LT::toNative(DownloadPriority::Normal));
|
||||||
const auto nativeIndexes = m_torrentInfo.nativeIndexes();
|
const auto nativeIndexes = m_torrentInfo.nativeIndexes();
|
||||||
for (int i = 0; i < priorities.size(); ++i)
|
for (qsizetype i = 0; i < priorities.size(); ++i)
|
||||||
nativePriorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(priorities[i]);
|
nativePriorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(priorities[i]);
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "Changing files priorities...";
|
qDebug() << Q_FUNC_INFO << "Changing files priorities...";
|
||||||
|
|||||||
@ -184,7 +184,7 @@ QByteArray TorrentInfo::rawData() const
|
|||||||
if (!isValid()) return {};
|
if (!isValid()) return {};
|
||||||
#ifdef QBT_USES_LIBTORRENT2
|
#ifdef QBT_USES_LIBTORRENT2
|
||||||
const lt::span<const char> infoSection {m_nativeInfo->info_section()};
|
const lt::span<const char> infoSection {m_nativeInfo->info_section()};
|
||||||
return {infoSection.data(), static_cast<int>(infoSection.size())};
|
return {infoSection.data(), static_cast<qsizetype>(infoSection.size())};
|
||||||
#else
|
#else
|
||||||
return {m_nativeInfo->metadata().get(), m_nativeInfo->metadata_size()};
|
return {m_nativeInfo->metadata().get(), m_nativeInfo->metadata_size()};
|
||||||
#endif
|
#endif
|
||||||
@ -214,7 +214,7 @@ QList<int> TorrentInfo::fileIndicesForPiece(const int pieceIndex) const
|
|||||||
res.reserve(static_cast<decltype(res)::size_type>(files.size()));
|
res.reserve(static_cast<decltype(res)::size_type>(files.size()));
|
||||||
for (const lt::file_slice &fileSlice : files)
|
for (const lt::file_slice &fileSlice : files)
|
||||||
{
|
{
|
||||||
const int index = m_nativeIndexes.indexOf(fileSlice.file_index);
|
const qsizetype index = m_nativeIndexes.indexOf(fileSlice.file_index);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
res.append(index);
|
res.append(index);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,7 +73,7 @@ namespace
|
|||||||
std::optional<QStringPair> parseHeaderLine(const QByteArrayView line)
|
std::optional<QStringPair> parseHeaderLine(const QByteArrayView line)
|
||||||
{
|
{
|
||||||
// [rfc7230] 3.2. Header Fields
|
// [rfc7230] 3.2. Header Fields
|
||||||
const int i = line.indexOf(u':');
|
const qsizetype i = line.indexOf(u':');
|
||||||
if (i <= 0)
|
if (i <= 0)
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "invalid http header:" << line;
|
qWarning() << Q_FUNC_INFO << "invalid http header:" << line;
|
||||||
@ -95,7 +95,7 @@ RequestParser::ParseResult RequestParser::parse(const QByteArray &data)
|
|||||||
RequestParser::ParseResult RequestParser::doParse(const QByteArrayView data)
|
RequestParser::ParseResult RequestParser::doParse(const QByteArrayView data)
|
||||||
{
|
{
|
||||||
// we don't handle malformed requests which use double `LF` as delimiter
|
// we don't handle malformed requests which use double `LF` as delimiter
|
||||||
const int headerEnd = data.indexOf(EOH);
|
const qsizetype headerEnd = data.indexOf(EOH);
|
||||||
if (headerEnd < 0)
|
if (headerEnd < 0)
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "incomplete request";
|
qDebug() << Q_FUNC_INFO << "incomplete request";
|
||||||
@ -109,7 +109,7 @@ RequestParser::ParseResult RequestParser::doParse(const QByteArrayView data)
|
|||||||
return {ParseStatus::BadRequest, Request(), 0};
|
return {ParseStatus::BadRequest, Request(), 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
const int headerLength = headerEnd + EOH.length();
|
const qsizetype headerLength = headerEnd + EOH.length();
|
||||||
|
|
||||||
// handle supported methods
|
// handle supported methods
|
||||||
if ((m_request.method == HEADER_REQUEST_METHOD_GET) || (m_request.method == HEADER_REQUEST_METHOD_HEAD))
|
if ((m_request.method == HEADER_REQUEST_METHOD_GET) || (m_request.method == HEADER_REQUEST_METHOD_HEAD))
|
||||||
@ -127,7 +127,7 @@ RequestParser::ParseResult RequestParser::doParse(const QByteArrayView data)
|
|||||||
return Utils::String::parseInt(rawValue).value_or(-1);
|
return Utils::String::parseInt(rawValue).value_or(-1);
|
||||||
};
|
};
|
||||||
|
|
||||||
const int contentLength = parseContentLength();
|
const qsizetype contentLength = parseContentLength();
|
||||||
if (contentLength < 0)
|
if (contentLength < 0)
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "bad request: content-length invalid";
|
qWarning() << Q_FUNC_INFO << "bad request: content-length invalid";
|
||||||
@ -289,7 +289,7 @@ bool RequestParser::parsePostMessage(const QByteArrayView data)
|
|||||||
|
|
||||||
// find boundary delimiter
|
// find boundary delimiter
|
||||||
const QString boundaryFieldName = u"boundary="_s;
|
const QString boundaryFieldName = u"boundary="_s;
|
||||||
const int idx = contentType.indexOf(boundaryFieldName);
|
const qsizetype idx = contentType.indexOf(boundaryFieldName);
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "Could not find boundary in multipart/form-data header!";
|
qWarning() << Q_FUNC_INFO << "Could not find boundary in multipart/form-data header!";
|
||||||
@ -328,7 +328,7 @@ bool RequestParser::parsePostMessage(const QByteArrayView data)
|
|||||||
|
|
||||||
bool RequestParser::parseFormData(const QByteArrayView data)
|
bool RequestParser::parseFormData(const QByteArrayView data)
|
||||||
{
|
{
|
||||||
const int eohPos = data.indexOf(EOH);
|
const qsizetype eohPos = data.indexOf(EOH);
|
||||||
|
|
||||||
if (eohPos < 0)
|
if (eohPos < 0)
|
||||||
{
|
{
|
||||||
@ -356,7 +356,7 @@ bool RequestParser::parseFormData(const QByteArrayView data)
|
|||||||
|
|
||||||
for (const auto &directive : directives)
|
for (const auto &directive : directives)
|
||||||
{
|
{
|
||||||
const int idx = directive.indexOf(u'=');
|
const qsizetype idx = directive.indexOf(u'=');
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ namespace Http
|
|||||||
// when `status != ParseStatus::OK`, `request` & `frameSize` are undefined
|
// when `status != ParseStatus::OK`, `request` & `frameSize` are undefined
|
||||||
ParseStatus status = ParseStatus::BadRequest;
|
ParseStatus status = ParseStatus::BadRequest;
|
||||||
Request request;
|
Request request;
|
||||||
long frameSize = 0; // http request frame size (bytes)
|
qsizetype frameSize = 0; // http request frame size (bytes)
|
||||||
};
|
};
|
||||||
|
|
||||||
static ParseResult parse(const QByteArray &data);
|
static ParseResult parse(const QByteArray &data);
|
||||||
|
|||||||
@ -87,7 +87,7 @@ void Http::compressContent(Response &response)
|
|||||||
response.headers.remove(HEADER_CONTENT_ENCODING);
|
response.headers.remove(HEADER_CONTENT_ENCODING);
|
||||||
|
|
||||||
// for very small files, compressing them only wastes cpu cycles
|
// for very small files, compressing them only wastes cpu cycles
|
||||||
const int contentSize = response.content.size();
|
const qsizetype contentSize = response.content.size();
|
||||||
if (contentSize <= 1024) // 1 kb
|
if (contentSize <= 1024) // 1 kb
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@ -305,7 +305,7 @@ QVariantHash GeoIPDatabase::readMetadata() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QByteArray data = QByteArray::fromRawData(ptr, size);
|
const QByteArray data = QByteArray::fromRawData(ptr, size);
|
||||||
int index = data.lastIndexOf(METADATA_BEGIN_MARK);
|
qsizetype index = data.lastIndexOf(METADATA_BEGIN_MARK);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
if (m_size > MAX_METADATA_SIZE)
|
if (m_size > MAX_METADATA_SIZE)
|
||||||
|
|||||||
@ -67,7 +67,7 @@ namespace
|
|||||||
// ascii characters 0x36 ("6") and 0x5c ("\") are selected because they have large
|
// ascii characters 0x36 ("6") and 0x5c ("\") are selected because they have large
|
||||||
// Hamming distance (http://en.wikipedia.org/wiki/Hamming_distance)
|
// Hamming distance (http://en.wikipedia.org/wiki/Hamming_distance)
|
||||||
|
|
||||||
for (int i = 0; i < key.length(); ++i)
|
for (qsizetype i = 0; i < key.length(); ++i)
|
||||||
{
|
{
|
||||||
innerPadding[i] = innerPadding[i] ^ key.at(i); // XOR operation between every byte in key and innerpadding, of key length
|
innerPadding[i] = innerPadding[i] ^ key.at(i); // XOR operation between every byte in key and innerpadding, of key length
|
||||||
outerPadding[i] = outerPadding[i] ^ key.at(i); // XOR operation between every byte in key and outerpadding, of key length
|
outerPadding[i] = outerPadding[i] ^ key.at(i); // XOR operation between every byte in key and outerpadding, of key length
|
||||||
@ -148,7 +148,7 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje
|
|||||||
// Encode the body in base64
|
// Encode the body in base64
|
||||||
QString crlfBody = body;
|
QString crlfBody = body;
|
||||||
const QByteArray b = crlfBody.replace(u"\n"_s, u"\r\n"_s).toUtf8().toBase64();
|
const QByteArray b = crlfBody.replace(u"\n"_s, u"\r\n"_s).toUtf8().toBase64();
|
||||||
for (int i = 0, end = b.length(); i < end; i += 78)
|
for (qsizetype i = 0, end = b.length(); i < end; i += 78)
|
||||||
m_message += b.mid(i, 78);
|
m_message += b.mid(i, 78);
|
||||||
m_from = from;
|
m_from = from;
|
||||||
m_rcpt = to;
|
m_rcpt = to;
|
||||||
@ -187,7 +187,7 @@ void Smtp::readyRead()
|
|||||||
m_buffer += m_socket->readAll();
|
m_buffer += m_socket->readAll();
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
const int pos = m_buffer.indexOf("\r\n");
|
const qsizetype pos = m_buffer.indexOf("\r\n");
|
||||||
if (pos < 0) return; // Loop exit condition
|
if (pos < 0) return; // Loop exit condition
|
||||||
const QByteArray line = m_buffer.first(pos);
|
const QByteArray line = m_buffer.first(pos);
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||||
@ -347,7 +347,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, cons
|
|||||||
const QByteArray utf8 = value.toUtf8();
|
const QByteArray utf8 = value.toUtf8();
|
||||||
// Use base64 encoding
|
// Use base64 encoding
|
||||||
const QByteArray base64 = utf8.toBase64();
|
const QByteArray base64 = utf8.toBase64();
|
||||||
const int ct = base64.length();
|
const qsizetype ct = base64.length();
|
||||||
line += "=?utf-8?b?";
|
line += "=?utf-8?b?";
|
||||||
for (int i = 0; i < ct; i += 4)
|
for (int i = 0; i < ct; i += 4)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -143,7 +143,7 @@ Path Path::rootItem() const
|
|||||||
{
|
{
|
||||||
// does not support UNC path
|
// does not support UNC path
|
||||||
|
|
||||||
const int slashIndex = m_pathStr.indexOf(u'/');
|
const qsizetype slashIndex = m_pathStr.indexOf(u'/');
|
||||||
if (slashIndex < 0)
|
if (slashIndex < 0)
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ Path Path::parentPath() const
|
|||||||
{
|
{
|
||||||
// does not support UNC path
|
// does not support UNC path
|
||||||
|
|
||||||
const int slashIndex = m_pathStr.lastIndexOf(u'/');
|
const qsizetype slashIndex = m_pathStr.lastIndexOf(u'/');
|
||||||
if (slashIndex == -1)
|
if (slashIndex == -1)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ Path Path::parentPath() const
|
|||||||
|
|
||||||
QString Path::filename() const
|
QString Path::filename() const
|
||||||
{
|
{
|
||||||
const int slashIndex = m_pathStr.lastIndexOf(u'/');
|
const qsizetype slashIndex = m_pathStr.lastIndexOf(u'/');
|
||||||
if (slashIndex == -1)
|
if (slashIndex == -1)
|
||||||
return m_pathStr;
|
return m_pathStr;
|
||||||
|
|
||||||
@ -193,9 +193,9 @@ QString Path::extension() const
|
|||||||
if (!suffix.isEmpty())
|
if (!suffix.isEmpty())
|
||||||
return (u"." + suffix);
|
return (u"." + suffix);
|
||||||
|
|
||||||
const int slashIndex = m_pathStr.lastIndexOf(u'/');
|
const qsizetype slashIndex = m_pathStr.lastIndexOf(u'/');
|
||||||
const auto filename = QStringView(m_pathStr).sliced(slashIndex + 1);
|
const auto filename = QStringView(m_pathStr).sliced(slashIndex + 1);
|
||||||
const int dotIndex = filename.lastIndexOf(u'.', -2);
|
const qsizetype dotIndex = filename.lastIndexOf(u'.', -2);
|
||||||
return ((dotIndex == -1) ? QString() : filename.sliced(dotIndex).toString());
|
return ((dotIndex == -1) ? QString() : filename.sliced(dotIndex).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -101,7 +101,7 @@ QList<QVariantHash> RSS::Private::FeedSerializer::loadArticles(const QByteArray
|
|||||||
QList<QVariantHash> result;
|
QList<QVariantHash> result;
|
||||||
const QJsonArray jsonArr = jsonDoc.array();
|
const QJsonArray jsonArr = jsonDoc.array();
|
||||||
result.reserve(jsonArr.size());
|
result.reserve(jsonArr.size());
|
||||||
for (int i = 0; i < jsonArr.size(); ++i)
|
for (qsizetype i = 0; i < jsonArr.size(); ++i)
|
||||||
{
|
{
|
||||||
const QJsonValue jsonVal = jsonArr[i];
|
const QJsonValue jsonVal = jsonArr[i];
|
||||||
if (!jsonVal.isObject())
|
if (!jsonVal.isObject())
|
||||||
|
|||||||
@ -406,7 +406,7 @@ void AutoDownloader::handleFeedURLChanged(Feed *feed, const QString &oldURL)
|
|||||||
{
|
{
|
||||||
for (AutoDownloadRule &rule : m_rules)
|
for (AutoDownloadRule &rule : m_rules)
|
||||||
{
|
{
|
||||||
if (const auto i = rule.feedURLs().indexOf(oldURL); i >= 0)
|
if (const qsizetype i = rule.feedURLs().indexOf(oldURL); i >= 0)
|
||||||
{
|
{
|
||||||
auto feedURLs = rule.feedURLs();
|
auto feedURLs = rule.feedURLs();
|
||||||
feedURLs.replace(i, feed->url());
|
feedURLs.replace(i, feed->url());
|
||||||
|
|||||||
@ -60,7 +60,7 @@ QList<Article *> Folder::articles() const
|
|||||||
|
|
||||||
for (Item *item : asConst(items()))
|
for (Item *item : asConst(items()))
|
||||||
{
|
{
|
||||||
int n = news.size();
|
qsizetype n = news.size();
|
||||||
news << item->articles();
|
news << item->articles();
|
||||||
std::inplace_merge(news.begin(), news.begin() + n, news.end()
|
std::inplace_merge(news.begin(), news.begin() + n, news.end()
|
||||||
, [](Article *a1, Article *a2)
|
, [](Article *a1, Article *a2)
|
||||||
|
|||||||
@ -94,7 +94,7 @@ QStringList Item::expandPath(const QString &path)
|
|||||||
// if (!isValidRSSFolderName(folder))
|
// if (!isValidRSSFolderName(folder))
|
||||||
// return result;
|
// return result;
|
||||||
|
|
||||||
int index = 0;
|
qsizetype index = 0;
|
||||||
while ((index = path.indexOf(Item::PathSeparator, index)) >= 0)
|
while ((index = path.indexOf(Item::PathSeparator, index)) >= 0)
|
||||||
{
|
{
|
||||||
result << path.first(index);
|
result << path.first(index);
|
||||||
@ -107,12 +107,12 @@ QStringList Item::expandPath(const QString &path)
|
|||||||
|
|
||||||
QString Item::parentPath(const QString &path)
|
QString Item::parentPath(const QString &path)
|
||||||
{
|
{
|
||||||
const int pos = path.lastIndexOf(Item::PathSeparator);
|
const qsizetype pos = path.lastIndexOf(Item::PathSeparator);
|
||||||
return (pos >= 0) ? path.first(pos) : QString();
|
return (pos >= 0) ? path.first(pos) : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Item::relativeName(const QString &path)
|
QString Item::relativeName(const QString &path)
|
||||||
{
|
{
|
||||||
const int pos = path.lastIndexOf(Item::PathSeparator);
|
const qsizetype pos = path.lastIndexOf(Item::PathSeparator);
|
||||||
return (pos >= 0) ? path.sliced(pos + 1) : path;
|
return (pos >= 0) ? path.sliced(pos + 1) : path;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -452,7 +452,7 @@ namespace
|
|||||||
// if (month >= 12 || dayOfWeek >= 7
|
// if (month >= 12 || dayOfWeek >= 7
|
||||||
// || (dayOfWeek < 0 && format == RFCDateDay))
|
// || (dayOfWeek < 0 && format == RFCDateDay))
|
||||||
// return QDateTime;
|
// return QDateTime;
|
||||||
const int i = parts[nyear].size();
|
const qsizetype i = parts[nyear].size();
|
||||||
if (i < 4)
|
if (i < 4)
|
||||||
{
|
{
|
||||||
// It's an obsolete year specification with less than 4 digits
|
// It's an obsolete year specification with less than 4 digits
|
||||||
@ -503,7 +503,7 @@ namespace
|
|||||||
{
|
{
|
||||||
// Check for any other alphabetic time zone
|
// Check for any other alphabetic time zone
|
||||||
bool nonalpha = false;
|
bool nonalpha = false;
|
||||||
for (int i = 0, end = zone.size(); (i < end) && !nonalpha; ++i)
|
for (qsizetype i = 0, end = zone.size(); (i < end) && !nonalpha; ++i)
|
||||||
nonalpha = !isalpha(zone[i]);
|
nonalpha = !isalpha(zone[i]);
|
||||||
if (nonalpha)
|
if (nonalpha)
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@ -206,7 +206,7 @@ void SearchHandler::readSearchOutput()
|
|||||||
bool SearchHandler::parseSearchResult(const QByteArrayView line, SearchResult &searchResult)
|
bool SearchHandler::parseSearchResult(const QByteArrayView line, SearchResult &searchResult)
|
||||||
{
|
{
|
||||||
const QList<QByteArrayView> parts = Utils::ByteArray::splitToViews(line, "|");
|
const QList<QByteArrayView> parts = Utils::ByteArray::splitToViews(line, "|");
|
||||||
const int nbFields = parts.size();
|
const qsizetype nbFields = parts.size();
|
||||||
|
|
||||||
if (nbFields <= PL_ENGINE_URL)
|
if (nbFields <= PL_ENGINE_URL)
|
||||||
return false; // Anything after ENGINE_URL is optional
|
return false; // Anything after ENGINE_URL is optional
|
||||||
|
|||||||
@ -148,7 +148,7 @@ void SettingsStorage::readNativeSettings()
|
|||||||
.arg(newPath.toString()), Log::WARNING);
|
.arg(newPath.toString()), Log::WARNING);
|
||||||
|
|
||||||
QString finalPathStr = newPath.data();
|
QString finalPathStr = newPath.data();
|
||||||
const int index = finalPathStr.lastIndexOf(u"_new", -1, Qt::CaseInsensitive);
|
const qsizetype index = finalPathStr.lastIndexOf(u"_new", -1, Qt::CaseInsensitive);
|
||||||
finalPathStr.remove(index, 4);
|
finalPathStr.remove(index, 4);
|
||||||
|
|
||||||
const Path finalPath {finalPathStr};
|
const Path finalPath {finalPathStr};
|
||||||
@ -201,7 +201,7 @@ bool SettingsStorage::writeNativeSettings() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString finalPathStr = newPath.data();
|
QString finalPathStr = newPath.data();
|
||||||
const int index = finalPathStr.lastIndexOf(u"_new", -1, Qt::CaseInsensitive);
|
const qsizetype index = finalPathStr.lastIndexOf(u"_new", -1, Qt::CaseInsensitive);
|
||||||
finalPathStr.remove(index, 4);
|
finalPathStr.remove(index, 4);
|
||||||
|
|
||||||
const Path finalPath {finalPathStr};
|
const Path finalPath {finalPathStr};
|
||||||
|
|||||||
@ -74,7 +74,7 @@ int Utils::Compare::naturalCompare(const QString &left, const QString &right, co
|
|||||||
return (numViewL.length() - numViewR.length());
|
return (numViewL.length() - numViewR.length());
|
||||||
|
|
||||||
// both string/view has the same length
|
// both string/view has the same length
|
||||||
for (int i = 0; i < numViewL.length(); ++i)
|
for (qsizetype i = 0; i < numViewL.length(); ++i)
|
||||||
{
|
{
|
||||||
const QChar numL = numViewL[i];
|
const QChar numL = numViewL[i];
|
||||||
const QChar numR = numViewR[i];
|
const QChar numR = numViewR[i];
|
||||||
|
|||||||
@ -82,7 +82,7 @@ namespace
|
|||||||
// User reports: `python --version` -> "Python 3.6.6+"
|
// User reports: `python --version` -> "Python 3.6.6+"
|
||||||
// So trim off unrelated characters
|
// So trim off unrelated characters
|
||||||
const auto versionStr = QString::fromLocal8Bit(outputSplit[1]);
|
const auto versionStr = QString::fromLocal8Bit(outputSplit[1]);
|
||||||
const int idx = versionStr.indexOf(QRegularExpression(u"[^\\.\\d]"_s));
|
const qsizetype idx = versionStr.indexOf(QRegularExpression(u"[^\\.\\d]"_s));
|
||||||
const auto version = PythonInfo::Version::fromString(versionStr.left(idx));
|
const auto version = PythonInfo::Version::fromString(versionStr.left(idx));
|
||||||
if (!version.isValid())
|
if (!version.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -57,11 +57,11 @@ namespace Utils
|
|||||||
// Taken from https://crackstation.net/hashing-security.htm
|
// Taken from https://crackstation.net/hashing-security.htm
|
||||||
bool Utils::Password::slowEquals(const QByteArray &a, const QByteArray &b)
|
bool Utils::Password::slowEquals(const QByteArray &a, const QByteArray &b)
|
||||||
{
|
{
|
||||||
const int lengthA = a.length();
|
const qsizetype lengthA = a.length();
|
||||||
const int lengthB = b.length();
|
const qsizetype lengthB = b.length();
|
||||||
|
|
||||||
int diff = lengthA ^ lengthB;
|
qsizetype diff = lengthA ^ lengthB;
|
||||||
for (int i = 0; (i < lengthA) && (i < lengthB); ++i)
|
for (qsizetype i = 0; (i < lengthA) && (i < lengthB); ++i)
|
||||||
diff |= a[i] ^ b[i];
|
diff |= a[i] ^ b[i];
|
||||||
|
|
||||||
return (diff == 0);
|
return (diff == 0);
|
||||||
|
|||||||
@ -140,7 +140,7 @@ namespace Utils
|
|||||||
static Version fromString(const QStringView string, const Version &defaultVersion = {})
|
static Version fromString(const QStringView string, const Version &defaultVersion = {})
|
||||||
{
|
{
|
||||||
const QList<QStringView> stringParts = string.split(u'.');
|
const QList<QStringView> stringParts = string.split(u'.');
|
||||||
const int count = stringParts.size();
|
const qsizetype count = stringParts.size();
|
||||||
|
|
||||||
if ((count > N) || (count < Mandatory))
|
if ((count > N) || (count < Mandatory))
|
||||||
return defaultVersion;
|
return defaultVersion;
|
||||||
|
|||||||
@ -87,7 +87,7 @@ namespace
|
|||||||
// savePath is a folder, not an absolute file path
|
// savePath is a folder, not an absolute file path
|
||||||
int indexOfPath(const FileSystemPathComboEdit *fsPathEdit, const Path &savePath)
|
int indexOfPath(const FileSystemPathComboEdit *fsPathEdit, const Path &savePath)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < fsPathEdit->count(); ++i)
|
for (qsizetype i = 0; i < fsPathEdit->count(); ++i)
|
||||||
{
|
{
|
||||||
if (fsPathEdit->item(i) == savePath)
|
if (fsPathEdit->item(i) == savePath)
|
||||||
return i;
|
return i;
|
||||||
@ -130,7 +130,7 @@ namespace
|
|||||||
|
|
||||||
auto pathList = settings()->loadValue<QStringList>(settingsKey);
|
auto pathList = settings()->loadValue<QStringList>(settingsKey);
|
||||||
|
|
||||||
const int selectedSavePathIndex = pathList.indexOf(path.toString());
|
const qsizetype selectedSavePathIndex = pathList.indexOf(path.toString());
|
||||||
if (selectedSavePathIndex > -1)
|
if (selectedSavePathIndex > -1)
|
||||||
pathList.move(selectedSavePathIndex, 0);
|
pathList.move(selectedSavePathIndex, 0);
|
||||||
else
|
else
|
||||||
@ -598,7 +598,7 @@ void AddNewTorrentDialog::updateDiskSpaceLabel()
|
|||||||
const auto torrentInfo = *torrentDescr.info();
|
const auto torrentInfo = *torrentDescr.info();
|
||||||
const QList<BitTorrent::DownloadPriority> &priorities = m_contentAdaptor->filePriorities();
|
const QList<BitTorrent::DownloadPriority> &priorities = m_contentAdaptor->filePriorities();
|
||||||
Q_ASSERT(priorities.size() == torrentInfo.filesCount());
|
Q_ASSERT(priorities.size() == torrentInfo.filesCount());
|
||||||
for (int i = 0; i < priorities.size(); ++i)
|
for (qsizetype i = 0; i < priorities.size(); ++i)
|
||||||
{
|
{
|
||||||
if (priorities[i] > BitTorrent::DownloadPriority::Ignored)
|
if (priorities[i] > BitTorrent::DownloadPriority::Ignored)
|
||||||
torrentSize += torrentInfo.fileSize(i);
|
torrentSize += torrentInfo.fileSize(i);
|
||||||
|
|||||||
@ -230,8 +230,8 @@ void FileSystemPathEdit::setFileNameFilter(const QString &val)
|
|||||||
// QFileSystemModel applies name filters to directories too.
|
// QFileSystemModel applies name filters to directories too.
|
||||||
// To use the filters we have to subclass QFileSystemModel and skip directories while filtering
|
// To use the filters we have to subclass QFileSystemModel and skip directories while filtering
|
||||||
// extract file masks
|
// extract file masks
|
||||||
const int openBracePos = val.indexOf(u'(');
|
const qsizetype openBracePos = val.indexOf(u'(');
|
||||||
const int closeBracePos = val.indexOf(u')', (openBracePos + 1));
|
const qsizetype closeBracePos = val.indexOf(u')', (openBracePos + 1));
|
||||||
if ((openBracePos > 0) && (closeBracePos > 0) && (closeBracePos > openBracePos + 2))
|
if ((openBracePos > 0) && (closeBracePos > 0) && (closeBracePos > openBracePos + 2))
|
||||||
{
|
{
|
||||||
const QString filterString = val.sliced((openBracePos + 1), (closeBracePos - openBracePos - 1));
|
const QString filterString = val.sliced((openBracePos + 1), (closeBracePos - openBracePos - 1));
|
||||||
|
|||||||
@ -1874,7 +1874,7 @@ void OptionsDialog::setLocale(const QString &localeStr)
|
|||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
//Attempt to find a language match without a country
|
//Attempt to find a language match without a country
|
||||||
const int pos = name.indexOf(u'_');
|
const qsizetype pos = name.indexOf(u'_');
|
||||||
if (pos > -1)
|
if (pos > -1)
|
||||||
{
|
{
|
||||||
const QString lang = name.first(pos);
|
const QString lang = name.first(pos);
|
||||||
|
|||||||
@ -154,7 +154,7 @@ QImage DownloadedPiecesBar::renderImage()
|
|||||||
QList<float> scaledPiecesDl = bitfieldToFloatVector(m_downloadedPieces, image.width());
|
QList<float> scaledPiecesDl = bitfieldToFloatVector(m_downloadedPieces, image.width());
|
||||||
|
|
||||||
// filling image
|
// filling image
|
||||||
for (int x = 0; x < scaledPieces.size(); ++x)
|
for (qsizetype x = 0; x < scaledPieces.size(); ++x)
|
||||||
{
|
{
|
||||||
float piecesToValue = scaledPieces.at(x);
|
float piecesToValue = scaledPieces.at(x);
|
||||||
float piecesToValueDl = scaledPiecesDl.at(x);
|
float piecesToValueDl = scaledPiecesDl.at(x);
|
||||||
|
|||||||
@ -145,7 +145,7 @@ QImage PieceAvailabilityBar::renderImage()
|
|||||||
QList<float> scaledPieces = intToFloatVector(m_pieces, image.width());
|
QList<float> scaledPieces = intToFloatVector(m_pieces, image.width());
|
||||||
|
|
||||||
// filling image
|
// filling image
|
||||||
for (int x = 0; x < scaledPieces.size(); ++x)
|
for (qsizetype x = 0; x < scaledPieces.size(); ++x)
|
||||||
{
|
{
|
||||||
float piecesToValue = scaledPieces.at(x);
|
float piecesToValue = scaledPieces.at(x);
|
||||||
image.setPixel(x, 0, pieceColors()[piecesToValue * 255]);
|
image.setPixel(x, 0, pieceColors()[piecesToValue * 255]);
|
||||||
|
|||||||
@ -136,7 +136,7 @@ void TorrentCategoryDialog::setCategoryName(const QString &categoryName)
|
|||||||
{
|
{
|
||||||
m_ui->textCategoryName->setText(categoryName);
|
m_ui->textCategoryName->setText(categoryName);
|
||||||
|
|
||||||
const int subcategoryNameStart = categoryName.lastIndexOf(u"/") + 1;
|
const qsizetype subcategoryNameStart = categoryName.lastIndexOf(u'/') + 1;
|
||||||
m_ui->textCategoryName->setSelection(subcategoryNameStart, (categoryName.size() - subcategoryNameStart));
|
m_ui->textCategoryName->setSelection(subcategoryNameStart, (categoryName.size() - subcategoryNameStart));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -194,7 +194,7 @@ void TorrentContentModel::updateFilesProgress()
|
|||||||
if (m_filesIndex.size() != filesProgress.size()) [[unlikely]]
|
if (m_filesIndex.size() != filesProgress.size()) [[unlikely]]
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < filesProgress.size(); ++i)
|
for (qsizetype i = 0; i < filesProgress.size(); ++i)
|
||||||
m_filesIndex[i]->setProgress(filesProgress[i]);
|
m_filesIndex[i]->setProgress(filesProgress[i]);
|
||||||
// Update folders progress in the tree
|
// Update folders progress in the tree
|
||||||
m_rootItem->recalculateProgress();
|
m_rootItem->recalculateProgress();
|
||||||
@ -211,7 +211,7 @@ void TorrentContentModel::updateFilesPriorities()
|
|||||||
if (m_filesIndex.size() != fprio.size())
|
if (m_filesIndex.size() != fprio.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < fprio.size(); ++i)
|
for (qsizetype i = 0; i < fprio.size(); ++i)
|
||||||
m_filesIndex[i]->setPriority(static_cast<BitTorrent::DownloadPriority>(fprio[i]));
|
m_filesIndex[i]->setPriority(static_cast<BitTorrent::DownloadPriority>(fprio[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ void TorrentContentModel::updateFilesAvailability()
|
|||||||
if (!m_contentHandler || (m_contentHandler != handler))
|
if (!m_contentHandler || (m_contentHandler != handler))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < m_filesIndex.size(); ++i)
|
for (qsizetype i = 0; i < m_filesIndex.size(); ++i)
|
||||||
m_filesIndex[i]->setAvailability(availableFileFractions.value(i, 0));
|
m_filesIndex[i]->setAvailability(availableFileFractions.value(i, 0));
|
||||||
// Update folders progress in the tree
|
// Update folders progress in the tree
|
||||||
m_rootItem->recalculateProgress();
|
m_rootItem->recalculateProgress();
|
||||||
|
|||||||
@ -98,7 +98,7 @@ void TorrentContentModelFolder::updatePriority()
|
|||||||
// then the folder should have the same
|
// then the folder should have the same
|
||||||
// priority
|
// priority
|
||||||
const BitTorrent::DownloadPriority prio = m_childItems.constFirst()->priority();
|
const BitTorrent::DownloadPriority prio = m_childItems.constFirst()->priority();
|
||||||
for (int i = 1; i < m_childItems.size(); ++i)
|
for (qsizetype i = 1; i < m_childItems.size(); ++i)
|
||||||
{
|
{
|
||||||
if (m_childItems.at(i)->priority() != prio)
|
if (m_childItems.at(i)->priority() != prio)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -100,12 +100,12 @@ public:
|
|||||||
m_parent->decreaseTorrentsCount(delta);
|
m_parent->decreaseTorrentsCount(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos() const
|
qsizetype pos() const
|
||||||
{
|
{
|
||||||
if (!m_parent)
|
if (!m_parent)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (const int posByName = m_parent->m_childUids.indexOf(m_name); posByName >= 0)
|
if (const qsizetype posByName = m_parent->m_childUids.indexOf(m_name); posByName >= 0)
|
||||||
return posByName;
|
return posByName;
|
||||||
|
|
||||||
// special cases
|
// special cases
|
||||||
@ -174,7 +174,7 @@ namespace
|
|||||||
{
|
{
|
||||||
QString shortName(const QString &fullName)
|
QString shortName(const QString &fullName)
|
||||||
{
|
{
|
||||||
const int pos = fullName.lastIndexOf(u'/');
|
const qsizetype pos = fullName.lastIndexOf(u'/');
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
return fullName.sliced(pos + 1);
|
return fullName.sliced(pos + 1);
|
||||||
return fullName;
|
return fullName;
|
||||||
|
|||||||
@ -322,7 +322,7 @@ int TagFilterModel::findRow(const Tag &tag) const
|
|||||||
if (!tag.isValid())
|
if (!tag.isValid())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (int i = 0; i < m_tagItems.size(); ++i)
|
for (qsizetype i = 0; i < m_tagItems.size(); ++i)
|
||||||
{
|
{
|
||||||
if (m_tagItems[i].tag() == tag)
|
if (m_tagItems[i].tag() == tag)
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
@ -172,7 +172,7 @@ void WatchedFoldersModel::onFolderSet(const Path &path, const TorrentFilesWatche
|
|||||||
|
|
||||||
void WatchedFoldersModel::onFolderRemoved(const Path &path)
|
void WatchedFoldersModel::onFolderRemoved(const Path &path)
|
||||||
{
|
{
|
||||||
const int row = m_watchedFolders.indexOf(path);
|
const qsizetype row = m_watchedFolders.indexOf(path);
|
||||||
if (row >= 0)
|
if (row >= 0)
|
||||||
removeRows(row, 1);
|
removeRows(row, 1);
|
||||||
|
|
||||||
|
|||||||
@ -184,7 +184,7 @@ void SearchController::resultsAction()
|
|||||||
|
|
||||||
const std::shared_ptr<SearchHandler> &searchHandler = iter.value();
|
const std::shared_ptr<SearchHandler> &searchHandler = iter.value();
|
||||||
const QList<SearchResult> searchResults = searchHandler->results();
|
const QList<SearchResult> searchResults = searchHandler->results();
|
||||||
const int size = searchResults.size();
|
const qsizetype size = searchResults.size();
|
||||||
|
|
||||||
if (offset > size)
|
if (offset > size)
|
||||||
throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));
|
throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));
|
||||||
|
|||||||
@ -637,7 +637,7 @@ void TorrentsController::infoAction()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const int size = torrentList.size();
|
const qsizetype size = torrentList.size();
|
||||||
// normalize offset
|
// normalize offset
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
offset = size + offset;
|
offset = size + offset;
|
||||||
@ -993,11 +993,11 @@ void TorrentsController::pieceStatesAction()
|
|||||||
|
|
||||||
QJsonArray pieceStates;
|
QJsonArray pieceStates;
|
||||||
const QBitArray states = torrent->pieces();
|
const QBitArray states = torrent->pieces();
|
||||||
for (int i = 0; i < states.size(); ++i)
|
for (qsizetype i = 0; i < states.size(); ++i)
|
||||||
pieceStates.append(static_cast<int>(states[i]) * 2);
|
pieceStates.append(static_cast<int>(states[i]) * 2);
|
||||||
|
|
||||||
const QBitArray dlstates = torrent->fetchDownloadingPieces().takeResult();
|
const QBitArray dlstates = torrent->fetchDownloadingPieces().takeResult();
|
||||||
for (int i = 0; i < states.size(); ++i)
|
for (qsizetype i = 0; i < states.size(); ++i)
|
||||||
{
|
{
|
||||||
if (dlstates[i])
|
if (dlstates[i])
|
||||||
pieceStates[i] = 1;
|
pieceStates[i] = 1;
|
||||||
|
|||||||
@ -88,7 +88,7 @@ namespace
|
|||||||
|
|
||||||
for (const auto &cookie : cookies)
|
for (const auto &cookie : cookies)
|
||||||
{
|
{
|
||||||
const int idx = cookie.indexOf(u'=');
|
const qsizetype idx = cookie.indexOf(u'=');
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -230,9 +230,9 @@ void WebApplication::translateDocument(QString &data) const
|
|||||||
{
|
{
|
||||||
const QRegularExpression regex(u"QBT_TR\\((([^\\)]|\\)(?!QBT_TR))+)\\)QBT_TR\\[CONTEXT=([a-zA-Z_][a-zA-Z0-9_]*)\\]"_s);
|
const QRegularExpression regex(u"QBT_TR\\((([^\\)]|\\)(?!QBT_TR))+)\\)QBT_TR\\[CONTEXT=([a-zA-Z_][a-zA-Z0-9_]*)\\]"_s);
|
||||||
|
|
||||||
int i = 0;
|
qsizetype i = 0;
|
||||||
bool found = true;
|
bool found = true;
|
||||||
while (i < data.size() && found)
|
while ((i < data.size()) && found)
|
||||||
{
|
{
|
||||||
QRegularExpressionMatch regexMatch;
|
QRegularExpressionMatch regexMatch;
|
||||||
i = data.indexOf(regex, i, ®exMatch);
|
i = data.indexOf(regex, i, ®exMatch);
|
||||||
@ -483,7 +483,7 @@ void WebApplication::configure()
|
|||||||
|
|
||||||
for (const QStringView line : customHeaderLines)
|
for (const QStringView line : customHeaderLines)
|
||||||
{
|
{
|
||||||
const int idx = line.indexOf(u':');
|
const qsizetype idx = line.indexOf(u':');
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
{
|
{
|
||||||
// require separator `:` to be present even if `value` field can be empty
|
// require separator `:` to be present even if `value` field can be empty
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user