1/****************************************************************************
2**
3** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qpropertynodeaddedchange.h"
41#include "qpropertynodeaddedchange_p.h"
42
43#include <Qt3DCore/private/qnode_p.h>
44
45QT_BEGIN_NAMESPACE
46
47namespace Qt3DCore {
48
49QPropertyNodeAddedChangePrivate::QPropertyNodeAddedChangePrivate()
50 : QStaticPropertyValueAddedChangeBasePrivate()
51 , m_addedNodeIdTypePair()
52{
53}
54
55/*!
56 * \class Qt3DCore::QPropertyNodeAddedChange
57 * \inheaderfile Qt3DCore/QPropertyNodeAddedChange
58 * \inherits Qt3DCore::QStaticPropertyValueAddedChangeBase
59 * \inmodule Qt3DCore
60 * \brief Used to notify when a node is added to a property.
61 *
62 */
63
64/*!
65 * \typedef Qt3DCore::QPropertyNodeAddedChangePtr
66 * \relates Qt3DCore::QPropertyNodeAddedChange
67 *
68 * A shared pointer for QPropertyNodeAddedChange.
69 */
70
71/*!
72 * Constructs a new QPropertyNodeAddedChange with \a subjectId, \a node.
73 */
74QPropertyNodeAddedChange::QPropertyNodeAddedChange(QNodeId subjectId, QNode *node)
75 : QStaticPropertyValueAddedChangeBase(*new QPropertyNodeAddedChangePrivate, subjectId)
76{
77 Q_D(QPropertyNodeAddedChange);
78 Q_ASSERT(node);
79 d->m_addedNodeIdTypePair = QNodeIdTypePair(node->id(), QNodePrivate::findStaticMetaObject(metaObject: node->metaObject()));
80
81 // Ensure the node has issued a node creation change. We can end
82 // up here if a newly created node with a parent is immediately set
83 // as a property on another node. In this case the deferred call to
84 // _q_postConstructorInit() will not have happened yet as the event
85 // loop will still be blocked. So force it here and we catch this
86 // eventuality in the _q_postConstructorInit() function so that we
87 // do not repeat the creation and new child scene change events.
88 QNodePrivate::get(q: node)->_q_ensureBackendNodeCreated();
89}
90
91/*! \internal */
92QPropertyNodeAddedChange::~QPropertyNodeAddedChange()
93{
94}
95
96/*!
97 * \return the id of the node added to the property.
98 */
99QNodeId QPropertyNodeAddedChange::addedNodeId() const
100{
101 Q_D(const QPropertyNodeAddedChange);
102 return d->m_addedNodeIdTypePair.id;
103}
104
105/*!
106 * \return the meta object of the node added to the property.
107 */
108const QMetaObject *QPropertyNodeAddedChange::metaObject() const
109{
110 Q_D(const QPropertyNodeAddedChange);
111 return d->m_addedNodeIdTypePair.type;
112}
113
114} // namespace Qt3DCore
115
116QT_END_NAMESPACE
117

source code of qt3d/src/core/changes/qpropertynodeaddedchange.cpp