aboutsummaryrefslogtreecommitdiffstats
path: root/qface/builtin/qtcpp/templates/interface.cpp
blob: 7aab4aec4643fa58bf434e4db94defa19b068bbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{# Copyright (c) Pelagicore AB 2016 #}
{% set class = 'Qml{0}'.format(interface) %}
/*
 * This is a preserved file.
 * Changes will not be overriden by the generator.
 * To reset the file you need to delete it first.
 */

#include "{{class|lower}}.h"

#include <QtQml>


/*!
    \inqmlmodule {{module}} 1.0
 */

QObject* {{class|lower}}_singletontype_provider(QQmlEngine*, QJSEngine*)
{
      return new {{class}}();
}


/*!
   \qmltype {{interface}}
   \inqmlmodule {{module}}
{% with doc = interface.comment|parse_doc %}
   \brief {{doc.brief}}

   {{doc.description}}
{% endwith %}
*/

{{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 %}
}