summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/helper/remoteobjects/qivipagingmodel.rep14
-rw-r--r--src/helper/remoteobjects/qivipagingmodelqtroadapter.cpp73
-rw-r--r--src/helper/remoteobjects/qivipagingmodelqtroadapter.h78
-rw-r--r--src/helper/remoteobjects/remoteobjects.pro15
-rw-r--r--src/tools/ivigenerator/common/backend_simulation.cpp.tpl8
-rw-r--r--src/tools/ivigenerator/common/pagingmodel.rep.tpl61
-rw-r--r--src/tools/ivigenerator/ivigenerator.pro1
-rw-r--r--src/tools/ivigenerator/templates_backend_qtro.yaml2
-rw-r--r--src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl19
-rw-r--r--src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl4
-rw-r--r--src/tools/ivigenerator/templates_backend_qtro/pagingmodel.cpp.tpl18
-rw-r--r--src/tools/ivigenerator/templates_backend_qtro/pagingmodel.h.tpl12
-rw-r--r--src/tools/ivigenerator/templates_backend_qtro/plugin.cpp.tpl6
-rw-r--r--src/tools/ivigenerator/templates_backend_qtro/plugin.pri.tpl1
-rw-r--r--src/tools/ivigenerator/templates_server_qtro.yaml2
-rw-r--r--src/tools/ivigenerator/templates_server_qtro/server.pri.tpl1
-rw-r--r--src/tools/ivigenerator/templates_server_qtro_simulator.yaml2
-rw-r--r--src/tools/ivigenerator/templates_server_qtro_simulator/adapter.cpp.tpl53
-rw-r--r--src/tools/ivigenerator/templates_server_qtro_simulator/adapter.h.tpl26
-rw-r--r--src/tools/ivigenerator/templates_server_qtro_simulator/main.cpp.tpl9
-rw-r--r--src/tools/ivigenerator/templates_server_qtro_simulator/server.pri.tpl1
-rw-r--r--sync.profile4
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp2
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h4
24 files changed, 304 insertions, 112 deletions
diff --git a/src/helper/remoteobjects/qivipagingmodel.rep b/src/helper/remoteobjects/qivipagingmodel.rep
new file mode 100644
index 0000000..938ce34
--- /dev/null
+++ b/src/helper/remoteobjects/qivipagingmodel.rep
@@ -0,0 +1,14 @@
+#include <QtIviCore/QtIviCoreModule>
+#include <QUuid>
+
+class QIviPagingModel
+{
+ SLOT(void registerInstance(const QUuid &identifier))
+ SLOT(void unregisterInstance(const QUuid &identifier))
+ SLOT(void fetchData(const QUuid &identifier, int start, int count))
+
+ SIGNAL(supportedCapabilitiesChanged(const QUuid &identifier, QtIviCoreModule::ModelCapabilities capabilities))
+ SIGNAL(countChanged(const QUuid &identifier, int newLength))
+ SIGNAL(dataFetched(const QUuid &identifier, const QList<QVariant> &data, int start, bool moreAvailable))
+ SIGNAL(dataChanged(const QUuid &identifier, const QList<QVariant> &data, int start, int count))
+};
diff --git a/src/helper/remoteobjects/qivipagingmodelqtroadapter.cpp b/src/helper/remoteobjects/qivipagingmodelqtroadapter.cpp
new file mode 100644
index 0000000..6ddc865
--- /dev/null
+++ b/src/helper/remoteobjects/qivipagingmodelqtroadapter.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIVI module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite 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$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#include "qivipagingmodelqtroadapter.h"
+
+QIviPagingModelQtRoAdapter::QIviPagingModelQtRoAdapter(const QString &remoteObjectsLookupName, QIviPagingModelInterface *parent)
+ : QIviPagingModelSource(parent)
+ , m_remoteObjectsLookupName(remoteObjectsLookupName)
+ , m_backend(parent)
+{
+ connect(m_backend, &QIviPagingModelInterface::supportedCapabilitiesChanged, this, &QIviPagingModelQtRoAdapter::supportedCapabilitiesChanged);
+ connect(m_backend, &QIviPagingModelInterface::countChanged, this, &QIviPagingModelQtRoAdapter::countChanged);
+ connect(m_backend, &QIviPagingModelInterface::dataFetched, this, &QIviPagingModelQtRoAdapter::dataFetched);
+ connect(m_backend, &QIviPagingModelInterface::dataChanged, this, &QIviPagingModelQtRoAdapter::dataChanged);
+}
+
+QString QIviPagingModelQtRoAdapter::remoteObjectsLookupName() const
+{
+ return m_remoteObjectsLookupName;
+}
+
+void QIviPagingModelQtRoAdapter::registerInstance(const QUuid &identifier)
+{
+ m_backend->registerInstance(identifier);
+}
+
+void QIviPagingModelQtRoAdapter::unregisterInstance(const QUuid &identifier)
+{
+ m_backend->unregisterInstance(identifier);
+}
+
+void QIviPagingModelQtRoAdapter::fetchData(const QUuid &identifier, int start, int count)
+{
+ m_backend->fetchData(identifier, start, count);
+}
diff --git a/src/helper/remoteobjects/qivipagingmodelqtroadapter.h b/src/helper/remoteobjects/qivipagingmodelqtroadapter.h
new file mode 100644
index 0000000..9bd9a75
--- /dev/null
+++ b/src/helper/remoteobjects/qivipagingmodelqtroadapter.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIVI module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite 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$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+#ifndef QIVIPAGINGMODELQTROADAPTER_H
+#define QIVIPAGINGMODELQTROADAPTER_H
+
+#include <QtIviCore/QIviPagingModelInterface>
+#include <rep_qivipagingmodel_source.h>
+
+QT_BEGIN_NAMESPACE
+
+template <class ObjectType>
+struct QIviPagingModelAddressWrapper: public QIviPagingModelSourceAPI<ObjectType> {
+ QIviPagingModelAddressWrapper(ObjectType *object)
+ : QIviPagingModelSourceAPI<ObjectType>(object, object->remoteObjectsLookupName())
+ {}
+};
+
+class QIviPagingModelQtRoAdapter : public QIviPagingModelSource
+{
+ Q_OBJECT
+
+public:
+ explicit QIviPagingModelQtRoAdapter(const QString &remoteObjectsLookupName, QIviPagingModelInterface *parent = nullptr);
+
+ QString remoteObjectsLookupName() const;
+
+public Q_SLOTS:
+ void registerInstance(const QUuid &identifier) override;
+ void unregisterInstance(const QUuid &identifier) override;
+ void fetchData(const QUuid &identifier, int start, int count) override;
+
+private:
+ QString m_remoteObjectsLookupName;
+ QIviPagingModelInterface *m_backend;
+};
+
+QT_END_NAMESPACE
+
+#endif // QIVIPAGINGMODELQTROADAPTER_H
diff --git a/src/helper/remoteobjects/remoteobjects.pro b/src/helper/remoteobjects/remoteobjects.pro
index 22317f1..b56c388 100644
--- a/src/helper/remoteobjects/remoteobjects.pro
+++ b/src/helper/remoteobjects/remoteobjects.pro
@@ -8,13 +8,28 @@ CMAKE_MODULE_TESTS = '-'
CONFIG -= create_cmake
SOURCES += \
+ qivipagingmodelqtroadapter.cpp \
qiviremoteobjectreplicahelper.cpp \
qiviremoteobjectpendingresult.cpp
HEADERS += \
+ qivipagingmodelqtroadapter.h \
qiviremoteobjectreplicahelper.h \
qiviremoteobjectsourcehelper.h \
qiviremoteobjectpendingresult.h
+REPC_SOURCE += \
+ qivipagingmodel.rep
+
+REPC_REPLICA += \
+ qivipagingmodel.rep
+
load(qt_module)
+
+# This is a ugly hack to make sure the generated rep_* headers are installed as well.
+# Because the headers are marked as injected headers, syncqt correctly adds them to the headers.pri.
+# qmake reads the pri in qt_module.prf and creates the INSTALL targets, but these are only created
+# if the files also exist at this point.
+targ_headers.CONFIG = no_check_exist
+
CONFIG -= hide_symbols
diff --git a/src/tools/ivigenerator/common/backend_simulation.cpp.tpl b/src/tools/ivigenerator/common/backend_simulation.cpp.tpl
index 7684b68..9ee929e 100644
--- a/src/tools/ivigenerator/common/backend_simulation.cpp.tpl
+++ b/src/tools/ivigenerator/common/backend_simulation.cpp.tpl
@@ -62,7 +62,13 @@ QT_BEGIN_NAMESPACE
, m_parent(parent)
, m_zone(zone)
{% for property in interface.properties %}
-{% if not property.type.is_model %}
+{% if property.type.is_model %}
+{% if interface_zoned %}
+ , m_{{ property }}(new Zoned{{property|upperfirst}}ModelBackend(this))
+{% else %}
+ , m_{{ property }}(new {{property|upperfirst}}ModelBackend(this));
+{% endif %}
+{% else %}
, m_{{ property }}({{property|default_value}})
{% endif %}
{% endfor %}
diff --git a/src/tools/ivigenerator/common/pagingmodel.rep.tpl b/src/tools/ivigenerator/common/pagingmodel.rep.tpl
deleted file mode 100644
index 0ccda70..0000000
--- a/src/tools/ivigenerator/common/pagingmodel.rep.tpl
+++ /dev/null
@@ -1,61 +0,0 @@
-{#
-# Copyright (C) 2019 Luxoft Sweden AB
-# Copyright (C) 2018 Pelagicore AG.
-# Contact: https://www.qt.io/licensing/
-#
-# This file is part of the QtIvi module of the Qt Toolkit.
-#
-# $QT_BEGIN_LICENSE:LGPL-QTAS$
-# Commercial License Usage
-# Licensees holding valid commercial Qt Automotive Suite 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$
-#
-# SPDX-License-Identifier: LGPL-3.0
-#}
-/////////////////////////////////////////////////////////////////////////////
-// Generated from '{{module}}.qface'
-//
-// Created by: The QFace generator (QtAS {{qtASVersion}})
-//
-// WARNING! All changes made in this file will be lost!
-/////////////////////////////////////////////////////////////////////////////
-
-#include <QtIviCore/QtIviCoreModule>
-#include <QUuid>
-
-class PagingModel
-{
- SLOT(void registerInstance(const QUuid &identifier))
- SLOT(void unregisterInstance(const QUuid &identifier))
- SLOT(void fetchData(const QUuid &identifier, int start, int count))
-
- SIGNAL(supportedCapabilitiesChanged(const QUuid &identifier, QtIviCoreModule::ModelCapabilities capabilities))
- SIGNAL(countChanged(const QUuid &identifier, int newLength))
- SIGNAL(dataFetched(const QUuid &identifier, const QList<QVariant> &data, int start, bool moreAvailable))
- SIGNAL(dataChanged(const QUuid &identifier, const QList<QVariant> &data, int start, int count))
-};
diff --git a/src/tools/ivigenerator/ivigenerator.pro b/src/tools/ivigenerator/ivigenerator.pro
index 59784d4..d9dc54d 100644
--- a/src/tools/ivigenerator/ivigenerator.pro
+++ b/src/tools/ivigenerator/ivigenerator.pro
@@ -18,7 +18,6 @@ common.files += \
common/plugins.qmltypes.tpl \
common/qmldir.tpl \
common/interface.rep.tpl \
- common/pagingmodel.rep.tpl \
common/simulation_data.json.tpl \
common/simulation.qrc.tpl \
common/module_simulation.qml.tpl \
diff --git a/src/tools/ivigenerator/templates_backend_qtro.yaml b/src/tools/ivigenerator/templates_backend_qtro.yaml
index f8c0010..c0acde6 100644
--- a/src/tools/ivigenerator/templates_backend_qtro.yaml
+++ b/src/tools/ivigenerator/templates_backend_qtro.yaml
@@ -8,8 +8,6 @@ generate_rules:
template_file: "plugin.json"
- dest_file: "{{srcBase|lower}}.pri"
template_file: "plugin.pri.tpl"
- - dest_file: "pagingmodel.rep"
- template_file: "common/pagingmodel.rep.tpl"
interface_rules:
- dest_file: '{{interface|lower}}backend.h'
template_file: 'backend.h.tpl'
diff --git a/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl b/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl
index 39c2bea..5a46282 100644
--- a/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl
+++ b/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl
@@ -65,7 +65,9 @@ QT_BEGIN_NAMESPACE
, m_parent(parent)
, m_zone(zone)
{% for property in interface.properties %}
-{% if not property.type.is_model %}
+{% if property.type.is_model %}
+ , m_{{property}}(new Zoned{{property|upperfirst}}ModelBackend(QStringLiteral("{{interface.qualified_name}}.{{property}}.") + m_zone, this))
+{% else %}
, m_{{ property }}({{property|default_value}})
{% endif %}
{% endfor %}
@@ -83,10 +85,13 @@ void {{zone_class}}::sync()
return;
{% for property in interface.properties %}
+{% if not property.type.is_model %}
m_propertiesToSync.append(QStringLiteral("{{property}}"));
+{% endif %}
{% endfor %}
{% for property in interface.properties %}
+{% if not property.type.is_model %}
QRemoteObjectPendingReply<{{property|return_type}}> {{property}}Reply = m_parent->m_replica->{{property|getter_name}}(m_zone);
auto {{property}}Watcher = new QRemoteObjectPendingCallWatcher({{property}}Reply);
connect({{property}}Watcher, &QRemoteObjectPendingCallWatcher::finished, this, [this](QRemoteObjectPendingCallWatcher *self) mutable {
@@ -97,6 +102,7 @@ void {{zone_class}}::sync()
}
self->deleteLater();
});
+{% endif %}
{% endfor %}
}
@@ -122,13 +128,18 @@ void {{zone_class}}::emitCurrentState()
{% endfor %}
{% endif %}
-{{class}}::{{class}}(QObject *parent)
+{{class}}::{{class}}(const QString &remoteObjectsLookupName, QObject *parent)
: {{class}}Interface(parent)
, m_node(nullptr)
+ , m_remoteObjectsLookupName(remoteObjectsLookupName)
, m_helper(new QIviRemoteObjectReplicaHelper(qLcRO{{interface}}(), this))
{% for property in interface.properties %}
{% if property.type.is_model %}
- , m_{{property}}(new {{property|upperfirst}}ModelBackend(this))
+{% if interface_zoned %}
+ , m_{{property}}(new Zoned{{property|upperfirst}}ModelBackend(QStringLiteral("{{interface.qualified_name}}.{{property}}"), this))
+{% else %}
+ , m_{{property}}(new {{property|upperfirst}}ModelBackend(QStringLiteral("{{interface.qualified_name}}.{{property}}"), this))
+{% endif %}
{% endif %}
{% endfor %}
{% if interface_zoned %}
@@ -295,7 +306,7 @@ bool {{class}}::connectToNode()
return false;
}
qCInfo(qLcRO{{interface}}) << "Connecting to" << m_url;
- m_replica.reset(m_node->acquire<{{interface}}Replica>(QStringLiteral("{{interface.qualified_name}}")));
+ m_replica.reset(m_node->acquire<{{interface}}Replica>(m_remoteObjectsLookupName));
setupConnections();
}
return true;
diff --git a/src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl b/src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl
index 7020177..74ee93e 100644
--- a/src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl
+++ b/src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl
@@ -106,7 +106,8 @@ class {{class}} : public {{class}}Interface
Q_OBJECT
public:
- explicit {{class}}(QObject *parent = nullptr);
+ explicit {{class}}(const QString &remoteObjectsLookupName = QStringLiteral("{{interface.qualified_name}}"),
+ QObject *parent = nullptr);
~{{class}}();
void initialize() override;
@@ -141,6 +142,7 @@ protected:
QSharedPointer<{{interface}}Replica> m_replica;
QRemoteObjectNode* m_node= nullptr;
QUrl m_url;
+ QString m_remoteObjectsLookupName;
QHash<quint64, QIviPendingReplyBase> m_pendingReplies;
QIviRemoteObjectReplicaHelper *m_helper;
{% for property in interface.properties %}
diff --git a/src/tools/ivigenerator/templates_backend_qtro/pagingmodel.cpp.tpl b/src/tools/ivigenerator/templates_backend_qtro/pagingmodel.cpp.tpl
index 6a20585..b9e7558 100644
--- a/src/tools/ivigenerator/templates_backend_qtro/pagingmodel.cpp.tpl
+++ b/src/tools/ivigenerator/templates_backend_qtro/pagingmodel.cpp.tpl
@@ -36,14 +36,20 @@
#
# SPDX-License-Identifier: LGPL-3.0
#}
+{% set interface_zoned = interface.tags.config and interface.tags.config.zoned %}
+{% if interface_zoned %}
+{% set class = 'Zoned{0}ModelBackend'.format(property|upperfirst) %}
+{% else %}
{% set class = '{0}ModelBackend'.format(property|upperfirst) %}
+{% endif %}
Q_LOGGING_CATEGORY(qLcRO{{interface}}{{property|upper_first}}, "{{module|qml_type|lower}}.{{interface|lower}}backend.{{property|lower}}.remoteobjects", QtInfoMsg)
-{{class}}::{{class}}(QObject* parent)
+{{class}}::{{class}}(const QString &remoteObjectsLookupName, QObject* parent)
: QIviPagingModelInterface(parent)
, m_node(nullptr)
, m_helper(new QIviRemoteObjectReplicaHelper(qLcRO{{interface}}{{property|upper_first}}(), this))
+ , m_remoteObjectsLookupName(remoteObjectsLookupName)
{
qRegisterMetaType<QIviPagingModelInterface*>();
}
@@ -110,7 +116,7 @@ bool {{class}}::connectToNode()
return false;
}
qCInfo(qLcRO{{interface}}{{property|upper_first}}) << "Connecting to" << m_url;
- m_replica.reset(m_node->acquire<PagingModelReplica>(QStringLiteral("{{interface.qualified_name}}.{{property}}")));
+ m_replica.reset(m_node->acquire<QIviPagingModelReplica>(m_remoteObjectsLookupName));
setupConnections();
}
return true;
@@ -123,8 +129,8 @@ void {{class}}::setupConnections()
connect(m_helper, &QIviRemoteObjectReplicaHelper::errorChanged, this, &QIviFeatureInterface::errorChanged);
connect(m_replica.data(), &QRemoteObjectReplica::stateChanged, m_helper, &QIviRemoteObjectReplicaHelper::onReplicaStateChanged);
- connect(m_replica.data(), &PagingModelReplica::supportedCapabilitiesChanged, this, &{{class}}::supportedCapabilitiesChanged);
- connect(m_replica.data(), &PagingModelReplica::countChanged, this, &{{class}}::countChanged);
- connect(m_replica.data(), &PagingModelReplica::dataFetched, this, &{{class}}::dataFetched);
- connect(m_replica.data(), &PagingModelReplica::dataChanged, this, &{{class}}::dataChanged);
+ connect(m_replica.data(), &QIviPagingModelReplica::supportedCapabilitiesChanged, this, &{{class}}::supportedCapabilitiesChanged);
+ connect(m_replica.data(), &QIviPagingModelReplica::countChanged, this, &{{class}}::countChanged);
+ connect(m_replica.data(), &QIviPagingModelReplica::dataFetched, this, &{{class}}::dataFetched);
+ connect(m_replica.data(), &QIviPagingModelReplica::dataChanged, this, &{{class}}::dataChanged);
}
diff --git a/src/tools/ivigenerator/templates_backend_qtro/pagingmodel.h.tpl b/src/tools/ivigenerator/templates_backend_qtro/pagingmodel.h.tpl
index ceeaff9..740298f 100644
--- a/src/tools/ivigenerator/templates_backend_qtro/pagingmodel.h.tpl
+++ b/src/tools/ivigenerator/templates_backend_qtro/pagingmodel.h.tpl
@@ -36,18 +36,23 @@
#
# SPDX-License-Identifier: LGPL-3.0
#}
+{% set interface_zoned = interface.tags.config and interface.tags.config.zoned %}
+{% if interface_zoned %}
+{% set class = 'Zoned{0}ModelBackend'.format(property|upperfirst) %}
+{% else %}
{% set class = '{0}ModelBackend'.format(property|upperfirst) %}
+{% endif %}
#include <QIviPagingModelInterface>
#include "{{property.type.nested|lower}}.h"
-#include "rep_pagingmodel_replica.h"
+#include "rep_qivipagingmodel_replica.h"
class {{class}} : public QIviPagingModelInterface
{
Q_OBJECT
public:
- explicit {{class}}(QObject *parent = nullptr);
+ explicit {{class}}(const QString &remoteObjectsLookupName = QStringLiteral("{{interface.qualified_name}}.{{property}}"), QObject *parent = nullptr);
~{{class}}();
void initialize() override;
@@ -60,9 +65,10 @@ private:
bool connectToNode();
void setupConnections();
- QSharedPointer<PagingModelReplica> m_replica;
+ QSharedPointer<QIviPagingModelReplica> m_replica;
QIviRemoteObjectReplicaHelper *m_helper;
QRemoteObjectNode *m_node= nullptr;
+ QString m_remoteObjectsLookupName;
QUrl m_url;
QVariantList m_list;
};
diff --git a/src/tools/ivigenerator/templates_backend_qtro/plugin.cpp.tpl b/src/tools/ivigenerator/templates_backend_qtro/plugin.cpp.tpl
index febdbb1..2224ec8 100644
--- a/src/tools/ivigenerator/templates_backend_qtro/plugin.cpp.tpl
+++ b/src/tools/ivigenerator/templates_backend_qtro/plugin.cpp.tpl
@@ -53,9 +53,9 @@ QT_BEGIN_NAMESPACE
{{class}}::{{class}}(QObject *parent)
: QObject(parent)
{
-{% for interface in module.interfaces %}
- m_interfaces << new {{interface}}Backend(this);
-{% endfor %}
+{% for interface in module.interfaces %}
+ m_interfaces << new {{interface}}Backend(QStringLiteral("{{interface.qualified_name}}"), this);
+{% endfor %}
}
QStringList {{class}}::interfaces() const
diff --git a/src/tools/ivigenerator/templates_backend_qtro/plugin.pri.tpl b/src/tools/ivigenerator/templates_backend_qtro/plugin.pri.tpl
index 8d1f3c5..e1372da 100644
--- a/src/tools/ivigenerator/templates_backend_qtro/plugin.pri.tpl
+++ b/src/tools/ivigenerator/templates_backend_qtro/plugin.pri.tpl
@@ -57,7 +57,6 @@ SOURCES += \
$$PWD/{{module.module_name|lower}}plugin.cpp
REPC_REPLICA += \
- $$PWD/pagingmodel.rep \
{% for interface in module.interfaces %}
$$PWD/{{interface|lower}}.rep \
{% endfor %}
diff --git a/src/tools/ivigenerator/templates_server_qtro.yaml b/src/tools/ivigenerator/templates_server_qtro.yaml
index 3b2955d..3dec840 100644
--- a/src/tools/ivigenerator/templates_server_qtro.yaml
+++ b/src/tools/ivigenerator/templates_server_qtro.yaml
@@ -6,8 +6,6 @@ generate_rules:
template_file: "core.h.tpl"
- dest_file: "{{srcBase|lower}}.pri"
template_file: "server.pri.tpl"
- - dest_file: "pagingmodel.rep"
- template_file: "common/pagingmodel.rep.tpl"
interface_rules:
- dest_file: "{{interface|lower}}.rep"
template_file: "common/interface.rep.tpl"
diff --git a/src/tools/ivigenerator/templates_server_qtro/server.pri.tpl b/src/tools/ivigenerator/templates_server_qtro/server.pri.tpl
index aca2f24..230f897 100644
--- a/src/tools/ivigenerator/templates_server_qtro/server.pri.tpl
+++ b/src/tools/ivigenerator/templates_server_qtro/server.pri.tpl
@@ -49,7 +49,6 @@ HEADERS += $$PWD/core.h
SOURCES += $$PWD/core.cpp
REPC_SOURCE += \
- $$PWD/pagingmodel.rep \
{% for interface in module.interfaces %}
$$PWD/{{interface|lower}}.rep \
{% endfor %}
diff --git a/src/tools/ivigenerator/templates_server_qtro_simulator.yaml b/src/tools/ivigenerator/templates_server_qtro_simulator.yaml
index 5f7ab45..06bd8e9 100644
--- a/src/tools/ivigenerator/templates_server_qtro_simulator.yaml
+++ b/src/tools/ivigenerator/templates_server_qtro_simulator.yaml
@@ -6,8 +6,6 @@ generate_rules:
template_file: "core.h.tpl"
- dest_file: "{{srcBase|lower}}.pri"
template_file: "server.pri.tpl"
- - dest_file: "pagingmodel.rep"
- template_file: "common/pagingmodel.rep.tpl"
- dest_file: "main.cpp"
template_file: "main.cpp.tpl"
- dest_file: "{{module.module_name|lower}}_simulation.qml"
diff --git a/src/tools/ivigenerator/templates_server_qtro_simulator/adapter.cpp.tpl b/src/tools/ivigenerator/templates_server_qtro_simulator/adapter.cpp.tpl
index a006ae7..e5e1d6b 100644
--- a/src/tools/ivigenerator/templates_server_qtro_simulator/adapter.cpp.tpl
+++ b/src/tools/ivigenerator/templates_server_qtro_simulator/adapter.cpp.tpl
@@ -41,6 +41,9 @@
{% set class = '{0}QtRoAdapter'.format(interface) %}
{% set interface_zoned = interface.tags.config and interface.tags.config.zoned %}
#include "{{interface|lower}}adapter.h"
+
+#include <QIviPagingModelAddressWrapper>
+
Q_LOGGING_CATEGORY(qLcRO{{interface}}, "{{module|qml_type|lower}}.{{interface|lower}}backend.remoteobjects", QtInfoMsg)
/*
@@ -50,8 +53,15 @@ Q_LOGGING_CATEGORY(qLcRO{{interface}}, "{{module|qml_type|lower}}.{{interface|lo
* to inform the client that the return value is not yet ready. Once the QIviPendingReply is ready
* the value is send with the pendingResultAvailable value
*/
+
{{class}}::{{class}}({{interface}}Backend *parent)
+ : {{class}}(QStringLiteral("{{interface.qualified_name}}"), parent)
+{
+}
+
+{{class}}::{{class}}(const QString &remoteObjectsLookupName, {{interface}}Backend *parent)
: {{interface}}Source(parent)
+ , m_remoteObjectsLookupName(remoteObjectsLookupName)
, m_backend(parent)
, m_helper(this, qLcRO{{interface}}())
{
@@ -65,6 +75,49 @@ Q_LOGGING_CATEGORY(qLcRO{{interface}}, "{{module|qml_type|lower}}.{{interface|lo
{% endfor %}
}
+QString {{class}}::remoteObjectsLookupName() const
+{
+ return m_remoteObjectsLookupName;
+}
+
+void {{class}}::enableRemoting(QRemoteObjectHostBase *node)
+{
+ node->enableRemoting<{{interface}}AddressWrapper>(this);
+{% set vars = { 'models': False } %}
+{% for property in interface.properties %}
+{% if property.type.is_model %}
+{% if vars.update({ 'models': True}) %}{% endif %}
+ auto {{property|lowerfirst}}Adapter = new QIviPagingModelQtRoAdapter(QStringLiteral("{{interface.qualified_name}}.{{property}}"), m_backend->{{property|getter_name}}());
+ node->enableRemoting<QIviPagingModelAddressWrapper>({{property|lowerfirst}}Adapter);
+ m_modelAdapters.insert(node, {{property|lowerfirst}}Adapter);
+{% endif %}
+{% endfor %}
+{% if vars.models and interface_zoned %}
+ // When this is called the backend should already been initialized
+ const QStringList zones = m_backend->availableZones();
+ for (const QString &zone : zones) {
+{% for property in interface.properties %}
+{% if property.type.is_model %}
+ auto {{property|lowerfirst}}Adapter = new QIviPagingModelQtRoAdapter(QStringLiteral("{{interface.qualified_name}}.{{property}}.") + zone, m_backend->zoneAt(zone)->{{property|getter_name}}());
+ node->enableRemoting<QIviPagingModelAddressWrapper>({{property|lowerfirst}}Adapter);
+ m_modelAdapters.insert(node, {{property|lowerfirst}}Adapter);
+{% endif %}
+{% endfor %}
+ }
+{% endif %}
+}
+
+void {{class}}::disableRemoting(QRemoteObjectHostBase *node)
+{
+ node->disableRemoting(this);
+ const auto adapterList = m_modelAdapters.values(node);
+ for (QIviPagingModelQtRoAdapter *adapter : adapterList) {
+ node->disableRemoting(adapter);
+ delete adapter;
+ }
+ m_modelAdapters.remove(node);
+}
+
{% if interface_zoned %}
QStringList {{class}}::availableZones()
{
diff --git a/src/tools/ivigenerator/templates_server_qtro_simulator/adapter.h.tpl b/src/tools/ivigenerator/templates_server_qtro_simulator/adapter.h.tpl
index 27ccc31..1c20792 100644
--- a/src/tools/ivigenerator/templates_server_qtro_simulator/adapter.h.tpl
+++ b/src/tools/ivigenerator/templates_server_qtro_simulator/adapter.h.tpl
@@ -48,7 +48,7 @@
#include "{{interface|lower}}backend.h"
#include "rep_{{interface|lower}}_source.h"
-#include "rep_pagingmodel_source.h"
+#include "rep_qivipagingmodel_source.h"
QT_BEGIN_NAMESPACE
@@ -59,27 +59,23 @@ QT_BEGIN_NAMESPACE
*/
template <class ObjectType>
struct {{interface}}AddressWrapper: public {{interface}}SourceAPI<ObjectType> {
- {{interface}}AddressWrapper(ObjectType *object, const QString &name = QStringLiteral("{{interface.qualified_name}}"))
- : {{interface}}SourceAPI<ObjectType>(object, name)
- {}
-};
-{% for property in interface.properties %}
-{% if property.type.is_model %}
-template <class ObjectType>
-struct {{interface}}{{property}}ModelAddressWrapper: public PagingModelSourceAPI<ObjectType> {
- {{interface}}{{property}}ModelAddressWrapper(ObjectType *object, const QString &name = QStringLiteral("{{interface.qualified_name}}.{{property}}"))
- : PagingModelSourceAPI<ObjectType>(object, name)
+ {{interface}}AddressWrapper(ObjectType *object)
+ : {{interface}}SourceAPI<ObjectType>(object, object->remoteObjectsLookupName())
{}
};
-{% endif %}
-{% endfor %}
+class QIviPagingModelQtRoAdapter;
class {{class}} : public {{interface}}Source
{
Q_OBJECT
public:
- {{class}}({{interface}}Backend *parent = nullptr);
+ {{class}}({{interface}}Backend *parent);
+ {{class}}(const QString &remoteObjectsLookupName, {{interface}}Backend *parent);
+
+ QString remoteObjectsLookupName() const;
+ void enableRemoting(QRemoteObjectHostBase *node);
+ void disableRemoting(QRemoteObjectHostBase *node);
{% if interface_zoned %}
Q_INVOKABLE QStringList availableZones() override;
@@ -113,7 +109,9 @@ public Q_SLOTS:
{% endfor %}
private:
+ QString m_remoteObjectsLookupName;
{{interface}}Backend *m_backend;
+ QMultiHash<QRemoteObjectHostBase *, QIviPagingModelQtRoAdapter *> m_modelAdapters;
QIviRemoteObjectSourceHelper<{{class}}> m_helper;
};
diff --git a/src/tools/ivigenerator/templates_server_qtro_simulator/main.cpp.tpl b/src/tools/ivigenerator/templates_server_qtro_simulator/main.cpp.tpl
index dfed9b6..8da233a 100644
--- a/src/tools/ivigenerator/templates_server_qtro_simulator/main.cpp.tpl
+++ b/src/tools/ivigenerator/templates_server_qtro_simulator/main.cpp.tpl
@@ -88,13 +88,10 @@ int main(int argc, char *argv[])
//Start Remoting the backends
{% for interface in module.interfaces %}
- Core::instance()->host()->enableRemoting<{{interface}}AddressWrapper>(new {{interface}}QtRoAdapter({{interface|lowerfirst}}Instance));
-{% for property in interface.properties %}
-{% if property.type.is_model %}
- Core::instance()->host()->enableRemoting<{{interface}}{{property}}ModelAddressWrapper>(qobject_cast<{{property|upperfirst}}ModelBackend *>({{interface|lowerfirst}}Instance->{{property|getter_name}}()));
-{% endif %}
-{% endfor %}
+ auto {{interface|lowerfirst}}Adapter = new {{interface}}QtRoAdapter({{interface|lowerfirst}}Instance);
+ {{interface|lowerfirst}}Adapter->enableRemoting(Core::instance()->host());
{% endfor %}
+
return app.exec();
}
diff --git a/src/tools/ivigenerator/templates_server_qtro_simulator/server.pri.tpl b/src/tools/ivigenerator/templates_server_qtro_simulator/server.pri.tpl
index b126fd6..5e8b66a 100644
--- a/src/tools/ivigenerator/templates_server_qtro_simulator/server.pri.tpl
+++ b/src/tools/ivigenerator/templates_server_qtro_simulator/server.pri.tpl
@@ -59,7 +59,6 @@ SOURCES += \
$$PWD/main.cpp \
REPC_SOURCE += \
- $$PWD/pagingmodel.rep \
{% for interface in module.interfaces %}
$$PWD/{{interface|lower}}.rep \
{% endfor %}
diff --git a/sync.profile b/sync.profile
index 10ca36e..f35fed8 100644
--- a/sync.profile
+++ b/sync.profile
@@ -26,3 +26,7 @@
"qtmultimedia" => ""
);
+%inject_headers = (
+ "$basedir/src/helper/remoteobjects" => [ "rep_qivipagingmodel_source.h", "rep_qivipagingmodel_replica.h" ]
+)
+
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp
index 2e7d542..78584de 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp
@@ -30,7 +30,7 @@
#include "contactsmodelservice.h"
ContactsModelService::ContactsModelService(QObject* parent)
- : PagingModelSimpleSource(parent)
+ : QIviPagingModelSimpleSource(parent)
{
}
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h
index 5a257f5..6578fa8 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h
@@ -31,9 +31,9 @@
#define CONTACTSMODELSERVICE_H
#include "contact.h"
-#include "rep_pagingmodel_source.h"
+#include "rep_qivipagingmodel_source.h"
-class ContactsModelService : public PagingModelSimpleSource
+class ContactsModelService : public QIviPagingModelSimpleSource
{
public:
ContactsModelService(QObject* parent = nullptr);