summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-11-29 19:09:21 +0000
committerSean Harmer <sean.harmer@kdab.com>2016-01-01 09:58:26 +0000
commit992faf509586275fdec707524da094830fcbda23 (patch)
treeb5e311b1dc9ffcbac96120c504da39ae93efe931 /tools
parent210fb8d762fee838c5acd2b76b94ccda0c8b448e (diff)
Add template for QtCreator to create subclasses of some Qt3D types
Change-Id: I050e45a8b2e884ec9ee805fa9ddcbafe705802c3 Reviewed-by: Mike Krus <mike.krus@kdab.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/utils/qtcreator/README5
-rw-r--r--tools/utils/qtcreator/templates/wizards/classes/qt3d/file.cpp42
-rw-r--r--tools/utils/qtcreator/templates/wizards/classes/qt3d/file.h54
-rw-r--r--tools/utils/qtcreator/templates/wizards/classes/qt3d/file_p.h39
-rw-r--r--tools/utils/qtcreator/templates/wizards/classes/qt3d/wizard.json138
5 files changed, 278 insertions, 0 deletions
diff --git a/tools/utils/qtcreator/README b/tools/utils/qtcreator/README
new file mode 100644
index 000000000..d732f30f5
--- /dev/null
+++ b/tools/utils/qtcreator/README
@@ -0,0 +1,5 @@
+This directory contains some templates for use with QtCreator. Install them
+into your QtCreator's respective directory by symlinking or copying into
+place. E.g.:
+
+ln -s templates/wizards/classes/qt3d $QTCREATOR/share/qtcreator/templates/wizards/classes/qt3d
diff --git a/tools/utils/qtcreator/templates/wizards/classes/qt3d/file.cpp b/tools/utils/qtcreator/templates/wizards/classes/qt3d/file.cpp
new file mode 100644
index 000000000..03d99bdbc
--- /dev/null
+++ b/tools/utils/qtcreator/templates/wizards/classes/qt3d/file.cpp
@@ -0,0 +1,42 @@
+%{Cpp:LicenseTemplate}\
+#include "%{HdrFileName}"
+#include "%{PrivateHdrFileName}"
+
+QT_BEGIN_NAMESPACE
+%{JS: Cpp.openNamespaces('%{Class}')}
+@if '%{Base}' === 'QNode' || '%{Base}' === 'QComponent' || '%{Base}' === 'QEntity'
+%{CN}Private::%{CN}Private()
+ : Qt3DCore::%{Base}Private()
+{
+}
+
+%{CN}::%{CN}(Qt3DCore::QNode *parent)
+ : Qt3DCore::%{Base}(*new %{CN}Private, parent)
+{
+}
+
+%{CN}::%{CN}(%{CN}Private &dd, Qt3DCore::QNode *parent)
+ : Qt3DCore::%{Base}(dd, parent)
+{
+}
+
+%{CN}::~%{CN}()
+{
+ QNode::cleanup();
+}
+@else
+// TODO: Implement QBackendNode template
+@endif
+
+@if '%{Base}' === 'QNode' || '%{Base}' === 'QComponent' || '%{Base}' === 'QEntity'
+void %{CN}::copy(const QNode *ref)
+{
+ %{Base}::copy(ref);
+ const %{CN} *object = static_cast<const %{CN} *>(ref);
+
+ // TODO: Copy the objects's members
+}
+@endif
+%{JS: Cpp.closeNamespaces('%{Class}')}\
+
+QT_END_NAMESPACE
diff --git a/tools/utils/qtcreator/templates/wizards/classes/qt3d/file.h b/tools/utils/qtcreator/templates/wizards/classes/qt3d/file.h
new file mode 100644
index 000000000..050e58ce5
--- /dev/null
+++ b/tools/utils/qtcreator/templates/wizards/classes/qt3d/file.h
@@ -0,0 +1,54 @@
+%{Cpp:LicenseTemplate}\
+#ifndef %{GUARD}
+#define %{GUARD}
+
+@if '%{Base}' === 'QNode'
+#include <Qt3DCore/qnode.h>
+@elsif '%{Base}' === 'QComponent'
+#include <Qt3DCore/qcomponent.h>
+@elsif '%{Base}' === 'QEntity'
+#include <Qt3DCore/qentity.h>
+@elsif '%{Base}' === 'QBackendNode'
+#include <Qt3DCore/qbackendnode.h>
+@endif
+
+QT_BEGIN_NAMESPACE
+%{JS: Cpp.openNamespaces('%{Class}')}
+class %{CN}Private;
+
+@if '%{Base}'
+class %{CN} : public Qt3DCore::%{Base}
+@else
+class %{CN}
+@endif
+{
+@if %{isQObject}
+ Q_OBJECT
+ // TODO: Add property declarations
+@endif
+public:
+@if '%{Base}' === 'QNode' || '%{Base}' === 'QComponent' || '%{Base}' === 'QEntity'
+ explicit %{CN}(Qt3DCore::QNode *parent = 0);
+@else
+ %{CN}();
+@endif
+ ~%{CN}();
+
+public Q_SLOTS:
+
+Q_SIGNALS:
+
+@if '%{Base}' === 'QNode' || '%{Base}' === 'QComponent' || '%{Base}' === 'QEntity'
+protected:
+ Q_DECLARE_PRIVATE(%{CN})
+ %{CN}(%{CN}Private &dd, Qt3DCore::QNode *parent = 0);
+ void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
+
+private:
+ QT3D_CLONEABLE(%{CN})
+@endif
+};
+%{JS: Cpp.closeNamespaces('%{Class}')}
+QT_END_NAMESPACE
+
+#endif // %{GUARD}\
diff --git a/tools/utils/qtcreator/templates/wizards/classes/qt3d/file_p.h b/tools/utils/qtcreator/templates/wizards/classes/qt3d/file_p.h
new file mode 100644
index 000000000..420f2edef
--- /dev/null
+++ b/tools/utils/qtcreator/templates/wizards/classes/qt3d/file_p.h
@@ -0,0 +1,39 @@
+%{Cpp:LicenseTemplate}\
+#ifndef %{PRIVATEGUARD}
+#define %{PRIVATEGUARD}
+
+//
+// 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.
+//
+
+@if '%{Base}' === 'QNode'
+#include <Qt3DCore/private/qnode_p.h>
+@elsif '%{Base}' === 'QComponent'
+#include <Qt3DCore/private/qcomponent_p.h>
+@elsif '%{Base}' === 'QEntity'
+#include <Qt3DCore/private/qentity_p.h>
+@elsif '%{Base}' === 'QBackendNode'
+#include <Qt3DCore/private/qbackendnode_p.h>
+@endif
+
+QT_BEGIN_NAMESPACE
+%{JS: Cpp.openNamespaces('%{Class}')}
+class %{CN}Private : public Qt3DCore::%{Base}Private
+{
+public:
+ %{CN}Private();
+
+
+};
+%{JS: Cpp.closeNamespaces('%{Class}')}
+
+QT_END_NAMESPACE
+
+#endif // %{PRIVATEGUARD}\
diff --git a/tools/utils/qtcreator/templates/wizards/classes/qt3d/wizard.json b/tools/utils/qtcreator/templates/wizards/classes/qt3d/wizard.json
new file mode 100644
index 000000000..de7053d08
--- /dev/null
+++ b/tools/utils/qtcreator/templates/wizards/classes/qt3d/wizard.json
@@ -0,0 +1,138 @@
+{
+ "version": 1,
+ "kind": "file",
+ "id": "D.Qt3DClass",
+ "category": "O.C++",
+ "trDescription": "Creates a Qt3D class consisting of a C++ header, source file and private header for a new component that you can add to a C++ project.",
+ "trDisplayName": "Qt3D Class",
+ "trDisplayCategory": "C++",
+ "icon": "../../global/genericfilewizard.png",
+ "enabled": "%{JS: [ %{Plugins} ].indexOf('CppEditor') >= 0}",
+
+ "options":
+ [
+ { "key": "TargetPath", "value": "%{Path}" },
+ { "key": "HdrPath", "value": "%{Path}/%{HdrFileName}" },
+ { "key": "PrivateHdrPath", "value": "%{Path}/%{PrivateHdrFileName}" },
+ { "key": "SrcPath", "value": "%{Path}/%{SrcFileName}" },
+ { "key": "CN", "value": "%{JS: Cpp.className('%{Class}')}" },
+ { "key": "Base", "value": "%{JS: ( '%{BaseCB}' === '' ) ? '%{BaseEdit}' : '%{BaseCB}'}" },
+ { "key": "isQObject", "value": "%{JS: [ 'QNode', 'QComponent', 'QEntity'].indexOf('%{Base}') >= 0 }" },
+ { "key": "GUARD", "value": "%{JS: Cpp.classToHeaderGuard('%{Class}', '%{JS: Util.preferredSuffix('text/x-c++hdr')}')}" },
+ { "key": "PRIVATEGUARD", "value": "%{JS: Cpp.classToHeaderGuard('%{Class}' + '_P', '%{JS: Util.preferredSuffix('text/x-c++hdr')}')}" },
+ { "key": "SharedDataInit", "value": "%{JS: ('%{IncludeQSharedData}') ? 'data(new %{CN}Data)' : '' }" },
+ { "key": "IncludeQNode", "value": "%{JS: '%{BaseCB}' === 'QNode'}" },
+ { "key": "IncludeQComponent", "value": "%{JS: '%{BaseCB}' === 'QComponent'}" },
+ { "key": "IncludeQEntity", "value": "%{JS: '%{BaseCB}' === 'QEntity'}" },
+ { "key": "IncludeQBackendNode", "value": "%{JS: '%{BaseCB}' === 'QBackendNode'}" }
+ ],
+
+ "pages":
+ [
+ {
+ "trDisplayName": "Define Qt3D Class",
+ "trShortTitle": "Details",
+ "typeId": "Fields",
+ "data" :
+ [
+ {
+ "name": "Class",
+ "trDisplayName": "Class name:",
+ "mandatory": true,
+ "type": "LineEdit",
+ "data": { "validator": "(?:(?:[a-zA-Z_][a-zA-Z_0-9]*::)+[a-zA-Z_][a-zA-Z_0-9]*|)" }
+ },
+ {
+ "name": "BaseCB",
+ "trDisplayName": "Base class:",
+ "type": "ComboBox",
+ "data":
+ {
+ "items": [ { "trKey": "<Custom>", "value": "" },
+ "QQNode", "QComponent", "QEntity", "QBackendNode" ]
+ }
+ },
+ {
+ "name": "BaseEdit",
+ "type": "LineEdit",
+ "enabled": "%{JS: '%{BaseCB}' === ''}",
+ "mandatory": false,
+ "data":
+ {
+ "trText": "%{BaseCB}",
+ "trDisabledText": "%{BaseCB}"
+ }
+ },
+
+ {
+ "name": "Sp1",
+ "type": "Spacer",
+ "data": { "factor": 2 }
+ },
+ {
+ "name": "HdrFileName",
+ "type": "LineEdit",
+ "trDisplayName": "Header file:",
+ "mandatory": true,
+ "data": { "trText": "%{JS: Cpp.classToFileName('%{Class}', '%{JS: Util.preferredSuffix('text/x-c++hdr')}')}" }
+ },
+ {
+ "name": "PrivateHdrFileName",
+ "type": "LineEdit",
+ "trDisplayName": "Private header file:",
+ "mandatory": true,
+ "data": { "trText": "%{JS: Cpp.classToFileName('%{Class}' + '_p', '%{JS: Util.preferredSuffix('text/x-c++hdr')}')}" }
+ },
+ {
+ "name": "SrcFileName",
+ "type": "LineEdit",
+ "trDisplayName": "Source file:",
+ "mandatory": true,
+ "data": { "trText": "%{JS: Cpp.classToFileName('%{Class}', '%{JS: Util.preferredSuffix('text/x-c++src')}')}" }
+ },
+ {
+ "name": "Path",
+ "type": "PathChooser",
+ "trDisplayName": "Path:",
+ "mandatory": true,
+ "data":
+ {
+ "kind": "existingDirectory",
+ "basePath": "%{InitialPath}",
+ "path": "%{InitialPath}"
+ }
+ }
+ ]
+ },
+ {
+ "trDisplayName": "Project Management",
+ "trShortTitle": "Summary",
+ "typeId": "Summary"
+ }
+ ],
+
+ "generators":
+ [
+ {
+ "typeId": "File",
+ "data":
+ [
+ {
+ "source": "file.h",
+ "target": "%{HdrPath}",
+ "openInEditor": true
+ },
+ {
+ "source": "file_p.h",
+ "target": "%{PrivateHdrPath}",
+ "openInEditor": true
+ },
+ {
+ "source": "file.cpp",
+ "target": "%{SrcPath}",
+ "openInEditor": true
+ }
+ ]
+ }
+ ]
+}