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:
Chocobo1
2025-09-29 03:08:02 +08:00
committed by GitHub
parent 01ac8c012c
commit eed0e56d1a
39 changed files with 86 additions and 85 deletions

View File

@@ -184,7 +184,7 @@ void SearchController::resultsAction()
const std::shared_ptr<SearchHandler> &searchHandler = iter.value();
const QList<SearchResult> 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"));

View File

@@ -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<int>(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;

View File

@@ -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, &regexMatch);
@@ -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