diff --git a/src/app/application.cpp b/src/app/application.cpp index da09211bd..0cc5dda46 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -543,7 +543,7 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo 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'%') continue; diff --git a/src/app/cmdoptions.cpp b/src/app/cmdoptions.cpp index 84f50e988..cb4ce6c01 100644 --- a/src/app/cmdoptions.cpp +++ b/src/app/cmdoptions.cpp @@ -356,7 +356,7 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args) { 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]; diff --git a/src/base/bittorrent/dbresumedatastorage.cpp b/src/base/bittorrent/dbresumedatastorage.cpp index 4c6a3576c..76479ac15 100644 --- a/src/base/bittorrent/dbresumedatastorage.cpp +++ b/src/base/bittorrent/dbresumedatastorage.cpp @@ -170,8 +170,8 @@ namespace std::pair joinColumns(const QList &columns) { - int namesSize = columns.size(); - int valuesSize = columns.size(); + qsizetype namesSize = columns.size(); + qsizetype valuesSize = columns.size(); for (const Column &column : columns) { namesSize += column.name.size() + 2; diff --git a/src/base/bittorrent/peerinfo.cpp b/src/base/bittorrent/peerinfo.cpp index 3706b1e81..5d9abbec6 100644 --- a/src/base/bittorrent/peerinfo.cpp +++ b/src/base/bittorrent/peerinfo.cpp @@ -273,12 +273,12 @@ QString PeerInfo::connectionType() const qreal PeerInfo::calcRelevance(const QBitArray &allPieces) const { - const int localMissing = allPieces.count(false); + const qsizetype localMissing = allPieces.count(false); if (localMissing <= 0) return 0; const QBitArray peerPieces = pieces(); - const int remoteHaves = (peerPieces & (~allPieces)).count(true); + const qsizetype remoteHaves = (peerPieces & (~allPieces)).count(true); return static_cast(remoteHaves) / localMissing; } diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 13176a39e..d771b132b 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -404,7 +404,7 @@ bool Session::isValidCategoryName(const QString &name) QString Session::subcategoryName(const QString &category) { - const int sepIndex = category.lastIndexOf(u'/'); + const qsizetype sepIndex = category.lastIndexOf(u'/'); if (sepIndex >= 0) return category.sliced(sepIndex + 1); @@ -413,7 +413,7 @@ QString Session::subcategoryName(const QString &category) QString Session::parentCategoryName(const QString &category) { - const int sepIndex = category.lastIndexOf(u'/'); + const qsizetype sepIndex = category.lastIndexOf(u'/'); if (sepIndex >= 0) return category.first(sepIndex); @@ -2843,7 +2843,7 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr 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]); } @@ -2944,7 +2944,7 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr { const TorrentInfo torrentInfo {*p.ti}; 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(); } @@ -4146,7 +4146,7 @@ void SessionImpl::applyFilenameFilter(const PathList &files, QList TorrentImpl::filesProgress() const if (!hasMetadata()) return {}; - const int count = m_filesProgress.size(); + const qsizetype count = m_filesProgress.size(); Q_ASSERT(count == filesCount()); if (count != filesCount()) [[unlikely]] 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 // 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]; if (filePrio <= DownloadPriority::Ignored) @@ -1808,7 +1808,7 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi m_filesProgress.resize(filesCount()); updateProgress(); - for (int i = 0; i < fileNames.size(); ++i) + for (qsizetype i = 0; i < fileNames.size(); ++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); - 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.save_path = savePath.toString().toStdString(); @@ -2152,7 +2152,7 @@ void TorrentImpl::handleSaveResumeData(lt::add_torrent_params params) const auto nativeIndexes = metadata.nativeIndexes(); 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); m_indexMap[nativeIndex] = i; @@ -2931,7 +2931,7 @@ void TorrentImpl::prioritizeFiles(const QList &priorities) // Reset 'm_hasSeedStatus' if needed in order to react again to // "torrent finished" event and e.g. show tray notifications const QList oldPriorities = filePriorities(); - for (int i = 0; i < oldPriorities.size(); ++i) + for (qsizetype i = 0; i < oldPriorities.size(); ++i) { if ((oldPriorities[i] == DownloadPriority::Ignored) && (priorities[i] > DownloadPriority::Ignored) @@ -2945,7 +2945,7 @@ void TorrentImpl::prioritizeFiles(const QList &priorities) const int internalFilesCount = m_torrentInfo.nativeInfo()->files().num_files(); // including .pad files auto nativePriorities = std::vector(internalFilesCount, LT::toNative(DownloadPriority::Normal)); 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]); qDebug() << Q_FUNC_INFO << "Changing files priorities..."; diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index 590930fe2..eb7388643 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -184,7 +184,7 @@ QByteArray TorrentInfo::rawData() const if (!isValid()) return {}; #ifdef QBT_USES_LIBTORRENT2 const lt::span infoSection {m_nativeInfo->info_section()}; - return {infoSection.data(), static_cast(infoSection.size())}; + return {infoSection.data(), static_cast(infoSection.size())}; #else return {m_nativeInfo->metadata().get(), m_nativeInfo->metadata_size()}; #endif @@ -214,7 +214,7 @@ QList TorrentInfo::fileIndicesForPiece(const int pieceIndex) const res.reserve(static_cast(files.size())); 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) res.append(index); } diff --git a/src/base/http/requestparser.cpp b/src/base/http/requestparser.cpp index 524b39e1f..bfeac9320 100644 --- a/src/base/http/requestparser.cpp +++ b/src/base/http/requestparser.cpp @@ -73,7 +73,7 @@ namespace std::optional parseHeaderLine(const QByteArrayView line) { // [rfc7230] 3.2. Header Fields - const int i = line.indexOf(u':'); + const qsizetype i = line.indexOf(u':'); if (i <= 0) { 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) { // 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) { qDebug() << Q_FUNC_INFO << "incomplete request"; @@ -109,7 +109,7 @@ RequestParser::ParseResult RequestParser::doParse(const QByteArrayView data) return {ParseStatus::BadRequest, Request(), 0}; } - const int headerLength = headerEnd + EOH.length(); + const qsizetype headerLength = headerEnd + EOH.length(); // handle supported methods 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); }; - const int contentLength = parseContentLength(); + const qsizetype contentLength = parseContentLength(); if (contentLength < 0) { qWarning() << Q_FUNC_INFO << "bad request: content-length invalid"; @@ -289,7 +289,7 @@ bool RequestParser::parsePostMessage(const QByteArrayView data) // find boundary delimiter const QString boundaryFieldName = u"boundary="_s; - const int idx = contentType.indexOf(boundaryFieldName); + const qsizetype idx = contentType.indexOf(boundaryFieldName); if (idx < 0) { 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) { - const int eohPos = data.indexOf(EOH); + const qsizetype eohPos = data.indexOf(EOH); if (eohPos < 0) { @@ -356,7 +356,7 @@ bool RequestParser::parseFormData(const QByteArrayView data) for (const auto &directive : directives) { - const int idx = directive.indexOf(u'='); + const qsizetype idx = directive.indexOf(u'='); if (idx < 0) continue; diff --git a/src/base/http/requestparser.h b/src/base/http/requestparser.h index fa8661e1d..850c1e86c 100644 --- a/src/base/http/requestparser.h +++ b/src/base/http/requestparser.h @@ -50,7 +50,7 @@ namespace Http // when `status != ParseStatus::OK`, `request` & `frameSize` are undefined ParseStatus status = ParseStatus::BadRequest; Request request; - long frameSize = 0; // http request frame size (bytes) + qsizetype frameSize = 0; // http request frame size (bytes) }; static ParseResult parse(const QByteArray &data); diff --git a/src/base/http/responsegenerator.cpp b/src/base/http/responsegenerator.cpp index b34b973db..0c4495b93 100644 --- a/src/base/http/responsegenerator.cpp +++ b/src/base/http/responsegenerator.cpp @@ -87,7 +87,7 @@ void Http::compressContent(Response &response) response.headers.remove(HEADER_CONTENT_ENCODING); // 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 return; diff --git a/src/base/net/geoipdatabase.cpp b/src/base/net/geoipdatabase.cpp index 5655827ea..abc358b2b 100644 --- a/src/base/net/geoipdatabase.cpp +++ b/src/base/net/geoipdatabase.cpp @@ -305,7 +305,7 @@ QVariantHash GeoIPDatabase::readMetadata() const } 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 (m_size > MAX_METADATA_SIZE) diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index e130f6b11..851c91100 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -67,7 +67,7 @@ namespace // ascii characters 0x36 ("6") and 0x5c ("\") are selected because they have large // 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 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 QString crlfBody = body; 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_from = from; m_rcpt = to; @@ -187,7 +187,7 @@ void Smtp::readyRead() m_buffer += m_socket->readAll(); 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 const QByteArray line = m_buffer.first(pos); #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(); // Use base64 encoding const QByteArray base64 = utf8.toBase64(); - const int ct = base64.length(); + const qsizetype ct = base64.length(); line += "=?utf-8?b?"; for (int i = 0; i < ct; i += 4) { diff --git a/src/base/path.cpp b/src/base/path.cpp index 55162d6df..262caf026 100644 --- a/src/base/path.cpp +++ b/src/base/path.cpp @@ -143,7 +143,7 @@ Path Path::rootItem() const { // does not support UNC path - const int slashIndex = m_pathStr.indexOf(u'/'); + const qsizetype slashIndex = m_pathStr.indexOf(u'/'); if (slashIndex < 0) return *this; @@ -162,7 +162,7 @@ Path Path::parentPath() const { // does not support UNC path - const int slashIndex = m_pathStr.lastIndexOf(u'/'); + const qsizetype slashIndex = m_pathStr.lastIndexOf(u'/'); if (slashIndex == -1) return {}; @@ -180,7 +180,7 @@ Path Path::parentPath() const QString Path::filename() const { - const int slashIndex = m_pathStr.lastIndexOf(u'/'); + const qsizetype slashIndex = m_pathStr.lastIndexOf(u'/'); if (slashIndex == -1) return m_pathStr; @@ -193,9 +193,9 @@ QString Path::extension() const if (!suffix.isEmpty()) 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 int dotIndex = filename.lastIndexOf(u'.', -2); + const qsizetype dotIndex = filename.lastIndexOf(u'.', -2); return ((dotIndex == -1) ? QString() : filename.sliced(dotIndex).toString()); } diff --git a/src/base/rss/feed_serializer.cpp b/src/base/rss/feed_serializer.cpp index 838ad06a9..e55b7dc14 100644 --- a/src/base/rss/feed_serializer.cpp +++ b/src/base/rss/feed_serializer.cpp @@ -101,7 +101,7 @@ QList RSS::Private::FeedSerializer::loadArticles(const QByteArray QList result; const QJsonArray jsonArr = jsonDoc.array(); 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]; if (!jsonVal.isObject()) diff --git a/src/base/rss/rss_autodownloader.cpp b/src/base/rss/rss_autodownloader.cpp index 873223dbd..c77b1d9bd 100644 --- a/src/base/rss/rss_autodownloader.cpp +++ b/src/base/rss/rss_autodownloader.cpp @@ -406,7 +406,7 @@ void AutoDownloader::handleFeedURLChanged(Feed *feed, const QString &oldURL) { 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(); feedURLs.replace(i, feed->url()); diff --git a/src/base/rss/rss_folder.cpp b/src/base/rss/rss_folder.cpp index ccf06e0ef..62dc8bb6e 100644 --- a/src/base/rss/rss_folder.cpp +++ b/src/base/rss/rss_folder.cpp @@ -60,7 +60,7 @@ QList
Folder::articles() const for (Item *item : asConst(items())) { - int n = news.size(); + qsizetype n = news.size(); news << item->articles(); std::inplace_merge(news.begin(), news.begin() + n, news.end() , [](Article *a1, Article *a2) diff --git a/src/base/rss/rss_item.cpp b/src/base/rss/rss_item.cpp index 19f340fa0..11ced1479 100644 --- a/src/base/rss/rss_item.cpp +++ b/src/base/rss/rss_item.cpp @@ -94,7 +94,7 @@ QStringList Item::expandPath(const QString &path) // if (!isValidRSSFolderName(folder)) // return result; - int index = 0; + qsizetype index = 0; while ((index = path.indexOf(Item::PathSeparator, index)) >= 0) { result << path.first(index); @@ -107,12 +107,12 @@ QStringList Item::expandPath(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(); } 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; } diff --git a/src/base/rss/rss_parser.cpp b/src/base/rss/rss_parser.cpp index d34212b40..2ccb833b3 100644 --- a/src/base/rss/rss_parser.cpp +++ b/src/base/rss/rss_parser.cpp @@ -452,7 +452,7 @@ namespace // if (month >= 12 || dayOfWeek >= 7 // || (dayOfWeek < 0 && format == RFCDateDay)) // return QDateTime; - const int i = parts[nyear].size(); + const qsizetype i = parts[nyear].size(); if (i < 4) { // It's an obsolete year specification with less than 4 digits @@ -503,7 +503,7 @@ namespace { // Check for any other alphabetic time zone 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]); if (nonalpha) return {}; diff --git a/src/base/search/searchhandler.cpp b/src/base/search/searchhandler.cpp index 670c2b42a..8527cdb49 100644 --- a/src/base/search/searchhandler.cpp +++ b/src/base/search/searchhandler.cpp @@ -206,7 +206,7 @@ void SearchHandler::readSearchOutput() bool SearchHandler::parseSearchResult(const QByteArrayView line, SearchResult &searchResult) { const QList parts = Utils::ByteArray::splitToViews(line, "|"); - const int nbFields = parts.size(); + const qsizetype nbFields = parts.size(); if (nbFields <= PL_ENGINE_URL) return false; // Anything after ENGINE_URL is optional diff --git a/src/base/settingsstorage.cpp b/src/base/settingsstorage.cpp index c6006beb7..26d421176 100644 --- a/src/base/settingsstorage.cpp +++ b/src/base/settingsstorage.cpp @@ -148,7 +148,7 @@ void SettingsStorage::readNativeSettings() .arg(newPath.toString()), Log::WARNING); 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); const Path finalPath {finalPathStr}; @@ -201,7 +201,7 @@ bool SettingsStorage::writeNativeSettings() const } 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); const Path finalPath {finalPathStr}; diff --git a/src/base/utils/compare.cpp b/src/base/utils/compare.cpp index 15d438b2d..0ebc52ff8 100644 --- a/src/base/utils/compare.cpp +++ b/src/base/utils/compare.cpp @@ -74,7 +74,7 @@ int Utils::Compare::naturalCompare(const QString &left, const QString &right, co return (numViewL.length() - numViewR.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 numR = numViewR[i]; diff --git a/src/base/utils/foreignapps.cpp b/src/base/utils/foreignapps.cpp index 91a254d91..5b834ffbc 100644 --- a/src/base/utils/foreignapps.cpp +++ b/src/base/utils/foreignapps.cpp @@ -82,7 +82,7 @@ namespace // User reports: `python --version` -> "Python 3.6.6+" // So trim off unrelated characters 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)); if (!version.isValid()) return false; diff --git a/src/base/utils/password.cpp b/src/base/utils/password.cpp index fd3ffdfee..75019d9cc 100644 --- a/src/base/utils/password.cpp +++ b/src/base/utils/password.cpp @@ -57,11 +57,11 @@ namespace Utils // Taken from https://crackstation.net/hashing-security.htm bool Utils::Password::slowEquals(const QByteArray &a, const QByteArray &b) { - const int lengthA = a.length(); - const int lengthB = b.length(); + const qsizetype lengthA = a.length(); + const qsizetype lengthB = b.length(); - int diff = lengthA ^ lengthB; - for (int i = 0; (i < lengthA) && (i < lengthB); ++i) + qsizetype diff = lengthA ^ lengthB; + for (qsizetype i = 0; (i < lengthA) && (i < lengthB); ++i) diff |= a[i] ^ b[i]; return (diff == 0); diff --git a/src/base/utils/version.h b/src/base/utils/version.h index 36f20512e..a01688380 100644 --- a/src/base/utils/version.h +++ b/src/base/utils/version.h @@ -140,7 +140,7 @@ namespace Utils static Version fromString(const QStringView string, const Version &defaultVersion = {}) { const QList stringParts = string.split(u'.'); - const int count = stringParts.size(); + const qsizetype count = stringParts.size(); if ((count > N) || (count < Mandatory)) return defaultVersion; diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index a82dabf52..5ab0fd0d0 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -87,7 +87,7 @@ namespace // savePath is a folder, not an absolute file path 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) return i; @@ -130,7 +130,7 @@ namespace auto pathList = settings()->loadValue(settingsKey); - const int selectedSavePathIndex = pathList.indexOf(path.toString()); + const qsizetype selectedSavePathIndex = pathList.indexOf(path.toString()); if (selectedSavePathIndex > -1) pathList.move(selectedSavePathIndex, 0); else @@ -598,7 +598,7 @@ void AddNewTorrentDialog::updateDiskSpaceLabel() const auto torrentInfo = *torrentDescr.info(); const QList &priorities = m_contentAdaptor->filePriorities(); 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) torrentSize += torrentInfo.fileSize(i); diff --git a/src/gui/fspathedit.cpp b/src/gui/fspathedit.cpp index 477a93a77..a9f6c64a6 100644 --- a/src/gui/fspathedit.cpp +++ b/src/gui/fspathedit.cpp @@ -230,8 +230,8 @@ void FileSystemPathEdit::setFileNameFilter(const QString &val) // QFileSystemModel applies name filters to directories too. // To use the filters we have to subclass QFileSystemModel and skip directories while filtering // extract file masks - const int openBracePos = val.indexOf(u'('); - const int closeBracePos = val.indexOf(u')', (openBracePos + 1)); + const qsizetype openBracePos = val.indexOf(u'('); + const qsizetype closeBracePos = val.indexOf(u')', (openBracePos + 1)); if ((openBracePos > 0) && (closeBracePos > 0) && (closeBracePos > openBracePos + 2)) { const QString filterString = val.sliced((openBracePos + 1), (closeBracePos - openBracePos - 1)); diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 56bf1a457..f5d597232 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -1874,7 +1874,7 @@ void OptionsDialog::setLocale(const QString &localeStr) if (index < 0) { //Attempt to find a language match without a country - const int pos = name.indexOf(u'_'); + const qsizetype pos = name.indexOf(u'_'); if (pos > -1) { const QString lang = name.first(pos); diff --git a/src/gui/properties/downloadedpiecesbar.cpp b/src/gui/properties/downloadedpiecesbar.cpp index 305baad9f..7c6d51cf5 100644 --- a/src/gui/properties/downloadedpiecesbar.cpp +++ b/src/gui/properties/downloadedpiecesbar.cpp @@ -154,7 +154,7 @@ QImage DownloadedPiecesBar::renderImage() QList scaledPiecesDl = bitfieldToFloatVector(m_downloadedPieces, image.width()); // filling image - for (int x = 0; x < scaledPieces.size(); ++x) + for (qsizetype x = 0; x < scaledPieces.size(); ++x) { float piecesToValue = scaledPieces.at(x); float piecesToValueDl = scaledPiecesDl.at(x); diff --git a/src/gui/properties/pieceavailabilitybar.cpp b/src/gui/properties/pieceavailabilitybar.cpp index 5a9e61845..0e9e2a656 100644 --- a/src/gui/properties/pieceavailabilitybar.cpp +++ b/src/gui/properties/pieceavailabilitybar.cpp @@ -145,7 +145,7 @@ QImage PieceAvailabilityBar::renderImage() QList scaledPieces = intToFloatVector(m_pieces, image.width()); // filling image - for (int x = 0; x < scaledPieces.size(); ++x) + for (qsizetype x = 0; x < scaledPieces.size(); ++x) { float piecesToValue = scaledPieces.at(x); image.setPixel(x, 0, pieceColors()[piecesToValue * 255]); diff --git a/src/gui/torrentcategorydialog.cpp b/src/gui/torrentcategorydialog.cpp index a9762d81d..ce02d6667 100644 --- a/src/gui/torrentcategorydialog.cpp +++ b/src/gui/torrentcategorydialog.cpp @@ -136,7 +136,7 @@ void TorrentCategoryDialog::setCategoryName(const QString &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)); } diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index 73aa8f766..0238174c3 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -194,7 +194,7 @@ void TorrentContentModel::updateFilesProgress() if (m_filesIndex.size() != filesProgress.size()) [[unlikely]] return; - for (int i = 0; i < filesProgress.size(); ++i) + for (qsizetype i = 0; i < filesProgress.size(); ++i) m_filesIndex[i]->setProgress(filesProgress[i]); // Update folders progress in the tree m_rootItem->recalculateProgress(); @@ -211,7 +211,7 @@ void TorrentContentModel::updateFilesPriorities() if (m_filesIndex.size() != fprio.size()) return; - for (int i = 0; i < fprio.size(); ++i) + for (qsizetype i = 0; i < fprio.size(); ++i) m_filesIndex[i]->setPriority(static_cast(fprio[i])); } @@ -226,7 +226,7 @@ void TorrentContentModel::updateFilesAvailability() if (!m_contentHandler || (m_contentHandler != handler)) 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)); // Update folders progress in the tree m_rootItem->recalculateProgress(); diff --git a/src/gui/torrentcontentmodelfolder.cpp b/src/gui/torrentcontentmodelfolder.cpp index baaa098aa..418e36306 100644 --- a/src/gui/torrentcontentmodelfolder.cpp +++ b/src/gui/torrentcontentmodelfolder.cpp @@ -98,7 +98,7 @@ void TorrentContentModelFolder::updatePriority() // then the folder should have the same // 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) { diff --git a/src/gui/transferlistfilters/categoryfiltermodel.cpp b/src/gui/transferlistfilters/categoryfiltermodel.cpp index 45516321f..4f27dd640 100644 --- a/src/gui/transferlistfilters/categoryfiltermodel.cpp +++ b/src/gui/transferlistfilters/categoryfiltermodel.cpp @@ -100,12 +100,12 @@ public: m_parent->decreaseTorrentsCount(delta); } - int pos() const + qsizetype pos() const { if (!m_parent) 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; // special cases @@ -174,7 +174,7 @@ namespace { QString shortName(const QString &fullName) { - const int pos = fullName.lastIndexOf(u'/'); + const qsizetype pos = fullName.lastIndexOf(u'/'); if (pos >= 0) return fullName.sliced(pos + 1); return fullName; diff --git a/src/gui/transferlistfilters/tagfiltermodel.cpp b/src/gui/transferlistfilters/tagfiltermodel.cpp index da76e7be6..6e741cf86 100644 --- a/src/gui/transferlistfilters/tagfiltermodel.cpp +++ b/src/gui/transferlistfilters/tagfiltermodel.cpp @@ -322,7 +322,7 @@ int TagFilterModel::findRow(const Tag &tag) const if (!tag.isValid()) 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) return i; diff --git a/src/gui/watchedfoldersmodel.cpp b/src/gui/watchedfoldersmodel.cpp index 0bb4e4c75..344f1b9ac 100644 --- a/src/gui/watchedfoldersmodel.cpp +++ b/src/gui/watchedfoldersmodel.cpp @@ -172,7 +172,7 @@ void WatchedFoldersModel::onFolderSet(const Path &path, const TorrentFilesWatche void WatchedFoldersModel::onFolderRemoved(const Path &path) { - const int row = m_watchedFolders.indexOf(path); + const qsizetype row = m_watchedFolders.indexOf(path); if (row >= 0) removeRows(row, 1); diff --git a/src/webui/api/searchcontroller.cpp b/src/webui/api/searchcontroller.cpp index 0257b16ec..c7baca6d8 100644 --- a/src/webui/api/searchcontroller.cpp +++ b/src/webui/api/searchcontroller.cpp @@ -184,7 +184,7 @@ void SearchController::resultsAction() const std::shared_ptr &searchHandler = iter.value(); const QList searchResults = searchHandler->results(); - const int size = searchResults.size(); + const qsizetype size = searchResults.size(); if (offset > size) throw APIError(APIErrorType::Conflict, tr("Offset is out of range")); diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 10b7033a4..550eb3ec9 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -637,7 +637,7 @@ void TorrentsController::infoAction() }); } - const int size = torrentList.size(); + const qsizetype size = torrentList.size(); // normalize offset if (offset < 0) offset = size + offset; @@ -993,11 +993,11 @@ void TorrentsController::pieceStatesAction() QJsonArray pieceStates; 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(states[i]) * 2); 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]) pieceStates[i] = 1; diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index e7bd3d02f..35cba850e 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -88,7 +88,7 @@ namespace for (const auto &cookie : cookies) { - const int idx = cookie.indexOf(u'='); + const qsizetype idx = cookie.indexOf(u'='); if (idx < 0) 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); - int i = 0; + qsizetype i = 0; bool found = true; - while (i < data.size() && found) + while ((i < data.size()) && found) { QRegularExpressionMatch regexMatch; i = data.indexOf(regex, i, ®exMatch); @@ -483,7 +483,7 @@ void WebApplication::configure() for (const QStringView line : customHeaderLines) { - const int idx = line.indexOf(u':'); + const qsizetype idx = line.indexOf(u':'); if (idx < 0) { // require separator `:` to be present even if `value` field can be empty