summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro4
-rw-r--r--src/geniviextras/qdltregistration.cpp3
-rw-r--r--src/ivicore/doc/src/concepts.qdoc2
-rw-r--r--src/ivicore/doc/src/examples-qface-tutorial.qdoc21
-rw-r--r--src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc1
-rw-r--r--src/ivicore/doc/src/qtivi.qdoc3
-rw-r--r--src/ivicore/qiviabstractfeature.cpp26
-rw-r--r--src/ivicore/qiviabstractfeaturelistmodel.cpp2
-rw-r--r--src/ivicore/qivipagingmodel.cpp2
-rw-r--r--src/ivicore/qivipagingmodelinterface.cpp4
-rw-r--r--src/ivicore/qivipagingmodelinterface.h2
-rw-r--r--src/ivicore/qivipendingreply.cpp42
-rw-r--r--src/ivicore/qivipendingreply.h2
-rw-r--r--src/ivicore/qiviqmlconversion_helper.cpp36
-rw-r--r--src/ivicore/qiviserviceinterface.cpp2
-rw-r--r--src/ivicore/qivisimulationglobalobject.cpp6
-rw-r--r--src/ivicore/qtivicoremodule.cpp2
-rw-r--r--src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml8
-rw-r--r--src/tools/ivigenerator/generator/filters.py6
-rw-r--r--src/tools/ivigenerator/templates/common/pagingmodel_simulation.cpp.tpl10
-rw-r--r--src/tools/ivigenerator/templates/common/pagingmodel_simulation.h.tpl5
-rw-r--r--src/tools/ivigenerator/templates/common/simulation.qmltypes.tpl1
-rw-r--r--src/tools/ivigenerator/templates/frontend/struct.cpp.tpl49
-rw-r--r--src/tools/ivigenerator/templates/frontend/struct.h.tpl10
-rw-r--r--tests/auto/core/ivigenerator/org.example.echo.qface8
25 files changed, 168 insertions, 89 deletions
diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro b/examples/ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro
index a80c220..48c0164 100644
--- a/examples/ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro
+++ b/examples/ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro
@@ -12,9 +12,9 @@ INCLUDEPATH += $$OUT_PWD/../frontend
QFACE_FORMAT = server_qtro_simulator
QFACE_SOURCES = ../instrument-cluster.qface
-RESOURCES += ../backend_simulator/simulation.qrc
-
QML_IMPORT_PATH = $$OUT_PWD/qml
+RESOURCES += ../backend_simulator/simulation.qrc
+
target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter5-ipc/simulation_server
INSTALLS += target
diff --git a/src/geniviextras/qdltregistration.cpp b/src/geniviextras/qdltregistration.cpp
index 14b2130..bef94d1 100644
--- a/src/geniviextras/qdltregistration.cpp
+++ b/src/geniviextras/qdltregistration.cpp
@@ -55,6 +55,9 @@ QT_BEGIN_NAMESPACE
void qtGeniviLogLevelChangedHandler(char context_id[], uint8_t log_level, uint8_t trace_status)
{
+ if (!globalDltRegistration())
+ return;
+
auto d = globalDltRegistration()->d_ptr;
d->m_mutex.lock();
const QLoggingCategory *category = d->dltLogLevelChanged(context_id, log_level, trace_status);
diff --git a/src/ivicore/doc/src/concepts.qdoc b/src/ivicore/doc/src/concepts.qdoc
index d34905a..cb23917 100644
--- a/src/ivicore/doc/src/concepts.qdoc
+++ b/src/ivicore/doc/src/concepts.qdoc
@@ -33,7 +33,7 @@ All Qt IVI feature APIs depend on the following set of key concepts:
\list
\li \l {Dynamic Backend System}
- \li \l {Qt IVI Autogenerator}
+ \li \l {Qt IVI Generator}
\li \l {Models}
\li \l {Qt IVI Query Language}
\li \l {Qt IVI Simulation System}
diff --git a/src/ivicore/doc/src/examples-qface-tutorial.qdoc b/src/ivicore/doc/src/examples-qface-tutorial.qdoc
index 4fe5726..394fef2 100644
--- a/src/ivicore/doc/src/examples-qface-tutorial.qdoc
+++ b/src/ivicore/doc/src/examples-qface-tutorial.qdoc
@@ -115,7 +115,7 @@
\section2 Autogeneration
Now that our first version of the IDL file is ready, it's time to autogenerate API from it,
- using the \l{Qt IVI Autogenerator}{IVI Generator tool}. Similar to
+ using the \l{Qt IVI Generator}{IVI Generator tool}. Similar to
\l{https://doc.qt.io/qt-5/moc.html}{moc}, this autogeneration process is integrated into the
qmake Build System and is done on compile time.
@@ -393,6 +393,19 @@
function or using the \c QT_PLUGIN_PATH environment variable. For more information, see
\l{https://doc.qt.io/qt-5/plugins-howto.html}{How to create Qt Plugins}.
+ Now everything is in place, but because our plugin links against the frontend library, we need
+ to make sure the library can be found by the dynamic linker. This can be achieved by
+ setting the \c LD_LIBRARY_PATH environment variable to our library folder. But this results
+ in the problem, that every user would need to set this variable to be able to use our
+ application.
+ To make things easier for the user, we rather use a relative RPATH instead and annotate our
+ plugin with the information for the linker, where it might find the needed libraries, relative
+ to the plugin's location:
+
+ \quotefromfile ivicore/qface-tutorial/chapter3-simulation-backend/backend_simulator/backend_simulator.pro
+ \skipto INCLUDEPATH
+ \printuntil QMAKE_RPATHDIR
+
\section2 Export the QML Types in a QML Plugin
In the first chapter, we extended our \c main.cpp to register all types of our autogenerated
@@ -429,7 +442,7 @@
search for it and is still using the old hardcoded registration. So, we can now remove the
linking step in the \c instrument-cluster.pro file and change our main file accordingly:
- \quotefromfile ivicore/qface-tutorial/chapter1-basics/instrument-cluster/main.cpp
+ \quotefromfile ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/main.cpp
\skipto #include
\printuntil }
@@ -612,7 +625,7 @@
part can also be autogenerated using the IVI Generator in a similar fashion:
\quotefromfile ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro
- \printto target.path
+ \printto RESOURCES
Because we'd like to generate a server binary, the \c TEMPLATE needs to be set to "app" instead
of "lib". Similar to the plugin, the server also needs to link against our library to give it
@@ -704,7 +717,7 @@
\quotefromfile ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterplugin.cpp
\skipto #include
- \printuntil eof
+ \printto
In \c interfaces() we use the IID which is defined in \c{instrumentclusterbackendinterface.h}
from our autogenerated library. In \c insterfaceInstance() we check for the correct string and
diff --git a/src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc b/src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc
index b174b43..485ea6f 100644
--- a/src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc
+++ b/src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc
@@ -52,6 +52,7 @@ Currently, Qt IVI generator has the following limitations:
\list
\li There's no support for external C++ types, outside of the IDL, such as reusing a
QGeoCoordinate inside a QFace IDL.
+ \li Defined Interfaces can't be used as types in properties or function arguments.
\li The \c map<> type is not supported.
\li Any default values provided directly in the QFace file are currently ignored.
\endlist
diff --git a/src/ivicore/doc/src/qtivi.qdoc b/src/ivicore/doc/src/qtivi.qdoc
index 5d3aca6..697594e 100644
--- a/src/ivicore/doc/src/qtivi.qdoc
+++ b/src/ivicore/doc/src/qtivi.qdoc
@@ -32,7 +32,7 @@
The Qt In-Vehicle Infotainment (IVI) module provides both, the tools and the core APIs, for you
to implement Middleware APIs, Middleware Backends, and Middlware Services. The
- \l{Qt IVI Autogenerator} provides a flexible way to define new APIs via an Interface Definition
+ \l{Qt IVI Generator} provides a flexible way to define new APIs via an Interface Definition
Language (IDL) and generate classes for use, from C++ and QML.
Qt IVI is built around a pattern that separates the API exposed to the application developer,
@@ -64,6 +64,7 @@
\li \l{Configuration}
\li \l{Concepts and Architecture}
\li \l{Get Started with the Qt IVI Generator}
+ \li \l{Qt IVI Generator Tutorial}
\li \l{Extending Qt IVI}
\endlist
diff --git a/src/ivicore/qiviabstractfeature.cpp b/src/ivicore/qiviabstractfeature.cpp
index aaa59d0..ce5cd05 100644
--- a/src/ivicore/qiviabstractfeature.cpp
+++ b/src/ivicore/qiviabstractfeature.cpp
@@ -133,25 +133,21 @@ void QIviAbstractFeaturePrivate::onInitializationDone()
\inmodule QtIviCore
\brief The QIviAbstractFeature is the base class for all QtIvi Features.
- QIviAbstractFeature is the base class for the front-facing API towards the developer.
- The QIviAbstractFeature provides you with a way to automatically connect to a backend
- implementing the interface needed. To discover a backend, we start it using the
- startAutoDiscovery() function.
+ QIviAbstractFeature is the base class for the front-facing API towards the developer. Subclass
+ QIviAbstractFeature to create an API for your feature.
- Once the auto discovery is complete, you can check whether a backend was found using the
- isValid() function.
+ QIviAbstractFeature provides you with auto discovery: a way to automatically connect to a
+ backend that implements the required interface. To discover a backend, use the
+ startAutoDiscovery() function. Once auto discovery is complete, use the isValid() function to
+ check whether a suitable backend was found.
- The auto discovery gives you an easy way to automatically connect to the right backend
- implementation. If you don't want to use the auto discovery, it's also possible to use
- QIviServiceManager to retrieve all backends. Then, manually search for the right backend
- and call setServiceObject() to connect it to the QIviAbstractFeature.
-
- The type of backend to load can be controlled by setting the \c discvoeryMode to
+ The type of backend to load can be controlled by setting the \c discoveryMode to
\c AutoDiscovery. This mode is enabled by default, which indicates that a production backend
is always preferred over a simulation backend.
- QIviAbstractFeature is an abstract base class that you need to subclass to create an API
- for your feature.
+ Alternatively, it's also possible to use QIviServiceManager to retrieve all backends. Then,
+ manually search for the right backend and call setServiceObject() to connect it to the
+ QIviAbstractFeature.
\section1 Write a Subclass
@@ -165,7 +161,7 @@ void QIviAbstractFeaturePrivate::onInitializationDone()
\endlist
Once a QIviServiceObject has been set, either via startAutoDiscovery() or setServiceObject(),
- the acceptServiceObject() function is then called to make sure that the implemented feature
+ call the acceptServiceObject() function to make sure that the feature you've implemented
can work with the QIviServiceObject and, in turn, the QIviServiceObject provides the required
interface.
diff --git a/src/ivicore/qiviabstractfeaturelistmodel.cpp b/src/ivicore/qiviabstractfeaturelistmodel.cpp
index dbd8e3e..d23b77a 100644
--- a/src/ivicore/qiviabstractfeaturelistmodel.cpp
+++ b/src/ivicore/qiviabstractfeaturelistmodel.cpp
@@ -138,7 +138,7 @@ QIviFeatureInterface *QIviAbstractFeatureListModelPrivate::backend() const
\list
\li For more details on how to integrate with the \l{Dynamic Backend System}, see
- \l{QIviAbstractFeature::Write a Subclass}{QIviAbstractFeature}.
+ \l{Write a Subclass}{QIviAbstractFeature}.
\li For more details on what you need to do to provide the model's required
functionality, see \l{QAbstractListModel - Subclassing}.
\li For a class that implements all the necessary QIviAbstractFeatureListModel functions
diff --git a/src/ivicore/qivipagingmodel.cpp b/src/ivicore/qivipagingmodel.cpp
index 5986138..0ddf289 100644
--- a/src/ivicore/qivipagingmodel.cpp
+++ b/src/ivicore/qivipagingmodel.cpp
@@ -151,7 +151,7 @@ void QIviPagingModelPrivate::onDataFetched(const QUuid &identifier, const QList<
void QIviPagingModelPrivate::onCountChanged(const QUuid &identifier, int new_length)
{
- if (!identifier.isNull() && (identifier != m_identifier || m_loadingType != QIviPagingModel::DataChanged || m_itemList.count() == new_length))
+ if (m_loadingType != QIviPagingModel::DataChanged || (!identifier.isNull() && identifier != m_identifier) || m_itemList.count() == new_length)
return;
Q_Q(QIviPagingModel);
diff --git a/src/ivicore/qivipagingmodelinterface.cpp b/src/ivicore/qivipagingmodelinterface.cpp
index 2d528d6..c8fed22 100644
--- a/src/ivicore/qivipagingmodelinterface.cpp
+++ b/src/ivicore/qivipagingmodelinterface.cpp
@@ -123,10 +123,10 @@ QIviPagingModelInterface::QIviPagingModelInterface(QObjectPrivate &dd, QObject *
*/
/*!
- \fn void QIviPagingModelInterface::countChanged(const QUuid &identifier, int newLength)
+ \fn void QIviPagingModelInterface::countChanged(const QUuid &identifier, int count)
This signal is emitted when the current number of items in the QIviPagingModel instance identified by \a identifier changed.
- The new number of items is returned as \a newLength.
+ The new number of items is returned as \a count.
This signal is expected to be emitted after the model instance has requested new data for the first time by calling fetchData() and
should be emitted before the data is returned by emitting the dataFetched() signal.
diff --git a/src/ivicore/qivipagingmodelinterface.h b/src/ivicore/qivipagingmodelinterface.h
index 0f3375a..4a6973e 100644
--- a/src/ivicore/qivipagingmodelinterface.h
+++ b/src/ivicore/qivipagingmodelinterface.h
@@ -69,7 +69,7 @@ protected:
Q_SIGNALS:
void supportedCapabilitiesChanged(const QUuid &identifier, QtIviCoreModule::ModelCapabilities capabilities);
- void countChanged(const QUuid &identifier, int newLength);
+ void countChanged(const QUuid &identifier = QUuid(), int count = -1);
void dataFetched(const QUuid &identifier, const QList<QVariant> &data, int start, bool moreAvailable);
void dataChanged(const QUuid &identifier, const QList<QVariant> &data, int start, int count);
};
diff --git a/src/ivicore/qivipendingreply.cpp b/src/ivicore/qivipendingreply.cpp
index 8fe9391..2caa926 100644
--- a/src/ivicore/qivipendingreply.cpp
+++ b/src/ivicore/qivipendingreply.cpp
@@ -59,18 +59,31 @@ QT_BEGIN_NAMESPACE
#define QTIVI_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeId, AliasingType) \
QTIVI_ADD_STATIC_METATYPE2(MetaTypeName, MetaTypeId, AliasingType, nullptr)
-struct QIviPendingReplyRegistrator {
- QIviPendingReplyRegistrator() {
- qRegisterMetaType<QIviPendingReplyBase>("QIviPendingReplyBase");
- QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_CORE_POINTER(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_CORE_TEMPLATE(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_CORE_CLASS(QTIVI_ADD_STATIC_METATYPE)
- QT_FOR_EACH_STATIC_ALIAS_TYPE(QTIVI_ADD_STATIC_METATYPE2)
- }
-};
-static QIviPendingReplyRegistrator _registrator;
+
+/*!
+ \relates QIviPendingReply
+
+ Registers QIviPendingReplys of all Qt basic types to the meta type system.
+
+ Usually this function called automatically when creating a QCoreApplication or a QIviPendingReply
+ and doesn't need to be called manually.
+*/
+void qiviRegisterPendingReplyBasicTypes() {
+ static bool once = false;
+ if (once)
+ return;
+
+ qRegisterMetaType<QIviPendingReplyBase>("QIviPendingReplyBase");
+ QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_CORE_POINTER(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_CORE_TEMPLATE(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_CORE_CLASS(QTIVI_ADD_STATIC_METATYPE)
+ QT_FOR_EACH_STATIC_ALIAS_TYPE(QTIVI_ADD_STATIC_METATYPE2)
+ once = true;
+}
+
+Q_COREAPP_STARTUP_FUNCTION(qiviRegisterPendingReplyBasicTypes)
// TODO make it reentrant
@@ -561,6 +574,7 @@ void QIviPendingReplyWatcher::then(const QJSValue &success, const QJSValue &fail
QIviPendingReplyBase::QIviPendingReplyBase(int userType)
: m_watcher(new QIviPendingReplyWatcher(userType))
{
+ qiviRegisterPendingReplyBasicTypes();
}
QIviPendingReplyBase::QIviPendingReplyBase(const QIviPendingReplyBase &other)
@@ -828,9 +842,9 @@ void QIviPendingReplyBase::setSuccessNoCheck(const QVariant &value)
*/
/*!
- \fn template <class T> QIviPendingReply<T>::setSuccess(const T &value)
+ \fn template <class T> QIviPendingReply<T>::setSuccess(const T &val)
- Sets the result of the reply to \a value and marks the reply as succeeded.
+ Sets the result of the reply to \a val and marks the reply as succeeded.
\note a result can only be set once and cannot be changed again later.
diff --git a/src/ivicore/qivipendingreply.h b/src/ivicore/qivipendingreply.h
index e0b5aeb..36368b8 100644
--- a/src/ivicore/qivipendingreply.h
+++ b/src/ivicore/qivipendingreply.h
@@ -55,6 +55,8 @@ QT_BEGIN_NAMESPACE
class QIviPendingReplyWatcherPrivate;
+Q_QTIVICORE_EXPORT void qiviRegisterPendingReplyBasicTypes();
+
class Q_QTIVICORE_EXPORT QIviPendingReplyWatcher : public QObject
{
Q_OBJECT
diff --git a/src/ivicore/qiviqmlconversion_helper.cpp b/src/ivicore/qiviqmlconversion_helper.cpp
index bad773a..f73eb41 100644
--- a/src/ivicore/qiviqmlconversion_helper.cpp
+++ b/src/ivicore/qiviqmlconversion_helper.cpp
@@ -114,11 +114,15 @@ QVariant qtivi_convertFromJSON(const QVariant &value)
if (type == QStringLiteral("enum")) {
QString enumValue = value.toString();
const int lastIndex = enumValue.lastIndexOf(QStringLiteral("::"));
- const QString className = enumValue.left(lastIndex - 1 );
+ const QString className = enumValue.left(lastIndex) + QStringLiteral("*");
enumValue = enumValue.right(enumValue.count() - lastIndex - 2);
const QMetaObject *mo = QMetaType::metaObjectForType(QMetaType::type(className.toLatin1()));
- if (!mo)
+ if (Q_UNLIKELY(!mo)) {
+ qWarning() << "Couldn't retrieve MetaObject for enum parsing:" << map;
+ qWarning("Please make sure %s is registered in Qt's meta-type system: qRegisterMetaType<%s>()",
+ qPrintable(className), qPrintable(className));
return QVariant();
+ }
for (int i = mo->enumeratorOffset(); i < mo->enumeratorCount(); ++i) {
QMetaEnum me = mo->enumerator(i);
@@ -132,14 +136,38 @@ QVariant qtivi_convertFromJSON(const QVariant &value)
} else {
int typeId = QMetaType::type(type.toLatin1());
const QMetaObject *mo = QMetaType::metaObjectForType(typeId);
- if (!mo)
+ if (Q_UNLIKELY(!mo)) {
+ qWarning() << "Couldn't retrieve MetaObject for struct parsing:" << map;
+ qWarning("Please make sure %s is registered in Qt's meta-type system: qRegisterMetaType<%s>()",
+ qPrintable(type), qPrintable(type));
return QVariant();
+ }
QVariantList values = value.toList();
for (auto i = values.begin(); i != values.end(); ++i)
*i = qtivi_convertFromJSON(*i);
- void *gadget = mo->newInstance(Q_ARG(QVariant, QVariant(values)));
+ void *gadget = QMetaType::create(typeId);
+ if (!Q_UNLIKELY(gadget)) {
+ qWarning("Couldn't create a new instance of %s", QMetaType::typeName(typeId));
+ return QVariant();
+ }
+
+ /* Left here for debugging
+ for (int i = mo->methodOffset(); i < mo->methodCount(); ++i)
+ qDebug() << mo->method(i).methodSignature();
+ */
+
+ int moIdx = mo->indexOfMethod("fromJSON(QVariant)");
+ if (Q_UNLIKELY(moIdx == -1)) {
+ qWarning("Couldn't find method: %s::fromJSON(QVariant)\n"
+ "If your are using code created by the ivigenerator, please regenerate"
+ "your frontend code. See AUTOSUITE-1374 for why this is needed",
+ QMetaType::typeName(typeId));
+ return QVariant();
+ }
+
+ mo->method(moIdx).invokeOnGadget(gadget, Q_ARG(QVariant, QVariant(values)));
return QVariant(typeId, gadget);
}
}
diff --git a/src/ivicore/qiviserviceinterface.cpp b/src/ivicore/qiviserviceinterface.cpp
index 06d1885..8fe00a7 100644
--- a/src/ivicore/qiviserviceinterface.cpp
+++ b/src/ivicore/qiviserviceinterface.cpp
@@ -85,7 +85,7 @@ QIviServiceInterface::~QIviServiceInterface()
/*!
\fn QObject* QIviServiceInterface::interfaceInstance(const QString& interfaceName) const
- Returns an object implementing the service interface requested through \a interface.
+ Returns an object implementing the service interface requested through \a interfaceName.
*/
QT_END_NAMESPACE
diff --git a/src/ivicore/qivisimulationglobalobject.cpp b/src/ivicore/qivisimulationglobalobject.cpp
index db312b6..48b413a 100644
--- a/src/ivicore/qivisimulationglobalobject.cpp
+++ b/src/ivicore/qivisimulationglobalobject.cpp
@@ -401,12 +401,12 @@ QString QIviSimulationGlobalObject::constraint(const QVariantMap &data, const QS
}
/*!
- \qmlmethod IviSimulator::checkSettings(object data, var data, string zone)
+ \qmlmethod IviSimulator::checkSettings(object data, var value, string zone)
Searches for all boundary settings in \a data for the given \a zone and returns whether the
- provided \a value meets this contraint.
+ provided \a value meets this constraint.
- To show meaningful error messages when the value is not within the boundaries, the contraint()
+ To show meaningful error messages when the value is not within the boundaries, the constraint()
function can be used.
\sa constraint()
diff --git a/src/ivicore/qtivicoremodule.cpp b/src/ivicore/qtivicoremodule.cpp
index 18836de..576fd01 100644
--- a/src/ivicore/qtivicoremodule.cpp
+++ b/src/ivicore/qtivicoremodule.cpp
@@ -69,7 +69,7 @@ QObject* serviceManagerSingelton(QQmlEngine *, QJSEngine *)
\inmodule QtIviCore
\brief The QtIviCoreModule class holds enums which are used by multiple classes of QtIviCore
- and provides convenience functions to register types to QML
+ and provides convenience functions to register types to QML.
*/
/*!
diff --git a/src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml b/src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml
index 0aa9ed7..94e7d2b 100644
--- a/src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml
+++ b/src/plugins/ivivehiclefunctions/vehiclefunctions_simulator/QIviConcreteWindowControlSimulation.qml
@@ -149,7 +149,7 @@ QtObject {
backend.heaterMode = heaterMode
}
} else {
- console.error("SIMULATION changing heaterMode is not possible: provided: " + heaterMode + "constraint: " + IviSimulator.constraint_string(settings["heaterMode"]));
+ console.error("SIMULATION changing heaterMode is not possible: provided: " + heaterMode + "constraint: " + IviSimulator.constraint(settings["heaterMode"]));
}
}
@@ -164,7 +164,7 @@ QtObject {
backend.heater = heater
}
} else {
- console.error("SIMULATION changing heater is not possible: provided: " + heater + "constraint: " + IviSimulator.constraint_string(settings["heater"]));
+ console.error("SIMULATION changing heater is not possible: provided: " + heater + "constraint: " + IviSimulator.constraint(settings["heater"]));
}
}
@@ -178,7 +178,7 @@ QtObject {
backend.state = state
}
} else {
- console.error("SIMULATION changing state is not possible: provided: " + state + "constraint: " + IviSimulator.constraint_string(settings["state"]));
+ console.error("SIMULATION changing state is not possible: provided: " + state + "constraint: " + IviSimulator.constraint(settings["state"]));
}
}
@@ -199,7 +199,7 @@ QtObject {
backend.blindState = blindState
}
} else {
- console.error("SIMULATION changing blindState is not possible: provided: " + blindState + "constraint: " + IviSimulator.constraint_string(settings["blindState"]));
+ console.error("SIMULATION changing blindState is not possible: provided: " + blindState + "constraint: " + IviSimulator.constraint(settings["blindState"]));
}
}
}
diff --git a/src/tools/ivigenerator/generator/filters.py b/src/tools/ivigenerator/generator/filters.py
index 3fd4a8b..b4df14c 100644
--- a/src/tools/ivigenerator/generator/filters.py
+++ b/src/tools/ivigenerator/generator/filters.py
@@ -132,7 +132,7 @@ def test_type_value(symbol):
if t.is_bool:
return 'true'
if t.is_string:
- return '"TEST STRING"'
+ return 'QStringLiteral("TEST STRING")'
if t.is_real:
return '1234.5678'
if t.is_var:
@@ -187,10 +187,10 @@ def default_value_helper(symbol, res):
else:
return 'false'
if t.is_string:
- return 'QLatin1String("{0}")'.format(res.replace("\\", "\\\\"))
+ return 'QStringLiteral("{0}")'.format(res.replace("\\", "\\\\"))
if t.is_var:
if isinstance(res, str):
- res = 'QLatin1String("{0}")'.format(res)
+ res = 'QStringLiteral("{0}")'.format(res)
return 'QVariant({0})'.format(res)
return '{0}'.format(res)
diff --git a/src/tools/ivigenerator/templates/common/pagingmodel_simulation.cpp.tpl b/src/tools/ivigenerator/templates/common/pagingmodel_simulation.cpp.tpl
index a6b222e..184cecf 100644
--- a/src/tools/ivigenerator/templates/common/pagingmodel_simulation.cpp.tpl
+++ b/src/tools/ivigenerator/templates/common/pagingmodel_simulation.cpp.tpl
@@ -56,6 +56,11 @@
{
}
+int {{class}}::count() const
+{
+ return m_list.count();
+}
+
void {{class}}::initialize()
{
QIVI_SIMULATION_TRY_CALL({{class}}, "initialize", void);
@@ -92,6 +97,7 @@ void {{class}}::insert(int index, const {{property.type.nested}} &item)
m_list.insert(index, item);
Q_EMIT dataChanged(QUuid(), { QVariant::fromValue(item) }, index, 0);
+ Q_EMIT countChanged(QUuid(), m_list.count());
}
void {{class}}::remove(int index)
@@ -99,6 +105,7 @@ void {{class}}::remove(int index)
m_list.removeAt(index);
Q_EMIT dataChanged(QUuid(), QVariantList(), index, 1);
+ Q_EMIT countChanged(QUuid(), m_list.count());
}
void {{class}}::move(int currentIndex, int newIndex)
@@ -117,6 +124,7 @@ void {{class}}::move(int currentIndex, int newIndex)
void {{class}}::reset()
{
Q_EMIT dataChanged(QUuid(), QVariantList(), 0, m_list.count());
+ Q_EMIT countChanged(QUuid(), 0);
m_list.clear();
}
@@ -126,7 +134,7 @@ void {{class}}::update(int index, const {{property.type.nested}} &item)
Q_EMIT dataChanged(QUuid(), { QVariant::fromValue(item) }, index, 1);
}
-const {{property.type.nested}} &{{class}}::at(int index) const
+{{property.type.nested}} {{class}}::at(int index) const
{
return m_list.at(index);
}
diff --git a/src/tools/ivigenerator/templates/common/pagingmodel_simulation.h.tpl b/src/tools/ivigenerator/templates/common/pagingmodel_simulation.h.tpl
index ace6a72..be911f8 100644
--- a/src/tools/ivigenerator/templates/common/pagingmodel_simulation.h.tpl
+++ b/src/tools/ivigenerator/templates/common/pagingmodel_simulation.h.tpl
@@ -51,10 +51,13 @@
class {{class}} : public QIviPagingModelInterface
{
Q_OBJECT
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
explicit {{class}}(QObject *parent = nullptr);
~{{class}}();
+ int count() const;
+
Q_INVOKABLE void initialize() override;
Q_INVOKABLE void registerInstance(const QUuid &identifier) override;
Q_INVOKABLE void unregisterInstance(const QUuid &identifier) override;
@@ -67,7 +70,7 @@ public Q_SLOTS:
void move(int currentIndex, int newIndex);
void reset();
void update(int index, const {{property.type.nested}} &item);
- const {{property.type.nested}} &at(int index) const;
+ {{property.type.nested}} at(int index) const;
private:
QList<{{property.type.nested}}> m_list;
diff --git a/src/tools/ivigenerator/templates/common/simulation.qmltypes.tpl b/src/tools/ivigenerator/templates/common/simulation.qmltypes.tpl
index 80173c8..b8e79dc 100644
--- a/src/tools/ivigenerator/templates/common/simulation.qmltypes.tpl
+++ b/src/tools/ivigenerator/templates/common/simulation.qmltypes.tpl
@@ -103,6 +103,7 @@ Module {
exports: ["{{module|qml_type}}.simulation/{{property|upperfirst}}ModelBackend {{module.majorVersion}}.{{module.minorVersion}}"]
Property { name: "Base"; type: "{{property|upperfirst}}ModelBackend"; isPointer: true }
+ Property { name: "count"; type: "int" }
Method { name: "initialize" }
Method {
diff --git a/src/tools/ivigenerator/templates/frontend/struct.cpp.tpl b/src/tools/ivigenerator/templates/frontend/struct.cpp.tpl
index 7b4a57d..00ea37b 100644
--- a/src/tools/ivigenerator/templates/frontend/struct.cpp.tpl
+++ b/src/tools/ivigenerator/templates/frontend/struct.cpp.tpl
@@ -109,31 +109,6 @@ public:
{
}
-{{class}}::{{class}}(const QVariant &variant)
- : {{class}}()
-{
- QVariant value = qtivi_convertFromJSON(variant);
- // First try to convert the values to a Map or a List
- // This is needed as it could also store a QStringList or a Hash
- if (value.canConvert(QVariant::Map))
- value.convert(QVariant::Map);
- if (value.canConvert(QVariant::List))
- value.convert(QVariant::List);
-
- if (value.type() == QVariant::Map) {
- QVariantMap map = value.toMap();
-{% for field in struct.fields %}
- if (map.contains(QStringLiteral("{{field}}")))
- d->m_{{field}} = map.value(QStringLiteral("{{field}}")).value<{{field|return_type}}>();
-{% endfor %}
- } else if (value.type() == QVariant::List) {
- QVariantList values = value.toList();
-{% for field in struct.fields %}
- d->m_{{field}} = values.value({{loop.index0}}).value<{{field|return_type}}>();
-{% endfor %}
- }
-}
-
/*! \internal */
{{class}}::~{{class}}()
{
@@ -167,6 +142,30 @@ QString {{class}}::type() const
{% endfor %}
+void {{class}}::fromJSON(const QVariant &variant)
+{
+ QVariant value = qtivi_convertFromJSON(variant);
+ // First try to convert the values to a Map or a List
+ // This is needed as it could also store a QStringList or a Hash
+ if (value.canConvert(QVariant::Map))
+ value.convert(QVariant::Map);
+ if (value.canConvert(QVariant::List))
+ value.convert(QVariant::List);
+
+ if (value.type() == QVariant::Map) {
+ QVariantMap map = value.toMap();
+{% for field in struct.fields %}
+ if (map.contains(QStringLiteral("{{field}}")))
+ d->m_{{field}} = map.value(QStringLiteral("{{field}}")).value<{{field|return_type}}>();
+{% endfor %}
+ } else if (value.type() == QVariant::List) {
+ QVariantList values = value.toList();
+{% for field in struct.fields %}
+ d->m_{{field}} = values.value({{loop.index0}}).value<{{field|return_type}}>();
+{% endfor %}
+ }
+}
+
bool operator==(const {{class}} &left, const {{class}} &right) Q_DECL_NOTHROW
{
if (left.d == right.d)
diff --git a/src/tools/ivigenerator/templates/frontend/struct.h.tpl b/src/tools/ivigenerator/templates/frontend/struct.h.tpl
index c9d4ea4..3eaa480 100644
--- a/src/tools/ivigenerator/templates/frontend/struct.h.tpl
+++ b/src/tools/ivigenerator/templates/frontend/struct.h.tpl
@@ -73,11 +73,10 @@ class {{exportsymbol}} {{class}} : public QIviStandardItem
Q_CLASSINFO("IviPropertyDomains", "{{ struct.fields|json_domain|replace("\"", "\\\"") }}")
public:
- Q_INVOKABLE {{class}}();
- Q_INVOKABLE {{class}}(const {{class}} &rhs);
+ {{class}}();
+ {{class}}(const {{class}} &rhs);
{{class}} &operator=(const {{class}} &);
- Q_INVOKABLE {{class}}({{struct.fields|map('parameter_type')|join(', ')}});
- Q_INVOKABLE {{class}}(const QVariant &variant);
+ {{class}}({{struct.fields|map('parameter_type')|join(', ')}});
~{{class}}();
QString type() const override;
@@ -97,6 +96,9 @@ public:
{% endif %}
{% endfor %}
+protected:
+ Q_INVOKABLE void fromJSON(const QVariant &variant);
+
private:
QSharedDataPointer<{{class}}Private> d;
friend {{exportsymbol}} bool operator==(const {{class}} &left, const {{class}} &right) Q_DECL_NOTHROW;
diff --git a/tests/auto/core/ivigenerator/org.example.echo.qface b/tests/auto/core/ivigenerator/org.example.echo.qface
index 17a519c..faed373 100644
--- a/tests/auto/core/ivigenerator/org.example.echo.qface
+++ b/tests/auto/core/ivigenerator/org.example.echo.qface
@@ -34,6 +34,9 @@ interface Echo {
WeekDay weekDay;
TestEnum testEnum;
real UPPERCASEPROPERTY;
+ /* AUTOSUITE-1340 */
+ @config_simulator: { default: ["Hello Qt"] }
+ OnlyAStringInAStruct stringInAStructProperty;
string echo(string msg);
string id() const;
@@ -144,3 +147,8 @@ struct Combo {
struct AnotherStruct {
int justANumber;
}
+
+/* AUTOSUITE-1340 */
+struct OnlyAStringInAStruct {
+ string myString;
+}