diff options
author | Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com> | 2017-01-13 10:52:19 +0100 |
---|---|---|
committer | Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com> | 2017-01-13 10:52:19 +0100 |
commit | af48c23a7180285e4159c0235b8f1a3c09fe8309 (patch) | |
tree | fd5f31c0b6c488467e3df8124683b79f28c81aaf /examples/qtcpp/generator/templates | |
parent | 440e3fe4818100d9164491f609148fdcca8f7089 (diff) | |
download | qtivi-qface-af48c23a7180285e4159c0235b8f1a3c09fe8309.tar.gz |
Extracted the qtcpp builtin generator into own folder started to re-layout the examples folder.
Diffstat (limited to 'examples/qtcpp/generator/templates')
-rw-r--r-- | examples/qtcpp/generator/templates/abstractinterface.cpp | 53 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/abstractinterface.h | 51 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/generated.pri | 31 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/interface.cpp | 35 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/interface.h | 23 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/module.cpp | 46 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/module.h | 40 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/plugin.cpp | 26 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/plugin.h | 18 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/plugin.pro | 47 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/qmldir | 3 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/struct.cpp | 21 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/struct.h | 29 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/structmodel.cpp | 106 | ||||
-rw-r--r-- | examples/qtcpp/generator/templates/structmodel.h | 40 |
15 files changed, 0 insertions, 569 deletions
diff --git a/examples/qtcpp/generator/templates/abstractinterface.cpp b/examples/qtcpp/generator/templates/abstractinterface.cpp deleted file mode 100644 index e0ac7cc..0000000 --- a/examples/qtcpp/generator/templates/abstractinterface.cpp +++ /dev/null @@ -1,53 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -{% set class = 'QmlAbstract{0}'.format(interface) %} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#include "{{class|lower}}.h" - -#include <QtQml> - -{{interface.comment}} -{{class}}::{{class}}(QObject *parent) - : QObject(parent) -{% for property in interface.properties %} - , m_{{property}}({{property|defaultValue}}) -{% endfor %} -{ -} - -{{class}}::~{{class}}() -{ -} - -{% for property in interface.properties %} -{% if not property.is_readonly %} -void {{class}}::set{{property|upperfirst}}({{ property|parameterType }}) -{ - if(m_{{property}} == {{property}}) { - return; - } - m_{{property}} = {{property}}; - emit {{property}}Changed(); -} -{% endif %} - -{{property|returnType}} {{class}}::{{property}}() const -{ - return m_{{property}}; -} -{% endfor %} - -{%- for operation in interface.operations %} -{{operation|returnType}} {{class}}::{{operation}}({{operation.parameters|map('parameterType')|join(', ')}}) -{ - {% for parameter in operation.parameters %} - Q_UNUSED({{parameter.name}}); - {% endfor %} - qWarning() << "{{class}}::{{operation}}(...) not implemented"; - return {{operation|defaultValue}}; -} -{% endfor %} - diff --git a/examples/qtcpp/generator/templates/abstractinterface.h b/examples/qtcpp/generator/templates/abstractinterface.h deleted file mode 100644 index 1f8474e..0000000 --- a/examples/qtcpp/generator/templates/abstractinterface.h +++ /dev/null @@ -1,51 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -{% set class = 'QmlAbstract{0}'.format(interface) %} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#pragma once - -#include <QtCore> - -#include "qml{{module.module_name|lower}}module.h" - -class {{class}} : public QObject -{ - Q_OBJECT -{% for property in interface.properties %} - Q_PROPERTY({{property|returnType}} {{property}} READ {{property}} {%if not property.is_readonly%}WRITE set{{property|upperfirst}} {%endif%}NOTIFY {{property}}Changed) -{% endfor %} - -public: - {{class}}(QObject *parent=0); - ~{{class}}(); - -public Q_SLOTS: -{% for operation in interface.operations %} - virtual {{operation|returnType}} {{operation}}({{operation.parameters|map('parameterType')|join(', ')}}); -{% endfor %} - -public: -{% for property in interface.properties %} -{% if not property.is_readonly %} - virtual void set{{property|upperfirst}}({{ property|parameterType }}); -{% endif %} -{% endfor %} - -public: -{% for property in interface.properties %} - virtual {{property|returnType}} {{property}}() const; -{% endfor %} - -Q_SIGNALS: -{% for property in interface.properties %} - void {{property}}Changed(); -{% endfor %} - -protected: -{% for property in interface.properties %} - {{property|returnType}} m_{{property}}; -{% endfor %} -}; diff --git a/examples/qtcpp/generator/templates/generated.pri b/examples/qtcpp/generator/templates/generated.pri deleted file mode 100644 index 31f9aac..0000000 --- a/examples/qtcpp/generator/templates/generated.pri +++ /dev/null @@ -1,31 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -############################################################################# -## This is an auto-generated file. -## Do not edit! All changes made to it will be lost. -############################################################################# - -QT += qml quick -CONFIG += c++11 - -HEADERS += \ - $$PWD/qml{{module.module_name|lower}}module.h \ -{% for interface in module.interfaces %} - $$PWD/qmlabstract{{interface|lower}}.h \ -{% endfor %} -{% for struct in module.structs %} - $$PWD/qml{{struct|lower}}.h \ - $$PWD/qml{{struct|lower}}model.h {% if not loop.last %}\{% endif %} -{% endfor %} - - -SOURCES += \ - $$PWD/qml{{module.module_name|lower}}module.cpp \ -{% for interface in module.interfaces %} - $$PWD/qmlabstract{{interface|lower}}.cpp \ -{% endfor %} -{% for struct in module.structs %} - $$PWD/qml{{struct|lower}}.cpp \ - $$PWD/qml{{struct|lower}}model.cpp {% if not loop.last %}\{% endif %} -{% endfor %} - - diff --git a/examples/qtcpp/generator/templates/interface.cpp b/examples/qtcpp/generator/templates/interface.cpp deleted file mode 100644 index abde3d7..0000000 --- a/examples/qtcpp/generator/templates/interface.cpp +++ /dev/null @@ -1,35 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -{% set class = 'Qml{0}'.format(interface) %} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#include "{{class|lower}}.h" - -#include <QtQml> - -QObject* {{class|lower}}_singletontype_provider(QQmlEngine*, QJSEngine*) -{ - return new {{class}}(); -} - - -{{interface.comment}} -{{class}}::{{class}}(QObject *parent) - : QmlAbstract{{interface}}(parent) -{ -} - -{{class}}::~{{class}}() -{ -} - -void {{class}}::registerQmlTypes(const QString& uri, int majorVersion, int minorVersion) -{ - {% if 'singleton' in interface.tags %} - qmlRegisterSingletonType<{{class}}>(uri.toLatin1(), majorVersion, minorVersion, "{{interface}}", {{class|lower}}_singletontype_provider); - {% else %} - qmlRegisterType<{{class}}>(uri.toLatin1(), majorVersion, minorVersion, "{{interface}}"); - {% endif %} -} diff --git a/examples/qtcpp/generator/templates/interface.h b/examples/qtcpp/generator/templates/interface.h deleted file mode 100644 index 8978be5..0000000 --- a/examples/qtcpp/generator/templates/interface.h +++ /dev/null @@ -1,23 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -{% set class = 'Qml{0}'.format(interface) %} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#pragma once - -#include <QtCore> - -#include "generated/qml{{module.module_name|lower}}module.h" -#include "generated/qmlabstract{{interface|lower}}.h" - -class {{class}} : public QmlAbstract{{interface}} -{ - Q_OBJECT -public: - {{class}}(QObject *parent=0); - virtual ~{{class}}(); - - static void registerQmlTypes(const QString& uri, int majorVersion=1, int minorVersion=0); -}; diff --git a/examples/qtcpp/generator/templates/module.cpp b/examples/qtcpp/generator/templates/module.cpp deleted file mode 100644 index 6579b2c..0000000 --- a/examples/qtcpp/generator/templates/module.cpp +++ /dev/null @@ -1,46 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ -{% set class = 'Qml{0}Module'.format(module.module_name) %} - - -#include "{{class|lower}}.h" - -#include <QtQml> - -QObject* {{class|lower}}_singletontype_provider(QQmlEngine*, QJSEngine*) -{ - return new {{class}}(); -} - -{{class}}::{{class}}(QObject *parent) - : QObject(parent) -{ -} - -{% for struct in module.structs %} -Qml{{struct}} {{class}}::create{{struct}}() -{ - return Qml{{struct}}(); -} -{% endfor %} - -void {{class}}::registerTypes() -{ - {% for struct in module.structs %} - qRegisterMetaType<Qml{{struct}}>(); - {% endfor %} - {% for enum in module.enums %} - qRegisterMetaType<{{class}}::{{enum}}>(); - {% endfor %} -} - -void {{class}}::registerQmlTypes(const QString& uri, int majorVersion, int minorVersion) -{ - {% for struct in module.structs %} - qmlRegisterUncreatableType<Qml{{struct}}Model>(uri.toLatin1(), majorVersion, minorVersion, "{{struct}}Model", "Model can not be instantiated from QML"); - {% endfor %} - qmlRegisterSingletonType<{{class}}>(uri.toLatin1(), majorVersion, minorVersion, "{{module.module_name}}Module", {{class|lower}}_singletontype_provider); -} diff --git a/examples/qtcpp/generator/templates/module.h b/examples/qtcpp/generator/templates/module.h deleted file mode 100644 index 65ba2db..0000000 --- a/examples/qtcpp/generator/templates/module.h +++ /dev/null @@ -1,40 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ -{% set class = 'Qml{0}Module'.format(module.module_name) %} - -#pragma once - -#include <QtCore> - -{% for struct in module.structs %} -#include "qml{{struct|lower}}.h" -#include "qml{{struct|lower}}model.h" -{% endfor %} - -class {{class}} : public QObject { - Q_OBJECT -public: - {{class}}(QObject *parent=0); - -{% for enum in module.enums %} - {% set comma = joiner(",") %} - enum {{enum}} { - {%- for member in enum.members -%} - {{ comma() }} - {{member.name}} = {{member.value}} - {%- endfor %} - - }; - Q_ENUM({{enum}}) -{% endfor %} - -{% for struct in module.structs %} - Q_INVOKABLE Qml{{struct}} create{{struct}}(); -{% endfor %} - - static void registerTypes(); - static void registerQmlTypes(const QString& uri, int majorVersion = 1, int minorVersion = 0); -}; diff --git a/examples/qtcpp/generator/templates/plugin.cpp b/examples/qtcpp/generator/templates/plugin.cpp deleted file mode 100644 index aa8fb9a..0000000 --- a/examples/qtcpp/generator/templates/plugin.cpp +++ /dev/null @@ -1,26 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -{% set module_name = 'Qml{0}Module'.format(module.module_name) %} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#include "plugin.h" - -#include <qqml.h> - -#include "generated/{{module_name|lower}}.h" - -{% for interface in module.interfaces %} -#include "qml{{interface|lower}}.h" -{% endfor %} - -void Plugin::registerTypes(const char *uri) -{ - {{module_name}}::registerTypes(); - // @uri {{module|lower}} - {{module_name}}::registerQmlTypes(uri, 1, 0); -{% for interface in module.interfaces %} - Qml{{interface}}::registerQmlTypes(uri, 1, 0); -{% endfor %} -} diff --git a/examples/qtcpp/generator/templates/plugin.h b/examples/qtcpp/generator/templates/plugin.h deleted file mode 100644 index 1952c35..0000000 --- a/examples/qtcpp/generator/templates/plugin.h +++ /dev/null @@ -1,18 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#pragma once - -#include <QtQml> - -class Plugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri); -}; diff --git a/examples/qtcpp/generator/templates/plugin.pro b/examples/qtcpp/generator/templates/plugin.pro deleted file mode 100644 index 00c9d6e..0000000 --- a/examples/qtcpp/generator/templates/plugin.pro +++ /dev/null @@ -1,47 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -############################################################################# -## This is an auto-generated file. -## Do not edit! All changes made to it will be lost. -############################################################################# - -TEMPLATE = lib -QT += qml quick -CONFIG += qt plugin c++11 -TARGET = $$qtLibraryTarget({{module|lower}}) - -uri = {{module}} - - -HEADERS += \ -{% for interface in module.interfaces %} - qml{{interface|lower}}.h \ -{% endfor %} - plugin.h - - -SOURCES += \ -{% for interface in module.interfaces %} - qml{{interface|lower}}.cpp \ -{% endfor %} - plugin.cpp - - -include( generated/generated.pri ) - -DISTFILES = qmldir - -!equals(_PRO_FILE_PWD_, $$OUT_PWD) { - copy_qmldir.target = $$OUT_PWD/qmldir - copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir - copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" - QMAKE_EXTRA_TARGETS += copy_qmldir - PRE_TARGETDEPS += $$copy_qmldir.target -} - -qmldir.files = qmldir -unix { - installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) - qmldir.path = $$installPath - target.path = $$installPath - INSTALLS += target qmldir -} diff --git a/examples/qtcpp/generator/templates/qmldir b/examples/qtcpp/generator/templates/qmldir deleted file mode 100644 index 9fe5d2b..0000000 --- a/examples/qtcpp/generator/templates/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -module {{module}} -plugin {{module}}
\ No newline at end of file diff --git a/examples/qtcpp/generator/templates/struct.cpp b/examples/qtcpp/generator/templates/struct.cpp deleted file mode 100644 index 5b132ec..0000000 --- a/examples/qtcpp/generator/templates/struct.cpp +++ /dev/null @@ -1,21 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -{% set class = 'Qml{0}'.format(struct) %} -{% set ampersand = joiner(" &&") %} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#include "{{class|lower}}.h" - - -{{struct.comment}} - -bool {{class}}::operator==(const {{class}} &other) const -{ - return ( - {%- for field in struct.fields %}{{ ampersand() }} - m_{{field}} == other.m_{{field}} - {%- endfor %} ); -} - diff --git a/examples/qtcpp/generator/templates/struct.h b/examples/qtcpp/generator/templates/struct.h deleted file mode 100644 index 2e0d6d1..0000000 --- a/examples/qtcpp/generator/templates/struct.h +++ /dev/null @@ -1,29 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -{% set class = 'Qml{0}'.format(struct) %} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#pragma once - -#include <QtCore> - -class {{class}} -{ - Q_GADGET -{% for field in struct.fields %} - Q_PROPERTY({{field|returnType}} {{field}} MEMBER m_{{field}}) -{% endfor %} - -public: -{% for field in struct.fields %} - {{field|returnType}} m_{{field}}; -{% endfor %} - - bool operator==(const {{class}} &other) const; -}; - -Q_DECLARE_METATYPE({{class}}) - - diff --git a/examples/qtcpp/generator/templates/structmodel.cpp b/examples/qtcpp/generator/templates/structmodel.cpp deleted file mode 100644 index 3f13cb6..0000000 --- a/examples/qtcpp/generator/templates/structmodel.cpp +++ /dev/null @@ -1,106 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -{% set class = 'Qml{0}Model'.format(struct) %} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#include "{{class|lower}}.h" - -{{class}}::{{class}}(QObject *parent) - : QAbstractListModel(parent) -{ - {% for field in struct.fields %} - m_roleNames.insert(Roles::{{field|upperfirst}}, QByteArray("{{field}}")); - {% endfor %} -} - -int {{class}}::count() const -{ - return m_data.count(); -} - -Qml{{struct}} {{class}}::get(int index) -{ - return m_data.value(index); -} - -int {{class}}::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent) - return m_data.count(); -} - -QVariant {{class}}::data(const QModelIndex &index, int role) const -{ - if(index.row() < 0 || index.row() >= count()) { - return QVariant(); - } - const Qml{{struct}} &{{struct|lower}} = m_data.at(index.row()); - switch(role) { - {% for field in struct.fields %} - case Roles::{{field|upperfirst}}: - return QVariant::fromValue({{struct|lower}}.m_{{field}}); - {% endfor %} - } - return QVariant(); -} - -QHash<int, QByteArray> {{class}}::roleNames() const -{ - return m_roleNames; -} - - -void {{class}}::insert(int row, const Qml{{struct}} &{{struct|lower}}) -{ - if (row < 0) - row = 0; - if (row >= m_data.count()) - row = m_data.count(); - - beginInsertRows(QModelIndex(), row, row); - m_data.insert(row, {{struct|lower}}); - endInsertRows(); - emit countChanged(count()); -} - -void {{class}}::reset(const QList<Qml{{struct}}> data) -{ - beginResetModel(); - m_data = data; - endResetModel(); -} - -void {{class}}::append(const Qml{{struct}} &{{struct|lower}}) -{ - insert(m_data.count(), {{struct|lower}}); -} - -void {{class}}::update(int row, const Qml{{struct}} &{{struct|lower}}) -{ - if(row < 0 || row >= m_data.count()) { - return; - } - m_data[row] = {{struct|lower}}; - const QModelIndex &index = createIndex(row, 0); - emit dataChanged(index, index); -} - -void {{class}}::remove(int row) -{ - if(row < 0 || row >= m_data.count()) { - return; - } - beginRemoveRows(QModelIndex(), row, row); - m_data.removeAt(row); - endRemoveRows(); -} - -void {{class}}::clear() -{ - beginResetModel(); - m_data.clear(); - endResetModel(); -} - diff --git a/examples/qtcpp/generator/templates/structmodel.h b/examples/qtcpp/generator/templates/structmodel.h deleted file mode 100644 index d212265..0000000 --- a/examples/qtcpp/generator/templates/structmodel.h +++ /dev/null @@ -1,40 +0,0 @@ -{# Copyright (c) Pelagicore AB 2016 #} -{% set class = 'Qml{0}Model'.format(struct) %} -/**************************************************************************** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -****************************************************************************/ - -#pragma once - -#include <QtCore> - -#include "qml{{struct|lower}}.h" - -class {{class}} : public QAbstractListModel -{ - Q_OBJECT - Q_PROPERTY(int count READ count NOTIFY countChanged) -public: - enum Roles { {{struct.fields|map('upperfirst')|join(', ')}} }; - {{class}}(QObject *parent=0); - Q_INVOKABLE Qml{{struct}} get(int index); - int count() const; - Q_INVOKABLE void insert(int row, const Qml{{struct}} &{{struct|lower}}); - Q_INVOKABLE void append(const Qml{{struct}} &{{struct|lower}}); - Q_INVOKABLE void update(int row, const Qml{{struct}} &{{struct|lower}}); - Q_INVOKABLE void remove(int row); - void reset(const QList<Qml{{struct}}> data); - Q_INVOKABLE void clear(); -public: // from QAbstractListModel - virtual int rowCount(const QModelIndex &parent) const; - virtual QVariant data(const QModelIndex &index, int role) const; - virtual QHash<int, QByteArray> roleNames() const; -Q_SIGNALS: - void countChanged(int count); -private: - QList<Qml{{struct}}> m_data; - QHash<int, QByteArray> m_roleNames; -}; - - |