diff options
32 files changed, 401 insertions, 215 deletions
diff --git a/.qmake.conf b/.qmake.conf index 4ef7016..2316085 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,3 +1,5 @@ load(qt_build_config) +DEFINES += QT_NO_FOREACH + MODULE_VERSION = 5.7.0 diff --git a/examples/vehiclefunctions/climate_widget/climate_widget.pro b/examples/vehiclefunctions/climate_widget/climate_widget.pro index a7c5b0d..b9ae89f 100644 --- a/examples/vehiclefunctions/climate_widget/climate_widget.pro +++ b/examples/vehiclefunctions/climate_widget/climate_widget.pro @@ -1,4 +1,5 @@ QT += core gui ivicore ivivehiclefunctions +CONFIG += c++11 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets @@ -10,7 +10,9 @@ enable-tests { QML_IMPORT_PATH = $$shadowed($$PWD)/qml -lessThan(QT_MAJOR_VERSION, 5): error("QtIvi only supports Qt 5.") +MIN_MINOR = 5 +!equals(QT_MAJOR_VERSION, 5)|lessThan(QT_MINOR_VERSION, $$MIN_MINOR):error("QtIvi needs to be built against Qt 5.$${MIN_MINOR}+") + load(configure) qtCompileTest(dlt) qtCompileTest(taglib) diff --git a/src/doc/qtautomotivesuite/qtautomotivesuite-online.qdocconf b/src/doc/qtautomotivesuite/qtautomotivesuite-online.qdocconf new file mode 100644 index 0000000..d0a2c31 --- /dev/null +++ b/src/doc/qtautomotivesuite/qtautomotivesuite-online.qdocconf @@ -0,0 +1,7 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults-online.qdocconf) + +# Add an .html file with sidebar content, used in the online style +# HTML.stylesheets += style/qt5-sidebar.html + +include(qtautomotivesuite-project.qdocconf) + diff --git a/src/doc/qtautomotivesuite/qtautomotivesuite-project.qdocconf b/src/doc/qtautomotivesuite/qtautomotivesuite-project.qdocconf new file mode 100644 index 0000000..6be589b --- /dev/null +++ b/src/doc/qtautomotivesuite/qtautomotivesuite-project.qdocconf @@ -0,0 +1,46 @@ +project = QtAutomotiveSuite +description = Qt Automotive Suite Documentation +version = 1.0.0 + +sourcedirs += src + +qhp.projects = QtAutomotiveSuite + +qhp.QtAutomotiveSuite.file = qtautomotivesuite.qhp +qhp.QtAutomotiveSuite.namespace = org.qt-project.qtautomotivesuite.100 +qhp.QtAutomotiveSuite.virtualFolder = qtautomotivesuite +qhp.QtAutomotiveSuite.indexTitle = Qt Automotive Suite +qhp.QtAutomotiveSuite.indexRoot = + +qhp.QtAutomotiveSuite.filterAttributes = qtautomotivesuite 1.0.0 qtrefdoc +qhp.QtAutomotiveSuite.customFilters.Qt.name = QtAutomotiveSuite 1.0.0 +qhp.QtAutomotiveSuite.customFilters.Qt.filterAttributes = qtautomotivesuite 1.0.0 + +qhp.QtAutomotiveSuite.subprojects = overview install +qhp.QtAutomotiveSuite.subprojects.overview.title = Overview +qhp.QtAutomotiveSuite.subprojects.overview.indexTitle = Qt Automotive Suite Overview +qhp.QtAutomotiveSuite.subprojects.overview.selectors = fake:none + +qhp.QtAutomotiveSuite.subprojects.install.title = Installation +qhp.QtAutomotiveSuite.subprojects.install.indexTitle = Installing Qt Automotive Suite +qhp.QtAutomotiveSuite.subprojects.install.selectors = fake:none + +tagfile = qtautomotivesuite.tags + +#Check dependencies, linking using external URLs for now +depends += \ + qtdoc \ + qtivi \ + applicationmanager \ + qmllive \ + qtquickcontrols2 \ + qtdatavisualization \ + qtcharts \ + qtwebengine \ + qtvirtualkeyboard \ + qtquick + +buildversion = "Qt Automotive Suite 1.0" + +macro.QAS = "Qt Automotive Suite" +navigation.homepage = "Qt Automotive Suite" diff --git a/src/doc/qtautomotivesuite/qtautomotivesuite.pro b/src/doc/qtautomotivesuite/qtautomotivesuite.pro index 49ba370..fd4fcbc 100644 --- a/src/doc/qtautomotivesuite/qtautomotivesuite.pro +++ b/src/doc/qtautomotivesuite/qtautomotivesuite.pro @@ -1,7 +1,11 @@ TEMPLATE = aux +build_online_docs: { + QMAKE_DOCS_TARGETDIR = qtautomotivesuite + QMAKE_DOCS = $$PWD/qtautomotivesuite-online.qdocconf +} else { + QMAKE_DOCS = $$PWD/qtautomotivesuite.qdocconf +} -QMAKE_DOCS = $$PWD/qtautomotivesuite.qdocconf -QMAKE_DOCS_OUTPUTDIR = $$OUT_PWD/qtautomotivesuite - -OTHER_FILES += $$QMAKE_DOCS \ +OTHER_FILES += \ + $$PWD/*.qdocconf \ $$PWD/src/*.qdoc diff --git a/src/doc/qtautomotivesuite/qtautomotivesuite.qdocconf b/src/doc/qtautomotivesuite/qtautomotivesuite.qdocconf index df7935c..efe29d7 100644 --- a/src/doc/qtautomotivesuite/qtautomotivesuite.qdocconf +++ b/src/doc/qtautomotivesuite/qtautomotivesuite.qdocconf @@ -1,35 +1,2 @@ -include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) - -project = QtAutomotiveSuite -description = Qt Automotive Suite Documentation -version = 1.0.0 - -sourcedirs += src - -qhp.projects = QtAutomotiveSuite - -qhp.QtAutomotiveSuite.file = qtautomotivesuite.qhp -qhp.QtAutomotiveSuite.namespace = org.qt-project.qtautomotivesuite.100 -qhp.QtAutomotiveSuite.virtualFolder = qtautomotivesuite -qhp.QtAutomotiveSuite.indexTitle = Qt Automotive Suite -qhp.QtAutomotiveSuite.indexRoot = - -qhp.QtAutomotiveSuite.filterAttributes = qtautomotivesuite 1.0.0 qtrefdoc -qhp.QtAutomotiveSuite.customFilters.Qt.name = QtAutomotiveSuite 1.0.0 -qhp.QtAutomotiveSuite.customFilters.Qt.filterAttributes = qtautomotivesuite 1.0.0 - -qhp.QtAutomotiveSuite.subprojects = manual -qhp.QtAutomotiveSuite.subprojects.manual.title = Qt Automotive Suite -qhp.QtAutomotiveSuite.subprojects.manual.indexTitle = Qt Automotive Suite -qhp.QtAutomotiveSuite.subprojects.manual.selectors = doc:page -qhp.QtAutomotiveSuite.subprojects.manual.sortPages = true - -tagfile = qtautomotivesuite.tags - -depends += qtdoc qtivi qtautomotiveota - -buildversion = "Qt Automotive Suite 1.0" - -macro.QAS = "Qt Automotive Suite" -navigation.homepage = "Qt Automotive Suite" -HTML.nosubdirs = "false" +include($QT_INSTALL_DOCS/global/qt-module-defaults-offline.qdocconf) +include(qtautomotivesuite.qdocconf) diff --git a/src/doc/qtautomotivesuite/src/external-resources.qdoc b/src/doc/qtautomotivesuite/src/external-resources.qdoc index 927206e..4f59b5a 100644 --- a/src/doc/qtautomotivesuite/src/external-resources.qdoc +++ b/src/doc/qtautomotivesuite/src/external-resources.qdoc @@ -31,58 +31,23 @@ */ /*! - \externalpage https://doc.qt.io/ - \title Qt reference documentation -*/ - -/*! - \externalpage https://doc.qt.io/QtDataVisualization - \title Qt Data Visualization -*/ - -/*! - \externalpage https://doc.qt.io/QtVirtualKeyboard - \title Qt Virtual Keyboard -*/ - -/*! - \externalpage https://doc.qt.io/QtCharts - \title Qt Charts -*/ - -/*! \externalpage https://doc.qt.io/QtQuickCompiler \title Qt Quick Compiler */ /*! - \externalpage https://doc.qt.io/qt-5/qtwebengine-index.html - \title Qt WebEngine -*/ - -/*! - \externalpage https://doc.qt.io/qt-5/qtquick-index.html - \title Qt Quick -*/ - -/*! \externalpage https://doc.qt.io/qtcreator/ \title Qt Creator */ /*! - \externalpage https://www.kdab.com/gammaray/ - \title GammaRay -*/ - -/*! \externalpage https://doc.qt.io/QtWebBrowser/ \title Qt Web Browser */ /*! - \externalpage https://doc.qt.io/qt-5/qtquickcontrols2-index.html - \title Qt Quick Controls 2 + \externalpage https://www.kdab.com/gammaray/ + \title GammaRay */ /*! @@ -109,3 +74,13 @@ \externalpage https://doc.qt.io/QtForDeviceCreation/index.html \title Qt for Device Creation */ + +/*! + \externalpage https://doc.qt.io/QtOTA/index.html + \title Over-The-Air Update +*/ + +/*! + \externalpage https://doc.qt.io/QtForDeviceCreation/qtee-installation-guide.html + \title Qt for Device Creation: Installation Guide +*/ diff --git a/src/doc/qtautomotivesuite/src/qtautomotivesuite.qdoc b/src/doc/qtautomotivesuite/src/qtautomotivesuite.qdoc index 4b143b2..336f4e9 100644 --- a/src/doc/qtautomotivesuite/src/qtautomotivesuite.qdoc +++ b/src/doc/qtautomotivesuite/src/qtautomotivesuite.qdoc @@ -26,8 +26,9 @@ ****************************************************************************/ /*! - \page qtautomotivesuite-index.html + \page qtautomotivie-index.html \title Qt Automotive Suite + \nextpage {Qt Automotive Suite Overview}{Overview} \e {\QAS} is a collection of software components and tools to enable development of \e In-Vehicle-Infotainment (IVI) systems. Built on top @@ -45,6 +46,7 @@ \list \li \l {Qt Automotive Suite Overview}{Overview} + \li \l {Installing Qt Automotive Suite}{Install Instructions} \li \l {Related Information} \endlist @@ -62,6 +64,8 @@ /*! \page qtas-overview.html \title Qt Automotive Suite Overview + \previouspage {Qt Automotive Suite} + \nextpage {Installing Qt Automotive Suite}{Installation} \section1 Components @@ -95,10 +99,6 @@ \li \l {Qt Quick Compiler} - enables compiling .qml source files into application binaries, improving load times and security for code assets. - \li \l {Qt Charts} - UI Components for displaying visually pleasing - charts, driven by static or dynamic data models. - \li \l {Qt Data Visualization} - UI Components for creating stunning 3D - data visualizations. \li \l {Qt WebEngine} - provides a web browser engine based on the \l {http://www.chromium.org}{Chromium} project. \endlist @@ -125,7 +125,7 @@ \section3 QmlLive - \e QmlLive provides a live reloader environment for rapid development of + \l{Qt QML Live}{QmlLive} provides a live reloader environment for rapid development of Qt Quick applications, dramatically reducing the time it takes to deploy and test changes in the UI design. @@ -163,3 +163,16 @@ tools that assist in enabling distribution of software updates in embedded Linux devices over wireless networks. */ + +/*! + \page qtas-install.html + \title Installing Qt Automotive Suite + \previouspage {Qt Automotive Suite Overview}{Overview} + + \QAS is based on the \l {Qt for Device Creation} offering. System requirements + and install instructions are available here: + + \list + \li \l {Qt for Device Creation: Installation Guide} + \endlist +*/ diff --git a/src/doc/qtivi/qtivi-online.qdocconf b/src/doc/qtivi/qtivi-online.qdocconf new file mode 100644 index 0000000..6c13484 --- /dev/null +++ b/src/doc/qtivi/qtivi-online.qdocconf @@ -0,0 +1,6 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults-online.qdocconf) + +# Add an .html file with sidebar content, used in the online style +# HTML.stylesheets += style/qt5-sidebar.html + +include(qtivi-project.qdocconf) diff --git a/src/doc/qtivi/qtivi-project.qdocconf b/src/doc/qtivi/qtivi-project.qdocconf new file mode 100644 index 0000000..d59e440 --- /dev/null +++ b/src/doc/qtivi/qtivi-project.qdocconf @@ -0,0 +1,49 @@ +project = QtIvi +description = QtIvi Reference Documentation +version = $QT_VERSION + +sourcedirs += . +headerdirs += . + +# include sub-modules' sources and headers +include(../../ivicore/doc/qtivicore.qdocconf) +include(../../ivivehiclefunctions/doc/qtivivehiclefunctions.qdocconf) + +qhp.projects = QtIvi + +qhp.QtIvi.file = qtivi.qhp +qhp.QtIvi.namespace = org.qt-project.qtivi.$QT_VERSION_TAG +qhp.QtIvi.virtualFolder = qtivi +qhp.QtIvi.indexTitle = Qt IVI +qhp.QtIvi.indexRoot = + +qhp.QtIvi.filterAttributes = qtivi $QT_VERSION qtrefdoc +qhp.QtIvi.customFilters.Qt.name = QtIvi $QT_VERSION +qhp.QtIvi.customFilters.Qt.filterAttributes = qtivi $QT_VERSION + +qhp.QtIvi.subprojects = classes qml examples + +qhp.QtIvi.subprojects.classes.title = C++ Classes +qhp.QtIvi.subprojects.classes.indexTitle = Qt IVI C++ Classes +qhp.QtIvi.subprojects.classes.selectors = class fake:headerfile +qhp.QtIvi.subprojects.classes.sortPages = true + +qhp.QtIvi.subprojects.qml.title = QML Types +qhp.QtIvi.subprojects.qml.indexTitle = Qt IVI QML Types +qhp.QtIvi.subprojects.qml.selectors = qmlclass +qhp.QtIvi.subprojects.qml.sortPages = true + +qhp.QtIvi.subprojects.examples.title = Examples +qhp.QtIvi.subprojects.examples.indexTitle = Qt IVI Examples +qhp.QtIvi.subprojects.examples.selectors = fake:example +qhp.QtIvi.subprojects.examples.sortPages = true + +tagfile = qtivi.tags + +depends += qtcore qtdoc qtquick qtqml + +examplesinstallpath = vehiclefunctions + +navigation.landingpage = "Qt IVI" +navigation.cppclassespage = "Qt IVI C++ Classes" +navigation.qmltypespage = "Qt IVI QML Types" diff --git a/src/doc/qtivi/qtivi.pro b/src/doc/qtivi/qtivi.pro index cb01f8a..09e5ff4 100644 --- a/src/doc/qtivi/qtivi.pro +++ b/src/doc/qtivi/qtivi.pro @@ -1,5 +1,11 @@ TEMPLATE = aux +build_online_docs: { + QMAKE_DOCS_TARGETDIR = qtivi + QMAKE_DOCS = $$PWD/qtivi-online.qdocconf +} else { + QMAKE_DOCS = $$PWD/qtivi.qdocconf +} -QMAKE_DOCS = $$PWD/qtivi.qdocconf -OTHER_FILES += $$QMAKE_DOCS \ +OTHER_FILES += \ + $$PWD/*.qdocconf \ $$PWD/src/*.qdoc diff --git a/src/doc/qtivi/qtivi.qdocconf b/src/doc/qtivi/qtivi.qdocconf index f9cece2..a3a064a 100644 --- a/src/doc/qtivi/qtivi.qdocconf +++ b/src/doc/qtivi/qtivi.qdocconf @@ -1,52 +1,3 @@ -include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) - -project = QtIvi -description = QtIvi Reference Documentation -version = $QT_VERSION - -sourcedirs += . -headerdirs += . - -# include sub-modules' sources and headers -include(../../ivicore/doc/qtivicore.qdocconf) -include(../../ivivehiclefunctions/doc/qtivivehiclefunctions.qdocconf) +include($QT_INSTALL_DOCS/global/qt-module-defaults-offline.qdocconf) +include(qtivi.qdocconf) include(../../ivimedia/doc/qtivimedia.qdocconf) - -qhp.projects = QtIvi - -qhp.QtIvi.file = qtivi.qhp -qhp.QtIvi.namespace = org.qt-project.qtivi.$QT_VERSION_TAG -qhp.QtIvi.virtualFolder = qtivi -qhp.QtIvi.indexTitle = Qt IVI -qhp.QtIvi.indexRoot = - -qhp.QtIvi.filterAttributes = qtivi $QT_VERSION qtrefdoc -qhp.QtIvi.customFilters.Qt.name = QtIvi $QT_VERSION -qhp.QtIvi.customFilters.Qt.filterAttributes = qtivi $QT_VERSION - -qhp.QtIvi.subprojects = classes qml examples - -qhp.QtIvi.subprojects.classes.title = C++ Classes -qhp.QtIvi.subprojects.classes.indexTitle = Qt IVI C++ Classes -qhp.QtIvi.subprojects.classes.selectors = class fake:headerfile -qhp.QtIvi.subprojects.classes.sortPages = true - -qhp.QtIvi.subprojects.qml.title = QML Types -qhp.QtIvi.subprojects.qml.indexTitle = Qt IVI QML Types -qhp.QtIvi.subprojects.qml.selectors = qmlclass -qhp.QtIvi.subprojects.qml.sortPages = true - -qhp.QtIvi.subprojects.examples.title = Examples -qhp.QtIvi.subprojects.examples.indexTitle = Qt IVI Examples -qhp.QtIvi.subprojects.examples.selectors = fake:example -qhp.QtIvi.subprojects.examples.sortPages = true - -tagfile = qtivi.tags - -depends += qtcore qtdoc qtquick qtqml - -examplesinstallpath = vehiclefunctions - -navigation.landingpage = "Qt IVI" -navigation.cppclassespage = "Qt IVI C++ Classes" -navigation.qmltypespage = "Qt IVI QML Types" diff --git a/src/geniviextras/qdltregistration.cpp b/src/geniviextras/qdltregistration.cpp index 498bc67..d98ef25 100644 --- a/src/geniviextras/qdltregistration.cpp +++ b/src/geniviextras/qdltregistration.cpp @@ -165,6 +165,9 @@ void QDltRegistration::registerApplication(const char *dltAppID, const char *dlt void QDltRegistration::registerCategory(const QLoggingCategory *category, const char *dltCtxName, const char *dltCtxDescription) { Q_D(QDltRegistration); + Q_ASSERT_X(!d->m_dltAppID.isEmpty(), "registerCategory", "A DLT Application needs to be registered before registering a Logging Category"); + Q_ASSERT(category); + Q_ASSERT(strlen(category->categoryName()) != 0); //TODO memory leak d->registerCategory(category, new DltContext, dltCtxName, dltCtxDescription); } diff --git a/src/ivicore/ivicore.pro b/src/ivicore/ivicore.pro index e473be3..318b7d0 100644 --- a/src/ivicore/ivicore.pro +++ b/src/ivicore/ivicore.pro @@ -31,6 +31,7 @@ HEADERS += \ qivitypetraits.h \ qiviabstractfeaturelistmodel.h \ qiviabstractfeaturelistmodel_p.h \ + qtiviglobal_p.h \ qivisearchandbrowsemodel.h \ qivisearchandbrowsemodel_p.h \ qivisearchandbrowsemodelinterface.h \ @@ -39,6 +40,7 @@ HEADERS += \ SOURCES += \ qiviservicemanager.cpp \ + qiviserviceinterface.cpp \ qiviserviceobject.cpp \ qiviabstractfeature.cpp \ qiviabstractzonedfeature.cpp \ diff --git a/src/ivicore/qiviabstractfeature.cpp b/src/ivicore/qiviabstractfeature.cpp index 0edfa49..891dfe3 100644 --- a/src/ivicore/qiviabstractfeature.cpp +++ b/src/ivicore/qiviabstractfeature.cpp @@ -41,6 +41,7 @@ #include "qiviabstractfeature.h" #include "qiviabstractfeature_p.h" +#include "qtiviglobal_p.h" #include "qiviserviceobject.h" #include "qiviservicemanager.h" @@ -298,7 +299,7 @@ bool QIviAbstractFeature::setServiceObject(QIviServiceObject *so) //We only want to call clearServiceObject if we are sure that the serviceObject changes if (!so) { clearServiceObject(); - } else if (so && !acceptServiceObject(so)) { + } else if (Q_UNLIKELY(so && !acceptServiceObject(so))) { qWarning("ServiceObject is not accepted"); clearServiceObject(); @@ -551,7 +552,7 @@ QIviAbstractFeature::DiscoveryResult QIviAbstractFeature::startAutoDiscovery() //Check whether we can use the found production backends bool serviceObjectSet = false; - foreach (QIviServiceObject *object, serviceObjects) { + for (QIviServiceObject *object : qAsConst(serviceObjects)) { qCDebug(qLcIviServiceManagement) << "Trying to use" << object << "Supported Interfaces:" << object->interfaces(); if (setServiceObject(object)) { serviceObjectSet = true; @@ -571,7 +572,7 @@ QIviAbstractFeature::DiscoveryResult QIviAbstractFeature::startAutoDiscovery() if (Q_UNLIKELY(serviceObjects.isEmpty())) qWarning() << "There is no simulation backend implementing" << d->m_interface << "."; - foreach (QIviServiceObject *object, serviceObjects) { + for (QIviServiceObject* object : qAsConst(serviceObjects)) { qCDebug(qLcIviServiceManagement) << "Trying to use" << object << "Supported Interfaces:" << object->interfaces(); if (setServiceObject(object)) { serviceObjectSet = true; diff --git a/src/ivicore/qiviabstractzonedfeature.cpp b/src/ivicore/qiviabstractzonedfeature.cpp index 58d3442..a8b1c6a 100644 --- a/src/ivicore/qiviabstractzonedfeature.cpp +++ b/src/ivicore/qiviabstractzonedfeature.cpp @@ -51,6 +51,10 @@ QIviAbstractZonedFeaturePrivate::QIviAbstractZonedFeaturePrivate(const QString & , m_zone(zone) {} +QIviAbstractZonedFeaturePrivate::~QIviAbstractZonedFeaturePrivate() +{ +} + /*! \class QIviAbstractZonedFeature \inmodule QtIviCore @@ -224,7 +228,8 @@ void QIviAbstractZonedFeature::initializeZones() return; Q_D(QIviAbstractZonedFeature); - foreach (const QString &zone, backend()->availableZones()) { + const auto zones = backend()->availableZones(); + for (const QString &zone : zones) { QIviAbstractZonedFeature *f = zoneAt(zone); if (!f) { if (this->zone() == zone) @@ -267,7 +272,7 @@ QStringList QIviAbstractZonedFeature::availableZones() const QIviAbstractZonedFeature *QIviAbstractZonedFeature::zoneAt(const QString &zone) const { Q_D(const QIviAbstractZonedFeature); - foreach (QIviAbstractZonedFeature *f, d->m_zoneFeatures) + for (QIviAbstractZonedFeature *f : d->m_zoneFeatures) if (f->zone() == zone) return f; return 0; diff --git a/src/ivicore/qiviabstractzonedfeature_p.h b/src/ivicore/qiviabstractzonedfeature_p.h index eb756dd..d2d970c 100644 --- a/src/ivicore/qiviabstractzonedfeature_p.h +++ b/src/ivicore/qiviabstractzonedfeature_p.h @@ -62,6 +62,7 @@ class Q_QTIVICORE_EXPORT QIviAbstractZonedFeaturePrivate : public QIviAbstractFe { public: QIviAbstractZonedFeaturePrivate(const QString &interface, const QString &zone, QIviAbstractFeature *parent); + ~QIviAbstractZonedFeaturePrivate(); QString m_zone; QList<QIviAbstractZonedFeature*> m_zoneFeatures; diff --git a/src/ivicore/qiviproperty.cpp b/src/ivicore/qiviproperty.cpp index cdd278c..d8f61bd 100644 --- a/src/ivicore/qiviproperty.cpp +++ b/src/ivicore/qiviproperty.cpp @@ -58,12 +58,12 @@ QIviPropertyPrivate::QIviPropertyPrivate(int userType, QtPrivate::QSlotObjectBas void QIviPropertyPrivate::throwError(QObject *object, const QString &error) { QJSEngine *jsEngine = qjsEngine(object); - if (jsEngine) { - QV4::ExecutionEngine *v4 = QV8Engine::getV4(jsEngine); - v4->throwError(error); - } else { + if (Q_UNLIKELY(!jsEngine)) { qWarning("%s", qPrintable(error)); + return; } + QV4::ExecutionEngine *v4 = QV8Engine::getV4(jsEngine); + v4->throwError(error); } /*! diff --git a/src/ivicore/qivipropertyfactory.h b/src/ivicore/qivipropertyfactory.h index b40dbc3..ce532e8 100644 --- a/src/ivicore/qivipropertyfactory.h +++ b/src/ivicore/qivipropertyfactory.h @@ -116,7 +116,7 @@ public: QMetaType metaType(userType); if (metaType.flags() & QMetaType::IsEnumeration) { const QMetaObject *mo = metaType.metaObject(); - if (!mo) + if (Q_UNLIKELY(!mo)) //TODO Do we want to use a qFatal() here or just report a qCritical instead ? qFatal("The provided enum needs to be declared as Q_ENUM or Q_FLAG"); } diff --git a/src/ivicore/qiviqmlconversion_helper.h b/src/ivicore/qiviqmlconversion_helper.h index a899c6c..cd7834f 100644 --- a/src/ivicore/qiviqmlconversion_helper.h +++ b/src/ivicore/qiviqmlconversion_helper.h @@ -71,9 +71,11 @@ template <typename T> QVariant qtivi_convertValue(const T &val) template <typename T> QVariantList qtivi_convertAvailableValues(const QVector<T> &aValues) { QVariantList list; - Q_FOREACH (const T &val, aValues) + list.reserve(aValues.size()); + for (const T &val : aValues) { //As QML doesn't support Enums in Lists we need to convert it to int list.append(qtivi_convertValue<T>(val)); + } return list; } diff --git a/src/ivicore/qiviserviceinterface.cpp b/src/ivicore/qiviserviceinterface.cpp new file mode 100644 index 0000000..ba59693 --- /dev/null +++ b/src/ivicore/qiviserviceinterface.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 +** +****************************************************************************/ + +#include "qiviserviceinterface.h" + +QT_BEGIN_NAMESPACE + +QIviServiceInterface::~QIviServiceInterface() +{ +} + +QT_END_NAMESPACE diff --git a/src/ivicore/qiviserviceinterface.h b/src/ivicore/qiviserviceinterface.h index 3b261e1..9d22154 100644 --- a/src/ivicore/qiviserviceinterface.h +++ b/src/ivicore/qiviserviceinterface.h @@ -42,14 +42,16 @@ #ifndef QIVISERVICEINTERFACE_H #define QIVISERVICEINTERFACE_H +#include <QtIviCore/qtiviglobal.h> + #include <QtCore/QtPlugin> QT_BEGIN_NAMESPACE -class QIviServiceInterface { - +class Q_QTIVICORE_EXPORT QIviServiceInterface +{ public: - virtual ~QIviServiceInterface() {} + virtual ~QIviServiceInterface(); virtual QStringList interfaces() const = 0; virtual QObject *interfaceInstance(const QString &interface) const = 0; diff --git a/src/ivicore/qiviservicemanager.cpp b/src/ivicore/qiviservicemanager.cpp index 18fe2eb..3b6d29b 100644 --- a/src/ivicore/qiviservicemanager.cpp +++ b/src/ivicore/qiviservicemanager.cpp @@ -71,12 +71,12 @@ QIviServiceManagerPrivate *QIviServiceManagerPrivate::get(QIviServiceManager *se return serviceManager->d_ptr; } -QList<QIviServiceObject *> QIviServiceManagerPrivate::findServiceByInterface(const QString &interface, QIviServiceManager::SearchFlags searchFlags) +QList<QIviServiceObject *> QIviServiceManagerPrivate::findServiceByInterface(const QString &interface, QIviServiceManager::SearchFlags searchFlags) const { QList<QIviServiceObject*> list; qCDebug(qLcIviServiceManagement) << "Searching for a backend for:" << interface << "SearchFlags:" << searchFlags; - foreach (Backend *backend, m_backends) { + for (Backend *backend : m_backends) { if (backend->metaData[QLatin1String("interfaces")].toStringList().contains(interface)) { const QString& fileName = backend->metaData[QLatin1String("fileName")].toString(); @@ -102,7 +102,8 @@ QList<QIviServiceObject *> QIviServiceManagerPrivate::findServiceByInterface(con void QIviServiceManagerPrivate::searchPlugins() { bool found = false; - foreach (const QString &pluginDir, QCoreApplication::libraryPaths()) { + const auto pluginDirs = QCoreApplication::libraryPaths(); + for (const QString &pluginDir : pluginDirs) { QDir dir(pluginDir); QString path = pluginDir + QDir::separator() + QLatin1Literal(QIVI_PLUGIN_DIRECTORY); @@ -110,8 +111,8 @@ void QIviServiceManagerPrivate::searchPlugins() if (!QDir(path).exists(QStringLiteral("."))) continue; - QStringList plugins = QDir(path).entryList(QDir::Files); - foreach (const QString &pluginPath, plugins) { + const QStringList plugins = QDir(path).entryList(QDir::Files); + for (const QString &pluginPath : plugins) { if (!QLibrary::isLibrary(pluginPath)) continue; QString fileName = QDir::cleanPath(path + QLatin1Char('/') + pluginPath); @@ -120,17 +121,16 @@ void QIviServiceManagerPrivate::searchPlugins() found = true; } } - if (!found) - { + if (Q_UNLIKELY(!found)) qWarning() << "No plugins found in search path: " << QCoreApplication::libraryPaths().join(QLatin1String(":")); - } } void QIviServiceManagerPrivate::registerBackend(const QString &fileName, const QJsonObject &metaData) { QVariantMap backendMetaData = metaData.value(QLatin1String("MetaData")).toVariant().toMap(); - if (backendMetaData[QLatin1String("interfaces")].isNull() || backendMetaData[QLatin1String("interfaces")].toList().isEmpty()) { + if (Q_UNLIKELY(backendMetaData[QLatin1String("interfaces")].isNull() || + backendMetaData[QLatin1String("interfaces")].toList().isEmpty())) { qCWarning(qLcIviServiceManagement, "PluginManager - Malformed metaData in '%s'. MetaData must contain a list of interfaces", qPrintable(fileName)); return; } @@ -213,12 +213,23 @@ void QIviServiceManagerPrivate::addBackend(Backend *backend) m_backends.append(backend); q->endInsertRows(); - foreach (const QString &interface, backend->metaData[QLatin1String("interfaces")].toStringList()) { + const auto interfaces = backend->metaData[QLatin1String("interfaces")].toStringList(); + for (const QString &interface : interfaces) m_interfaceNames.insert(interface); - } } -QIviServiceInterface *QIviServiceManagerPrivate::loadServiceBackendInterface(struct Backend *backend) +namespace { +Q_NEVER_INLINE +static QIviServiceInterface *warn(const char *what, const QPluginLoader *loader) +{ + qWarning("ServiceManager::serviceObjects - failed to %s '%s'", + what, qPrintable(loader->fileName())); + delete loader; + return Q_NULLPTR; +} +} // unnamed namespace + +QIviServiceInterface *QIviServiceManagerPrivate::loadServiceBackendInterface(struct Backend *backend) const { if (backend->interface) { return backend->interface; @@ -226,25 +237,16 @@ QIviServiceInterface *QIviServiceManagerPrivate::loadServiceBackendInterface(str QPluginLoader *loader = new QPluginLoader(backend->metaData[QLatin1String("fileName")].toString()); QObject *plugin = loader->instance(); - if (plugin) { - - QIviServiceInterface *backendInterface = qobject_cast<QIviServiceInterface*>(plugin); - if (backendInterface) { - backend->interface = backendInterface; - backend->loader = loader; - return backend->interface; - } else { - qCWarning(qLcIviServiceManagement, "ServiceManager::serviceObjects - failed to cast to interface from '%s'", qPrintable(loader->fileName())); - } + if (Q_UNLIKELY(!plugin)) + return warn("load", loader); - } else { - qCWarning(qLcIviServiceManagement, "ServiceManager::serviceObjects - failed to load '%s'", qPrintable(loader->fileName())); - } - - //Only delete the Loader right away if we didn't succeeded with loading the interfaces. - delete loader; + QIviServiceInterface *backendInterface = qobject_cast<QIviServiceInterface*>(plugin); + if (Q_UNLIKELY(!backendInterface)) + return warn("cast to interface from", loader); - return 0; + backend->interface = backendInterface; + backend->loader = loader; + return backend->interface; } /*! diff --git a/src/ivicore/qiviservicemanager_p.h b/src/ivicore/qiviservicemanager_p.h index 86253a8..16b71af 100644 --- a/src/ivicore/qiviservicemanager_p.h +++ b/src/ivicore/qiviservicemanager_p.h @@ -89,7 +89,7 @@ public: static QIviServiceManagerPrivate* get(QIviServiceManager *serviceManager); - QList<QIviServiceObject*> findServiceByInterface(const QString &interface, QIviServiceManager::SearchFlags searchFlags); + QList<QIviServiceObject*> findServiceByInterface(const QString &interface, QIviServiceManager::SearchFlags searchFlags) const; void searchPlugins(); void registerBackend(const QString &fileName, const QJsonObject &metaData); @@ -98,7 +98,7 @@ public: void unloadAllBackends(); - QIviServiceInterface *loadServiceBackendInterface(struct Backend *backend); + QIviServiceInterface *loadServiceBackendInterface(struct Backend *backend) const; QList<Backend*> m_backends; QSet<QString> m_interfaceNames; diff --git a/src/ivicore/qtiviglobal_p.h b/src/ivicore/qtiviglobal_p.h new file mode 100644 index 0000000..defd4a4 --- /dev/null +++ b/src/ivicore/qtiviglobal_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 +** +****************************************************************************/ + +#ifndef QTIVIGLOBAL_P_H +#define QTIVIGLOBAL_P_H + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +//Backport some functions to keep it working with 5.6 +#if (QT_VERSION < QT_VERSION_CHECK(5,7,0)) +namespace QtPrivate { +template <typename T> struct QAddConst { typedef const T Type; }; +} + +// this adds const to non-const objects (like std::as_const) +template <typename T> +Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; } +// prevent rvalue arguments: +template <typename T> +void qAsConst(const T &&) Q_DECL_EQ_DELETE; + +#ifndef qUtf16Printable +# define qUtf16Printable(string) \ + static_cast<const wchar_t*>(static_cast<const void*>(QString(string).utf16())) +#endif +#endif + +QT_END_NAMESPACE + +#endif // QTIVIGLOBAL_P_H + diff --git a/src/ivicore/queryparser/qiviqueryterm.cpp b/src/ivicore/queryparser/qiviqueryterm.cpp index 0d67fea..2415c80 100644 --- a/src/ivicore/queryparser/qiviqueryterm.cpp +++ b/src/ivicore/queryparser/qiviqueryterm.cpp @@ -164,18 +164,14 @@ QIviAbstractQueryTerm::Type QIviConjunctionTerm::type() const QString QIviConjunctionTerm::toString() const { Q_D(const QIviConjunctionTerm); - QString conjunction = QLatin1String("&"); - if (d->m_conjunction == Or) - conjunction = QLatin1String("|"); + const QChar conjunction = d->m_conjunction == Or ? QLatin1Char('|') : QLatin1Char('&'); QString string; - QListIterator<QIviAbstractQueryTerm*> it(d->m_terms); - while (it.hasNext()) { - string += it.next()->toString(); - if (it.hasNext()) - string += QLatin1Literal(" ") + conjunction + QLatin1Literal(" "); + if (!d->m_terms.empty()) { + for (QIviAbstractQueryTerm *term : d->m_terms) + string += term->toString() + QLatin1Char(' ') + conjunction + QLatin1Char(' '); + string.chop(3); // remove trailing " & " or " | " } - return string; } diff --git a/src/ivivehiclefunctions/doc/src/qtivivehiclefunctions.qdoc b/src/ivivehiclefunctions/doc/src/qtivivehiclefunctions.qdoc index 4d69846..80f4409 100644 --- a/src/ivivehiclefunctions/doc/src/qtivivehiclefunctions.qdoc +++ b/src/ivivehiclefunctions/doc/src/qtivivehiclefunctions.qdoc @@ -101,7 +101,8 @@ Looping zones is done with QIviAbstractZonedFeature::zones(): \code - foreach (QClimateControl* z, m_climateControl->zones()) + const auto zones = m_climateControl->zones(); + for (QClimateControl *z : zones) if (z->zone() == "FrontSeat") z->setSeatHeater(true); \endcode diff --git a/src/plugins/ivivehiclefunctions/vehiclefunction_simulator/climatecontrolbackend.cpp b/src/plugins/ivivehiclefunctions/vehiclefunction_simulator/climatecontrolbackend.cpp index f3a61e5..149692c 100644 --- a/src/plugins/ivivehiclefunctions/vehiclefunction_simulator/climatecontrolbackend.cpp +++ b/src/plugins/ivivehiclefunctions/vehiclefunction_simulator/climatecontrolbackend.cpp @@ -131,7 +131,8 @@ void ClimateControlBackend::initializeAttributes() emit automaticClimateFanIntensityLevelChanged(m_automaticClimateFanIntensityLevel); emit automaticClimateFanIntensityLevelAttributeChanged(QIviPropertyAttribute<int>(false)); - foreach (QString zone, availableZones()) { + const auto zones = availableZones(); + for (const QString &zone : zones) { emit targetTemperatureAttributeChanged(m_zoneMap[zone].targetTemperatureAttribute, zone); emit targetTemperatureChanged(m_zoneMap[zone].targetTemperature, zone); emit seatCoolerAttributeChanged(m_zoneMap[zone].seatCoolerAttribute, zone); diff --git a/src/plugins/ivivehiclefunctions/vehiclefunction_simulator/windowcontrolbackend.cpp b/src/plugins/ivivehiclefunctions/vehiclefunction_simulator/windowcontrolbackend.cpp index e79bc5b..e2a8b04 100644 --- a/src/plugins/ivivehiclefunctions/vehiclefunction_simulator/windowcontrolbackend.cpp +++ b/src/plugins/ivivehiclefunctions/vehiclefunction_simulator/windowcontrolbackend.cpp @@ -216,7 +216,8 @@ QStringList WindowControlBackend::availableZones() const void WindowControlBackend::initializeAttributes() { - foreach (QString zone, availableZones()) { + const auto zones = availableZones(); + for (const QString &zone : zones) { emit heaterModeChanged(m_zoneMap[zone].heaterMode, zone); emit heaterModeAttributeChanged(m_zoneMap[zone].heaterModeAttribute, zone); emit heaterEnabledChanged(m_zoneMap[zone].heaterEnabled, zone); diff --git a/tests/auto/vehiclefunctions/climatecontroltest/tst_climatecontroltest.cpp b/tests/auto/vehiclefunctions/climatecontroltest/tst_climatecontroltest.cpp index 2629754..ace45ec 100644 --- a/tests/auto/vehiclefunctions/climatecontroltest/tst_climatecontroltest.cpp +++ b/tests/auto/vehiclefunctions/climatecontroltest/tst_climatecontroltest.cpp @@ -69,7 +69,7 @@ public: climate << QIviClimateControl::ClimateOff << QIviClimateControl::ClimateOn; m_climateModeAttribute = climate; m_zones << "FrontLeft" << "Upper" << "Lower"; - foreach (const QString &z, m_zones) { + for (const QString &z : qAsConst(m_zones)) { m_zoneTargetTemperature[z] = 0; m_zoneTargetTemperatureAttribute[z] = QIviPropertyAttribute<int>(0, 10); m_zoneSeatCooler[z] = 0; @@ -116,7 +116,7 @@ public: QStringList zones = availableZones(); zones.removeLast(); // Do not init zone "Dummy" - foreach (QString zone, zones) { + for (const QString &zone : qAsConst(zones)) { emit targetTemperatureChanged(m_zoneTargetTemperature[zone], zone); emit targetTemperatureAttributeChanged(m_zoneTargetTemperatureAttribute[zone], zone); emit seatCoolerChanged(m_zoneSeatCooler[zone], zone); @@ -692,9 +692,10 @@ void ClimateControlTest::testIntProperties() cc.startAutoDiscovery(); if (testZones) { - QStringList zones = cc.availableZones(); - zones.removeAll("Dummy"); - foreach (QString z, zones) { + const QStringList zones = cc.availableZones(); + for (const QString &z : zones) { + if (z == QLatin1String("Dummy")) + continue; QIviClimateControl *climateZone = qobject_cast<QIviClimateControl*>(cc.zoneAt(z)); testIVIProperty<QIviClimateControl, ClimateControlTestBackend, int>(testData, climateZone, service->testBackend(), z); } @@ -740,9 +741,10 @@ void ClimateControlTest::testBoolProperties() cc.startAutoDiscovery(); if (testZones) { - QStringList zones = cc.availableZones(); - zones.removeAll("Dummy"); - foreach (QString z, zones) { + const QStringList zones = cc.availableZones(); + for (const QString &z : zones) { + if (z == QLatin1String("Dummy")) + continue; QIviClimateControl *climateZone = qobject_cast<QIviClimateControl*>(cc.zoneAt(z)); testIVIProperty<QIviClimateControl, ClimateControlTestBackend, bool>(testData, climateZone, service->testBackend(), z); } diff --git a/tests/auto/vehiclefunctions/windowcontroltest/tst_windowcontroltest.cpp b/tests/auto/vehiclefunctions/windowcontroltest/tst_windowcontroltest.cpp index bf20000..bd17990 100644 --- a/tests/auto/vehiclefunctions/windowcontroltest/tst_windowcontroltest.cpp +++ b/tests/auto/vehiclefunctions/windowcontroltest/tst_windowcontroltest.cpp @@ -64,9 +64,9 @@ public: void initializeAttributes() Q_DECL_OVERRIDE { - QStringList zones = availableZones(); + const QStringList zones = availableZones(); //zones.removeLast(); // Do not init zone "Dummy" - foreach (QString zone, zones) { + for (const QString &zone : zones) { emit heaterModeChanged(m_zoneMap[zone].heaterMode, zone); emit heaterModeAttributeChanged(m_zoneMap[zone].heaterModeAttribute, zone); emit heaterEnabledChanged(m_zoneMap[zone].heaterEnabled, zone); @@ -377,9 +377,10 @@ void WindowControlTest::testHeaterMode() manager->registerService(service, service->interfaces()); QIviWindowControl wc; wc.startAutoDiscovery(); - QStringList zones = wc.availableZones(); - zones.removeAll("Dummy"); - foreach (QString z, zones) { + const QStringList zones = wc.availableZones(); + for (const QString &z : zones) { + if (z == QLatin1String("Dummy")) + continue; QIviWindowControl *window = qobject_cast<QIviWindowControl*>(wc.zoneAt(z)); testIVIProperty<QIviWindowControl, WindowControlTestBackend, QIviWindowControl::HeaterMode>(testData, window, service->testBackend(), z); } @@ -395,9 +396,10 @@ void WindowControlTest::testHeaterEnabled() manager->registerService(service, service->interfaces()); QIviWindowControl wc; wc.startAutoDiscovery(); - QStringList zones = wc.availableZones(); - zones.removeAll("Dummy"); - foreach (QString z, zones) { + const QStringList zones = wc.availableZones(); + for (const QString &z : zones) { + if (z == QLatin1String("Dummy")) + continue; QIviWindowControl *window = qobject_cast<QIviWindowControl*>(wc.zoneAt(z)); testIVIProperty<QIviWindowControl, WindowControlTestBackend, bool>(testData, window, service->testBackend(), z); } @@ -416,9 +418,10 @@ void WindowControlTest::testBlindMode() manager->registerService(service, service->interfaces()); QIviWindowControl wc; wc.startAutoDiscovery(); - QStringList zones = wc.availableZones(); - zones.removeAll("Dummy"); - foreach (QString z, zones) { + const QStringList zones = wc.availableZones(); + for (const QString &z : zones) { + if (z == QLatin1String("Dummy")) + continue; QIviWindowControl *window = qobject_cast<QIviWindowControl*>(wc.zoneAt(z)); testIVIProperty<QIviWindowControl, WindowControlTestBackend, QIviWindowControl::BlindMode>(testData, window, service->testBackend(), z); } @@ -448,9 +451,10 @@ void WindowControlTest::testStates() manager->registerService(service, service->interfaces()); QIviWindowControl wc; wc.startAutoDiscovery(); - QStringList zones = wc.availableZones(); - zones.removeAll("Dummy"); - foreach (QString z, zones) { + const QStringList zones = wc.availableZones(); + for (const QString &z : zones) { + if (z == QLatin1String("Dummy")) + continue; QIviWindowControl *window = qobject_cast<QIviWindowControl*>(wc.zoneAt(z)); testIVIProperty<QIviWindowControl, WindowControlTestBackend, QIviWindowControl::State>(testData, window, service->testBackend(), z); } |