From 66b633bbc1f9dd27825eb87030dbad134c1d24c8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 18 Aug 2022 11:10:09 +0200 Subject: [PATCH] Port QDir to qsizetype [3/3]: API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][QtCore][QDir] The count() function now returns, and the indexing operator now takes, qsizetype (was: uint and int, respectively). [ChangeLog][Potentially Source-Incompatible Changes][QDir] The count() function now returns qsizetype (was: uint). Task-number: QTBUG-103525 Change-Id: Ib84af36f6a95d9a0d1090a2d6fb973a4e363550c Reviewed-by: Qt CI Bot Reviewed-by: Sona Kurazyan Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira --- src/corelib/compat/removed_api.cpp | 14 ++++++++++++++ src/corelib/io/qdir.cpp | 9 +++++++-- src/corelib/io/qdir.h | 6 ++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index 4cde28e088..f3f741d830 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -299,6 +299,20 @@ void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj) #include "qbuffer.h" // inline removed API +#include "qdir.h" + +uint QDir::count() const +{ + return uint(count(QT6_CALL_NEW_OVERLOAD)); +} + +#if QT_POINTER_SIZE != 4 +QString QDir::operator[](int i) const +{ + return operator[](qsizetype{i}); +} +#endif + #include "qenvironmentvariables.h" bool qputenv(const char *varName, const QByteArray &value) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 3ee3088ee8..624efdafc9 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1262,9 +1262,12 @@ void QDir::setSorting(SortFlags sort) Equivalent to entryList().count(). + \note In Qt versions prior to 6.5, this function returned \c{uint}, not + \c{qsizetype}. + \sa operator[](), entryList() */ -uint QDir::count() const +qsizetype QDir::count(QT6_IMPL_NEW_OVERLOAD) const { const QDirPrivate* d = d_ptr.constData(); d->initFileLists(*this); @@ -1276,9 +1279,11 @@ uint QDir::count() const names. Equivalent to entryList().at(index). \a pos must be a valid index position in the list (i.e., 0 <= pos < count()). + \note In Qt versions prior to 6.5, \a pos was an \c{int}, not \c{qsizetype}. + \sa count(), entryList() */ -QString QDir::operator[](int pos) const +QString QDir::operator[](qsizetype pos) const { const QDirPrivate* d = d_ptr.constData(); d->initFileLists(*this); diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index b516777fb8..32bb471af4 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -146,10 +146,16 @@ public: SortFlags sorting() const; void setSorting(SortFlags sort); +#if QT_CORE_REMOVED_SINCE(6, 5) uint count() const; +#endif + qsizetype count(QT6_DECL_NEW_OVERLOAD) const; bool isEmpty(Filters filters = Filters(AllEntries | NoDotAndDotDot)) const; +#if QT_CORE_REMOVED_SINCE(6, 5) && QT_POINTER_SIZE != 4 QString operator[](int) const; +#endif + QString operator[](qsizetype) const; static QStringList nameFiltersFromString(const QString &nameFilter);