summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2016-04-21 10:30:17 +0100
committerSean Harmer <sean.harmer@kdab.com>2016-04-21 14:50:48 +0000
commite52d11ef2a9ba8bfceb738a3b1c4c7c9a63f5000 (patch)
treeec7432a4431a4147db313b51a788d4106fd2e86a /src
parentd4204e818b2f35293790a7ef0fd9a79ca92e6319 (diff)
Introduce a new base class for node property change events
This will allow QScenePropertyChange to be a default implementation that uses QVariant as the payload for automatic uses. It will also allow to have a QNodeTypedPropertyChange template subclass for strongly typed payloads - similar to the creation changes. This will be useful for common change types like transformations sending a QMatrix4x4 to avoid QVariant and conversion overheads. Change-Id: Ia64dcb892b42e2cb2a18a55dfa7f4073ac58b2e3 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/core.pri5
-rw-r--r--src/core/qnodepropertychangebase.cpp116
-rw-r--r--src/core/qnodepropertychangebase.h72
-rw-r--r--src/core/qnodepropertychangebase_p.h81
-rw-r--r--src/core/qscenepropertychange.cpp24
-rw-r--r--src/core/qscenepropertychange.h7
-rw-r--r--src/core/qscenepropertychange_p.h7
7 files changed, 280 insertions, 32 deletions
diff --git a/src/core/core.pri b/src/core/core.pri
index cc2724c2a..eff20581e 100644
--- a/src/core/core.pri
+++ b/src/core/core.pri
@@ -39,7 +39,9 @@ HEADERS += \
$$PWD/qcomponentaddedchange.h \
$$PWD/qcomponentaddedchange_p.h \
$$PWD/qcomponentremovedchange.h \
- $$PWD/qcomponentremovedchange_p.h
+ $$PWD/qcomponentremovedchange_p.h \
+ $$PWD/qnodepropertychangebase.h \
+ $$PWD/qnodepropertychangebase_p.h
SOURCES += \
$$PWD/qtickclock.cpp \
@@ -60,3 +62,4 @@ SOURCES += \
$$PWD/qnodedestroyedchange.cpp \
$$PWD/qcomponentaddedchange.cpp \
$$PWD/qcomponentremovedchange.cpp \
+ $$PWD/qnodepropertychangebase.cpp
diff --git a/src/core/qnodepropertychangebase.cpp b/src/core/qnodepropertychangebase.cpp
new file mode 100644
index 000000000..5166ea8be
--- /dev/null
+++ b/src/core/qnodepropertychangebase.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnodepropertychangebase.h"
+#include "qnodepropertychangebase_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+QNodePropertyChangeBasePrivate::QNodePropertyChangeBasePrivate()
+ : QSceneChangePrivate()
+{
+}
+
+QNodePropertyChangeBasePrivate::~QNodePropertyChangeBasePrivate()
+{
+}
+
+
+/*!
+ * \class Qt3DCore::QNodePropertyChangeBase
+ * \inmodule Qt3DCore
+ *
+ * TODO
+ */
+
+/*!
+ * \typedef Qt3DCore::QNodePropertyChangeBasePtr
+ * \relates Qt3DCore::QNodePropertyChangeBase
+ *
+ * A shared pointer for QNodePropertyChangeBase.
+ */
+
+/*!
+ * Constructs a new QNodePropertyChangeBase with \a type, \a observableType, \a subjectId, and
+ * \a priority.
+ */
+QNodePropertyChangeBase::QNodePropertyChangeBase(ChangeFlag type, ObservableType observableType, QNodeId subjectId, QSceneChange::Priority priority)
+ : QSceneChange(*new QNodePropertyChangeBasePrivate, type, observableType, subjectId, priority)
+{
+}
+
+/*! \internal */
+QNodePropertyChangeBase::QNodePropertyChangeBase(QNodePropertyChangeBasePrivate &dd)
+ : QSceneChange(dd)
+{
+}
+
+/*! \internal */
+QNodePropertyChangeBase::QNodePropertyChangeBase(QNodePropertyChangeBasePrivate &dd, ChangeFlag type, ObservableType observableType, QNodeId subjectId, QSceneChange::Priority priority)
+ : QSceneChange(dd, type, observableType, subjectId, priority)
+{
+}
+
+QNodePropertyChangeBase::~QNodePropertyChangeBase()
+{
+}
+
+/*!
+ * \return name of the property.
+ */
+const char *QNodePropertyChangeBase::propertyName() const
+{
+ Q_D(const QNodePropertyChangeBase);
+ return d->m_propertyName;
+}
+
+/*!
+ * Sets the property change \a name.
+ */
+void QNodePropertyChangeBase::setPropertyName(const char *name)
+{
+ Q_D(QNodePropertyChangeBase);
+ d->m_propertyName = name;
+}
+
+} // namespace Qt3DCore
+
+QT_END_NAMESPACE
diff --git a/src/core/qnodepropertychangebase.h b/src/core/qnodepropertychangebase.h
new file mode 100644
index 000000000..dd70a1f3f
--- /dev/null
+++ b/src/core/qnodepropertychangebase.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DCORE_QNODEPROPERTYCHANGEBASE_H
+#define QT3DCORE_QNODEPROPERTYCHANGEBASE_H
+
+#include <Qt3DCore/qscenechange.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class QNodePropertyChangeBasePrivate;
+
+class QT3DCORESHARED_EXPORT QNodePropertyChangeBase : public QSceneChange
+{
+public:
+ QNodePropertyChangeBase(ChangeFlag type, ObservableType observableType, QNodeId subjectId, Priority priority = Standard);
+ virtual ~QNodePropertyChangeBase();
+
+ const char *propertyName() const;
+ void setPropertyName(const char *name);
+
+protected:
+ Q_DECLARE_PRIVATE(QNodePropertyChangeBase)
+ QNodePropertyChangeBase(QNodePropertyChangeBasePrivate &dd);
+ QNodePropertyChangeBase(QNodePropertyChangeBasePrivate &dd, ChangeFlag type, ObservableType observableType, QNodeId subjectId, Priority priority = Standard);
+};
+
+typedef QSharedPointer<QNodePropertyChangeBase> QNodePropertyChangeBasePtr;
+
+} // namespace Qt3DCore
+
+QT_END_NAMESPACE
+
+#endif // QT3DCORE_QNODEPROPERTYCHANGEBASE_H
diff --git a/src/core/qnodepropertychangebase_p.h b/src/core/qnodepropertychangebase_p.h
new file mode 100644
index 000000000..5b487f1a0
--- /dev/null
+++ b/src/core/qnodepropertychangebase_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QNODEPROPERTYCHANGEBASE_P_H
+#define QNODEPROPERTYCHANGEBASE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qscenechange_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class QScenePropertyChange;
+class QFrameAllocator;
+
+class QNodePropertyChangeBasePrivate : public QSceneChangePrivate
+{
+public:
+ QNodePropertyChangeBasePrivate();
+ virtual ~QNodePropertyChangeBasePrivate();
+
+ Q_DECLARE_PUBLIC(QNodePropertyChangeBase)
+
+ /// FIXME: use QMetaProperty here once the NodeAboutToBeDeleted etc. change events
+ /// get refactored to their own QSceneChange subclass
+ const char *m_propertyName;
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QNODEPROPERTYCHANGEBASE_P_H
+
diff --git a/src/core/qscenepropertychange.cpp b/src/core/qscenepropertychange.cpp
index ce4b7a707..8d6b1a282 100644
--- a/src/core/qscenepropertychange.cpp
+++ b/src/core/qscenepropertychange.cpp
@@ -49,7 +49,7 @@ QFrameAllocator *QScenePropertyChangePrivate::m_allocator = new QFrameAllocator(
QMutex QScenePropertyChangePrivate::m_mutex;
QScenePropertyChangePrivate::QScenePropertyChangePrivate()
- : QSceneChangePrivate()
+ : QNodePropertyChangeBasePrivate()
{
}
@@ -98,7 +98,7 @@ QScenePropertyChange::QScenePropertyChange(ChangeFlag type, ObservableType obser
* \internal
*/
QScenePropertyChange::QScenePropertyChange(QScenePropertyChangePrivate &dd)
- : QSceneChange(dd)
+ : QNodePropertyChangeBase(dd)
{
}
@@ -106,7 +106,7 @@ QScenePropertyChange::QScenePropertyChange(QScenePropertyChangePrivate &dd)
* \internal
*/
QScenePropertyChange::QScenePropertyChange(QScenePropertyChangePrivate &dd, ChangeFlag type, ObservableType observableType, QNodeId subjectId, QSceneChange::Priority priority)
- : QSceneChange(dd, type, observableType, subjectId, priority)
+ : QNodePropertyChangeBase(dd, type, observableType, subjectId, priority)
{
}
@@ -115,15 +115,6 @@ QScenePropertyChange::~QScenePropertyChange()
}
/*!
- * \return name of the property.
- */
-const char *QScenePropertyChange::propertyName() const
-{
- Q_D(const QScenePropertyChange);
- return d->m_propertyName;
-}
-
-/*!
* \return property value.
*/
QVariant QScenePropertyChange::value() const
@@ -133,15 +124,6 @@ QVariant QScenePropertyChange::value() const
}
/*!
- * Sets the property change \a name.
- */
-void QScenePropertyChange::setPropertyName(const char *name)
-{
- Q_D(QScenePropertyChange);
- d->m_propertyName = name;
-}
-
-/*!
* Set the property change \a value.
*/
void QScenePropertyChange::setValue(const QVariant &value)
diff --git a/src/core/qscenepropertychange.h b/src/core/qscenepropertychange.h
index 82400f6ba..3a32b5aea 100644
--- a/src/core/qscenepropertychange.h
+++ b/src/core/qscenepropertychange.h
@@ -40,7 +40,7 @@
#ifndef QT3DCORE_QSCENEPROPERTYCHANGE_H
#define QT3DCORE_QSCENEPROPERTYCHANGE_H
-#include <Qt3DCore/qscenechange.h>
+#include <Qt3DCore/qnodepropertychangebase.h>
QT_BEGIN_NAMESPACE
@@ -48,16 +48,13 @@ namespace Qt3DCore {
class QScenePropertyChangePrivate;
-class QT3DCORESHARED_EXPORT QScenePropertyChange : public QSceneChange
+class QT3DCORESHARED_EXPORT QScenePropertyChange : public QNodePropertyChangeBase
{
public:
QScenePropertyChange(ChangeFlag type, ObservableType observableType, QNodeId subjectId, Priority priority = Standard);
virtual ~QScenePropertyChange();
- const char *propertyName() const;
QVariant value() const;
-
- void setPropertyName(const char *name);
void setValue(const QVariant &value);
static void *operator new(size_t size);
diff --git a/src/core/qscenepropertychange_p.h b/src/core/qscenepropertychange_p.h
index a290c1729..aaefda673 100644
--- a/src/core/qscenepropertychange_p.h
+++ b/src/core/qscenepropertychange_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <private/qscenechange_p.h>
+#include <private/qnodepropertychangebase_p.h>
#include <QVariant>
#include <QMutex>
@@ -62,7 +62,7 @@ namespace Qt3DCore {
class QScenePropertyChange;
class QFrameAllocator;
-class QScenePropertyChangePrivate : public QSceneChangePrivate
+class QScenePropertyChangePrivate : public QNodePropertyChangeBasePrivate
{
public:
QScenePropertyChangePrivate();
@@ -73,9 +73,6 @@ public:
Q_DECLARE_PUBLIC(QScenePropertyChange)
- /// FIXME: use QMetaProperty here once the NodeAboutToBeDeleted etc. change events
- /// get refactored to their own QSceneChange subclass
- const char *m_propertyName;
QVariant m_value;
static QFrameAllocator *m_allocator;