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>
bb10
Marc Mutz 2022-08-18 11:10:09 +02:00
parent cbae09fe42
commit 66b633bbc1
3 changed files with 27 additions and 2 deletions

View File

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

View File

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

View File

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