diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-09 10:46:07 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-09 18:09:30 +0100 |
commit | d7008c79d4ec023527ebfc118ad47f40075f244d (patch) | |
tree | ce4e1b3e4148820fd5682ee1877a7626274cdb59 /src/qml/qml/qqmllist.h | |
parent | 5824283a7804e7975140c17731329786045ef432 (diff) |
QQmlListProperty: Use qsizetype rather than int for sizes
[ChangeLog][QtQml] The QQmlListProperty callback functions use qsizetype
now as type for the size of a list. This is in line with the containers
that you might use to back the list.
Fixes: QTBUG-88269
Change-Id: Ia38403cb32f241e6c70e1a580dbeff1d6d694331
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmllist.h')
-rw-r--r-- | src/qml/qml/qqmllist.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h index c51a9c7636..7eb6d71670 100644 --- a/src/qml/qml/qqmllist.h +++ b/src/qml/qml/qqmllist.h @@ -60,10 +60,10 @@ template<typename T> class QQmlListProperty { public: using AppendFunction = void (*)(QQmlListProperty<T> *, T *); - using CountFunction = int (*)(QQmlListProperty<T> *); - using AtFunction = T *(*)(QQmlListProperty<T> *, int); + using CountFunction = qsizetype (*)(QQmlListProperty<T> *); + using AtFunction = T *(*)(QQmlListProperty<T> *, qsizetype); using ClearFunction = void (*)(QQmlListProperty<T> *); - using ReplaceFunction = void (*)(QQmlListProperty<T> *, int, T *); + using ReplaceFunction = void (*)(QQmlListProperty<T> *, qsizetype, T *); using RemoveLastFunction = void (*)(QQmlListProperty<T> *); QQmlListProperty() = default; @@ -126,39 +126,39 @@ private: static void qlist_append(QQmlListProperty *p, T *v) { reinterpret_cast<QList<T *> *>(p->data)->append(v); } - static int qlist_count(QQmlListProperty *p) { + static qsizetype qlist_count(QQmlListProperty *p) { return reinterpret_cast<QList<T *> *>(p->data)->count(); } - static T *qlist_at(QQmlListProperty *p, int idx) { + static T *qlist_at(QQmlListProperty *p, qsizetype idx) { return reinterpret_cast<QList<T *> *>(p->data)->at(idx); } static void qlist_clear(QQmlListProperty *p) { return reinterpret_cast<QList<T *> *>(p->data)->clear(); } - static void qlist_replace(QQmlListProperty *p, int idx, T *v) { + static void qlist_replace(QQmlListProperty *p, qsizetype idx, T *v) { return reinterpret_cast<QList<T *> *>(p->data)->replace(idx, v); } static void qlist_removeLast(QQmlListProperty *p) { return reinterpret_cast<QList<T *> *>(p->data)->removeLast(); } - static void qslow_replace(QQmlListProperty<T> *list, int idx, T *v) + static void qslow_replace(QQmlListProperty<T> *list, qsizetype idx, T *v) { - const int length = list->count(list); + const qsizetype length = list->count(list); if (idx < 0 || idx >= length) return; QVector<T *> stash; if (list->clear != qslow_clear) { stash.reserve(length); - for (int i = 0; i < length; ++i) + for (qsizetype i = 0; i < length; ++i) stash.append(i == idx ? v : list->at(list, i)); list->clear(list); for (T *item : qAsConst(stash)) list->append(list, item); } else { stash.reserve(length - idx - 1); - for (int i = length - 1; i > idx; --i) { + for (qsizetype i = length - 1; i > idx; --i) { stash.append(list->at(list, i)); list->removeLast(list); } @@ -171,18 +171,18 @@ private: static void qslow_clear(QQmlListProperty<T> *list) { - for (int i = 0, end = list->count(list); i < end; ++i) + for (qsizetype i = 0, end = list->count(list); i < end; ++i) list->removeLast(list); } static void qslow_removeLast(QQmlListProperty<T> *list) { - const int length = list->count(list) - 1; + const qsizetype length = list->count(list) - 1; if (length < 0) return; QVector<T *> stash; stash.reserve(length); - for (int i = 0; i < length; ++i) + for (qsizetype i = 0; i < length; ++i) stash.append(list->at(list, i)); list->clear(list); for (T *item : qAsConst(stash)) @@ -218,10 +218,10 @@ public: bool isReadable() const; bool append(QObject *) const; - QObject *at(int) const; + QObject *at(qsizetype) const; bool clear() const; - int count() const; - bool replace(int, QObject *) const; + qsizetype count() const; + bool replace(qsizetype, QObject *) const; bool removeLast() const; bool operator==(const QQmlListReference &other) const {return d == other.d;} |