summaryrefslogtreecommitdiffstats
path: root/src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2020-11-23 09:06:01 +0000
committerMike Krus <mike.krus@kdab.com>2021-01-08 11:32:08 +0000
commitd2fe37b3480cc55cf301426d7fa40475080cc6f9 (patch)
tree8c0ef31cdc3d2f75f4eed7d851a6d22e793d4c00 /src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp
parenteee0fca4abc800883dde40559290403e7e550d14 (diff)
Update QQMLPropertyList API
Use lambdas with local typedefs for index type Change-Id: I2876c71d619815e7e777f936e8bb0835b8269336 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp')
-rw-r--r--src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp70
1 files changed, 31 insertions, 39 deletions
diff --git a/src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp b/src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp
index 5e25c00c5..acb2f096f 100644
--- a/src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp
+++ b/src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp
@@ -48,47 +48,39 @@ QQuick3DMorphingAnimation::QQuick3DMorphingAnimation(QObject *parent)
QQmlListProperty<Qt3DAnimation::QMorphTarget> QQuick3DMorphingAnimation::morphTargets()
{
- return QQmlListProperty<Qt3DAnimation::QMorphTarget>(this, 0,
- &QQuick3DMorphingAnimation::appendMorphTarget,
- &QQuick3DMorphingAnimation::morphTargetCount,
- &QQuick3DMorphingAnimation::morphTargetAt,
- &QQuick3DMorphingAnimation::clearMorphTargets);
-}
-
-void QQuick3DMorphingAnimation::appendMorphTarget(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list,
- Qt3DAnimation::QMorphTarget *morphTarget)
-{
- QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object);
- if (animation)
- animation->parentMorphingAnimation()->addMorphTarget(morphTarget);
-}
-
-qsizetype QQuick3DMorphingAnimation::morphTargetCount(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list)
-{
- QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object);
- if (animation)
- return animation->parentMorphingAnimation()->morphTargetList().count();
- return 0;
-}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ using qt_size_type = qsizetype;
+#else
+ using qt_size_type = int;
+#endif
-Qt3DAnimation::QMorphTarget *QQuick3DMorphingAnimation::morphTargetAt(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list,
- qsizetype index)
-{
- QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object);
- if (animation) {
- return qobject_cast<Qt3DAnimation::QMorphTarget *>(
- animation->parentMorphingAnimation()->morphTargetList().at(index));
- }
- return nullptr;
-}
+ using ListContentType = Qt3DAnimation::QMorphTarget;
+ auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *morphTarget) {
+ QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object);
+ if (animation)
+ animation->parentMorphingAnimation()->addMorphTarget(morphTarget);
+ };
+ auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
+ QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object);
+ if (animation)
+ return animation->parentMorphingAnimation()->morphTargetList().count();
+ return 0;
+ };
+ auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
+ QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object);
+ if (animation) {
+ return qobject_cast<Qt3DAnimation::QMorphTarget *>(
+ animation->parentMorphingAnimation()->morphTargetList().at(index));
+ }
+ return nullptr;
+ };
+ auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
+ QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object);
+ if (animation)
+ animation->parentMorphingAnimation()->setMorphTargets({});
+ };
-void QQuick3DMorphingAnimation::clearMorphTargets(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list)
-{
- QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object);
- if (animation) {
- QList<Qt3DAnimation::QMorphTarget *> emptyList;
- animation->parentMorphingAnimation()->setMorphTargets(emptyList);
- }
+ return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
}
} // namespace Quick