diff options
Diffstat (limited to 'src/core')
128 files changed, 1703 insertions, 424 deletions
diff --git a/src/core/aspects/aspectcommanddebugger.cpp b/src/core/aspects/aspectcommanddebugger.cpp index 6bb93c827..eceec1bbd 100644 --- a/src/core/aspects/aspectcommanddebugger.cpp +++ b/src/core/aspects/aspectcommanddebugger.cpp @@ -37,14 +37,14 @@ ** ****************************************************************************/ -#ifdef QT3D_JOBS_RUN_STATS - #include "aspectcommanddebugger_p.h" + #include <Qt3DCore/qaspectengine.h> +#include <QtNetwork/QTcpSocket> +#include <QtCore/QJsonDocument> +#include <QtCore/QJsonObject> + #include <Qt3DCore/private/qabstractaspect_p.h> -#include <QTcpSocket> -#include <QJsonDocument> -#include <QJsonObject> QT_BEGIN_NAMESPACE @@ -216,5 +216,3 @@ void AspectCommandDebugger::executeCommand(const QString &command, } // Qt3DCore QT_END_NAMESPACE - -#endif diff --git a/src/core/aspects/aspectcommanddebugger_p.h b/src/core/aspects/aspectcommanddebugger_p.h index b173a5c09..bb6100df5 100644 --- a/src/core/aspects/aspectcommanddebugger_p.h +++ b/src/core/aspects/aspectcommanddebugger_p.h @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#ifdef QT3D_JOBS_RUN_STATS +#include <Qt3DCore/qt3dcore-config.h> #ifndef QT3DCORE_DEBUG_ASPECTCOMMANDDEBUGGER_H #define QT3DCORE_DEBUG_ASPECTCOMMANDDEBUGGER_H @@ -108,5 +108,3 @@ private: QT_END_NAMESPACE #endif // QT3DCORE_DEBUG_ASPECTCOMMANDDEBUGGER_H - -#endif // QT3D_JOBS_RUN_STATS diff --git a/src/core/aspects/aspects.pri b/src/core/aspects/aspects.pri index 773c736a3..54d939138 100644 --- a/src/core/aspects/aspects.pri +++ b/src/core/aspects/aspects.pri @@ -5,8 +5,7 @@ SOURCES += \ $$PWD/qaspectengine.cpp \ $$PWD/qaspectfactory.cpp \ $$PWD/qaspectmanager.cpp \ - $$PWD/qaspectthread.cpp \ - $$PWD/aspectcommanddebugger.cpp + $$PWD/qaspectthread.cpp HEADERS += \ $$PWD/qabstractaspect.h \ @@ -15,7 +14,13 @@ HEADERS += \ $$PWD/qaspectengine_p.h \ $$PWD/qaspectfactory_p.h \ $$PWD/qaspectmanager_p.h \ - $$PWD/qaspectthread_p.h \ - $$PWD/aspectcommanddebugger_p.h + $$PWD/qaspectthread_p.h INCLUDEPATH += $$PWD + +include($$OUT_PWD/../core/qt3dcore-config.pri) +QT_FOR_CONFIG += 3dcore-private +qtConfig(qt3d-profile-jobs): { + HEADERS += $$PWD/aspectcommanddebugger_p.h + SOURCES += $$PWD/aspectcommanddebugger.cpp +} diff --git a/src/core/aspects/qabstractaspect.cpp b/src/core/aspects/qabstractaspect.cpp index c049d3503..d7e62db68 100644 --- a/src/core/aspects/qabstractaspect.cpp +++ b/src/core/aspects/qabstractaspect.cpp @@ -38,15 +38,17 @@ ****************************************************************************/ #include "qabstractaspect.h" -#include "qentity.h" -#include <Qt3DCore/private/qaspectmanager_p.h> -#include <private/qabstractaspect_p.h> -#include <Qt3DCore/private/qaspectjobmanager_p.h> -#include <private/qchangearbiter_p.h> -#include <Qt3DCore/private/qscene_p.h> -#include <Qt3DCore/private/qnodevisitor_p.h> +#include "qabstractaspect_p.h" + +#include <Qt3DCore/qentity.h> #include <Qt3DCore/qpropertyupdatedchange.h> + #include <Qt3DCore/private/corelogging_p.h> +#include <Qt3DCore/private/qaspectjobmanager_p.h> +#include <Qt3DCore/private/qaspectmanager_p.h> +#include <Qt3DCore/private/qchangearbiter_p.h> +#include <Qt3DCore/private/qnodevisitor_p.h> +#include <Qt3DCore/private/qscene_p.h> QT_BEGIN_NAMESPACE @@ -157,6 +159,12 @@ void QAbstractAspect::registerBackendType(const QMetaObject &obj, const QBackend d->m_backendCreatorFunctors.insert(&obj, functor); } +void QAbstractAspect::unregisterBackendType(const QMetaObject &obj) +{ + Q_D(QAbstractAspect); + d->m_backendCreatorFunctors.remove(&obj); +} + void QAbstractAspectPrivate::sceneNodeAdded(QSceneChangePtr &change) { QNodeCreatedChangeBasePtr creationChange = qSharedPointerCast<QNodeCreatedChangeBase>(change); @@ -282,7 +290,15 @@ QAbstractAspectJobManager *QAbstractAspectPrivate::jobManager() const QVector<QAspectJobPtr> QAbstractAspectPrivate::jobsToExecute(qint64 time) { Q_Q(QAbstractAspect); - return q->jobsToExecute(time); + auto res = q->jobsToExecute(time); + + { + QMutexLocker lock(&m_singleShotMutex); + res << m_singleShotJobs; + m_singleShotJobs.clear(); + } + + return res; } /*! @@ -324,6 +340,13 @@ void QAbstractAspect::onEngineShutdown() { } +void QAbstractAspect::scheduleSingleShotJob(const Qt3DCore::QAspectJobPtr &job) +{ + Q_D(QAbstractAspect); + QMutexLocker lock(&d->m_singleShotMutex); + d->m_singleShotJobs.push_back(job); +} + namespace Debug { AsynchronousCommandReply::AsynchronousCommandReply(const QString &commandName, QObject *parent) diff --git a/src/core/aspects/qabstractaspect.h b/src/core/aspects/qabstractaspect.h index 86938d2d2..8ac1b251f 100644 --- a/src/core/aspects/qabstractaspect.h +++ b/src/core/aspects/qabstractaspect.h @@ -40,10 +40,10 @@ #ifndef QT3DCORE_QABSTRACTASPECT_H #define QT3DCORE_QABSTRACTASPECT_H -#include <QObject> -#include <QSharedPointer> #include <Qt3DCore/qt3dcore_global.h> #include <Qt3DCore/qnodeid.h> +#include <QtCore/QObject> +#include <QtCore/QSharedPointer> QT_BEGIN_NAMESPACE @@ -68,6 +68,8 @@ public: explicit QAbstractAspect(QObject *parent = nullptr); ~QAbstractAspect(); + void scheduleSingleShotJob(const Qt3DCore::QAspectJobPtr &job); + protected: explicit QAbstractAspect(QAbstractAspectPrivate &dd, QObject *parent = nullptr); @@ -76,6 +78,9 @@ protected: template<class Frontend> void registerBackendType(const QBackendNodeMapperPtr &functor); void registerBackendType(const QMetaObject &, const QBackendNodeMapperPtr &functor); + template<class Frontend> + void unregisterBackendType(); + void unregisterBackendType(const QMetaObject &); private: virtual QVariant executeCommand(const QStringList &args); @@ -99,6 +104,12 @@ void QAbstractAspect::registerBackendType(const QBackendNodeMapperPtr &functor) registerBackendType(Frontend::staticMetaObject, functor); } +template<class Frontend> +void QAbstractAspect::unregisterBackendType() +{ + unregisterBackendType(Frontend::staticMetaObject); +} + } // namespace Qt3DCore QT_END_NAMESPACE diff --git a/src/core/aspects/qabstractaspect_p.h b/src/core/aspects/qabstractaspect_p.h index 53b01cc40..a6c47c494 100644 --- a/src/core/aspects/qabstractaspect_p.h +++ b/src/core/aspects/qabstractaspect_p.h @@ -51,14 +51,18 @@ // We mean it. // -#include <private/qobject_p.h> -#include <private/qaspectjobproviderinterface_p.h> -#include <private/qbackendnode_p.h> -#include <private/qbackendnodefactory_p.h> -#include <private/qsceneobserverinterface_p.h> -#include <private/qt3dcore_global_p.h> -#include <Qt3DCore/qnodedestroyedchange.h> #include <Qt3DCore/qabstractaspect.h> +#include <Qt3DCore/qnodedestroyedchange.h> + +#include <Qt3DCore/private/qaspectjobproviderinterface_p.h> +#include <Qt3DCore/private/qbackendnode_p.h> +#include <Qt3DCore/private/qbackendnodefactory_p.h> +#include <Qt3DCore/private/qsceneobserverinterface_p.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> +#include <QtCore/private/qobject_p.h> + +#include <QMutex> +#include <QVector> QT_BEGIN_NAMESPACE @@ -136,6 +140,8 @@ public: QAbstractAspectJobManager *m_jobManager; QChangeArbiter *m_arbiter; QHash<const QMetaObject*, QBackendNodeMapperPtr> m_backendCreatorFunctors; + QMutex m_singleShotMutex; + QVector<QAspectJobPtr> m_singleShotJobs; static QAbstractAspectPrivate *get(QAbstractAspect *aspect); }; diff --git a/src/core/aspects/qaspectengine.cpp b/src/core/aspects/qaspectengine.cpp index 15f975332..b9c9d2283 100644 --- a/src/core/aspects/qaspectengine.cpp +++ b/src/core/aspects/qaspectengine.cpp @@ -38,27 +38,30 @@ ****************************************************************************/ #include "qaspectengine.h" +#include "qaspectengine_p.h" + +#include <Qt3DCore/qabstractaspect.h> +#include <Qt3DCore/qcomponent.h> +#include <Qt3DCore/qentity.h> +#include <Qt3DCore/qnode.h> +#include <QtCore/QMetaObject> -#include "qabstractaspect.h" -#include "qaspectthread_p.h" -#include "qaspectmanager_p.h" -#include "qchangearbiter_p.h" -#include "qabstractaspect.h" -#include "qnode.h" #include <Qt3DCore/private/corelogging_p.h> -#include <QMetaObject> -#include <private/qpostman_p.h> -#include <private/qscene_p.h> -#include <private/qaspectengine_p.h> -#include <private/qnode_p.h> -#include <private/qnodevisitor_p.h> -#include <private/qscene_p.h> -#include "qentity.h" -#include "qcomponent.h" +#include <Qt3DCore/private/qaspectthread_p.h> +#include <Qt3DCore/private/qaspectmanager_p.h> +#include <Qt3DCore/private/qchangearbiter_p.h> #include <Qt3DCore/private/qeventfilterservice_p.h> +#include <Qt3DCore/private/qnode_p.h> +#include <Qt3DCore/private/qnodevisitor_p.h> #include <Qt3DCore/private/qnodecreatedchangegenerator_p.h> +#include <Qt3DCore/private/qpostman_p.h> +#include <Qt3DCore/private/qscene_p.h> #include <Qt3DCore/private/qservicelocator_p.h> +#include <Qt3DCore/qt3dcore-config.h> + +#if defined(QT3D_JOBS_RUN_STATS) #include <Qt3DCore/private/aspectcommanddebugger_p.h> +#endif QT_BEGIN_NAMESPACE @@ -100,8 +103,8 @@ QAspectEnginePrivate::~QAspectEnginePrivate() */ void QAspectEnginePrivate::initNode(QNode *node) { - QNodePrivate::get(node)->setScene(m_scene); m_scene->addObservable(node); + QNodePrivate::get(node)->setScene(m_scene); } void QAspectEnginePrivate::initEntity(QEntity *entity) @@ -177,10 +180,6 @@ void QAspectEnginePrivate::generateCreationChanges(QNode *root) QAspectEngine::QAspectEngine(QObject *parent) : QObject(*new QAspectEnginePrivate, parent) { - // Don't show any debug output from Qt3D. If you need to enable additional logging - // for debugging use a rules file as explained in the QLoggingCategory documentation. - QLoggingCategory::setFilterRules(QString::fromUtf8("Qt3D.*.debug=false\n")); - qCDebug(Aspects) << Q_FUNC_INFO; Q_D(QAspectEngine); d->m_scene = new QScene(this); @@ -218,6 +217,8 @@ QAspectEngine::~QAspectEngine() void QAspectEnginePrivate::initNodeTree(QNode *node) { + // Set the root entity on the scene + m_scene->setRootNode(node); QNodeVisitor visitor; visitor.traverse(node, this, &QAspectEnginePrivate::initNode, &QAspectEnginePrivate::initEntity); } diff --git a/src/core/aspects/qaspectengine.h b/src/core/aspects/qaspectengine.h index 6de5df42c..28b15046b 100644 --- a/src/core/aspects/qaspectengine.h +++ b/src/core/aspects/qaspectengine.h @@ -40,10 +40,9 @@ #ifndef QT3DCORE_QASPECTENGINE_H #define QT3DCORE_QASPECTENGINE_H -#include <QObject> -#include <QVector> - #include <Qt3DCore/qt3dcore_global.h> +#include <QtCore/QObject> +#include <QtCore/QVector> QT_BEGIN_NAMESPACE diff --git a/src/core/aspects/qaspectengine_p.h b/src/core/aspects/qaspectengine_p.h index 10b3536df..a7311d054 100644 --- a/src/core/aspects/qaspectengine_p.h +++ b/src/core/aspects/qaspectengine_p.h @@ -51,11 +51,13 @@ // We mean it. // -#include <private/qobject_p.h> +#include <Qt3DCore/qt3dcore-config.h> #include <Qt3DCore/qnodecreatedchange.h> -#include <Qt3DCore/private/qaspectfactory_p.h> #include <QtCore/qsharedpointer.h> +#include <Qt3DCore/private/qaspectfactory_p.h> +#include <QtCore/private/qobject_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/aspects/qaspectfactory.cpp b/src/core/aspects/qaspectfactory.cpp index 3135e1653..94e04b34d 100644 --- a/src/core/aspects/qaspectfactory.cpp +++ b/src/core/aspects/qaspectfactory.cpp @@ -39,11 +39,9 @@ #include "qaspectfactory_p.h" -#include <QtGlobal> - -#include <QDebug> - #include <Qt3DCore/QAbstractAspect> +#include <QtCore/QDebug> +#include <QtCore/QtGlobal> QT_BEGIN_NAMESPACE diff --git a/src/core/aspects/qaspectfactory_p.h b/src/core/aspects/qaspectfactory_p.h index 9e2bedaaa..67b5e0b9d 100644 --- a/src/core/aspects/qaspectfactory_p.h +++ b/src/core/aspects/qaspectfactory_p.h @@ -51,8 +51,8 @@ // We mean it. // -#include <QHash> -#include <QStringList> +#include <QtCore/QHash> +#include <QtCore/QStringList> #include <Qt3DCore/private/qt3dcore_global_p.h> diff --git a/src/core/aspects/qaspectmanager.cpp b/src/core/aspects/qaspectmanager.cpp index 98fb982df..5ccc89b9e 100644 --- a/src/core/aspects/qaspectmanager.cpp +++ b/src/core/aspects/qaspectmanager.cpp @@ -38,27 +38,27 @@ ****************************************************************************/ #include "qaspectmanager_p.h" -#include "qabstractaspect.h" -#include "qabstractaspect_p.h" -#include "qchangearbiter_p.h" -// TODO Make the kind of job manager configurable (e.g. ThreadWeaver vs Intel TBB) -#include "qaspectjobmanager_p.h" -#include "qabstractaspectjobmanager_p.h" -#include "qentity.h" -#include <Qt3DCore/private/qservicelocator_p.h> +#include <Qt3DCore/qabstractaspect.h> +#include <Qt3DCore/qentity.h> +#include <QtCore/QEventLoop> +#include <QtCore/QThread> +#include <QtCore/QWaitCondition> +#include <QtGui/QSurface> -#include <Qt3DCore/private/qaspectjob_p.h> -#include <Qt3DCore/private/qthreadpooler_p.h> -#include <Qt3DCore/private/qtickclockservice_p.h> #include <Qt3DCore/private/corelogging_p.h> +#include <Qt3DCore/private/qabstractaspect_p.h> +#include <Qt3DCore/private/qabstractaspectjobmanager_p.h> +#include <Qt3DCore/private/qabstractframeadvanceservice_p.h> +// TODO Make the kind of job manager configurable (e.g. ThreadWeaver vs Intel TBB) +#include <Qt3DCore/private/qaspectjobmanager_p.h> +#include <Qt3DCore/private/qaspectjob_p.h> +#include <Qt3DCore/private/qchangearbiter_p.h> #include <Qt3DCore/private/qscheduler_p.h> +#include <Qt3DCore/private/qservicelocator_p.h> +#include <Qt3DCore/private/qthreadpooler_p.h> #include <Qt3DCore/private/qtickclock_p.h> -#include <Qt3DCore/private/qabstractframeadvanceservice_p.h> -#include <QEventLoop> -#include <QThread> -#include <QWaitCondition> -#include <QSurface> +#include <Qt3DCore/private/qtickclockservice_p.h> #if defined(QT3D_CORE_JOB_TIMING) #include <QElapsedTimer> diff --git a/src/core/aspects/qaspectmanager_p.h b/src/core/aspects/qaspectmanager_p.h index e4795516c..1c87738ed 100644 --- a/src/core/aspects/qaspectmanager_p.h +++ b/src/core/aspects/qaspectmanager_p.h @@ -51,13 +51,14 @@ // We mean it. // -#include <QObject> #include <Qt3DCore/qnodecreatedchange.h> +#include <QtCore/QObject> +#include <QtCore/QScopedPointer> +#include <QtCore/QSemaphore> +#include <QtCore/QVariant> +#include <QtCore/QVector> + #include <Qt3DCore/private/qt3dcore_global_p.h> -#include <QVector> -#include <QScopedPointer> -#include <QVariant> -#include <QSemaphore> QT_BEGIN_NAMESPACE diff --git a/src/core/aspects/qaspectthread.cpp b/src/core/aspects/qaspectthread.cpp index 9e6961901..31715b04e 100644 --- a/src/core/aspects/qaspectthread.cpp +++ b/src/core/aspects/qaspectthread.cpp @@ -38,10 +38,11 @@ ****************************************************************************/ #include "qaspectthread_p.h" -#include "qaspectmanager_p.h" +#include <QtCore/QMutexLocker> + +#include <Qt3DCore/private/qaspectmanager_p.h> #include <Qt3DCore/private/corelogging_p.h> -#include <QMutexLocker> QT_BEGIN_NAMESPACE diff --git a/src/core/aspects/qaspectthread_p.h b/src/core/aspects/qaspectthread_p.h index dc508b271..91fb363c5 100644 --- a/src/core/aspects/qaspectthread_p.h +++ b/src/core/aspects/qaspectthread_p.h @@ -51,10 +51,10 @@ // We mean it. // -#include <QThread> #include <Qt3DCore/qt3dcore_global.h> - #include <QtCore/QSemaphore> +#include <QtCore/QThread> + QT_BEGIN_NAMESPACE diff --git a/src/core/changes/changes.pri b/src/core/changes/changes.pri index 49d560a56..11d66a83e 100644 --- a/src/core/changes/changes.pri +++ b/src/core/changes/changes.pri @@ -35,7 +35,9 @@ HEADERS += \ $$PWD/qpropertyvalueaddedchange.h \ $$PWD/qpropertyvalueaddedchange_p.h \ $$PWD/qpropertyvalueremovedchange.h \ - $$PWD/qpropertyvalueremovedchange_p.h + $$PWD/qpropertyvalueremovedchange_p.h \ + $$PWD/qnodecommand.h \ + $$PWD/qnodecommand_p.h SOURCES += \ $$PWD/qscenechange.cpp \ @@ -54,4 +56,5 @@ SOURCES += \ $$PWD/qpropertynodeaddedchange.cpp \ $$PWD/qpropertynoderemovedchange.cpp \ $$PWD/qpropertyvalueaddedchange.cpp \ - $$PWD/qpropertyvalueremovedchange.cpp + $$PWD/qpropertyvalueremovedchange.cpp \ + $$PWD/qnodecommand.cpp diff --git a/src/core/changes/qcomponentaddedchange.cpp b/src/core/changes/qcomponentaddedchange.cpp index 985567849..e00c4ffab 100644 --- a/src/core/changes/qcomponentaddedchange.cpp +++ b/src/core/changes/qcomponentaddedchange.cpp @@ -39,9 +39,11 @@ #include "qcomponentaddedchange.h" #include "qcomponentaddedchange_p.h" + #include <Qt3DCore/qcomponent.h> #include <Qt3DCore/qentity.h> -#include <private/qnode_p.h> + +#include <Qt3DCore/private/qnode_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qcomponentaddedchange_p.h b/src/core/changes/qcomponentaddedchange_p.h index 99550c92f..5eb453363 100644 --- a/src/core/changes/qcomponentaddedchange_p.h +++ b/src/core/changes/qcomponentaddedchange_p.h @@ -51,10 +51,11 @@ // We mean it. // -#include <Qt3DCore/private/qt3dcore_global_p.h> -#include <private/qscenechange_p.h> #include <Qt3DCore/qnodeid.h> +#include <Qt3DCore/private/qscenechange_p.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> + struct QMetaObject; QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qcomponentremovedchange.cpp b/src/core/changes/qcomponentremovedchange.cpp index 30863cd89..5e5dfa5aa 100644 --- a/src/core/changes/qcomponentremovedchange.cpp +++ b/src/core/changes/qcomponentremovedchange.cpp @@ -39,9 +39,11 @@ #include "qcomponentremovedchange.h" #include "qcomponentremovedchange_p.h" + #include <Qt3DCore/qcomponent.h> #include <Qt3DCore/qentity.h> -#include <private/qnode_p.h> + +#include <Qt3DCore/private/qnode_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qcomponentremovedchange_p.h b/src/core/changes/qcomponentremovedchange_p.h index ff5c71f84..5284c7bbd 100644 --- a/src/core/changes/qcomponentremovedchange_p.h +++ b/src/core/changes/qcomponentremovedchange_p.h @@ -51,10 +51,11 @@ // We mean it. // -#include <Qt3DCore/private/qt3dcore_global_p.h> -#include <private/qscenechange_p.h> #include <Qt3DCore/qnodeid.h> +#include <Qt3DCore/private/qscenechange_p.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> + struct QMetaObject; QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qdynamicpropertyupdatedchange_p.h b/src/core/changes/qdynamicpropertyupdatedchange_p.h index 729ae44d0..c71c2a71a 100644 --- a/src/core/changes/qdynamicpropertyupdatedchange_p.h +++ b/src/core/changes/qdynamicpropertyupdatedchange_p.h @@ -51,10 +51,11 @@ // We mean it. // -#include <private/qpropertyupdatedchangebase_p.h> #include <QtCore/qbytearray.h> #include <QtCore/qvariant.h> +#include <Qt3DCore/private/qpropertyupdatedchangebase_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/changes/qnodecommand.cpp b/src/core/changes/qnodecommand.cpp new file mode 100644 index 000000000..fc7e01697 --- /dev/null +++ b/src/core/changes/qnodecommand.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnodecommand.h" +#include "qnodecommand_p.h" +#include <Qt3DCore/qnode.h> +#include <Qt3DCore/private/qnode_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +QNodeCommandPrivate::QNodeCommandPrivate() + : QSceneChangePrivate() + , m_commandId(createId()) + , m_replyToCommandId() +{ +} + +QNodeCommand::CommandId QNodeCommandPrivate::createId() +{ + static QBasicAtomicInteger<QNodeCommand::CommandId> next = Q_BASIC_ATOMIC_INITIALIZER(0); + return next.fetchAndAddRelaxed(1) + 1; +} + +/*! + * \class Qt3DCore::QNodeCommand + * \inheaderfile Qt3DCore/QNodeCommand + * \inherits Qt3DCore::QSceneChange + * \inmodule Qt3DCore + * \since 5.9 + * \brief The QNodeCommand class is the base class for all CommandRequested QSceneChange events + * + * The QNodeCommand class is the base class for all QSceneChange events that + * have the changeType() CommandRequested. + * + * You can subclass this to create your own node update types for communication between + * your QNode and QBackendNode subclasses when writing your own aspects. + */ + +/*! + * \typedef Qt3DCore::QNodeCommandPtr + * \relates Qt3DCore::QNodeCommand + * + * A shared pointer for QNodeCommand. + */ + +/*! + * Constructs a new QNodeCommand with \a node. + */ +QNodeCommand::QNodeCommand(QNodeId id) + : QSceneChange(*new QNodeCommandPrivate(), CommandRequested, id) +{ +} + +QNodeCommand::QNodeCommand(QNodeCommandPrivate &dd, QNodeId id) + : QSceneChange(dd, CommandRequested, id) +{ +} + +QNodeCommand::~QNodeCommand() +{ +} + +/*! + * \return commandId. + */ +QNodeCommand::CommandId QNodeCommand::commandId() const +{ + Q_D(const QNodeCommand); + return d->m_commandId; +} + +/*! + * \return name. + */ +QString QNodeCommand::name() const +{ + Q_D(const QNodeCommand); + return d->m_name; +} + +void QNodeCommand::setName(const QString &name) +{ + Q_D(QNodeCommand); + d->m_name = name; +} + +/*! + * \return data. + */ +QVariant QNodeCommand::data() const +{ + Q_D(const QNodeCommand); + return d->m_data; +} + +void QNodeCommand::setData(const QVariant &data) +{ + Q_D(QNodeCommand); + d->m_data = data; +} + +QNodeCommand::CommandId QNodeCommand::inReplyTo() const +{ + Q_D(const QNodeCommand); + return d->m_replyToCommandId; +} + +void QNodeCommand::setReplyToCommandId(QNodeCommand::CommandId id) +{ + Q_D(QNodeCommand); + d->m_replyToCommandId = id; +} + +} // namespace Qt3DCore + +QT_END_NAMESPACE diff --git a/src/core/changes/qnodecommand.h b/src/core/changes/qnodecommand.h new file mode 100644 index 000000000..c02365a59 --- /dev/null +++ b/src/core/changes/qnodecommand.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QNODECOMMAND_H +#define QT3DCORE_QNODECOMMAND_H + +#include <Qt3DCore/qt3dcore_global.h> +#include <Qt3DCore/qscenechange.h> + +#include <QtCore/qsharedpointer.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class QNodeCommandPrivate; + +class QT3DCORESHARED_EXPORT QNodeCommand : public QSceneChange +{ +public: +#if defined(Q_ATOMIC_INT64_IS_SUPPORTED) + typedef quint64 CommandId; +#else + typedef quint32 CommandId; +#endif + + explicit QNodeCommand(QNodeId id); + ~QNodeCommand(); + + CommandId commandId() const; + + QString name() const; + void setName(const QString &name); + QVariant data() const; + void setData(const QVariant &data); + CommandId inReplyTo() const; + void setReplyToCommandId(CommandId id); + +protected: + QNodeCommand(QNodeCommandPrivate &dd, QNodeId id); + +private: + Q_DECLARE_PRIVATE(QNodeCommand) +}; + +typedef QSharedPointer<QNodeCommand> QNodeCommandPtr; + +} // namespace Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QNODECOMMAND_H diff --git a/src/core/changes/qnodecommand_p.h b/src/core/changes/qnodecommand_p.h new file mode 100644 index 000000000..09be873f5 --- /dev/null +++ b/src/core/changes/qnodecommand_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DCORE_QNODECOMMAND_P_H +#define QT3DCORE_QNODECOMMAND_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/qt3dcore_global_p.h> +#include <private/qscenechange_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class QT3DCORE_PRIVATE_EXPORT QNodeCommandPrivate : public QSceneChangePrivate +{ +public: + QNodeCommandPrivate(); + + static QNodeCommand::CommandId createId(); + + QNodeCommand::CommandId m_commandId; + QNodeCommand::CommandId m_replyToCommandId; + QString m_name; + QVariant m_data; +}; + +} // namespace Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QNODECOMMAND_P_H diff --git a/src/core/changes/qnodecreatedchange.cpp b/src/core/changes/qnodecreatedchange.cpp index a77721cdc..34ca939d7 100644 --- a/src/core/changes/qnodecreatedchange.cpp +++ b/src/core/changes/qnodecreatedchange.cpp @@ -36,7 +36,9 @@ #include "qnodecreatedchange.h" #include "qnodecreatedchange_p.h" + #include <Qt3DCore/qnode.h> + #include <Qt3DCore/private/qnode_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qnodecreatedchange.h b/src/core/changes/qnodecreatedchange.h index 4b5e70b82..85444e00c 100644 --- a/src/core/changes/qnodecreatedchange.h +++ b/src/core/changes/qnodecreatedchange.h @@ -37,9 +37,8 @@ #ifndef QT3DCORE_QNODECREATEDCHANGE_H #define QT3DCORE_QNODECREATEDCHANGE_H -#include <Qt3DCore/qt3dcore_global.h> #include <Qt3DCore/qscenechange.h> - +#include <Qt3DCore/qt3dcore_global.h> #include <QtCore/qsharedpointer.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qnodecreatedchange_p.h b/src/core/changes/qnodecreatedchange_p.h index 75969e461..cb1470970 100644 --- a/src/core/changes/qnodecreatedchange_p.h +++ b/src/core/changes/qnodecreatedchange_p.h @@ -48,10 +48,11 @@ // We mean it. // -#include <Qt3DCore/private/qt3dcore_global_p.h> -#include <private/qscenechange_p.h> #include <Qt3DCore/qnodeid.h> +#include <Qt3DCore/private/qscenechange_p.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> + struct QMetaObject; QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qnodedestroyedchange.h b/src/core/changes/qnodedestroyedchange.h index 348fda23f..11a54f8e2 100644 --- a/src/core/changes/qnodedestroyedchange.h +++ b/src/core/changes/qnodedestroyedchange.h @@ -37,8 +37,8 @@ #ifndef QT3DCORE_QNODEDESTROYEDCHANGE_H #define QT3DCORE_QNODEDESTROYEDCHANGE_H -#include <Qt3DCore/qscenechange.h> #include <Qt3DCore/qnode.h> +#include <Qt3DCore/qscenechange.h> #include <QtCore/qsharedpointer.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qnodedestroyedchange_p.h b/src/core/changes/qnodedestroyedchange_p.h index 999976431..081ca858f 100644 --- a/src/core/changes/qnodedestroyedchange_p.h +++ b/src/core/changes/qnodedestroyedchange_p.h @@ -48,9 +48,10 @@ // We mean it. // -#include <private/qscenechange_p.h> #include <Qt3DCore/qnode.h> +#include <Qt3DCore/private/qscenechange_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/changes/qpropertynodeaddedchange.cpp b/src/core/changes/qpropertynodeaddedchange.cpp index 66b5c70d3..390a170b6 100644 --- a/src/core/changes/qpropertynodeaddedchange.cpp +++ b/src/core/changes/qpropertynodeaddedchange.cpp @@ -39,6 +39,7 @@ #include "qpropertynodeaddedchange.h" #include "qpropertynodeaddedchange_p.h" + #include <Qt3DCore/private/qnode_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qpropertynodeaddedchange_p.h b/src/core/changes/qpropertynodeaddedchange_p.h index 01340ae8c..2930867ea 100644 --- a/src/core/changes/qpropertynodeaddedchange_p.h +++ b/src/core/changes/qpropertynodeaddedchange_p.h @@ -51,9 +51,10 @@ // We mean it. // -#include <private/qstaticpropertyvalueaddedchangebase_p.h> #include <Qt3DCore/qnode.h> +#include <Qt3DCore/private/qstaticpropertyvalueaddedchangebase_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/changes/qpropertynoderemovedchange.cpp b/src/core/changes/qpropertynoderemovedchange.cpp index a7b4e95f3..a0f342d0b 100644 --- a/src/core/changes/qpropertynoderemovedchange.cpp +++ b/src/core/changes/qpropertynoderemovedchange.cpp @@ -39,6 +39,7 @@ #include "qpropertynoderemovedchange.h" #include "qpropertynoderemovedchange_p.h" + #include <Qt3DCore/private/qnode_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qpropertynoderemovedchange_p.h b/src/core/changes/qpropertynoderemovedchange_p.h index 6cd23661b..0145cc507 100644 --- a/src/core/changes/qpropertynoderemovedchange_p.h +++ b/src/core/changes/qpropertynoderemovedchange_p.h @@ -51,9 +51,10 @@ // We mean it. // -#include <private/qstaticpropertyvalueremovedchangebase_p.h> #include <Qt3DCore/qnode.h> +#include <Qt3DCore/private/qstaticpropertyvalueremovedchangebase_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/changes/qpropertyupdatedchange_p.h b/src/core/changes/qpropertyupdatedchange_p.h index f985120c9..ad908a8c4 100644 --- a/src/core/changes/qpropertyupdatedchange_p.h +++ b/src/core/changes/qpropertyupdatedchange_p.h @@ -51,8 +51,9 @@ // We mean it. // -#include <private/qstaticpropertyupdatedchangebase_p.h> -#include <QVariant> +#include <QtCore/QVariant> + +#include <Qt3DCore/private/qstaticpropertyupdatedchangebase_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qpropertyupdatedchangebase.cpp b/src/core/changes/qpropertyupdatedchangebase.cpp index d33c737e5..5d79b9049 100644 --- a/src/core/changes/qpropertyupdatedchangebase.cpp +++ b/src/core/changes/qpropertyupdatedchangebase.cpp @@ -46,7 +46,7 @@ namespace Qt3DCore { QPropertyUpdatedChangeBasePrivate::QPropertyUpdatedChangeBasePrivate() : QSceneChangePrivate() - , m_isFinal(false) + , m_isIntermediate(false) { } diff --git a/src/core/changes/qpropertyupdatedchangebase_p.h b/src/core/changes/qpropertyupdatedchangebase_p.h index 3c32b2237..7c66812a1 100644 --- a/src/core/changes/qpropertyupdatedchangebase_p.h +++ b/src/core/changes/qpropertyupdatedchangebase_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <private/qscenechange_p.h> +#include <Qt3DCore/private/qscenechange_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE @@ -69,7 +69,12 @@ public: static QPropertyUpdatedChangeBasePrivate *get(QPropertyUpdatedChangeBase *q); Q_DECLARE_PUBLIC(QPropertyUpdatedChangeBase) - bool m_isFinal; + + // Frontend nodes should not receive intermediate animated property + // updated by default. Only if they subscribe. The animation aspect + // will set this to true for animating properties apart from the final + // frame's update. + bool m_isIntermediate; }; } // namespace Qt3DCore diff --git a/src/core/changes/qpropertyvalueaddedchange_p.h b/src/core/changes/qpropertyvalueaddedchange_p.h index 538a591a1..edd59489f 100644 --- a/src/core/changes/qpropertyvalueaddedchange_p.h +++ b/src/core/changes/qpropertyvalueaddedchange_p.h @@ -51,10 +51,11 @@ // We mean it. // -#include <private/qstaticpropertyvalueaddedchangebase_p.h> -#include <Qt3DCore/private/qt3dcore_global_p.h> #include <QtCore/qvariant.h> +#include <Qt3DCore/private/qstaticpropertyvalueaddedchangebase_p.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/changes/qpropertyvalueaddedchangebase.cpp b/src/core/changes/qpropertyvalueaddedchangebase.cpp index 26dcd5555..3c9929496 100644 --- a/src/core/changes/qpropertyvalueaddedchangebase.cpp +++ b/src/core/changes/qpropertyvalueaddedchangebase.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qpropertyvalueaddedchangebase.h" + #include "qpropertyvalueaddedchangebase_p.h" QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qpropertyvalueaddedchangebase_p.h b/src/core/changes/qpropertyvalueaddedchangebase_p.h index 405b2ad3f..be92e2d5b 100644 --- a/src/core/changes/qpropertyvalueaddedchangebase_p.h +++ b/src/core/changes/qpropertyvalueaddedchangebase_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <private/qscenechange_p.h> +#include <Qt3DCore/private/qscenechange_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qpropertyvalueremovedchange.cpp b/src/core/changes/qpropertyvalueremovedchange.cpp index 6e8a1f817..9d420abc0 100644 --- a/src/core/changes/qpropertyvalueremovedchange.cpp +++ b/src/core/changes/qpropertyvalueremovedchange.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qpropertyvalueremovedchange.h" + #include "qpropertyvalueremovedchange_p.h" QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qpropertyvalueremovedchange_p.h b/src/core/changes/qpropertyvalueremovedchange_p.h index 82644b76c..b4e86bc9e 100644 --- a/src/core/changes/qpropertyvalueremovedchange_p.h +++ b/src/core/changes/qpropertyvalueremovedchange_p.h @@ -51,10 +51,11 @@ // We mean it. // -#include <private/qstaticpropertyvalueremovedchangebase_p.h> -#include <Qt3DCore/private/qt3dcore_global_p.h> #include <QtCore/qvariant.h> +#include <Qt3DCore/private/qstaticpropertyvalueremovedchangebase_p.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/changes/qpropertyvalueremovedchangebase.cpp b/src/core/changes/qpropertyvalueremovedchangebase.cpp index 8115d6e22..71213019c 100644 --- a/src/core/changes/qpropertyvalueremovedchangebase.cpp +++ b/src/core/changes/qpropertyvalueremovedchangebase.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qpropertyvalueremovedchangebase.h" + #include "qpropertyvalueremovedchangebase_p.h" QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qpropertyvalueremovedchangebase_p.h b/src/core/changes/qpropertyvalueremovedchangebase_p.h index e4c4be640..f9c1b4009 100644 --- a/src/core/changes/qpropertyvalueremovedchangebase_p.h +++ b/src/core/changes/qpropertyvalueremovedchangebase_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <private/qscenechange_p.h> +#include <Qt3DCore/private/qscenechange_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qscenechange.cpp b/src/core/changes/qscenechange.cpp index 959518904..df15e239d 100644 --- a/src/core/changes/qscenechange.cpp +++ b/src/core/changes/qscenechange.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qscenechange.h" + #include "qscenechange_p.h" QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qscenechange.h b/src/core/changes/qscenechange.h index 4555983e2..854bab051 100644 --- a/src/core/changes/qscenechange.h +++ b/src/core/changes/qscenechange.h @@ -40,9 +40,9 @@ #ifndef QT3DCORE_QSCENECHANGE_H #define QT3DCORE_QSCENECHANGE_H -#include <Qt3DCore/qt3dcore_global.h> -#include <QSharedPointer> #include <Qt3DCore/qnodeid.h> +#include <Qt3DCore/qt3dcore_global.h> +#include <QtCore/QSharedPointer> QT_BEGIN_NAMESPACE @@ -56,6 +56,7 @@ enum ChangeFlag { PropertyValueRemoved = 1 << 4, ComponentAdded = 1 << 5, ComponentRemoved = 1 << 6, + CommandRequested = 1 << 7, AllChanges = 0xFFFFFFFF }; Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) diff --git a/src/core/changes/qscenechange_p.h b/src/core/changes/qscenechange_p.h index 80ce4eaa5..cd0194b01 100644 --- a/src/core/changes/qscenechange_p.h +++ b/src/core/changes/qscenechange_p.h @@ -51,9 +51,10 @@ // We mean it. // -#include <QtGlobal> -#include <Qt3DCore/private/qt3dcore_global_p.h> #include <Qt3DCore/qscenechange.h> +#include <QtCore/QtGlobal> + +#include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qstaticpropertyupdatedchangebase.cpp b/src/core/changes/qstaticpropertyupdatedchangebase.cpp index 409d80add..d065dbf0b 100644 --- a/src/core/changes/qstaticpropertyupdatedchangebase.cpp +++ b/src/core/changes/qstaticpropertyupdatedchangebase.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qstaticpropertyupdatedchangebase.h" + #include "qstaticpropertyupdatedchangebase_p.h" QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qstaticpropertyupdatedchangebase_p.h b/src/core/changes/qstaticpropertyupdatedchangebase_p.h index c81df4076..3f76e2f56 100644 --- a/src/core/changes/qstaticpropertyupdatedchangebase_p.h +++ b/src/core/changes/qstaticpropertyupdatedchangebase_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <private/qpropertyupdatedchangebase_p.h> +#include <Qt3DCore/private/qpropertyupdatedchangebase_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qstaticpropertyvalueaddedchangebase.cpp b/src/core/changes/qstaticpropertyvalueaddedchangebase.cpp index 4fb658459..efd2c0165 100644 --- a/src/core/changes/qstaticpropertyvalueaddedchangebase.cpp +++ b/src/core/changes/qstaticpropertyvalueaddedchangebase.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qstaticpropertyvalueaddedchangebase.h" + #include "qstaticpropertyvalueaddedchangebase_p.h" QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qstaticpropertyvalueaddedchangebase_p.h b/src/core/changes/qstaticpropertyvalueaddedchangebase_p.h index 7a614c0d1..cd995d739 100644 --- a/src/core/changes/qstaticpropertyvalueaddedchangebase_p.h +++ b/src/core/changes/qstaticpropertyvalueaddedchangebase_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <private/qpropertyvalueaddedchangebase_p.h> +#include <Qt3DCore/private/qpropertyvalueaddedchangebase_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/changes/qstaticpropertyvalueremovedchangebase_p.h b/src/core/changes/qstaticpropertyvalueremovedchangebase_p.h index 47f43f745..ac4e1d875 100644 --- a/src/core/changes/qstaticpropertyvalueremovedchangebase_p.h +++ b/src/core/changes/qstaticpropertyvalueremovedchangebase_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <private/qpropertyvalueremovedchangebase_p.h> +#include <Qt3DCore/private/qpropertyvalueremovedchangebase_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/configure.json b/src/core/configure.json index ed44bfaeb..47a726d82 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -4,7 +4,9 @@ "commandline": { "options": { - "assimp": { "type": "enum", "values": [ "qt", "system" ] } + "assimp": { "type": "enum", "values": [ "qt", "system", "no" ] }, + "qt3d-profile-jobs": "boolean", + "qt3d-profile-gl": "boolean" } }, @@ -13,7 +15,7 @@ "label": "Assimp", "test": "assimp", "sources": [ - { "type": "pkgConfig", "args": "assimp" }, + { "type": "pkgConfig", "args": "assimp > 3.3.1" }, "-lassimp" ] } @@ -30,6 +32,22 @@ "disable": "input.assimp == 'qt'", "condition": "features.assimp && libs.assimp", "output": [ "privateFeature" ] + }, + "qt3d-profile-jobs": { + "label": "Output Qt3D Job traces", + "autoDetect": false, + "output": [ + "privateFeature", + { "type": "define", "name": "QT3D_JOBS_RUN_STATS", "value": 1 } + ] + }, + "qt3d-profile-gl": { + "label": "Output Qt3D GL traces", + "autoDetect": false, + "output": [ + "privateFeature", + { "type": "define", "name": "QT3D_OPENGL_RUN_STATS", "value": 1 } + ] } }, @@ -41,7 +59,9 @@ "section": "Qt 3D", "entries": [ "assimp", - "system-assimp" + "system-assimp", + "qt3d-profile-jobs", + "qt3d-profile-gl" ] } ] diff --git a/src/core/corelogging.cpp b/src/core/corelogging.cpp index 4ad8c5f0e..6bd7bfcb7 100644 --- a/src/core/corelogging.cpp +++ b/src/core/corelogging.cpp @@ -43,10 +43,10 @@ QT_BEGIN_NAMESPACE namespace Qt3DCore { -Q_LOGGING_CATEGORY(Nodes, "Qt3D.Core.Nodes") -Q_LOGGING_CATEGORY(Aspects, "Qt3D.Core.Aspects") -Q_LOGGING_CATEGORY(Resources, "Qt3D.Core.Resources") -Q_LOGGING_CATEGORY(ChangeArbiter, "Qt3D.Core.ChangeArbiter") +Q_LOGGING_CATEGORY(Nodes, "Qt3D.Core.Nodes", QtWarningMsg); +Q_LOGGING_CATEGORY(Aspects, "Qt3D.Core.Aspects", QtWarningMsg); +Q_LOGGING_CATEGORY(Resources, "Qt3D.Core.Resources", QtWarningMsg); +Q_LOGGING_CATEGORY(ChangeArbiter, "Qt3D.Core.ChangeArbiter", QtWarningMsg); } // Qt3D diff --git a/src/core/corelogging_p.h b/src/core/corelogging_p.h index 7fc3fff55..5ddd6ea73 100644 --- a/src/core/corelogging_p.h +++ b/src/core/corelogging_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QLoggingCategory> +#include <QtCore/QLoggingCategory> QT_BEGIN_NAMESPACE diff --git a/src/core/jobs/dependencyhandler.cpp b/src/core/jobs/dependencyhandler.cpp index dcea66a62..6a925d037 100644 --- a/src/core/jobs/dependencyhandler.cpp +++ b/src/core/jobs/dependencyhandler.cpp @@ -37,10 +37,10 @@ ** ****************************************************************************/ -#include <iterator> - #include "dependencyhandler_p.h" +#include <iterator> + QT_BEGIN_NAMESPACE namespace Qt3DCore { @@ -104,6 +104,7 @@ namespace { } DependencyHandler::DependencyHandler() + : m_mutex() { } diff --git a/src/core/jobs/dependencyhandler_p.h b/src/core/jobs/dependencyhandler_p.h index abaa8e55f..a5a023139 100644 --- a/src/core/jobs/dependencyhandler_p.h +++ b/src/core/jobs/dependencyhandler_p.h @@ -51,18 +51,21 @@ // We mean it. // -#include "task_p.h" - #include <QtCore/QMutex> #include <QtCore/QVector> +#include <Qt3DCore/private/task_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { struct Dependency { - Dependency() {} + Dependency() + : depender(nullptr) + , dependee(nullptr) + {} Dependency(RunnableInterface *depender, RunnableInterface *dependee) : depender(qMove(depender)), dependee(qMove(dependee)) {} diff --git a/src/core/jobs/qabstractaspectjobmanager_p.h b/src/core/jobs/qabstractaspectjobmanager_p.h index 32e6e499e..5c4e9f699 100644 --- a/src/core/jobs/qabstractaspectjobmanager_p.h +++ b/src/core/jobs/qabstractaspectjobmanager_p.h @@ -51,9 +51,8 @@ // We mean it. // -#include <QObject> - #include <Qt3DCore/qaspectjob.h> +#include <QtCore/QObject> QT_BEGIN_NAMESPACE diff --git a/src/core/jobs/qaspectjob.cpp b/src/core/jobs/qaspectjob.cpp index 59f48e9bf..6016bd273 100644 --- a/src/core/jobs/qaspectjob.cpp +++ b/src/core/jobs/qaspectjob.cpp @@ -39,7 +39,8 @@ #include "qaspectjob.h" #include "qaspectjob_p.h" -#include <QByteArray> + +#include <QtCore/QByteArray> QT_BEGIN_NAMESPACE diff --git a/src/core/jobs/qaspectjob.h b/src/core/jobs/qaspectjob.h index b2e5e587c..398cd88d1 100644 --- a/src/core/jobs/qaspectjob.h +++ b/src/core/jobs/qaspectjob.h @@ -41,8 +41,8 @@ #define QT3DCORE_QASPECTJOB_H #include <Qt3DCore/qt3dcore_global.h> -#include <QSharedPointer> -#include <QVector> +#include <QtCore/QSharedPointer> +#include <QtCore/QVector> QT_BEGIN_NAMESPACE diff --git a/src/core/jobs/qaspectjob_p.h b/src/core/jobs/qaspectjob_p.h index c54240a4e..6786ccef7 100644 --- a/src/core/jobs/qaspectjob_p.h +++ b/src/core/jobs/qaspectjob_p.h @@ -51,8 +51,10 @@ // We mean it. // -#include <QWeakPointer> +#include <QtCore/QWeakPointer> + #include <Qt3DCore/private/qt3dcore_global_p.h> +#include <Qt3DCore/qt3dcore-config.h> QT_BEGIN_NAMESPACE diff --git a/src/core/jobs/qaspectjobmanager.cpp b/src/core/jobs/qaspectjobmanager.cpp index f2a71412d..468d904b4 100644 --- a/src/core/jobs/qaspectjobmanager.cpp +++ b/src/core/jobs/qaspectjobmanager.cpp @@ -38,16 +38,17 @@ ****************************************************************************/ #include "qaspectjobmanager_p.h" -#include "task_p.h" -#include "qthreadpooler_p.h" -#include "dependencyhandler_p.h" - -#include <QAtomicInt> -#include <QDebug> -#include <QThread> -#include <QCoreApplication> + +#include <QtCore/QAtomicInt> +#include <QtCore/QCoreApplication> +#include <QtCore/QDebug> +#include <QtCore/QThread> #include <QtCore/QFuture> +#include <Qt3DCore/private/dependencyhandler_p.h> +#include <Qt3DCore/private/qthreadpooler_p.h> +#include <Qt3DCore/private/task_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/jobs/qaspectjobmanager_p.h b/src/core/jobs/qaspectjobmanager_p.h index 5b7f27ad6..6fbf03d22 100644 --- a/src/core/jobs/qaspectjobmanager_p.h +++ b/src/core/jobs/qaspectjobmanager_p.h @@ -51,12 +51,11 @@ // We mean it. // -#include <private/qabstractaspectjobmanager_p.h> -#include <Qt3DCore/private/qt3dcore_global_p.h> - #include <Qt3DCore/qaspectjob.h> +#include <QtCore/QVector> -#include <QVector> +#include <Qt3DCore/private/qabstractaspectjobmanager_p.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/jobs/qaspectjobproviderinterface_p.h b/src/core/jobs/qaspectjobproviderinterface_p.h index 1e2166ace..29b44b3c1 100644 --- a/src/core/jobs/qaspectjobproviderinterface_p.h +++ b/src/core/jobs/qaspectjobproviderinterface_p.h @@ -51,10 +51,10 @@ // We mean it. // -#include <Qt3DCore/private/qt3dcore_global_p.h> #include <Qt3DCore/qaspectjob.h> +#include <QtCore/QVector> -#include <QVector> +#include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/jobs/qthreadpooler.cpp b/src/core/jobs/qthreadpooler.cpp index 35e2df2a1..8ad6f7f0a 100644 --- a/src/core/jobs/qthreadpooler.cpp +++ b/src/core/jobs/qthreadpooler.cpp @@ -38,16 +38,17 @@ ****************************************************************************/ #include "qthreadpooler_p.h" -#include "dependencyhandler_p.h" - -#include <QDebug> +#include <Qt3DCore/qt3dcore-config.h> +#include <QtCore/QDebug> #ifdef QT3D_JOBS_RUN_STATS -#include <QFile> -#include <QThreadStorage> -#include <QDateTime> +#include <QtCore/QFile> +#include <QtCore/QThreadStorage> +#include <QtCore/QDateTime> #endif +#include <Qt3DCore/private/dependencyhandler_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { @@ -57,10 +58,11 @@ QElapsedTimer QThreadPooler::m_jobsStatTimer; #endif QThreadPooler::QThreadPooler(QObject *parent) - : QObject(parent), - m_futureInterface(nullptr), - m_mutex(), - m_taskCount(0) + : QObject(parent) + , m_futureInterface(nullptr) + , m_mutex() + , m_dependencyHandler(nullptr) + , m_taskCount(0) { // Ensures that threads will never be recycled m_threadPool.setExpiryTimeout(-1); @@ -196,7 +198,12 @@ void QThreadPooler::writeFrameJobLogStats() static QScopedPointer<QFile> traceFile; static quint32 frameId = 0; if (!traceFile) { - traceFile.reset(new QFile(QStringLiteral("trace_") + QDateTime::currentDateTime().toString() + QStringLiteral(".qt3d"))); + const QString fileName = QStringLiteral("trace_") + QCoreApplication::applicationName() + QDateTime::currentDateTime().toString(QStringLiteral("_ddd_dd_MM_yy-hh_mm_ss_"))+ QSysInfo::productType() + QStringLiteral("_") + QSysInfo::buildAbi() + QStringLiteral(".qt3d"); +#ifdef Q_OS_ANDROID + traceFile.reset(new QFile(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QStringLiteral("/") + fileName)); +#else + traceFile.reset(new QFile(fileName)); +#endif if (!traceFile->open(QFile::WriteOnly|QFile::Truncate)) qCritical("Failed to open trace file"); } diff --git a/src/core/jobs/qthreadpooler_p.h b/src/core/jobs/qthreadpooler_p.h index 47b28e639..9d632a696 100644 --- a/src/core/jobs/qthreadpooler_p.h +++ b/src/core/jobs/qthreadpooler_p.h @@ -51,17 +51,18 @@ // We mean it. // -#include "task_p.h" -#include "dependencyhandler_p.h" -#include "qaspectjob_p.h" +#include <QtCore/QFuture> +#include <QtCore/QFutureInterface> #include <QtCore/QObject> #include <QtCore/QSharedPointer> -#include <QtCore/QFutureInterface> -#include <QtCore/QFuture> -#include <QThreadPool> +#include <QtCore/QThreadPool> + +#include <Qt3DCore/private/dependencyhandler_p.h> +#include <Qt3DCore/private/qaspectjob_p.h> +#include <Qt3DCore/private/task_p.h> #ifdef QT3D_JOBS_RUN_STATS -#include <QElapsedTimer> +#include <QtCore/QElapsedTimer> #endif QT_BEGIN_NAMESPACE diff --git a/src/core/jobs/task.cpp b/src/core/jobs/task.cpp index 45da858f4..ca3c8b65a 100644 --- a/src/core/jobs/task.cpp +++ b/src/core/jobs/task.cpp @@ -38,12 +38,13 @@ ****************************************************************************/ #include "task_p.h" -#include "dependencyhandler_p.h" -#include "qthreadpooler_p.h" -#include <QMutexLocker> -#include <QElapsedTimer> -#include <QDebug> +#include <QtCore/QDebug> +#include <QtCore/QElapsedTimer> +#include <QtCore/QMutexLocker> + +#include <Qt3DCore/private/dependencyhandler_p.h> +#include <Qt3DCore/private/qthreadpooler_p.h> QT_BEGIN_NAMESPACE @@ -56,8 +57,9 @@ RunnableInterface::~RunnableInterface() // Aspect task AspectTaskRunnable::AspectTaskRunnable() - : m_dependencyHandler(0), - m_reserved(false) + : m_dependencyHandler(nullptr) + , m_pooler(nullptr) + , m_reserved(false) { } @@ -106,11 +108,12 @@ DependencyHandler *AspectTaskRunnable::dependencyHandler() SyncTaskRunnable::SyncTaskRunnable(QAbstractAspectJobManager::JobFunction func, void *arg, QAtomicInt *atomicCount) - : m_func(func), - m_arg(arg), - m_atomicCount(atomicCount), - m_pooler(nullptr), - m_reserved(false) + : m_func(func) + , m_arg(arg) + , m_atomicCount(atomicCount) + , m_pooler(nullptr) + , m_reserved(false) + , m_id(0) { } diff --git a/src/core/jobs/task_p.h b/src/core/jobs/task_p.h index 593d7d7ad..8193abaf6 100644 --- a/src/core/jobs/task_p.h +++ b/src/core/jobs/task_p.h @@ -51,13 +51,12 @@ // We mean it. // -#include "qaspectjobmanager_p.h" - -#include <QtCore/QtGlobal> -#include <QtCore/QThread> +#include <QtCore/QRunnable> #include <QtCore/QSharedPointer> +#include <QtCore/QThread> +#include <QtCore/QtGlobal> -#include <QtCore/QRunnable> +#include <Qt3DCore/private/qaspectjobmanager_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/propertychangehandler_p.h b/src/core/nodes/propertychangehandler_p.h index e91df5016..4bcfdef75 100644 --- a/src/core/nodes/propertychangehandler_p.h +++ b/src/core/nodes/propertychangehandler_p.h @@ -52,12 +52,11 @@ // #include <Qt3DCore/qt3dcore_global.h> - -#include <QObject> -#include <QHash> -#include <QVector> -#include <QMetaMethod> -#include <QDebug> +#include <QtCore/QDebug> +#include <QtCore/QHash> +#include <QtCore/QMetaMethod> +#include <QtCore/QObject> +#include <QtCore/QVector> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qabstractnodefactory_p.h b/src/core/nodes/qabstractnodefactory_p.h index bb7533e94..dbe0adffe 100644 --- a/src/core/nodes/qabstractnodefactory_p.h +++ b/src/core/nodes/qabstractnodefactory_p.h @@ -51,9 +51,10 @@ // We mean it. // -#include <Qt3DCore/private/qt3dcore_global_p.h> #include <Qt3DCore/qnode.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/nodes/qbackendnode.cpp b/src/core/nodes/qbackendnode.cpp index 6970794b8..65d140067 100644 --- a/src/core/nodes/qbackendnode.cpp +++ b/src/core/nodes/qbackendnode.cpp @@ -39,9 +39,12 @@ #include "qbackendnode.h" #include "qbackendnode_p.h" -#include "qaspectengine.h" -#include "qnode.h" -#include "qpropertyupdatedchange.h" + +#include <Qt3DCore/qaspectengine.h> +#include <Qt3DCore/qnode.h> +#include <Qt3DCore/qnodecommand.h> +#include <Qt3DCore/qpropertyupdatedchange.h> + #include <Qt3DCore/private/corelogging_p.h> QT_BEGIN_NAMESPACE @@ -204,6 +207,25 @@ void QBackendNode::notifyObservers(const QSceneChangePtr &e) d->notifyObservers(e); } +QNodeCommand::CommandId QBackendNode::sendCommand(const QString &name, + const QVariant &data, + QNodeCommand::CommandId replyTo) +{ + auto e = QNodeCommandPtr::create(peerId()); + e->setName(name); + e->setData(data); + e->setReplyToCommandId(replyTo); + e->setDeliveryFlags(QSceneChange::Nodes); + notifyObservers(e); + return e->commandId(); +} + +void QBackendNode::sendReply(const QNodeCommandPtr &command) +{ + command->setDeliveryFlags(QSceneChange::Nodes); + notifyObservers(command); +} + void QBackendNode::initializeFromPeer(const QNodeCreatedChangeBasePtr &change) { Q_UNUSED(change); @@ -231,7 +253,7 @@ void QBackendNode::sceneChangeEvent(const QSceneChangePtr &e) switch (e->type()) { case PropertyUpdated: { if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) - d->m_enabled = propertyChange->value().value<bool>(); + d->m_enabled = propertyChange->value().toBool(); break; } default: diff --git a/src/core/nodes/qbackendnode.h b/src/core/nodes/qbackendnode.h index 39114034d..99e483cff 100644 --- a/src/core/nodes/qbackendnode.h +++ b/src/core/nodes/qbackendnode.h @@ -40,10 +40,11 @@ #ifndef QT3DCORE_QBACKENDNODE_H #define QT3DCORE_QBACKENDNODE_H -#include <Qt3DCore/qt3dcore_global.h> -#include <Qt3DCore/qscenechange.h> #include <Qt3DCore/qnodecreatedchange.h> #include <Qt3DCore/qnodeid.h> +#include <Qt3DCore/qnodecommand.h> +#include <Qt3DCore/qscenechange.h> +#include <Qt3DCore/qt3dcore_global.h> QT_BEGIN_NAMESPACE @@ -90,6 +91,9 @@ protected: Q_DECLARE_PRIVATE(QBackendNode) explicit QBackendNode(QBackendNodePrivate &dd); void notifyObservers(const QSceneChangePtr &e); + QNodeCommand::CommandId sendCommand(const QString &name, const QVariant &data, + QNodeCommand::CommandId replyTo = QNodeCommand::CommandId()); + void sendReply(const QNodeCommandPtr &command); virtual void sceneChangeEvent(const QSceneChangePtr &e); QBackendNodePrivate *d_ptr; diff --git a/src/core/nodes/qbackendnode_p.h b/src/core/nodes/qbackendnode_p.h index 6cddfad11..6940f5623 100644 --- a/src/core/nodes/qbackendnode_p.h +++ b/src/core/nodes/qbackendnode_p.h @@ -51,13 +51,13 @@ // We mean it. // +#include <Qt3DCore/qbackendnode.h> #include <Qt3DCore/qnodeid.h> + +#include <Qt3DCore/private/qlockableobserverinterface_p.h> #include <Qt3DCore/private/qobservableinterface_p.h> #include <Qt3DCore/private/qobserverinterface_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> -#include <Qt3DCore/qbackendnode.h> -#include <Qt3DCore/private/qlockableobserverinterface_p.h> -#include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qcomponent.cpp b/src/core/nodes/qcomponent.cpp index abedb6244..8e337adf6 100644 --- a/src/core/nodes/qcomponent.cpp +++ b/src/core/nodes/qcomponent.cpp @@ -39,12 +39,14 @@ #include "qcomponent.h" #include "qcomponent_p.h" -#include "qentity.h" -#include "qentity_p.h" -#include "qscene_p.h" + #include <Qt3DCore/qpropertyupdatedchange.h> #include <Qt3DCore/qcomponentaddedchange.h> #include <Qt3DCore/qcomponentremovedchange.h> +#include <Qt3DCore/qentity.h> + +#include <Qt3DCore/private/qentity_p.h> +#include <Qt3DCore/private/qscene_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qcomponent_p.h b/src/core/nodes/qcomponent_p.h index 74cef1629..6c7c3c89d 100644 --- a/src/core/nodes/qcomponent_p.h +++ b/src/core/nodes/qcomponent_p.h @@ -51,8 +51,8 @@ // We mean it. // -#include <private/qnode_p.h> -#include <private/qt3dcore_global_p.h> +#include <Qt3DCore/private/qnode_p.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qdestructionidandtypecollector_p.h b/src/core/nodes/qdestructionidandtypecollector_p.h index 3e5fd9138..8557c27f0 100644 --- a/src/core/nodes/qdestructionidandtypecollector_p.h +++ b/src/core/nodes/qdestructionidandtypecollector_p.h @@ -48,8 +48,8 @@ // We mean it. // -#include <Qt3DCore/private/qnodevisitor_p.h> #include <Qt3DCore/private/qentity_p.h> +#include <Qt3DCore/private/qnodevisitor_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qentity.cpp b/src/core/nodes/qentity.cpp index b28898c60..9bc41f8cc 100644 --- a/src/core/nodes/qentity.cpp +++ b/src/core/nodes/qentity.cpp @@ -39,17 +39,18 @@ #include "qentity.h" #include "qentity_p.h" -#include "qcomponent.h" -#include "qcomponent_p.h" -#include <Qt3DCore/private/qscene_p.h> +#include <Qt3DCore/qcomponent.h> #include <Qt3DCore/qcomponentaddedchange.h> #include <Qt3DCore/qcomponentremovedchange.h> -#include <Qt3DCore/qpropertyupdatedchange.h> #include <Qt3DCore/qnodecreatedchange.h> +#include <Qt3DCore/qpropertyupdatedchange.h> +#include <QtCore/QMetaObject> +#include <QtCore/QMetaProperty> + #include <Qt3DCore/private/corelogging_p.h> -#include <QMetaObject> -#include <QMetaProperty> +#include <Qt3DCore/private/qcomponent_p.h> +#include <Qt3DCore/private/qscene_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qentity.h b/src/core/nodes/qentity.h index a7f492a96..978f84ebe 100644 --- a/src/core/nodes/qentity.h +++ b/src/core/nodes/qentity.h @@ -42,8 +42,7 @@ #include <Qt3DCore/qnode.h> #include <Qt3DCore/qt3dcore_global.h> - -#include <QMetaType> +#include <QtCore/QMetaType> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qentity_p.h b/src/core/nodes/qentity_p.h index a9dfb9b0d..9e9dbbd24 100644 --- a/src/core/nodes/qentity_p.h +++ b/src/core/nodes/qentity_p.h @@ -51,9 +51,10 @@ // We mean it. // +#include <Qt3DCore/qentity.h> + #include <Qt3DCore/private/qnode_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> -#include "qentity.h" QT_BEGIN_NAMESPACE @@ -70,10 +71,6 @@ public : QNodeId parentEntityId() const; QComponentVector m_components; - bool m_visible; - - // TODO: Is a bool enough here or do we need additional states for entities? - // Perhaps aboutToBeDeleted would be useful? mutable QNodeId m_parentEntityId; }; diff --git a/src/core/nodes/qnode.cpp b/src/core/nodes/qnode.cpp index ee327607f..58e016cda 100644 --- a/src/core/nodes/qnode.cpp +++ b/src/core/nodes/qnode.cpp @@ -40,25 +40,26 @@ #include "qnode.h" #include "qnode_p.h" -#include <Qt3DCore/qentity.h> +#include <Qt3DCore/QComponent> +#include <Qt3DCore/qaspectengine.h> #include <Qt3DCore/qdynamicpropertyupdatedchange.h> -#include <Qt3DCore/qpropertyupdatedchange.h> +#include <Qt3DCore/qentity.h> +#include <Qt3DCore/qnodedestroyedchange.h> #include <Qt3DCore/qpropertynodeaddedchange.h> #include <Qt3DCore/qpropertynoderemovedchange.h> -#include <Qt3DCore/qnodedestroyedchange.h> -#include <Qt3DCore/qaspectengine.h> -#include <Qt3DCore/private/qdestructionidandtypecollector_p.h> -#include <Qt3DCore/private/qscene_p.h> -#include <Qt3DCore/private/qpostman_p.h> -#include <QEvent> -#include <QChildEvent> -#include <QMetaObject> -#include <QMetaProperty> -#include <QtCore/private/qmetaobject_p.h> -#include <Qt3DCore/QComponent> +#include <Qt3DCore/qpropertyupdatedchange.h> +#include <QtCore/QChildEvent> +#include <QtCore/QEvent> +#include <QtCore/QMetaObject> +#include <QtCore/QMetaProperty> + #include <Qt3DCore/private/corelogging_p.h> +#include <Qt3DCore/private/qdestructionidandtypecollector_p.h> #include <Qt3DCore/private/qnodecreatedchangegenerator_p.h> #include <Qt3DCore/private/qnodevisitor_p.h> +#include <Qt3DCore/private/qpostman_p.h> +#include <Qt3DCore/private/qscene_p.h> +#include <QtCore/private/qmetaobject_p.h> QT_BEGIN_NAMESPACE @@ -73,7 +74,7 @@ QNodePrivate::QNodePrivate() , m_blockNotifications(false) , m_hasBackendNode(false) , m_enabled(true) - , m_propertyTrackMode(QNode::DefaultTrackMode) + , m_defaultPropertyTrackMode(QNode::TrackFinalValues) , m_propertyChangesSetup(false) , m_signals(this) { @@ -113,7 +114,7 @@ void QNodePrivate::notifyCreationChange() Q_Q(QNode); // Do nothing if we already have already sent a node creation change // and not a subsequent node destroyed change. - if (m_hasBackendNode) + if (m_hasBackendNode || !m_scene) return; QNodeCreatedChangeGenerator generator(q); const auto creationChanges = generator.creationChanges(); @@ -203,7 +204,7 @@ void QNodePrivate::_q_addChild(QNode *childNode) // removed from the scene as part of the destruction of the parent, when the // parent's children are deleted in the QObject dtor, we still have access to // the parentId. If we didn't store this, we wouldn't have access at that time - // because the parent woudl then only be a QObject, the QNode part would have + // because the parent would then only be a QObject, the QNode part would have // been destroyed already. QNodePrivate::get(childNode)->m_parentId = m_id; @@ -304,7 +305,21 @@ void QNodePrivate::_q_setParentHelper(QNode *parent) visitor.traverse(q, newParentNode->d_func(), &QNodePrivate::setSceneHelper); } - notifyCreationChange(); + // We want to make sure that subTreeRoot is always created before + // child. + // Given a case such as below + // QEntity *subTreeRoot = new QEntity(someGlobalExisitingRoot) + // QEntity *child = new QEntity(); + // child->setParent(subTreeRoot) + // We need to take into account that subTreeRoot needs to be + // created in the backend before the child. + // Therefore we only call notifyCreationChanges if the parent + // hasn't been created yet as we know that when the parent will be + // fully created, it will also send the changes for all of its + // children + + if (QNodePrivate::get(newParentNode)->m_hasBackendNode) + notifyCreationChange(); } // If we have a valid new parent, we let him know that we are its child @@ -393,19 +408,22 @@ void QNodePrivate::setSceneHelper(QNode *root) Recursively unsets and remove nodes in the subtree of base node \a root from the scene. Also takes care of removing Components and Entities connections. */ -void QNodePrivate::unsetSceneHelper(QNode *root) +void QNodePrivate::unsetSceneHelper(QNode *node) { + QNodePrivate *nodePrivate = QNodePrivate::get(node); + // We also need to handle QEntity <-> QComponent relationships removal - if (QComponent *c = qobject_cast<QComponent *>(root)) { + if (QComponent *c = qobject_cast<QComponent *>(node)) { const QVector<QEntity *> entities = c->entities(); for (QEntity *entity : entities) { - if (m_scene) - m_scene->removeEntityForComponent(c->id(), entity->id()); + if (nodePrivate->m_scene) + nodePrivate->m_scene->removeEntityForComponent(c->id(), entity->id()); } } - if (m_scene != nullptr) - m_scene->removeObservable(root); - root->d_func()->setScene(nullptr); + + if (nodePrivate->m_scene != nullptr) + nodePrivate->m_scene->removeObservable(node); + nodePrivate->setScene(nullptr); } /*! @@ -605,9 +623,9 @@ void QNodePrivate::updatePropertyTrackMode() { if (m_scene != nullptr) { QScene::NodePropertyTrackData trackData; - trackData.updateMode = m_propertyTrackMode; - trackData.namedProperties = m_trackedProperties; - m_scene->setPropertyTrackDataForNode(m_id,trackData); + trackData.defaultTrackMode = m_defaultPropertyTrackMode; + trackData.trackedPropertiesOverrides = m_trackedPropertiesOverrides; + m_scene->setPropertyTrackDataForNode(m_id, trackData); } } @@ -800,30 +818,16 @@ void QNode::setEnabled(bool isEnabled) emit enabledChanged(isEnabled); } -void QNode::setPropertyTrackMode(QNode::PropertyTrackMode mode) +void QNode::setDefaultPropertyTrackingMode(QNode::PropertyTrackingMode mode) { Q_D(QNode); - if (d->m_propertyTrackMode == mode) + if (d->m_defaultPropertyTrackMode == mode) return; - d->m_propertyTrackMode = mode; + d->m_defaultPropertyTrackMode = mode; // The backend doesn't care about such notification const bool blocked = blockNotifications(true); - emit propertyUpdateModeChanged(mode); - blockNotifications(blocked); - d->updatePropertyTrackMode(); -} - -void QNode::setTrackedProperties(const QStringList &trackedProperties) -{ - Q_D(QNode); - if (d->m_trackedProperties == trackedProperties) - return; - - d->m_trackedProperties = trackedProperties; - // The backend doesn't care about such notification - const bool blocked = blockNotifications(true); - emit trackedPropertiesChanged(trackedProperties); + emit defaultPropertyTrackingModeChanged(mode); blockNotifications(blocked); d->updatePropertyTrackMode(); } @@ -845,29 +849,45 @@ bool QNode::isEnabled() const } /*! - \property Qt3DCore::QNode::propertyTrackMode + \property Qt3DCore::QNode::defaultPropertyTrackingMode - Holds the property track mode which determines whether a QNode should - be listening for property updates + Holds the default property tracking mode which determines whether a QNode should + be listening for property updates. This only applies to properties which + haven't been overridden by a call to setPropertyTracking. - By default it is set to QNode::DontTrackProperties + By default it is set to QNode::TrackFinalValues */ -QNode::PropertyTrackMode QNode::propertyTrackMode() const +QNode::PropertyTrackingMode QNode::defaultPropertyTrackingMode() const { Q_D(const QNode); - return d->m_propertyTrackMode; + return d->m_defaultPropertyTrackMode; } -/*! - \property Qt3DCore::QNode::trackedProperties +void QNode::setPropertyTracking(const QString &propertyName, QNode::PropertyTrackingMode trackMode) +{ + Q_D(QNode); + d->m_trackedPropertiesOverrides.insert(propertyName, trackMode); + d->updatePropertyTrackMode(); +} - Holds the names of the properties to be tracked when propertyTrackMode is - set to TrackNamedProperties. -*/ -QStringList QNode::trackedProperties() const +QNode::PropertyTrackingMode QNode::propertyTracking(const QString &propertyName) const { Q_D(const QNode); - return d->m_trackedProperties; + return d->m_trackedPropertiesOverrides.value(propertyName, d->m_defaultPropertyTrackMode); +} + +void QNode::clearPropertyTracking(const QString &propertyName) +{ + Q_D(QNode); + d->m_trackedPropertiesOverrides.remove(propertyName); + d->updatePropertyTrackMode(); +} + +void QNode::clearPropertyTrackings() +{ + Q_D(QNode); + d->m_trackedPropertiesOverrides.clear(); + d->updatePropertyTrackMode(); } QNodeCreatedChangeBasePtr QNode::createNodeCreationChange() const @@ -882,6 +902,51 @@ QNodeCreatedChangeBasePtr QNode::createNodeCreationChange() const return QNodeCreatedChangeBasePtr::create(this); } +/*! + * \brief Sends a command messages to the backend node + * + * Creates a QNodeCommand message and dispatches it to the backend node. The + * command is given and a \a name and some \a data which can be used in the + * backend node to performe various operations. + * This returns a CommandId which can be used to identify the initial command + * when receiving a message in reply. If the command message is to be sent in + * reply to another command, \a replyTo contains the id of that command. + * + * \sa QNodeCommand, QNode::sendReply + */ +QNodeCommand::CommandId QNode::sendCommand(const QString &name, + const QVariant &data, + QNodeCommand::CommandId replyTo) +{ + Q_D(QNode); + + // Bail out early if we can to avoid operator new + if (d->m_blockNotifications) + return QNodeCommand::CommandId(0); + + auto e = QNodeCommandPtr::create(d->m_id); + e->setName(name); + e->setData(data); + e->setReplyToCommandId(replyTo); + d->notifyObservers(e); + return e->commandId(); +} + +/*! + * \brief Send a command back to the backend node + * + * Assumes the command is to be to sent back in reply to itself to the backend node + * + * \sa QNodeCommand, QNode::sendCommand + */ +void QNode::sendReply(const QNodeCommandPtr &command) +{ + Q_D(QNode); + command->setDeliveryFlags(QSceneChange::BackendNodes); + d->notifyObservers(command); +} + + namespace { /*! \internal */ diff --git a/src/core/nodes/qnode.h b/src/core/nodes/qnode.h index 75ea61cc7..1fe03f5e0 100644 --- a/src/core/nodes/qnode.h +++ b/src/core/nodes/qnode.h @@ -40,11 +40,12 @@ #ifndef QT3DCORE_QNODE_H #define QT3DCORE_QNODE_H -#include <QObject> -#include <Qt3DCore/qt3dcore_global.h> +#include <Qt3DCore/qnodecreatedchange.h> #include <Qt3DCore/qnodeid.h> +#include <Qt3DCore/qnodecommand.h> #include <Qt3DCore/qscenechange.h> -#include <Qt3DCore/qnodecreatedchange.h> +#include <Qt3DCore/qt3dcore_global.h> +#include <QtCore/QObject> #define Q_NODE_NULLPTR static_cast<Qt3DCore::QNode *>(nullptr) @@ -69,16 +70,15 @@ class QT3DCORESHARED_EXPORT QNode : public QObject Q_OBJECT Q_PROPERTY(Qt3DCore::QNode *parent READ parentNode WRITE setParent NOTIFY parentChanged) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(PropertyTrackMode propertyTrackMode READ propertyTrackMode WRITE setPropertyTrackMode NOTIFY propertyUpdateModeChanged) - Q_PROPERTY(QStringList trackedProperties READ trackedProperties WRITE setTrackedProperties NOTIFY trackedPropertiesChanged) + Q_PROPERTY(PropertyTrackingMode defaultPropertyTrackingMode READ defaultPropertyTrackingMode WRITE setDefaultPropertyTrackingMode NOTIFY defaultPropertyTrackingModeChanged REVISION 9) public: - enum PropertyTrackMode { - DefaultTrackMode, - TrackNamedPropertiesMode, - TrackAllPropertiesMode + enum PropertyTrackingMode : quint16 { + TrackFinalValues, + DontTrackValues, + TrackAllValues }; - Q_ENUM(PropertyTrackMode) + Q_ENUM(PropertyTrackingMode) explicit QNode(QNode *parent = nullptr); virtual ~QNode(); @@ -92,20 +92,26 @@ public: QNodeVector childNodes() const; bool isEnabled() const; - PropertyTrackMode propertyTrackMode() const; - QStringList trackedProperties() const; + PropertyTrackingMode defaultPropertyTrackingMode() const; + + void setPropertyTracking(const QString &propertyName, PropertyTrackingMode trackMode); + PropertyTrackingMode propertyTracking(const QString &propertyName) const; + void clearPropertyTracking(const QString &propertyName); + void clearPropertyTrackings(); + + QNodeCommand::CommandId sendCommand(const QString &name, const QVariant &data = QVariant(), + QNodeCommand::CommandId replyTo = QNodeCommand::CommandId()); + void sendReply(const QNodeCommandPtr &command); public Q_SLOTS: void setParent(QNode *parent); void setEnabled(bool isEnabled); - void setPropertyTrackMode(PropertyTrackMode mode); - void setTrackedProperties(const QStringList &trackedProperties); + void setDefaultPropertyTrackingMode(PropertyTrackingMode mode); Q_SIGNALS: void parentChanged(QObject *parent); void enabledChanged(bool enabled); - void propertyUpdateModeChanged(PropertyTrackMode mode); - void trackedPropertiesChanged(const QStringList &trackedProperties); + void defaultPropertyTrackingModeChanged(PropertyTrackingMode mode); void nodeDestroyed(); protected: diff --git a/src/core/nodes/qnode_p.h b/src/core/nodes/qnode_p.h index 5d6329e62..ad9d2376e 100644 --- a/src/core/nodes/qnode_p.h +++ b/src/core/nodes/qnode_p.h @@ -51,13 +51,15 @@ // We mean it. // -#include <private/qobject_p.h> #include <Qt3DCore/qnode.h> -#include <Qt3DCore/private/qobservableinterface_p.h> + +#include <functional> + +#include <Qt3DCore/private/propertychangehandler_p.h> #include <Qt3DCore/private/qchangearbiter_p.h> +#include <Qt3DCore/private/qobservableinterface_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> -#include "propertychangehandler_p.h" -#include <functional> +#include <QtCore/private/qobject_p.h> QT_BEGIN_NAMESPACE @@ -74,7 +76,7 @@ public: void init(QNode *parent); - void setScene(QScene *scene); + virtual void setScene(QScene *scene); QScene *scene() const; void setArbiter(QLockableObserverInterface *arbiter) Q_DECL_OVERRIDE; @@ -98,8 +100,8 @@ public: bool m_blockNotifications; bool m_hasBackendNode; bool m_enabled; - QNode::PropertyTrackMode m_propertyTrackMode; - QStringList m_trackedProperties; + QNode::PropertyTrackingMode m_defaultPropertyTrackMode; + QHash<QString, QNode::PropertyTrackingMode> m_trackedPropertiesOverrides; static QNodePrivate *get(QNode *q); static void nodePtrDeleter(QNode *q); diff --git a/src/core/nodes/qnodecreatedchangegenerator.cpp b/src/core/nodes/qnodecreatedchangegenerator.cpp index c350c866a..d91949fb1 100644 --- a/src/core/nodes/qnodecreatedchangegenerator.cpp +++ b/src/core/nodes/qnodecreatedchangegenerator.cpp @@ -35,6 +35,7 @@ ****************************************************************************/ #include "qnodecreatedchangegenerator_p.h" + #include <Qt3DCore/private/qnodevisitor_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qnodecreatedchangegenerator_p.h b/src/core/nodes/qnodecreatedchangegenerator_p.h index f00241b39..42c2847cc 100644 --- a/src/core/nodes/qnodecreatedchangegenerator_p.h +++ b/src/core/nodes/qnodecreatedchangegenerator_p.h @@ -48,12 +48,13 @@ // We mean it. // -#include <Qt3DCore/qt3dcore_global.h> #include <Qt3DCore/qnode.h> #include <Qt3DCore/qnodecreatedchange.h> -#include <Qt3DCore/private/qnode_p.h> +#include <Qt3DCore/qt3dcore_global.h> #include <QtCore/qvector.h> +#include <Qt3DCore/private/qnode_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/nodes/qnodeid.cpp b/src/core/nodes/qnodeid.cpp index f41627734..17bc4e8e1 100644 --- a/src/core/nodes/qnodeid.cpp +++ b/src/core/nodes/qnodeid.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "qnodeid.h" +#include <Qt3DCore/qnodeid.h> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qnodeid.h b/src/core/nodes/qnodeid.h index 7e8b1c97c..a00559df3 100644 --- a/src/core/nodes/qnodeid.h +++ b/src/core/nodes/qnodeid.h @@ -41,7 +41,7 @@ #define QT3DCORE_QNODEID_H #include <Qt3DCore/qt3dcore_global.h> -#include <QDebug> +#include <QtCore/QDebug> #include <QtCore/QHashFunctions> QT_BEGIN_NAMESPACE diff --git a/src/core/nodes/qnodevisitor_p.h b/src/core/nodes/qnodevisitor_p.h index 3637293f5..15bfa90db 100644 --- a/src/core/nodes/qnodevisitor_p.h +++ b/src/core/nodes/qnodevisitor_p.h @@ -51,9 +51,9 @@ // We mean it. // -#include <Qt3DCore/qt3dcore_global.h> -#include <Qt3DCore/qnode.h> #include <Qt3DCore/qentity.h> +#include <Qt3DCore/qnode.h> +#include <Qt3DCore/qt3dcore_global.h> QT_BEGIN_NAMESPACE diff --git a/src/core/qbackendnodefactory_p.h b/src/core/qbackendnodefactory_p.h index 9f2afb16d..46e68266f 100644 --- a/src/core/qbackendnodefactory_p.h +++ b/src/core/qbackendnodefactory_p.h @@ -51,9 +51,10 @@ // We mean it. // -#include <Qt3DCore/private/qt3dcore_global_p.h> #include <Qt3DCore/qnodecreatedchange.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/qchangearbiter.cpp b/src/core/qchangearbiter.cpp index a7ca3ed40..d6c7e05df 100644 --- a/src/core/qchangearbiter.cpp +++ b/src/core/qchangearbiter.cpp @@ -38,17 +38,18 @@ ****************************************************************************/ #include "qchangearbiter_p.h" -#include "qcomponent.h" -#include "qabstractaspectjobmanager_p.h" -#include "qsceneobserverinterface_p.h" -#include <Qt3DCore/private/qscene_p.h> +#include <Qt3DCore/qcomponent.h> +#include <QtCore/QMutexLocker> +#include <QtCore/QReadLocker> +#include <QtCore/QThread> +#include <QtCore/QWriteLocker> + #include <Qt3DCore/private/corelogging_p.h> -#include <QMutexLocker> -#include <QReadLocker> -#include <QThread> -#include <QWriteLocker> -#include <private/qpostman_p.h> +#include <Qt3DCore/private/qabstractaspectjobmanager_p.h> +#include <Qt3DCore/private/qpostman_p.h> +#include <Qt3DCore/private/qscene_p.h> +#include <Qt3DCore/private/qsceneobserverinterface_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/qchangearbiter_p.h b/src/core/qchangearbiter_p.h index e381abc65..54ef6a207 100644 --- a/src/core/qchangearbiter_p.h +++ b/src/core/qchangearbiter_p.h @@ -51,16 +51,17 @@ // We mean it. // -#include <QObject> -#include <QFlags> -#include <QReadWriteLock> -#include <QVariant> -#include <QVector> -#include <QPair> -#include <QThreadStorage> -#include <QMutex> #include <Qt3DCore/qnodeid.h> #include <Qt3DCore/qscenechange.h> +#include <QtCore/QFlags> +#include <QtCore/QMutex> +#include <QtCore/QObject> +#include <QtCore/QPair> +#include <QtCore/QReadWriteLock> +#include <QtCore/QThreadStorage> +#include <QtCore/QVariant> +#include <QtCore/QVector> + #include <Qt3DCore/private/qlockableobserverinterface_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> diff --git a/src/core/qobservableinterface_p.h b/src/core/qobservableinterface_p.h index e867f1b84..8b92168ff 100644 --- a/src/core/qobservableinterface_p.h +++ b/src/core/qobservableinterface_p.h @@ -52,7 +52,8 @@ // #include <Qt3DCore/qscenechange.h> -#include <private/qt3dcore_global_p.h> + +#include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/qpostman.cpp b/src/core/qpostman.cpp index 2b8e6c3a8..9fd8f9104 100644 --- a/src/core/qpostman.cpp +++ b/src/core/qpostman.cpp @@ -39,12 +39,15 @@ #include "qpostman_p.h" #include "qpostman_p_p.h" + +#include <Qt3DCore/qnode.h> #include <Qt3DCore/qpropertyupdatedchange.h> -#include <Qt3DCore/private/qscene_p.h> + #include <Qt3DCore/private/qlockableobserverinterface_p.h> -#include <Qt3DCore/qnode.h> #include <Qt3DCore/private/qnode_p.h> #include <Qt3DCore/private/qpropertyupdatedchangebase_p.h> +#include <Qt3DCore/private/qscene_p.h> +#include <QtCore/private/qobject_p.h> QT_BEGIN_NAMESPACE @@ -116,17 +119,25 @@ bool QPostman::shouldNotifyFrontend(const QSceneChangePtr &e) Q_D(QPostman); const QPropertyUpdatedChangePtr propertyChange = qSharedPointerDynamicCast<QPropertyUpdatedChange>(e); if (Q_LIKELY(d->m_scene != nullptr) && !propertyChange.isNull()) { - const bool isFinal = QPropertyUpdatedChangeBasePrivate::get(propertyChange.data())->m_isFinal; - if (isFinal) - return true; - const QScene::NodePropertyTrackData propertyTrackData = d->m_scene->lookupNodePropertyTrackData(e->subjectId()); - switch (propertyTrackData.updateMode) { - case QNode::TrackAllPropertiesMode: + const QScene::NodePropertyTrackData propertyTrackData + = d->m_scene->lookupNodePropertyTrackData(e->subjectId()); + + const QNode::PropertyTrackingMode trackMode = propertyTrackData.trackedPropertiesOverrides.value(QLatin1String(propertyChange->propertyName()), + propertyTrackData.defaultTrackMode); + + switch (trackMode) { + case QNode::TrackAllValues: return true; - case QNode::TrackNamedPropertiesMode: - return propertyTrackData.namedProperties.contains(QLatin1String(propertyChange->propertyName())); - case QNode::DefaultTrackMode: + + case QNode::DontTrackValues: return false; + + case QNode::TrackFinalValues: { + const bool isIntermediate + = QPropertyUpdatedChangeBasePrivate::get(propertyChange.data())->m_isIntermediate; + return !isIntermediate; + } + default: Q_UNREACHABLE(); return false; diff --git a/src/core/qscene.cpp b/src/core/qscene.cpp index 972659131..b5895c7aa 100644 --- a/src/core/qscene.cpp +++ b/src/core/qscene.cpp @@ -38,12 +38,14 @@ ****************************************************************************/ #include "qscene_p.h" -#include <QHash> -#include <QReadLocker> + #include <Qt3DCore/qnode.h> +#include <QtCore/QHash> +#include <QtCore/QReadLocker> + #include <Qt3DCore/private/qlockableobserverinterface_p.h> -#include <Qt3DCore/private/qobservableinterface_p.h> #include <Qt3DCore/private/qnode_p.h> +#include <Qt3DCore/private/qobservableinterface_p.h> QT_BEGIN_NAMESPACE @@ -55,6 +57,7 @@ public: QScenePrivate(QAspectEngine *engine) : m_engine(engine) , m_arbiter(nullptr) + , m_rootNode(nullptr) { } @@ -67,6 +70,7 @@ public: QLockableObserverInterface *m_arbiter; mutable QReadWriteLock m_lock; mutable QReadWriteLock m_nodePropertyTrackModeLock; + QNode *m_rootNode; }; @@ -171,6 +175,12 @@ QNodeId QScene::nodeIdFromObservable(QObservableInterface *observable) const return d->m_observableToUuid.value(observable); } +QNode *QScene::rootNode() const +{ + Q_D(const QScene); + return d->m_rootNode; +} + void QScene::setArbiter(QLockableObserverInterface *arbiter) { Q_D(QScene); @@ -212,7 +222,8 @@ bool QScene::hasEntityForComponent(QNodeId componentUuid, QNodeId entityUuid) { Q_D(QScene); QReadLocker lock(&d->m_lock); - return d->m_componentToEntities.values(componentUuid).contains(entityUuid); + const auto range = d->m_componentToEntities.equal_range(componentUuid); + return std::find(range.first, range.second, entityUuid) != range.second; } QScene::NodePropertyTrackData QScene::lookupNodePropertyTrackData(QNodeId id) const @@ -236,6 +247,12 @@ void QScene::removePropertyTrackDataForNode(QNodeId nodeId) d->m_nodePropertyTrackModeLookupTable.remove(nodeId); } +void QScene::setRootNode(QNode *root) +{ + Q_D(QScene); + d->m_rootNode = root; +} + } // Qt3D QT_END_NAMESPACE diff --git a/src/core/qscene_p.h b/src/core/qscene_p.h index 1a313c249..aaa8d9e92 100644 --- a/src/core/qscene_p.h +++ b/src/core/qscene_p.h @@ -51,10 +51,12 @@ // We mean it. // -#include <Qt3DCore/private/qt3dcore_global_p.h> -#include <Qt3DCore/private/qobservableinterface_p.h> +#include <QtCore/QScopedPointer> + #include <Qt3DCore/qnode.h> -#include <QScopedPointer> +#include <QtCore/qscopedpointer.h> +#include <Qt3DCore/private/qobservableinterface_p.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE @@ -83,6 +85,8 @@ public: QVector<QNode *> lookupNodes(const QVector<QNodeId> &ids) const; QNodeId nodeIdFromObservable(QObservableInterface *observable) const; + QNode *rootNode() const; + void setArbiter(Qt3DCore::QLockableObserverInterface *arbiter); Qt3DCore::QLockableObserverInterface *arbiter() const; @@ -95,8 +99,8 @@ public: // Node -> Property Update Data struct NodePropertyTrackData { - QNode::PropertyTrackMode updateMode = QNode::DefaultTrackMode; - QStringList namedProperties; + QNode::PropertyTrackingMode defaultTrackMode = QNode::TrackFinalValues; + QHash<QString, QNode::PropertyTrackingMode> trackedPropertiesOverrides; }; NodePropertyTrackData lookupNodePropertyTrackData(QNodeId id) const; void setPropertyTrackDataForNode(QNodeId id, const NodePropertyTrackData &data); @@ -105,6 +109,9 @@ public: private: Q_DECLARE_PRIVATE(QScene) QScopedPointer<QScenePrivate> d_ptr; + + void setRootNode(QNode *root); + friend class QAspectEnginePrivate; }; } // Qt3D diff --git a/src/core/qsceneobserverinterface_p.h b/src/core/qsceneobserverinterface_p.h index 77b1c3626..f183ab571 100644 --- a/src/core/qsceneobserverinterface_p.h +++ b/src/core/qsceneobserverinterface_p.h @@ -51,9 +51,10 @@ // We mean it. // -#include <Qt3DCore/private/qt3dcore_global_p.h> #include <Qt3DCore/qscenechange.h> +#include <Qt3DCore/private/qt3dcore_global_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/qscheduler.cpp b/src/core/qscheduler.cpp index 1df6d2607..cc2f9081e 100644 --- a/src/core/qscheduler.cpp +++ b/src/core/qscheduler.cpp @@ -39,10 +39,11 @@ #include "qscheduler_p.h" -#include "qabstractaspect.h" -#include "qabstractaspect_p.h" -#include "qaspectmanager_p.h" -#include "qabstractaspectjobmanager_p.h" +#include <Qt3DCore/qabstractaspect.h> + +#include <Qt3DCore/private/qabstractaspect_p.h> +#include <Qt3DCore/private/qaspectmanager_p.h> +#include <Qt3DCore/private/qabstractaspectjobmanager_p.h> QT_BEGIN_NAMESPACE @@ -50,6 +51,7 @@ namespace Qt3DCore { QScheduler::QScheduler(QObject *parent) : QObject(parent) + , m_aspectManager(nullptr) { } diff --git a/src/core/qscheduler_p.h b/src/core/qscheduler_p.h index 9d0f99ccb..9b1685e54 100644 --- a/src/core/qscheduler_p.h +++ b/src/core/qscheduler_p.h @@ -40,8 +40,8 @@ #ifndef QT3DCORE_QSCHEDULER_P_H #define QT3DCORE_QSCHEDULER_P_H -#include <QObject> #include <Qt3DCore/qt3dcore_global.h> +#include <QtCore/QObject> // // W A R N I N G diff --git a/src/core/qtickclock.cpp b/src/core/qtickclock.cpp index 4dfb29f1b..38ed07925 100644 --- a/src/core/qtickclock.cpp +++ b/src/core/qtickclock.cpp @@ -39,8 +39,9 @@ #include "qtickclock_p.h" +#include <QtCore/QThread> + #include <Qt3DCore/private/corelogging_p.h> -#include <QThread> QT_BEGIN_NAMESPACE diff --git a/src/core/qtickclock_p.h b/src/core/qtickclock_p.h index b19417173..2b6686745 100644 --- a/src/core/qtickclock_p.h +++ b/src/core/qtickclock_p.h @@ -52,8 +52,7 @@ // #include <Qt3DCore/qt3dcore_global.h> - -#include <QElapsedTimer> +#include <QtCore/QElapsedTimer> QT_BEGIN_NAMESPACE diff --git a/src/core/resources/qboundedcircularbuffer_p.h b/src/core/resources/qboundedcircularbuffer_p.h index f879a4a6f..22299d7da 100644 --- a/src/core/resources/qboundedcircularbuffer_p.h +++ b/src/core/resources/qboundedcircularbuffer_p.h @@ -51,12 +51,12 @@ // We mean it. // -#include <Qt3DCore/private/qcircularbuffer_p.h> +#include <QtCore/QReadWriteLock> +#include <QtCore/QReadLocker> +#include <QtCore/QSemaphore> +#include <QtCore/QtGlobal> -#include <QReadWriteLock> -#include <QReadLocker> -#include <QSemaphore> -#include <QtGlobal> +#include <Qt3DCore/private/qcircularbuffer_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/resources/qcircularbuffer_p.h b/src/core/resources/qcircularbuffer_p.h index 08665f4b5..e10b7236d 100644 --- a/src/core/resources/qcircularbuffer_p.h +++ b/src/core/resources/qcircularbuffer_p.h @@ -51,21 +51,23 @@ // We mean it. // +#include <Qt3DCore/qt3dcore_global.h> +#include <QtCore/QtGlobal> #include <QtCore/qlist.h> #include <QtCore/qpair.h> #include <QtCore/qshareddata.h> #include <QtCore/qvector.h> #include <algorithm> -#ifdef Q_COMPILER_INITIALIZER_LISTS -# include <initializer_list> -#endif #include <iterator> #include <limits> #include <memory> #include <new> -#include <QtGlobal> -#include <Qt3DCore/qt3dcore_global.h> + + +#ifdef Q_COMPILER_INITIALIZER_LISTS +# include <initializer_list> +#endif QT_BEGIN_NAMESPACE diff --git a/src/core/resources/qframeallocator_p.h b/src/core/resources/qframeallocator_p.h index cd0fa504c..b3ded0760 100644 --- a/src/core/resources/qframeallocator_p.h +++ b/src/core/resources/qframeallocator_p.h @@ -56,9 +56,10 @@ #include <valgrind/memcheck.h> #endif -#include <QDebug> -#include <QScopedPointer> -#include <QVector> +#include <QtCore/QDebug> +#include <QtCore/QScopedPointer> +#include <QtCore/QVector> + #include <Qt3DCore/private/qt3dcore_global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/resources/qhandlemanager_p.h b/src/core/resources/qhandlemanager_p.h index b41fc75b1..0c3609bb9 100644 --- a/src/core/resources/qhandlemanager_p.h +++ b/src/core/resources/qhandlemanager_p.h @@ -51,12 +51,12 @@ // We mean it. // -#include <QtGlobal> #include <Qt3DCore/qt3dcore_global.h> -#include "qhandle_p.h" - +#include <QtCore/QtGlobal> #include <QtCore/QVector> +#include <Qt3DCore/private/qhandle_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/resources/qresourcemanager_p.h b/src/core/resources/qresourcemanager_p.h index 1b79434fd..8ddc1c0a4 100644 --- a/src/core/resources/qresourcemanager_p.h +++ b/src/core/resources/qresourcemanager_p.h @@ -51,14 +51,15 @@ // We mean it. // -#include <QtGlobal> -#include <QReadWriteLock> -#include <QReadLocker> -#include <QMutex> -#include <QHash> #include <Qt3DCore/qt3dcore_global.h> -#include "qhandle_p.h" -#include "qhandlemanager_p.h" +#include <QtCore/QHash> +#include <QtCore/QMutex> +#include <QtCore/QReadLocker> +#include <QtCore/QReadWriteLock> +#include <QtCore/QtGlobal> + +#include <Qt3DCore/private/qhandle_p.h> +#include <Qt3DCore/private/qhandlemanager_p.h> // Silence complaints about unreferenced local variables in // ArrayAllocatingPolicy::deallocateBuckets() when the compiler diff --git a/src/core/services/nullservices_p.h b/src/core/services/nullservices_p.h index ed7bd3a39..f75c6abc1 100644 --- a/src/core/services/nullservices_p.h +++ b/src/core/services/nullservices_p.h @@ -52,8 +52,9 @@ // #include <Qt3DCore/qt3dcore_global.h> -#include "qopenglinformationservice_p.h" -#include "qsysteminformationservice_p.h" + +#include <Qt3DCore/private/qopenglinformationservice_p.h> +#include <Qt3DCore/private/qsysteminformationservice_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/services/qabstractframeadvanceservice_p.h b/src/core/services/qabstractframeadvanceservice_p.h index 2dde68f06..dac72a98d 100644 --- a/src/core/services/qabstractframeadvanceservice_p.h +++ b/src/core/services/qabstractframeadvanceservice_p.h @@ -52,8 +52,9 @@ // #include <Qt3DCore/qt3dcore_global.h> +#include <QtCore/QString> + #include <Qt3DCore/private/qservicelocator_p.h> -#include <QString> QT_BEGIN_NAMESPACE @@ -63,6 +64,7 @@ class QAbstractFrameAdvanceServicePrivate; class QT3DCORESHARED_EXPORT QAbstractFrameAdvanceService : public QAbstractServiceProvider { + Q_OBJECT public: virtual qint64 waitForNextFrame() = 0; virtual void start() = 0; diff --git a/src/core/services/qabstractframeadvanceservice_p_p.h b/src/core/services/qabstractframeadvanceservice_p_p.h index d73ca3116..c49586b8f 100644 --- a/src/core/services/qabstractframeadvanceservice_p_p.h +++ b/src/core/services/qabstractframeadvanceservice_p_p.h @@ -52,6 +52,7 @@ // #include <Qt3DCore/qt3dcore_global.h> + #include <Qt3DCore/private/qabstractserviceprovider_p.h> #include <Qt3DCore/private/qservicelocator_p.h> diff --git a/src/core/services/qabstractserviceprovider_p.h b/src/core/services/qabstractserviceprovider_p.h index 2913cee31..cef6ef034 100644 --- a/src/core/services/qabstractserviceprovider_p.h +++ b/src/core/services/qabstractserviceprovider_p.h @@ -51,23 +51,26 @@ // We mean it. // +#include <QtCore/private/qobject_p.h> #include <Qt3DCore/qt3dcore_global.h> #include <QtCore/qstring.h> +#include <Qt3DCore/private/qservicelocator_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { -class QAbstractServiceProviderPrivate +class QAbstractServiceProviderPrivate : public QObjectPrivate { public: - QAbstractServiceProviderPrivate(int type, const QString &description = QString()) - : m_type(type) + explicit QAbstractServiceProviderPrivate(int type, const QString &description = QString()) + : QObjectPrivate() + , m_type(type) , m_description(description) {} Q_DECLARE_PUBLIC(QAbstractServiceProvider) - QAbstractServiceProvider *q_ptr; int m_type; QString m_description; diff --git a/src/core/services/qdownloadhelperservice.cpp b/src/core/services/qdownloadhelperservice.cpp new file mode 100644 index 000000000..231e9172b --- /dev/null +++ b/src/core/services/qdownloadhelperservice.cpp @@ -0,0 +1,216 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 "qdownloadhelperservice_p.h" +#include "qdownloadnetworkworker_p.h" +#include <Qt3DCore/QAspectEngine> +#include <Qt3DCore/private/qabstractserviceprovider_p.h> +#include <Qt3DCore/private/qaspectengine_p.h> +#include <Qt3DCore/private/qaspectthread_p.h> +#include <Qt3DCore/private/qaspectmanager_p.h> +#include <Qt3DCore/private/qservicelocator_p.h> + +#include <QFile> + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +QDownloadRequest::QDownloadRequest(const QUrl &url) + : m_url(url) + , m_succeeded(false) + , m_cancelled(false) +{ + +} + +QDownloadRequest::~QDownloadRequest() +{ + +} + +void QDownloadRequest::onDownloaded() +{ + // this is called in dl thread. It's an opportunity to do long running tasks + // like loading the data into a QImage +} + + +class Q_AUTOTEST_EXPORT QDownloadHelperServicePrivate : public QAbstractServiceProviderPrivate +{ +public: + explicit QDownloadHelperServicePrivate(const QString &description); + ~QDownloadHelperServicePrivate(); + + void init(); + void shutdown(); + void _q_onRequestCompleted(const QDownloadRequestPtr &request); + + Q_DECLARE_PUBLIC(QDownloadHelperService) + + QThread *m_downloadThread; + QDownloadNetworkWorker *m_downloadWorker; +}; + + +QDownloadHelperServicePrivate::QDownloadHelperServicePrivate(const QString &description) + : QAbstractServiceProviderPrivate(QServiceLocator::DownloadHelperService, description) + , m_downloadThread(nullptr) + , m_downloadWorker(nullptr) +{ +} + +QDownloadHelperServicePrivate::~QDownloadHelperServicePrivate() +{ +} + +void QDownloadHelperServicePrivate::init() +{ + Q_Q(QDownloadHelperService); + m_downloadThread = new QThread(q); + m_downloadWorker = new QDownloadNetworkWorker; + m_downloadWorker->moveToThread(m_downloadThread); + QObject::connect(m_downloadWorker, SIGNAL(requestDownloaded(const Qt3DCore::QDownloadRequestPtr &)), + q, SLOT(_q_onRequestCompleted(const Qt3DCore::QDownloadRequestPtr &))); + m_downloadThread->start(); +} + +void QDownloadHelperServicePrivate::shutdown() +{ + m_downloadWorker->cancelAllRequests(); + m_downloadThread->exit(); + m_downloadThread->wait(); + m_downloadWorker->deleteLater(); +} + +void QDownloadHelperServicePrivate::_q_onRequestCompleted(const Qt3DCore::QDownloadRequestPtr &request) +{ + request->onCompleted(); +} + + +QDownloadHelperService::QDownloadHelperService(const QString &description) + : QAbstractServiceProvider(*new QDownloadHelperServicePrivate(description)) +{ + Q_D(QDownloadHelperService); + d->init(); + qRegisterMetaType<Qt3DCore::QDownloadRequestPtr>(); +} + +QDownloadHelperService::~QDownloadHelperService() +{ + Q_D(QDownloadHelperService); + d->shutdown(); +} + +void QDownloadHelperService::submitRequest(const Qt3DCore::QDownloadRequestPtr &request) +{ + Q_D(QDownloadHelperService); + + if (isLocal(request->url())) { + QFile file(urlToLocalFileOrQrc(request->url())); + if (file.open(QIODevice::ReadOnly)) { + request->m_data = file.readAll(); + file.close(); + request->m_succeeded = true; + } else { + request->m_succeeded = false; + } + request->onCompleted(); + } else { + emit d->m_downloadWorker->submitRequest(request); + } +} + +void QDownloadHelperService::cancelRequest(const Qt3DCore::QDownloadRequestPtr &request) +{ + Q_D(QDownloadHelperService); + request->m_cancelled = true; + emit d->m_downloadWorker->cancelRequest(request); +} + +void QDownloadHelperService::cancelAllRequests() +{ + Q_D(QDownloadHelperService); + emit d->m_downloadWorker->cancelAllRequests(); +} + +QString QDownloadHelperService::urlToLocalFileOrQrc(const QUrl &url) +{ + const QString scheme(url.scheme().toLower()); + if (scheme == QLatin1String("qrc")) { + if (url.authority().isEmpty()) + return QLatin1Char(':') + url.path(); + return QString(); + } + +#if defined(Q_OS_ANDROID) + if (scheme == QLatin1String("assets")) { + if (url.authority().isEmpty()) + return url.toString(); + return QString(); + } +#endif + + return url.toLocalFile(); +} + +QDownloadHelperService *QDownloadHelperService::getService(QAspectEngine *engine) +{ + auto enginePrivate = Qt3DCore::QAspectEnginePrivate::get(engine); + return enginePrivate->m_aspectThread->aspectManager()->serviceLocator()->downloadHelperService(); +} + +bool QDownloadHelperService::isLocal(const QUrl &url) +{ + const QString scheme(url.scheme().toLower()); + if (scheme == QLatin1String("file") || scheme == QLatin1String("qrc")) + return true; +#if defined(Q_OS_ANDROID) + if (scheme == QLatin1String("assets")) + return true; +#endif + return false; +} + +} // namespace Qt3DCore + +QT_END_NAMESPACE + +#include "moc_qdownloadhelperservice_p.cpp" diff --git a/src/core/services/qdownloadhelperservice_p.h b/src/core/services/qdownloadhelperservice_p.h new file mode 100644 index 000000000..780ed4806 --- /dev/null +++ b/src/core/services/qdownloadhelperservice_p.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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_QDOWNLOADHELPERSERVICE_P_H +#define QT3DCORE_QDOWNLOADHELPERSERVICE_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 <QSharedPointer> +#include <QObject> +#include <QUrl> + +#include <Qt3DCore/qaspectjob.h> +#include <Qt3DCore/qt3dcore_global.h> +#include <Qt3DCore/private/qservicelocator_p.h> + +QT_BEGIN_NAMESPACE + +class QThread; +class QNetworkAccessManager; +class QNetworkReply; + +namespace Qt3DCore { + +class QAspectEngine; +class QDownloadNetworkWorker; +class QDownloadHelperService; +class QDownloadHelperServicePrivate; + +class QT3DCORESHARED_EXPORT QDownloadRequest +{ +public: + QDownloadRequest(const QUrl &url); + virtual ~QDownloadRequest(); + + QUrl url() const { return m_url; } + bool succeeded() const { return m_succeeded; } + bool cancelled() const { return m_cancelled; } + + virtual void onDownloaded(); // this is called in dl thread + virtual void onCompleted() = 0; // this is called in job thread + +protected: + QUrl m_url; + QByteArray m_data; + +private: + friend class QDownloadNetworkWorker; + friend class QDownloadHelperService; + bool m_succeeded; + bool m_cancelled; +}; + +typedef QSharedPointer<QDownloadRequest> QDownloadRequestPtr; + + +class QT3DCORESHARED_EXPORT QDownloadHelperService : public QAbstractServiceProvider +{ + Q_OBJECT +public: + explicit QDownloadHelperService(const QString &description = QString()); + ~QDownloadHelperService(); + + void submitRequest(const QDownloadRequestPtr &request); + void cancelRequest(const QDownloadRequestPtr &request); + void cancelAllRequests(); + + static QString urlToLocalFileOrQrc(const QUrl &url); + static bool isLocal(const QUrl &url); + static QDownloadHelperService *getService(QAspectEngine *engine); + +private: + Q_DECLARE_PRIVATE(QDownloadHelperService) + Q_PRIVATE_SLOT(d_func(), void _q_onRequestCompleted(const Qt3DCore::QDownloadRequestPtr &)) +}; + +typedef QSharedPointer<QDownloadHelperService> QDownloadHelperServicePtr; + +} // namespace Qt3DCore + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(Qt3DCore::QDownloadRequestPtr) // LCOV_EXCL_LINE + +#endif // QT3DCORE_QDOWNLOADHELPERSERVICE_P_H diff --git a/src/core/services/qdownloadhelperservice_p_p.h b/src/core/services/qdownloadhelperservice_p_p.h new file mode 100644 index 000000000..202ae5236 --- /dev/null +++ b/src/core/services/qdownloadhelperservice_p_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Paul Lemire +** 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_QDOWNLOADHELPERSERVICE_P_P_H +#define QT3DCORE_QDOWNLOADHELPERSERVICE_P_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 <QSharedPointer> +#include <QObject> +#include <QUrl> + +#include <Qt3DCore/qaspectjob.h> +#include <Qt3DCore/private/qservicelocator_p.h> +#include <Qt3DCore/private/qdownloadhelperservice_p.h> +#include <Qt3DCore/private/qabstractserviceprovider_p.h> + +QT_BEGIN_NAMESPACE + +class QThread; +class QNetworkAccessManager; +class QNetworkReply; + +namespace Qt3DCore { + + +} // namespace Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QDOWNLOADHELPERSERVICE_P_P_H diff --git a/src/core/services/qdownloadnetworkworker.cpp b/src/core/services/qdownloadnetworkworker.cpp new file mode 100644 index 000000000..c728a1779 --- /dev/null +++ b/src/core/services/qdownloadnetworkworker.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 "qdownloadhelperservice_p.h" +#include "qdownloadnetworkworker_p.h" + +#include <QNetworkAccessManager> +#include <QNetworkRequest> +#include <QNetworkReply> +#include <QDataStream> + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +QDownloadNetworkWorker::QDownloadNetworkWorker(QObject *parent) + : QObject(parent) + , m_networkManager(nullptr) +{ + connect(this, &QDownloadNetworkWorker::submitRequest, + this, &QDownloadNetworkWorker::onRequestSubmited); + connect(this, &QDownloadNetworkWorker::cancelRequest, + this, &QDownloadNetworkWorker::onRequestCancelled); + connect(this, &QDownloadNetworkWorker::cancelAllRequests, + this, &QDownloadNetworkWorker::onAllRequestsCancelled); +} + +void QDownloadNetworkWorker::onRequestSubmited(const QDownloadRequestPtr &request) +{ + QMutexLocker l(&m_mutex); + if (!m_networkManager) { + m_networkManager = new QNetworkAccessManager(this); + connect(m_networkManager, &QNetworkAccessManager::finished, + this, &QDownloadNetworkWorker::onRequestFinished); + } + auto reply = m_networkManager->get(QNetworkRequest(request->url())); + m_requests << QPair<QDownloadRequestPtr, QNetworkReply *>(request, reply); + connect(reply, &QNetworkReply::downloadProgress, this, &QDownloadNetworkWorker::onDownloadProgressed); +} + +void QDownloadNetworkWorker::onRequestCancelled(const QDownloadRequestPtr &request) +{ + QMutexLocker l(&m_mutex); + auto it = std::find_if(m_requests.begin(), m_requests.end(), + [request](QPair<QDownloadRequestPtr, QNetworkReply *> e) { + return e.first == request; + }); + if (it == m_requests.end()) + return; + + (*it).first->m_cancelled = true; + (*it).second->abort(); +} + +void QDownloadNetworkWorker::onAllRequestsCancelled() +{ + QMutexLocker l(&m_mutex); + for (auto e: qAsConst(m_requests)) { + e.first->m_cancelled = true; + e.second->abort(); + } + m_requests.clear(); +} + +void QDownloadNetworkWorker::onRequestFinished(QNetworkReply *reply) +{ + QMutexLocker l(&m_mutex); + auto it = std::find_if(m_requests.begin(), m_requests.end(), + [reply](QPair<QDownloadRequestPtr, QNetworkReply *> e) { + return e.second == reply; + }); + if (it == m_requests.end()) + return; + + auto request = (*it).first; + if (reply->error() == QNetworkReply::NoError) { + request->m_succeeded = true; + } + request->onDownloaded(); + emit requestDownloaded(request); + + m_requests.erase(it); +} + +void QDownloadNetworkWorker::onDownloadProgressed(qint64 bytesReceived, qint64 bytesTotal) +{ + Q_UNUSED(bytesReceived); + Q_UNUSED(bytesTotal); + // TODO forward progress details somewhere + + QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender()); + if (!reply) + return; + + QMutexLocker l(&m_mutex); + auto it = std::find_if(m_requests.begin(), m_requests.end(), + [reply](QPair<QDownloadRequestPtr, QNetworkReply *> e) { + return e.second == reply; + }); + if (it == m_requests.end()) + return; + + auto request = (*it).first; + QDataStream stream(&request->m_data, QIODevice::Append); + QByteArray data = reply->readAll(); + stream.writeRawData(data.data(), data.size()); +} + +} // namespace Qt3DCore + +QT_END_NAMESPACE + diff --git a/src/core/services/qdownloadnetworkworker_p.h b/src/core/services/qdownloadnetworkworker_p.h new file mode 100644 index 000000000..faecbca2f --- /dev/null +++ b/src/core/services/qdownloadnetworkworker_p.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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_QDOWNLOADNETWORKWORKER_P_H +#define QT3DCORE_QDOWNLOADNETWORKWORKER_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 <QSharedPointer> +#include <QObject> +#include <QUrl> +#include <Qt3DCore/private/qdownloadhelperservice_p.h> +#include <QMutex> + +QT_BEGIN_NAMESPACE + +class QThread; +class QNetworkAccessManager; +class QNetworkReply; + +namespace Qt3DCore { + +class QDownloadRequest; +typedef QSharedPointer<QDownloadRequest> QDownloadRequestPtr; + +class QDownloadNetworkWorker : public QObject +{ + Q_OBJECT +public: + QDownloadNetworkWorker(QObject *parent = nullptr); + +signals: + void submitRequest(const Qt3DCore::QDownloadRequestPtr &request); + void cancelRequest(const Qt3DCore::QDownloadRequestPtr &request); + void cancelAllRequests(); + + void requestDownloaded(const Qt3DCore::QDownloadRequestPtr &request); + +private Q_SLOTS: + void onRequestSubmited(const Qt3DCore::QDownloadRequestPtr &request); + void onRequestCancelled(const Qt3DCore::QDownloadRequestPtr &request); + void onAllRequestsCancelled(); + void onRequestFinished(QNetworkReply *reply); + void onDownloadProgressed(qint64 bytesReceived, qint64 bytesTotal); + +private: + QNetworkAccessManager *m_networkManager; + QVector< QPair<QDownloadRequestPtr, QNetworkReply *> > m_requests; + QMutex m_mutex; +}; + +} // namespace Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QDOWNLOADNETWORKWORKER_P_H diff --git a/src/core/services/qeventfilterservice.cpp b/src/core/services/qeventfilterservice.cpp index 489ab9b45..6584c5e24 100644 --- a/src/core/services/qeventfilterservice.cpp +++ b/src/core/services/qeventfilterservice.cpp @@ -38,10 +38,12 @@ ****************************************************************************/ #include "qeventfilterservice_p.h" -#include "qabstractserviceprovider_p.h" -#include <QMap> -#include <QObject> -#include <QVector> + +#include <QtCore/QMap> +#include <QtCore/QObject> +#include <QtCore/QVector> + +#include <Qt3DCore/private/qabstractserviceprovider_p.h> QT_BEGIN_NAMESPACE @@ -83,6 +85,8 @@ public: : QAbstractServiceProviderPrivate(QServiceLocator::EventFilterService, QStringLiteral("Default event filter service implementation")) {} + Q_DECLARE_PUBLIC(QEventFilterService) + void registerEventFilter(QObject *eventFilter, int priority) { for (int i = 0, m = m_eventFilters.size(); i < m; ++i) diff --git a/src/core/services/qeventfilterservice_p.h b/src/core/services/qeventfilterservice_p.h index 4962e2af6..58b87d9cc 100644 --- a/src/core/services/qeventfilterservice_p.h +++ b/src/core/services/qeventfilterservice_p.h @@ -52,6 +52,7 @@ // #include <Qt3DCore/qt3dcore_global.h> + #include <Qt3DCore/private/qservicelocator_p.h> QT_BEGIN_NAMESPACE @@ -62,6 +63,7 @@ class QEventFilterServicePrivate; class QT3DCORESHARED_EXPORT QEventFilterService : public QAbstractServiceProvider { + Q_OBJECT public: QEventFilterService(); ~QEventFilterService(); diff --git a/src/core/services/qopenglinformationservice.cpp b/src/core/services/qopenglinformationservice.cpp index 0f62544c8..c1c05018e 100644 --- a/src/core/services/qopenglinformationservice.cpp +++ b/src/core/services/qopenglinformationservice.cpp @@ -62,7 +62,7 @@ namespace Qt3DCore { instantiate a QOpenGLInformationService object. */ QOpenGLInformationService::QOpenGLInformationService(const QString &description) - : QAbstractServiceProvider(QServiceLocator::OpenGLInformation, description) + : QAbstractServiceProvider(*new QOpenGLInformationServicePrivate(description)) { } diff --git a/src/core/services/qopenglinformationservice_p.h b/src/core/services/qopenglinformationservice_p.h index a2c37c29a..2adf73307 100644 --- a/src/core/services/qopenglinformationservice_p.h +++ b/src/core/services/qopenglinformationservice_p.h @@ -52,9 +52,10 @@ // #include <Qt3DCore/qt3dcore_global.h> -#include <Qt3DCore/private/qservicelocator_p.h> -#include <QtGui/qsurfaceformat.h> #include <QtCore/qstring.h> +#include <QtGui/qsurfaceformat.h> + +#include <Qt3DCore/private/qservicelocator_p.h> QT_BEGIN_NAMESPACE @@ -64,6 +65,7 @@ class QOpenGLInformationServicePrivate; class QT3DCORESHARED_EXPORT QOpenGLInformationService : public QAbstractServiceProvider { + Q_OBJECT public: virtual QSurfaceFormat format() const = 0; diff --git a/src/core/services/qopenglinformationservice_p_p.h b/src/core/services/qopenglinformationservice_p_p.h index 4abef6f18..d10d81d71 100644 --- a/src/core/services/qopenglinformationservice_p_p.h +++ b/src/core/services/qopenglinformationservice_p_p.h @@ -52,6 +52,7 @@ // #include <Qt3DCore/qt3dcore_global.h> + #include <Qt3DCore/private/qabstractserviceprovider_p.h> #include <Qt3DCore/private/qservicelocator_p.h> diff --git a/src/core/services/qservicelocator.cpp b/src/core/services/qservicelocator.cpp index 3d3d56386..bdcb4a521 100644 --- a/src/core/services/qservicelocator.cpp +++ b/src/core/services/qservicelocator.cpp @@ -38,11 +38,15 @@ ****************************************************************************/ #include "qservicelocator_p.h" -#include "qabstractserviceprovider_p.h" -#include "nullservices_p.h" -#include "qtickclockservice_p.h" -#include "qeventfilterservice_p.h" -#include <QHash> + +#include <QtCore/QHash> + +#include <Qt3DCore/private/nullservices_p.h> +#include <Qt3DCore/private/qabstractserviceprovider_p.h> +#include <Qt3DCore/private/qdownloadhelperservice_p.h> +#include <Qt3DCore/private/qeventfilterservice_p.h> +#include <Qt3DCore/private/qtickclockservice_p.h> + QT_BEGIN_NAMESPACE @@ -53,17 +57,15 @@ namespace Qt3DCore { \inmodule Qt3DCore */ -QAbstractServiceProvider::QAbstractServiceProvider(int type, const QString &description) - : d_ptr(new QAbstractServiceProviderPrivate(type, description)) +QAbstractServiceProvider::QAbstractServiceProvider(int type, const QString &description, QObject *parent) + : QObject(*new QAbstractServiceProviderPrivate(type, description), parent) { - d_ptr->q_ptr = this; } /* \internal */ -QAbstractServiceProvider::QAbstractServiceProvider(QAbstractServiceProviderPrivate &dd) - : d_ptr(&dd) +QAbstractServiceProvider::QAbstractServiceProvider(QAbstractServiceProviderPrivate &dd, QObject *parent) + : QObject(dd, parent) { - d_ptr->q_ptr = this; } QAbstractServiceProvider::~QAbstractServiceProvider() @@ -96,6 +98,7 @@ public: NullOpenGLInformationService m_nullOpenGLInfo; QTickClockService m_defaultFrameAdvanceService; QEventFilterService m_eventFilterService; + QDownloadHelperService m_downloadHelperService; int m_nonNullDefaultServices; }; @@ -229,6 +232,12 @@ QEventFilterService *QServiceLocator::eventFilterService() return static_cast<QEventFilterService *>(d->m_services.value(EventFilterService, &d->m_eventFilterService)); } +QDownloadHelperService *QServiceLocator::downloadHelperService() +{ + Q_D(QServiceLocator); + return static_cast<QDownloadHelperService *>(d->m_services.value(DownloadHelperService, &d->m_downloadHelperService)); +} + /* \internal */ @@ -244,6 +253,8 @@ QAbstractServiceProvider *QServiceLocator::_q_getServiceHelper(int type) return frameAdvanceService(); case EventFilterService: return eventFilterService(); + case DownloadHelperService: + return downloadHelperService(); default: return d->m_services.value(type, nullptr); } diff --git a/src/core/services/qservicelocator_p.h b/src/core/services/qservicelocator_p.h index c68b56ffd..9534b33ce 100644 --- a/src/core/services/qservicelocator_p.h +++ b/src/core/services/qservicelocator_p.h @@ -52,7 +52,8 @@ // #include <Qt3DCore/qt3dcore_global.h> -#include <QScopedPointer> +#include <QtCore/qobject.h> +#include <QtCore/qscopedpointer.h> QT_BEGIN_NAMESPACE @@ -60,8 +61,9 @@ namespace Qt3DCore { class QAbstractServiceProviderPrivate; -class QT3DCORESHARED_EXPORT QAbstractServiceProvider +class QT3DCORESHARED_EXPORT QAbstractServiceProvider : public QObject { + Q_OBJECT public: virtual ~QAbstractServiceProvider(); @@ -69,9 +71,8 @@ public: QString description() const; protected: - QAbstractServiceProvider(int type, const QString &description); - QAbstractServiceProvider(QAbstractServiceProviderPrivate &dd); - QScopedPointer<QAbstractServiceProviderPrivate> d_ptr; + explicit QAbstractServiceProvider(int type, const QString &description, QObject* parent = nullptr); + explicit QAbstractServiceProvider(QAbstractServiceProviderPrivate &dd, QObject* parent = nullptr); private: Q_DISABLE_COPY(QAbstractServiceProvider) @@ -83,6 +84,7 @@ class QOpenGLInformationService; class QSystemInformationService; class QServiceLocatorPrivate; class QEventFilterService; +class QDownloadHelperService; class QT3DCORESHARED_EXPORT QServiceLocator { @@ -96,6 +98,7 @@ public: CollisionService, FrameAdvanceService, EventFilterService, + DownloadHelperService, #if !defined(Q_QDOC) DefaultServiceCount, // Add additional default services before here #endif @@ -119,6 +122,7 @@ public: QOpenGLInformationService *openGLInformation(); QAbstractFrameAdvanceService *frameAdvanceService(); QEventFilterService *eventFilterService(); + QDownloadHelperService *downloadHelperService(); private: Q_DISABLE_COPY(QServiceLocator) diff --git a/src/core/services/qsysteminformationservice_p.h b/src/core/services/qsysteminformationservice_p.h index dc384fb93..01e976b77 100644 --- a/src/core/services/qsysteminformationservice_p.h +++ b/src/core/services/qsysteminformationservice_p.h @@ -52,9 +52,10 @@ // #include <Qt3DCore/qt3dcore_global.h> -#include <Qt3DCore/private/qservicelocator_p.h> #include <QtCore/qstringlist.h> +#include <Qt3DCore/private/qservicelocator_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { @@ -63,6 +64,7 @@ class QSystemInformationServicePrivate; class QT3DCORESHARED_EXPORT QSystemInformationService : public QAbstractServiceProvider { + Q_OBJECT public: virtual QStringList aspectNames() const = 0; virtual int threadPoolThreadCount() const = 0; diff --git a/src/core/services/qsysteminformationservice_p_p.h b/src/core/services/qsysteminformationservice_p_p.h index 897caf62b..e3ce9fe49 100644 --- a/src/core/services/qsysteminformationservice_p_p.h +++ b/src/core/services/qsysteminformationservice_p_p.h @@ -52,6 +52,7 @@ // #include <Qt3DCore/qt3dcore_global.h> + #include <Qt3DCore/private/qabstractserviceprovider_p.h> #include <Qt3DCore/private/qservicelocator_p.h> diff --git a/src/core/services/qtickclockservice.cpp b/src/core/services/qtickclockservice.cpp index 3691959ed..225e70ec2 100644 --- a/src/core/services/qtickclockservice.cpp +++ b/src/core/services/qtickclockservice.cpp @@ -38,9 +38,10 @@ ****************************************************************************/ #include "qtickclockservice_p.h" -#include "qtickclock_p.h" -#include "qabstractframeadvanceservice_p.h" -#include "qabstractframeadvanceservice_p_p.h" + +#include <Qt3DCore/private/qabstractframeadvanceservice_p.h> +#include <Qt3DCore/private/qabstractframeadvanceservice_p_p.h> +#include <Qt3DCore/private/qtickclock_p.h> QT_BEGIN_NAMESPACE diff --git a/src/core/services/qtickclockservice_p.h b/src/core/services/qtickclockservice_p.h index b84018d0b..6f02643f4 100644 --- a/src/core/services/qtickclockservice_p.h +++ b/src/core/services/qtickclockservice_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "qabstractframeadvanceservice_p.h" +#include <Qt3DCore/private/qabstractframeadvanceservice_p.h> QT_BEGIN_NAMESPACE @@ -61,6 +61,7 @@ class QTickClockServicePrivate; class QTickClockService : public QAbstractFrameAdvanceService { + Q_OBJECT public: QTickClockService(); ~QTickClockService(); diff --git a/src/core/services/services.pri b/src/core/services/services.pri index ae0cfd9f8..f311b8329 100644 --- a/src/core/services/services.pri +++ b/src/core/services/services.pri @@ -5,7 +5,9 @@ SOURCES += \ $$PWD/qopenglinformationservice.cpp \ $$PWD/qtickclockservice.cpp \ $$PWD/qabstractframeadvanceservice.cpp \ - $$PWD/qeventfilterservice.cpp + $$PWD/qeventfilterservice.cpp \ + $$PWD/qdownloadhelperservice.cpp \ + $$PWD/qdownloadnetworkworker.cpp HEADERS += \ $$PWD/qservicelocator_p.h \ @@ -18,6 +20,8 @@ HEADERS += \ $$PWD/qtickclockservice_p.h \ $$PWD/qabstractframeadvanceservice_p.h \ $$PWD/qabstractframeadvanceservice_p_p.h \ - $$PWD/qeventfilterservice_p.h + $$PWD/qeventfilterservice_p.h \ + $$PWD/qdownloadhelperservice_p.h \ + $$PWD/qdownloadnetworkworker_p.h INCLUDEPATH += $$PWD diff --git a/src/core/transforms/qmath3d_p.h b/src/core/transforms/qmath3d_p.h index 38ebbd99a..8c2afac31 100644 --- a/src/core/transforms/qmath3d_p.h +++ b/src/core/transforms/qmath3d_p.h @@ -50,7 +50,6 @@ // // We mean it. // - #include <QtGui/qmatrix4x4.h> #include <QtGui/qquaternion.h> #include <QtGui/qvector3d.h> diff --git a/src/core/transforms/qtransform.cpp b/src/core/transforms/qtransform.cpp index d28138cad..a551d83d8 100644 --- a/src/core/transforms/qtransform.cpp +++ b/src/core/transforms/qtransform.cpp @@ -39,10 +39,11 @@ #include "qtransform.h" #include "qtransform_p.h" -#include "qmath3d_p.h" #include <Qt3DCore/qpropertyupdatedchange.h> +#include <Qt3DCore/private/qmath3d_p.h> + QT_BEGIN_NAMESPACE namespace Qt3DCore { diff --git a/src/core/transforms/qtransform.h b/src/core/transforms/qtransform.h index 25b1da8cd..cb2b1bdce 100644 --- a/src/core/transforms/qtransform.h +++ b/src/core/transforms/qtransform.h @@ -41,7 +41,6 @@ #define QT3DCORE_QTRANSFORM_H #include <Qt3DCore/qcomponent.h> - #include <QtGui/qmatrix4x4.h> #include <QtGui/qquaternion.h> #include <QtGui/qvector3d.h> diff --git a/src/core/transforms/qtransform_p.h b/src/core/transforms/qtransform_p.h index 8d1a60566..89bc55491 100644 --- a/src/core/transforms/qtransform_p.h +++ b/src/core/transforms/qtransform_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <private/qcomponent_p.h> +#include <Qt3DCore/private/qcomponent_p.h> QT_BEGIN_NAMESPACE |