diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-08-18 11:10:09 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-09-07 15:15:28 +0200 |
commit | 66b633bbc1f9dd27825eb87030dbad134c1d24c8 (patch) | |
tree | 4be930597dfa78afe9038888cd1b0ed6b6a136a5 /src | |
parent | cbae09fe42d1381e00a226972714a6fb0171da66 (diff) |
Port QDir to qsizetype [3/3]: API
[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 <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/compat/removed_api.cpp | 14 | ||||
-rw-r--r-- | src/corelib/io/qdir.cpp | 9 | ||||
-rw-r--r-- | 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); |