diff options
author | Alexander Kutsan <AKutsan@luxoft.com> | 2016-08-26 18:48:22 +0300 |
---|---|---|
committer | Alexander Kutsan <AKutsan@luxoft.com> | 2016-08-26 18:48:57 +0300 |
commit | d73e6dc8724c5799fae14efd4dcb214af74e4904 (patch) | |
tree | 9ebed8b422490c4d669e90e70783e4f5b55b65c9 /src/components/qt_hmi/qml_plugins | |
parent | c201c11a35d360c0b96f36b103a2590bfaeb6026 (diff) | |
parent | 61ef8c42badb879216f53d240e1101b9f83a9bb7 (diff) | |
download | sdl_core-d73e6dc8724c5799fae14efd4dcb214af74e4904.tar.gz |
Merge branch 'release/4.1.0'
Diffstat (limited to 'src/components/qt_hmi/qml_plugins')
25 files changed, 323 insertions, 299 deletions
diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc index d026f4bbb5..60f07783a9 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.cc @@ -36,11 +36,11 @@ #include "interfaces/QT_HMI_API.h" #include <QtDBus/QDBusConnection> -DBusController::DBusController(QObject *parent) - : QObject(parent), - message(NULL) {} +DBusController::DBusController(QObject* parent) + : QObject(parent), message(NULL) {} -void DBusController::addMessage(const QDBusMessage& message, fillRoutine fill, +void DBusController::addMessage(const QDBusMessage& message, + fillRoutine fill, int async_uid) { delayedReply reply; reply.message = message; @@ -54,11 +54,11 @@ void DBusController::sendReply(QVariant asyncObject, QVariant data) { if (it != replies_.end()) { QDBusMessage msg = it->second.message.createReply(); if (!it->second.fill(msg, data.toMap())) { - QDBusConnection::sessionBus() - .send(it->second.message.createErrorReply(QDBusError::InternalError, - QString::number(hmi_apis::Common_Result::INVALID_DATA))); + QDBusConnection::sessionBus().send(it->second.message.createErrorReply( + QDBusError::InternalError, + QString::number(hmi_apis::Common_Result::INVALID_DATA))); } else { - QDBusConnection::sessionBus().send(msg); + QDBusConnection::sessionBus().send(msg); } replies_.erase(it); } @@ -69,15 +69,17 @@ void DBusController::sendReply(QVariant data) { return; QDBusMessage msg = message->createReply(); if (!fill(msg, data.toMap())) { - QDBusConnection::sessionBus() - .send(message->createErrorReply(QDBusError::InternalError, - QString::number(hmi_apis::Common_Result::INVALID_DATA))); + QDBusConnection::sessionBus().send(message->createErrorReply( + QDBusError::InternalError, + QString::number(hmi_apis::Common_Result::INVALID_DATA))); } else { QDBusConnection::sessionBus().send(msg); } } -void DBusController::sendError(QVariant asyncObject, QVariant code, QVariant message) { +void DBusController::sendError(QVariant asyncObject, + QVariant code, + QVariant message) { int uid = asyncObject.toMap()["__async_uid"].toInt(); std::map<int, delayedReply>::iterator it = replies_.find(uid); if (it != replies_.end()) { diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h index ecda598670..937bab5f90 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_controller.h @@ -41,7 +41,7 @@ typedef bool (*fillRoutine)(QDBusMessage&, const QVariantMap&); -class DBusController: public QObject { +class DBusController : public QObject { struct delayedReply { QDBusMessage message; fillRoutine fill; @@ -49,12 +49,14 @@ class DBusController: public QObject { Q_OBJECT public: - explicit DBusController(QObject *parent = 0); + explicit DBusController(QObject* parent = 0); void addMessage(const QDBusMessage& message, fillRoutine fill, int async_uid); Q_INVOKABLE void sendReply(QVariant asyncObject, QVariant data); Q_INVOKABLE void sendReply(QVariant data); Q_INVOKABLE void sendError(QVariant asyncObject, QVariant code); - Q_INVOKABLE void sendError(QVariant asyncObject, QVariant code, QVariant message); + Q_INVOKABLE void sendError(QVariant asyncObject, + QVariant code, + QVariant message); const QDBusMessage* message; fillRoutine fill; diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc index 0f41a28e73..5cc4dadb1e 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.cc @@ -48,18 +48,18 @@ #include <QtDBus/QDBusConnection> #if QT_4 -# include <QtDeclarative/QDeclarativeContext> -# include <QtDeclarative/QDeclarativeListReference> -# include <QtDeclarative/QDeclarativeEngine> +#include <QtDeclarative/QDeclarativeContext> +#include <QtDeclarative/QDeclarativeListReference> +#include <QtDeclarative/QDeclarativeEngine> #elif QT_5 -# include <QtQml/QQmlContext> -# include <QtQml/QQmlListReference> -# include <QtQml/QQmlEngine> +#include <QtQml/QQmlContext> +#include <QtQml/QQmlListReference> +#include <QtQml/QQmlEngine> #endif // QT_VERSION -log4cxx::LoggerPtr logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("DBusPlugin")); +log4cxx::LoggerPtr logger_ = + log4cxx::LoggerPtr(log4cxx::Logger::getLogger("DBusPlugin")); -void DbusPlugin::registerTypes(const char *uri) { +void DbusPlugin::registerTypes(const char* uri) { log4cxx::PropertyConfigurator::configure("log4cxx.properties"); // @uri sdl.core.api @@ -87,9 +87,9 @@ void DbusPlugin::registerTypes(const char *uri) { HmiProxy::api_adaptors_.SetDBusController(dbusController_); } -void DbusPlugin::initializeEngine(Engine *engine, const char *uri) { - engine->rootContext()->setContextProperty("DBus", dbusController_); - engine->rootContext()->setContextProperty("RequestToSDL", requestToSDL_); +void DbusPlugin::initializeEngine(Engine* engine, const char* uri) { + engine->rootContext()->setContextProperty("DBus", dbusController_); + engine->rootContext()->setContextProperty("RequestToSDL", requestToSDL_); } #if QT_4 diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h index ef2a925956..2b5bba6235 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/dbus_plugin.h @@ -38,11 +38,11 @@ #include "qt_version.h" #if QT_4 -# include <QtDeclarative/QDeclarativeExtensionPlugin> +#include <QtDeclarative/QDeclarativeExtensionPlugin> typedef QDeclarativeExtensionPlugin ExtensionPlugin; typedef QDeclarativeEngine Engine; #elif QT_5 -# include <QtQml/QQmlExtensionPlugin> +#include <QtQml/QQmlExtensionPlugin> typedef QQmlExtensionPlugin ExtensionPlugin; typedef QQmlEngine Engine; #endif // QT_VERSION @@ -58,13 +58,12 @@ class DbusPlugin : public ExtensionPlugin, public QDBusContext { Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") #endif // QT_5 - DBusController *dbusController_; - RequestToSDL *requestToSDL_; + DBusController* dbusController_; + RequestToSDL* requestToSDL_; public: - void registerTypes(const char *uri); - void initializeEngine(Engine *engine, const char *uri); + void registerTypes(const char* uri); + void initializeEngine(Engine* engine, const char* uri); }; #endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_DBUS_PLUGIN_H_ - diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc index 8b6cfd57d4..e196e5c5de 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.cc @@ -37,8 +37,7 @@ ApiAdaptors HmiProxy::api_adaptors_; -HmiProxy::HmiProxy(Item *parent) - : Item(parent) {} +HmiProxy::HmiProxy(Item* parent) : Item(parent) {} void HmiProxy::componentComplete() { Item::componentComplete(); diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h index 886d523157..d7277d017b 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/hmi_proxy.h @@ -39,10 +39,10 @@ #include "qml_dbus.h" #if QT_4 -# include <QtDeclarative/QDeclarativeItem> +#include <QtDeclarative/QDeclarativeItem> typedef QDeclarativeItem Item; #elif QT_5 -# include <QtQuick/QQuickItem> +#include <QtQuick/QQuickItem> typedef QQuickItem Item; #endif // QT_VERSION @@ -51,7 +51,7 @@ class HmiProxy : public Item { Q_DISABLE_COPY(HmiProxy) public: - explicit HmiProxy(Item *parent = 0); + explicit HmiProxy(Item* parent = 0); static ApiAdaptors api_adaptors_; protected: @@ -61,4 +61,3 @@ class HmiProxy : public Item { QML_DECLARE_TYPE(HmiProxy) #endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_HMI_PROXY_H_ - diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h index 5224da7f55..b127cea1a8 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/metatype.h @@ -35,25 +35,25 @@ #include <QMetaType> -template<typename T> +template <typename T> QMetaType::Type metatype(); -template<> +template <> inline QMetaType::Type metatype<int>() { return QMetaType::Int; } -template<> +template <> inline QMetaType::Type metatype<QString>() { return QMetaType::QString; } -template<> +template <> inline QMetaType::Type metatype<bool>() { return QMetaType::Bool; } -template<> +template <> inline QMetaType::Type metatype<double>() { return QMetaType::Double; } diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h index b9360c3eb4..ea6f68bb31 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/optional_argument.h @@ -38,38 +38,34 @@ #include "qt_version.h" #include <QtDBus/QDBusArgument> -template<class T> +template <class T> struct OptionalArgument { T val; bool presence; - explicit OptionalArgument(const T& value) - : val(value), - presence(true) {} - OptionalArgument() - : presence(false) {} + explicit OptionalArgument(const T& value) : val(value), presence(true) {} + OptionalArgument() : presence(false) {} }; -template<class T> -inline -QDBusArgument& operator << (QDBusArgument& arg, const OptionalArgument<T>& o) { +template <class T> +inline QDBusArgument& operator<<(QDBusArgument& arg, + const OptionalArgument<T>& o) { arg.beginStructure(); arg << o.presence << o.val; arg.endStructure(); return arg; } -template<class T> -inline -const QDBusArgument& operator >> (const QDBusArgument& arg, OptionalArgument<T>& o) { +template <class T> +inline const QDBusArgument& operator>>(const QDBusArgument& arg, + OptionalArgument<T>& o) { arg.beginStructure(); arg >> o.presence >> o.val; arg.endStructure(); return arg; } -template<class T> -inline -bool VariantToValue(const QVariant& variant, OptionalArgument<T>& o) { +template <class T> +inline bool VariantToValue(const QVariant& variant, OptionalArgument<T>& o) { if (variant.isNull()) { o.presence = false; return true; @@ -80,7 +76,7 @@ bool VariantToValue(const QVariant& variant, OptionalArgument<T>& o) { #if QT_4 Q_DECLARE_METATYPE(QList<int>) -#endif // QT_4 +#endif // QT_4 Q_DECLARE_METATYPE(OptionalArgument<int>) Q_DECLARE_METATYPE(OptionalArgument<QString>) diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h index eb9b93929f..fa9692f9d9 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus_common.h @@ -70,8 +70,7 @@ enum ErrorCode { inline void RaiseDbusError(QObject* adaptor, int code, const QString& message) { QDBusContext* context = dynamic_cast<QDBusContext*>(adaptor->parent()); if (context) { - context->sendErrorReply(QString::number(static_cast<int>(code)), - message); + context->sendErrorReply(QString::number(static_cast<int>(code)), message); } } @@ -79,31 +78,39 @@ inline void RaiseDbusError(QObject* adaptor, int code) { RaiseDbusError(adaptor, code, ""); } -template<typename T> +template <typename T> inline void PutArgToMap(QVariantMap& map, const char* name, const T& v) { map.insert(name, QVariant::fromValue(v)); } inline bool GetArgFromMap(const QVariantMap& map, const char* name, int& v) { QVariantMap::const_iterator it = map.find(name); - if (map.end() == it) return false; - if (it->type() != QVariant::Int) return false; + if (map.end() == it) + return false; + if (it->type() != QVariant::Int) + return false; v = it->toInt(); return true; } -inline bool GetArgFromMap(const QVariantMap& map, const char* name, QString& v) { +inline bool GetArgFromMap(const QVariantMap& map, + const char* name, + QString& v) { QVariantMap::const_iterator it = map.find(name); - if (map.end() == it) return false; - if (it->type() != QVariant::String) return false; + if (map.end() == it) + return false; + if (it->type() != QVariant::String) + return false; v = it->toString(); return true; } inline bool GetArgFromMap(const QVariantMap& map, const char* name, bool& v) { QVariantMap::const_iterator it = map.find(name); - if (map.end() == it) return false; - if (it->type() != QVariant::Bool) return false; + if (map.end() == it) + return false; + if (it->type() != QVariant::Bool) + return false; v = it->toBool(); return true; } @@ -111,78 +118,87 @@ inline bool GetArgFromMap(const QVariantMap& map, const char* name, bool& v) { inline bool isNumber(QVariant v) { QVariant::Type t = v.type(); return (t == QVariant::Double) || (t == QVariant::Int) || - (t == QVariant::UInt) || (t == QVariant::LongLong) || + (t == QVariant::UInt) || (t == QVariant::LongLong) || (t == QVariant::ULongLong); } inline bool GetArgFromMap(const QVariantMap& map, const char* name, double& v) { QVariantMap::const_iterator it = map.find(name); - if (map.end() == it) return false; - if (!isNumber(*it)) return false; + if (map.end() == it) + return false; + if (!isNumber(*it)) + return false; v = it->toDouble(); return true; } inline bool VariantToValue(const QVariant& variant, int& v) { - if (variant.type() != QVariant::Int) return false; - v = variant.toInt(); - return true; + if (variant.type() != QVariant::Int) + return false; + v = variant.toInt(); + return true; } inline bool VariantToValue(const QVariant& variant, QString& v) { - if (variant.type() != QVariant::String) return false; - v = variant.toString(); - return true; + if (variant.type() != QVariant::String) + return false; + v = variant.toString(); + return true; } inline bool VariantToValue(const QVariant& variant, bool& v) { - if (variant.type() != QVariant::Bool) return false; - v = variant.toBool(); - return true; + if (variant.type() != QVariant::Bool) + return false; + v = variant.toBool(); + return true; } inline bool VariantToValue(const QVariant& variant, double& v) { - if (variant.type() != QVariant::Double) return false; - v = variant.toDouble(); - return true; + if (variant.type() != QVariant::Double) + return false; + v = variant.toDouble(); + return true; } inline bool VariantToValue(const QVariant& variant, QStringList& v) { - if (variant.type() != QVariant::List) return false; + if (variant.type() != QVariant::List) + return false; QList<QVariant> list = variant.toList(); for (QList<QVariant>::const_iterator i = list.begin(); i != list.end(); ++i) { - if (i->type() != QVariant::String) return false; + if (i->type() != QVariant::String) + return false; v.append(i->toString()); } return true; } -template<typename T> +template <typename T> bool VariantToValue(const QVariant& variant, QList<T>& v) { - if (variant.type() != QVariant::List) return false; - QList<T> spare; - QList<QVariant> list = variant.toList(); - for (QList<QVariant>::const_iterator i = list.begin(); i != list.end(); ++i) { - QVariant::Type type = i->type(); -// Although this function is declared as returning QVariant::Type(obsolete), -// the return value should be interpreted as QMetaType::Type. -// (http://qt-project.org/doc/qt-5.0/qtcore/qvariant.html#type) - QMetaType::Type type_casted = static_cast<QMetaType::Type>(type); - if (type_casted != metatype<T>()) { - return false; - } - spare.append(i->value<T>()); + if (variant.type() != QVariant::List) + return false; + QList<T> spare; + QList<QVariant> list = variant.toList(); + for (QList<QVariant>::const_iterator i = list.begin(); i != list.end(); ++i) { + QVariant::Type type = i->type(); + // Although this function is declared as returning QVariant::Type(obsolete), + // the return value should be interpreted as QMetaType::Type. + // (http://qt-project.org/doc/qt-5.0/qtcore/qvariant.html#type) + QMetaType::Type type_casted = static_cast<QMetaType::Type>(type); + if (type_casted != metatype<T>()) { + return false; } - v.swap(spare); - return true; + spare.append(i->value<T>()); + } + v.swap(spare); + return true; } -template<typename T> +template <typename T> inline QVariant ValueToVariant(const T& v) { - return QVariant::fromValue(v); + return QVariant::fromValue(v); } -template<typename T> +template <typename T> inline QVariant ValueToVariant(const QList<T>& v) { QList<QVariant> list; for (typename QList<T>::const_iterator i = v.begin(); i != v.end(); ++i) @@ -190,7 +206,7 @@ inline QVariant ValueToVariant(const QList<T>& v) { return QVariant::fromValue(list); } -template<typename T> +template <typename T> inline void PutArgToMap(QVariantMap& map, const char* name, const QList<T>& v) { QList<QVariant> list; for (typename QList<T>::const_iterator i = v.begin(); i != v.end(); ++i) @@ -198,31 +214,38 @@ inline void PutArgToMap(QVariantMap& map, const char* name, const QList<T>& v) { map.insert(name, QVariant::fromValue(list)); } -template<typename T> -inline bool GetArgFromMap(const QVariantMap& map, const char* name, QList<T>& v) { +template <typename T> +inline bool GetArgFromMap(const QVariantMap& map, + const char* name, + QList<T>& v) { QVariantMap::const_iterator it = map.find(name); - if (map.end() == it) return false; + if (map.end() == it) + return false; const QVariant& variant = *it; - if (variant.type() != QVariant::List) return false; + if (variant.type() != QVariant::List) + return false; QList<QVariant> list = variant.toList(); for (QList<QVariant>::const_iterator i = list.begin(); i != list.end(); ++i) { T t; bool ok = VariantToValue(*i, t); - if (!ok) return false; + if (!ok) + return false; v.append(t); } return true; } -template<typename T> -inline void PutArgToMap(QVariantMap& map, const char* name, +template <typename T> +inline void PutArgToMap(QVariantMap& map, + const char* name, const OptionalArgument<T>& v) { if (v.presence) map.insert(name, ValueToVariant(v.val)); } -template<typename T> -inline bool GetArgFromMap(const QVariantMap& map, const char* name, +template <typename T> +inline bool GetArgFromMap(const QVariantMap& map, + const char* name, OptionalArgument<T>& v) { QVariantMap::const_iterator it = map.find(name); if (map.end() == it || !it->isValid()) { diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h b/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h index 4eff83bd5b..c41eea7403 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/qt_version.h @@ -37,11 +37,12 @@ #include <qglobal.h> -#define QT_4 ((QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && \ - (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))) +#define QT_4 \ + ((QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && \ + (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))) -#define QT_5 ((QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && \ - (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) +#define QT_5 \ + ((QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && \ + (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) #endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_QT_VERSION_H_ - diff --git a/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc index b60f5226c4..ec049b9533 100644 --- a/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc +++ b/src/components/qt_hmi/qml_plugins/dbus_adapter/stream_qvariant.cc @@ -35,33 +35,33 @@ std::basic_ostream<char>& operator<<(std::basic_ostream<char>& os, const QVariant& value) { switch (value.type()) { - case QVariant::Map: { - os << "{ "; - QVariantMap structure = value.toMap(); - QMapIterator<QString, QVariant> i(structure); - while (i.hasNext()) { - i.next(); - os << i.key() << ":" << i.value(); - if (i.hasNext()) { - os << ", "; + case QVariant::Map: { + os << "{ "; + QVariantMap structure = value.toMap(); + QMapIterator<QString, QVariant> i(structure); + while (i.hasNext()) { + i.next(); + os << i.key() << ":" << i.value(); + if (i.hasNext()) { + os << ", "; + } } - } - os << " }"; - } break; - case QVariant::List: { - os << "[ "; - QVariantList array = value.toList(); - QListIterator<QVariant> i(array); - while (i.hasNext()) { - os << i.next(); - if (i.hasNext()) { - os << ", "; + os << " }"; + } break; + case QVariant::List: { + os << "[ "; + QVariantList array = value.toList(); + QListIterator<QVariant> i(array); + while (i.hasNext()) { + os << i.next(); + if (i.hasNext()) { + os << ", "; + } } - } - os << " ]"; - } break; - default: - os << value.toString().toLatin1().data(); + os << " ]"; + } break; + default: + os << value.toString().toLatin1().data(); } return os; diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.cc b/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.cc index bcde90930f..899fc5b615 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.cc +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.cc @@ -34,6 +34,6 @@ #include "attributed_mouse_event.h" -Item *AttributedMouseEvent::item() const { - return item_; +Item* AttributedMouseEvent::item() const { + return item_; } diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.h b/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.h index 2d2babc29f..0486397058 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.h +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/attributed_mouse_event.h @@ -38,10 +38,10 @@ #include <QtCore/QObject> #if QT_4 -# include <QtDeclarative/QDeclarativeItem> +#include <QtDeclarative/QDeclarativeItem> typedef QDeclarativeItem Item; #elif QT_5 -# include <QtQuick/QQuickItem> +#include <QtQuick/QQuickItem> typedef QQuickItem Item; #endif // QT_VERSION @@ -50,12 +50,12 @@ class AttributedMouseEvent : public QObject { Q_PROPERTY(Item* item READ item) public: - explicit AttributedMouseEvent(Item *item) : item_(item) {} + explicit AttributedMouseEvent(Item* item) : item_(item) {} - Item *item() const; + Item* item() const; private: - Item *item_; + Item* item_; Q_DISABLE_COPY(AttributedMouseEvent) }; diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.cc b/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.cc index bf63c12cb1..62a090a509 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.cc +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.cc @@ -35,16 +35,16 @@ #include "hmi_hwbuttons.h" #if QT_4 -# include <QtDeclarative/qdeclarative.h> -# include <QtGui/QGraphicsColorizeEffect> +#include <QtDeclarative/qdeclarative.h> +#include <QtGui/QGraphicsColorizeEffect> #elif QT_5 -# include <QtQml> +#include <QtQml> #endif // QT_VERSION #include "masked_container.h" #include "attributed_mouse_event.h" -void HmiHWButtons::registerTypes(const char *uri) { +void HmiHWButtons::registerTypes(const char* uri) { // @uri com.ford.hmi_framework qmlRegisterType<MaskedContainer>(uri, 1, 0, "MaskedContainer"); qmlRegisterType<AttributedMouseEvent>(); diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.h b/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.h index cf8f0b5f4b..0cf71807c4 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.h +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/hmi_hwbuttons.h @@ -38,10 +38,10 @@ #include "qt_version.h" #if QT_4 -# include <QtDeclarative/QDeclarativeExtensionPlugin> +#include <QtDeclarative/QDeclarativeExtensionPlugin> typedef QDeclarativeExtensionPlugin ExtensionPlugin; #elif QT_5 -# include <QtQml/QQmlExtensionPlugin> +#include <QtQml/QQmlExtensionPlugin> typedef QQmlExtensionPlugin ExtensionPlugin; #endif // QT_VERSION @@ -52,8 +52,7 @@ class HmiHWButtons : public ExtensionPlugin { #endif // QT_5 public: - void registerTypes(const char *uri); + void registerTypes(const char* uri); }; #endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_HW_BUTTONS_HMI_HWBUTTONS_H_ - diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.cc b/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.cc index 0d144ff84c..f80e80907e 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.cc +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.cc @@ -35,74 +35,73 @@ #include "masked_container.h" #if QT_4 -# include <QtCore/QPointF> -# include <QtGui/QGraphicsSceneMouseEvent> -# define IMAGE "QDeclarativeImage" +#include <QtCore/QPointF> +#include <QtGui/QGraphicsSceneMouseEvent> +#define IMAGE "QDeclarativeImage" #elif QT_5 -# include <QtGui/QImage> -# include <QtCore/QEvent> -# define IMAGE "QQuickImage" +#include <QtGui/QImage> +#include <QtCore/QEvent> +#define IMAGE "QQuickImage" #endif // QT_VERSION -MaskedContainer::MaskedContainer(Item *parent) - : Item(parent), - mask_(NULL) { +MaskedContainer::MaskedContainer(Item* parent) : Item(parent), mask_(NULL) { setAcceptedMouseButtons(Qt::LeftButton); } void MaskedContainer::componentComplete() { - Item::componentComplete(); - - for (QObjectList::ConstIterator it = children().begin(); - it != children().end(); ++it) { - Item *item = qobject_cast<Item*>(*it); - if (item && item->inherits(IMAGE) && item->isVisible()) { - images_.push_back(item); - } + Item::componentComplete(); + + for (QObjectList::ConstIterator it = children().begin(); + it != children().end(); + ++it) { + Item* item = qobject_cast<Item*>(*it); + if (item && item->inherits(IMAGE) && item->isVisible()) { + images_.push_back(item); } + } - int height = this->height(); - int width =this->width(); - - for (size_t i = 0; i < images_.size(); ++i) { - Item *item = images_[i]; - int itemWidth = item->width(); - int itemHeight = item->height(); - int itemX = item->x(); - int itemY = item->y(); - if (height < itemHeight + itemY) - height = itemHeight + itemY; - if (width < itemWidth + itemX) - width = itemWidth + itemX; - } + int height = this->height(); + int width = this->width(); + + for (size_t i = 0; i < images_.size(); ++i) { + Item* item = images_[i]; + int itemWidth = item->width(); + int itemHeight = item->height(); + int itemX = item->x(); + int itemY = item->y(); + if (height < itemHeight + itemY) + height = itemHeight + itemY; + if (width < itemWidth + itemX) + width = itemWidth + itemX; + } - setHeight(height); - setWidth(width); - - mask_ = new int[height * width]; - std::fill(mask_, mask_ + height * width, -1); - - for (size_t i = 0; i < images_.size(); ++i) { - Item *item = images_[i]; - int itemWidth = item->width(); - int itemHeight = item->height(); - int itemX = item->x(); - int itemY = item->y(); - - QUrl url = item->property("source").toUrl(); - QImage img(url.path()); - const QRgb* bits = reinterpret_cast<const QRgb*>(img.constBits()); - for (int x = 0; x < itemWidth; ++x) { - for (int y = 0; y < itemHeight; ++y) { - if (qAlpha(bits[y * itemWidth + x]) > 128) { - mask_[(itemY + y) * width + (x + itemX)] = i; - } - } + setHeight(height); + setWidth(width); + + mask_ = new int[height * width]; + std::fill(mask_, mask_ + height * width, -1); + + for (size_t i = 0; i < images_.size(); ++i) { + Item* item = images_[i]; + int itemWidth = item->width(); + int itemHeight = item->height(); + int itemX = item->x(); + int itemY = item->y(); + + QUrl url = item->property("source").toUrl(); + QImage img(url.path()); + const QRgb* bits = reinterpret_cast<const QRgb*>(img.constBits()); + for (int x = 0; x < itemWidth; ++x) { + for (int y = 0; y < itemHeight; ++y) { + if (qAlpha(bits[y * itemWidth + x]) > 128) { + mask_[(itemY + y) * width + (x + itemX)] = i; } + } } + } } -void MaskedContainer::mousePressEvent(MouseEvent *mouse) { +void MaskedContainer::mousePressEvent(MouseEvent* mouse) { #if QT_4 qreal x = mouse->pos().x(); qreal y = mouse->pos().y(); @@ -126,7 +125,7 @@ void MaskedContainer::mousePressEvent(MouseEvent *mouse) { } } -void MaskedContainer::mouseReleaseEvent(MouseEvent *mouse) { +void MaskedContainer::mouseReleaseEvent(MouseEvent* mouse) { #if QT_4 qreal x = mouse->pos().x(); qreal y = mouse->pos().y(); @@ -152,4 +151,3 @@ void MaskedContainer::mouseReleaseEvent(MouseEvent *mouse) { MaskedContainer::~MaskedContainer() { delete[] mask_; } - diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.h b/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.h index 0048bdda2a..ae5303a693 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.h +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/masked_container.h @@ -41,11 +41,11 @@ #include "qt_version.h" #if QT_4 -# include <QtDeclarative/QDeclarativeItem> +#include <QtDeclarative/QDeclarativeItem> typedef QDeclarativeItem Item; typedef QGraphicsSceneMouseEvent MouseEvent; #elif QT_5 -# include <QtQuick/QQuickItem> +#include <QtQuick/QQuickItem> typedef QQuickItem Item; typedef QMouseEvent MouseEvent; #endif @@ -57,21 +57,21 @@ class MaskedContainer : public Item { Q_DISABLE_COPY(MaskedContainer) public: - explicit MaskedContainer(Item *parent = 0); + explicit MaskedContainer(Item* parent = 0); ~MaskedContainer(); - signals: - void pressed(AttributedMouseEvent *attr); - void released(AttributedMouseEvent *attr); +signals: + void pressed(AttributedMouseEvent* attr); + void released(AttributedMouseEvent* attr); protected: virtual void componentComplete(); - virtual void mousePressEvent(MouseEvent *event); - virtual void mouseReleaseEvent(MouseEvent *event); + virtual void mousePressEvent(MouseEvent* event); + virtual void mouseReleaseEvent(MouseEvent* event); private: std::vector<Item*> images_; - int *mask_; + int* mask_; #if QT_4 int indexOfMask(qreal x, qreal y) const { diff --git a/src/components/qt_hmi/qml_plugins/hw_buttons/qt_version.h b/src/components/qt_hmi/qml_plugins/hw_buttons/qt_version.h index fb2751504d..a700a87919 100644 --- a/src/components/qt_hmi/qml_plugins/hw_buttons/qt_version.h +++ b/src/components/qt_hmi/qml_plugins/hw_buttons/qt_version.h @@ -37,11 +37,12 @@ #include <qglobal.h> -#define QT_4 ((QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && \ - (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))) +#define QT_4 \ + ((QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && \ + (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))) -#define QT_5 ((QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && \ - (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) +#define QT_5 \ + ((QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && \ + (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) #endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_HW_BUTTONS_QT_VERSION_H_ - diff --git a/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.cc b/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.cc index da863e2e26..8b7efe23d7 100644 --- a/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.cc +++ b/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.cc @@ -37,58 +37,58 @@ #include <log4cxx/log4cxx.h> #include <log4cxx/propertyconfigurator.h> -log4cxx::LoggerPtr logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("Log4cxxPlugin")); +log4cxx::LoggerPtr logger_ = + log4cxx::LoggerPtr(log4cxx::Logger::getLogger("Log4cxxPlugin")); #if QT_4 -void smartLogger(QtMsgType type, const char *msg) { +void smartLogger(QtMsgType type, const char* msg) { log4cxx::spi::LocationInfo location("", "", -1); switch (type) { - case QtDebugMsg: - (*logger_).debug(msg, location); - break; - case QtWarningMsg: - (*logger_).warn(msg, location); - break; - case QtCriticalMsg: - (*logger_).error(msg, location); - break; - case QtFatalMsg: - (*logger_).fatal(msg, location); - break; - default: - (*logger_).info(msg, location); - break; + case QtDebugMsg: + (*logger_).debug(msg, location); + break; + case QtWarningMsg: + (*logger_).warn(msg, location); + break; + case QtCriticalMsg: + (*logger_).error(msg, location); + break; + case QtFatalMsg: + (*logger_).fatal(msg, location); + break; + default: + (*logger_).info(msg, location); + break; } } #elif QT_5 -void smartLogger(QtMsgType type, const QMessageLogContext &context, - const QString &msg) { - log4cxx::spi::LocationInfo location(context.file, - context.function ? context.function : "", - context.line); +void smartLogger(QtMsgType type, + const QMessageLogContext& context, + const QString& msg) { + log4cxx::spi::LocationInfo location( + context.file, context.function ? context.function : "", context.line); switch (type) { - case QtDebugMsg: - (*logger_).debug(msg.toStdString(), location); - break; - case QtWarningMsg: - (*logger_).warn(msg.toStdString(), location); - break; - case QtCriticalMsg: - (*logger_).error(msg.toStdString(), location); - break; - case QtFatalMsg: - (*logger_).fatal(msg.toStdString(), location); - break; - default: - (*logger_).info(msg.toStdString(), location); - break; + case QtDebugMsg: + (*logger_).debug(msg.toStdString(), location); + break; + case QtWarningMsg: + (*logger_).warn(msg.toStdString(), location); + break; + case QtCriticalMsg: + (*logger_).error(msg.toStdString(), location); + break; + case QtFatalMsg: + (*logger_).fatal(msg.toStdString(), location); + break; + default: + (*logger_).info(msg.toStdString(), location); + break; } } #endif // QT_VERSION -void Log4cxxPlugin::registerTypes(const char *uri) { +void Log4cxxPlugin::registerTypes(const char* uri) { log4cxx::PropertyConfigurator::configure("log4cxx.properties"); #if QT_4 diff --git a/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.h b/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.h index fc82352f0c..e8d1ff3347 100644 --- a/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.h +++ b/src/components/qt_hmi/qml_plugins/log4cxx/log4cxx_plugin.h @@ -37,19 +37,21 @@ #include <qglobal.h> -#define QT_4 ((QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && \ - (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))) +#define QT_4 \ + ((QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && \ + (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))) -#define QT_5 ((QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && \ - (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) +#define QT_5 \ + ((QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && \ + (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) #if QT_4 -# include <QtDeclarative/qdeclarative.h> -# include <QtDeclarative/QDeclarativeExtensionPlugin> +#include <QtDeclarative/qdeclarative.h> +#include <QtDeclarative/QDeclarativeExtensionPlugin> typedef QDeclarativeExtensionPlugin ExtensionPlugin; #elif QT_5 -# include <QtQml/qqml.h> -# include <QtQml/QQmlExtensionPlugin> +#include <QtQml/qqml.h> +#include <QtQml/QQmlExtensionPlugin> typedef QQmlExtensionPlugin ExtensionPlugin; #endif // QT_VERSION @@ -58,7 +60,7 @@ class Logger : public QObject { Q_DISABLE_COPY(Logger) public: - explicit Logger(QObject *parent = 0) : QObject(parent) {} + explicit Logger(QObject* parent = 0) : QObject(parent) {} }; class Log4cxxPlugin : public ExtensionPlugin { @@ -68,10 +70,9 @@ class Log4cxxPlugin : public ExtensionPlugin { #endif // QT_5 public: - void registerTypes(const char *uri); + void registerTypes(const char* uri); }; QML_DECLARE_TYPE(Logger) #endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_LOG4CXX_LOG4CXX_PLUGIN_H_ - diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.cc b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.cc index f51db76b99..46b057dcca 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.cc +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.cc @@ -41,10 +41,11 @@ void NamedPipeNotifier::run() { int fd = ::open(name_.toLocal8Bit().constData(), O_RDONLY); - if (-1 == fd) { // if open() fails + if (-1 == fd) { // if open() fails if ((errno != ENOENT) // we can only manage lack of pipe - || (-1 == ::mkfifo(name_.toLocal8Bit().constData(), 0666)) - || (-1 == (fd = ::open(name_.toLocal8Bit().constData(), O_RDONLY)))) { + || + (-1 == ::mkfifo(name_.toLocal8Bit().constData(), 0666)) || + (-1 == (fd = ::open(name_.toLocal8Bit().constData(), O_RDONLY)))) { emit openFailed(); return; } @@ -52,7 +53,7 @@ void NamedPipeNotifier::run() { ::fd_set readfds; FD_ZERO(&readfds); FD_SET(fd, &readfds); -// this select() is supposed to block till pipe is empty + // this select() is supposed to block till pipe is empty if (::select(fd + 1, &readfds, 0, 0, 0) > 0) { emit readyRead(); } diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.h b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.h index 993bb3cb31..cdca06466f 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.h +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier.h @@ -45,7 +45,9 @@ class NamedPipeNotifier : public QThread { public: explicit NamedPipeNotifier(QObject* parent = 0) : QThread(parent) {} - const QString& name() const { return name_; } + const QString& name() const { + return name_; + } void set_name(const QString& name) { if (name_ != name) { name_ = name; @@ -56,7 +58,7 @@ class NamedPipeNotifier : public QThread { protected: virtual void run(); - signals: +signals: void nameChanged(); void readyRead(); void openFailed(); diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.cc b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.cc index 8aa2b4cf76..dacb11ad93 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.cc +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.cc @@ -35,16 +35,16 @@ #include "named_pipe_notifier_plugin.h" #if QT_4 -# include <QtDeclarative/qdeclarative.h> +#include <QtDeclarative/qdeclarative.h> #elif QT_5 -# include <QtQml/qqml.h> +#include <QtQml/qqml.h> #endif // QT_VERSION #include "named_pipe_notifier.h" void NamedPipeNotifierPlugin::registerTypes(const char* uri) { - // @uri com.ford.sdl.hmi.named_pipe_notifier - qmlRegisterType<NamedPipeNotifier>(uri, 1, 0, "NamedPipeNotifier"); + // @uri com.ford.sdl.hmi.named_pipe_notifier + qmlRegisterType<NamedPipeNotifier>(uri, 1, 0, "NamedPipeNotifier"); } #if QT_4 diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.h b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.h index 6c64d531ac..426df483a2 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.h +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/named_pipe_notifier_plugin.h @@ -38,10 +38,10 @@ #include "qt_version.h" #if QT_4 -# include <QtDeclarative/QDeclarativeExtensionPlugin> +#include <QtDeclarative/QDeclarativeExtensionPlugin> typedef QDeclarativeExtensionPlugin ExtensionPlugin; #elif QT_5 -# include <QtQml/QQmlExtensionPlugin> +#include <QtQml/QQmlExtensionPlugin> typedef QQmlExtensionPlugin ExtensionPlugin; #endif // QT_5 diff --git a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/qt_version.h b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/qt_version.h index 91533346c0..0e2456d732 100644 --- a/src/components/qt_hmi/qml_plugins/named_pipe_notifier/qt_version.h +++ b/src/components/qt_hmi/qml_plugins/named_pipe_notifier/qt_version.h @@ -37,11 +37,12 @@ #include <qglobal.h> -#define QT_4 ((QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && \ - (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))) +#define QT_4 \ + ((QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && \ + (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))) -#define QT_5 ((QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && \ - (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) +#define QT_5 \ + ((QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && \ + (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) #endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_NAMED_PIPE_NOTIFIER_QT_VERSION_H_ - |