1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "quick3dchannelmapper_p.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | namespace Qt3DAnimation { |
9 | namespace Animation { |
10 | namespace Quick { |
11 | |
12 | Quick3DChannelMapper::Quick3DChannelMapper(QObject *parent) |
13 | : QObject(parent) |
14 | { |
15 | } |
16 | |
17 | QQmlListProperty<QAbstractChannelMapping> Quick3DChannelMapper::qmlMappings() |
18 | { |
19 | using qt_size_type = qsizetype; |
20 | using ListContentType = QAbstractChannelMapping; |
21 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *mapping) { |
22 | Quick3DChannelMapper *extension = qobject_cast<Quick3DChannelMapper *>(object: list->object); |
23 | extension->parentMapper()->addMapping(mapping); |
24 | }; |
25 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
26 | Quick3DChannelMapper *extension = qobject_cast<Quick3DChannelMapper *>(object: list->object); |
27 | return extension->parentMapper()->mappings().size(); |
28 | }; |
29 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
30 | Quick3DChannelMapper *extension = qobject_cast<Quick3DChannelMapper *>(object: list->object); |
31 | return extension->parentMapper()->mappings().at(i: index); |
32 | }; |
33 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
34 | Quick3DChannelMapper *extension = qobject_cast<Quick3DChannelMapper *>(object: list->object); |
35 | const auto mappings = extension->parentMapper()->mappings(); |
36 | for (QAbstractChannelMapping *mapping : mappings) |
37 | extension->parentMapper()->removeMapping(mapping); |
38 | }; |
39 | |
40 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
41 | } |
42 | |
43 | } // namespace Quick |
44 | } // namespace Animation |
45 | } // namespace Qt3DAnimation |
46 | |
47 | QT_END_NAMESPACE |
48 | |
49 | #include "moc_quick3dchannelmapper_p.cpp" |
50 |