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

@@ -101,7 +101,7 @@ QList<QVariantHash> RSS::Private::FeedSerializer::loadArticles(const QByteArray
QList<QVariantHash> 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())

View File

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

View File

@@ -60,7 +60,7 @@ QList<Article *> 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)

View File

@@ -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;
}

View File

@@ -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 {};