aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2016-05-13 10:19:30 +0200
committerDominik Holland <dominik.holland@pelagicore.com>2016-05-13 16:32:38 +0000
commit2be94ce592089c62bd808d58d6707f037858af15 (patch)
treee819a18b937ad076c3a8bc18dfff9396ffa0086b
parentce0593db73d3fd620e9264f9650ec8b5418a1b89 (diff)
Added a QtIVIAbstractFeatureListModel class
This class can be used when a new Feature needs to be created which needs to be a QAbstractListModel and a QtIVIAbstractFeature at the same time. The class doesn't introduce any new functionality it's just forwarding all calls and signals to an underlying QtIVIAbstracteFeature and makes deriving easier. Change-Id: Iaa883ea8de8940b10c7222e0239c5e92c77385a4 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rw-r--r--src/ivicore/ivicore.pro7
-rw-r--r--src/ivicore/qtiviabstractfeaturelistmodel.cpp180
-rw-r--r--src/ivicore/qtiviabstractfeaturelistmodel.h105
-rw-r--r--src/ivicore/qtiviabstractfeaturelistmodel_p.h90
4 files changed, 380 insertions, 2 deletions
diff --git a/src/ivicore/ivicore.pro b/src/ivicore/ivicore.pro
index 9238e95..95835ad 100644
--- a/src/ivicore/ivicore.pro
+++ b/src/ivicore/ivicore.pro
@@ -28,7 +28,9 @@ HEADERS += \
qtiviabstractzonedfeature_p.h \
qtiviqmlconversion_helper.h \
qtivipropertytester_p.h \
- qtivitypetraits.h
+ qtivitypetraits.h \
+ qtiviabstractfeaturelistmodel.h \
+ qtiviabstractfeaturelistmodel_p.h
SOURCES += \
qtiviservicemanager.cpp \
@@ -39,7 +41,8 @@ SOURCES += \
qtivizonedfeatureinterface.cpp \
qtivipropertyattribute.cpp \
qtiviproperty.cpp \
- qtivipropertyfactory.cpp
+ qtivipropertyfactory.cpp \
+ qtiviabstractfeaturelistmodel.cpp
include(queryparser/queryparser.pri)
diff --git a/src/ivicore/qtiviabstractfeaturelistmodel.cpp b/src/ivicore/qtiviabstractfeaturelistmodel.cpp
new file mode 100644
index 0000000..a2368b0
--- /dev/null
+++ b/src/ivicore/qtiviabstractfeaturelistmodel.cpp
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** 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 "qtiviabstractfeaturelistmodel.h"
+#include "qtiviabstractfeaturelistmodel_p.h"
+
+QtIVIHelperFeature::QtIVIHelperFeature(const QString &interface, QtIVIAbstractFeatureListModel *model)
+ : QtIVIAbstractFeature(interface)
+ , m_model(model)
+{
+}
+
+bool QtIVIHelperFeature::acceptServiceObject(QtIVIServiceObject *so)
+{
+ return m_model->acceptServiceObject(so);
+}
+
+void QtIVIHelperFeature::connectToServiceObject(QtIVIServiceObject *so)
+{
+ m_model->connectToServiceObject(so);
+}
+
+void QtIVIHelperFeature::disconnectFromServiceObject(QtIVIServiceObject *so)
+{
+ m_model->disconnectFromServiceObject(so);
+}
+
+void QtIVIHelperFeature::clearServiceObject()
+{
+ m_model->clearServiceObject();
+}
+
+QtIVIAbstractFeatureListModelPrivate::QtIVIAbstractFeatureListModelPrivate(const QString &interface, QtIVIAbstractFeatureListModel *model)
+ : QAbstractItemModelPrivate()
+ , m_feature(new QtIVIHelperFeature(interface, model))
+{
+
+}
+
+QtIVIAbstractFeatureListModelPrivate::~QtIVIAbstractFeatureListModelPrivate()
+{
+ delete m_feature;
+}
+
+QtIVIAbstractFeatureListModel::QtIVIAbstractFeatureListModel(const QString &interface, QObject *parent)
+ : QAbstractListModel(*new QtIVIAbstractFeatureListModelPrivate(interface, this), parent)
+{
+ Q_D(QtIVIAbstractFeatureListModel);
+ connect(d->m_feature, &QtIVIAbstractFeature::serviceObjectChanged, this, &QtIVIAbstractFeatureListModel::serviceObjectChanged);
+ connect(d->m_feature, &QtIVIAbstractFeature::discoveryModeChanged, this, &QtIVIAbstractFeatureListModel::discoveryModeChanged);
+ connect(d->m_feature, &QtIVIAbstractFeature::discoveryResultChanged, this, &QtIVIAbstractFeatureListModel::discoveryResultChanged);
+ connect(d->m_feature, &QtIVIAbstractFeature::isValidChanged, this, &QtIVIAbstractFeatureListModel::isValidChanged);
+ connect(d->m_feature, &QtIVIAbstractFeature::errorChanged, this, &QtIVIAbstractFeatureListModel::errorChanged);
+}
+
+QtIVIAbstractFeatureListModel::~QtIVIAbstractFeatureListModel()
+{
+
+}
+
+QtIVIServiceObject *QtIVIAbstractFeatureListModel::serviceObject() const
+{
+ Q_D(const QtIVIAbstractFeatureListModel);
+ return d->m_feature->serviceObject();
+}
+
+QtIVIAbstractFeature::DiscoveryMode QtIVIAbstractFeatureListModel::discoveryMode() const
+{
+ Q_D(const QtIVIAbstractFeatureListModel);
+ return d->m_feature->discoveryMode();
+}
+
+QtIVIAbstractFeature::DiscoveryResult QtIVIAbstractFeatureListModel::discoveryResult() const
+{
+ Q_D(const QtIVIAbstractFeatureListModel);
+ return d->m_feature->discoveryResult();
+}
+
+bool QtIVIAbstractFeatureListModel::isValid() const
+{
+ Q_D(const QtIVIAbstractFeatureListModel);
+ return d->m_feature->isValid();
+}
+
+QtIVIAbstractFeature::Error QtIVIAbstractFeatureListModel::error() const
+{
+ Q_D(const QtIVIAbstractFeatureListModel);
+ return d->m_feature->error();
+}
+
+QString QtIVIAbstractFeatureListModel::errorMessage() const
+{
+ Q_D(const QtIVIAbstractFeatureListModel);
+ return d->m_feature->errorMessage();
+}
+
+bool QtIVIAbstractFeatureListModel::setServiceObject(QtIVIServiceObject *so)
+{
+ Q_D(QtIVIAbstractFeatureListModel);
+ return d->m_feature->setServiceObject(so);
+}
+
+void QtIVIAbstractFeatureListModel::setDiscoveryMode(QtIVIAbstractFeature::DiscoveryMode discoveryMode)
+{
+ Q_D(QtIVIAbstractFeatureListModel);
+ return d->m_feature->setDiscoveryMode(discoveryMode);
+}
+
+QtIVIAbstractFeature::DiscoveryResult QtIVIAbstractFeatureListModel::startAutoDiscovery()
+{
+ Q_D(QtIVIAbstractFeatureListModel);
+ return d->m_feature->startAutoDiscovery();
+}
+
+QtIVIAbstractFeatureListModel::QtIVIAbstractFeatureListModel(QtIVIAbstractFeatureListModelPrivate &dd, QObject *parent)
+ : QAbstractListModel(dd, parent)
+{
+ Q_D(QtIVIAbstractFeatureListModel);
+ connect(d->m_feature, &QtIVIAbstractFeature::serviceObjectChanged, this, &QtIVIAbstractFeatureListModel::serviceObjectChanged);
+ connect(d->m_feature, &QtIVIAbstractFeature::discoveryModeChanged, this, &QtIVIAbstractFeatureListModel::discoveryModeChanged);
+ connect(d->m_feature, &QtIVIAbstractFeature::discoveryResultChanged, this, &QtIVIAbstractFeatureListModel::discoveryResultChanged);
+ connect(d->m_feature, &QtIVIAbstractFeature::isValidChanged, this, &QtIVIAbstractFeatureListModel::isValidChanged);
+ connect(d->m_feature, &QtIVIAbstractFeature::errorChanged, this, &QtIVIAbstractFeatureListModel::errorChanged);
+}
+
+QString QtIVIAbstractFeatureListModel::interfaceName() const
+{
+ Q_D(const QtIVIAbstractFeatureListModel);
+ return d->m_feature->interfaceName();
+}
+
+QString QtIVIAbstractFeatureListModel::errorText() const
+{
+ Q_D(const QtIVIAbstractFeatureListModel);
+ return d->m_feature->errorText();
+}
+
+void QtIVIAbstractFeatureListModel::setError(QtIVIAbstractFeature::Error error, const QString &message)
+{
+ Q_D(QtIVIAbstractFeatureListModel);
+ d->m_feature->setError(error, message);
+}
diff --git a/src/ivicore/qtiviabstractfeaturelistmodel.h b/src/ivicore/qtiviabstractfeaturelistmodel.h
new file mode 100644
index 0000000..5c80e00
--- /dev/null
+++ b/src/ivicore/qtiviabstractfeaturelistmodel.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** 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 QTIVIABSTRACTFEATURELISTMODEL_H
+#define QTIVIABSTRACTFEATURELISTMODEL_H
+
+#include <QAbstractListModel>
+#include <QtIVICore/QtIVIAbstractFeature>
+
+QT_BEGIN_NAMESPACE
+
+class QtIVIAbstractFeatureListModelPrivate;
+
+class Q_QTIVICORE_EXPORT QtIVIAbstractFeatureListModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QtIVIAbstractFeature::DiscoveryMode discoveryMode READ discoveryMode WRITE setDiscoveryMode NOTIFY discoveryModeChanged)
+ Q_PROPERTY(QtIVIAbstractFeature::DiscoveryResult discoveryResult READ discoveryResult NOTIFY discoveryResultChanged)
+ Q_PROPERTY(QtIVIServiceObject* serviceObject READ serviceObject WRITE setServiceObject NOTIFY serviceObjectChanged)
+ Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged)
+ Q_PROPERTY(QString error READ errorMessage NOTIFY errorChanged)
+
+public:
+
+ explicit QtIVIAbstractFeatureListModel(const QString &interface, QObject *parent = 0);
+ ~QtIVIAbstractFeatureListModel();
+
+ QtIVIServiceObject *serviceObject() const;
+ QtIVIAbstractFeature::DiscoveryMode discoveryMode() const;
+ QtIVIAbstractFeature::DiscoveryResult discoveryResult() const;
+ bool isValid() const;
+ QtIVIAbstractFeature::Error error() const;
+ QString errorMessage() const;
+
+public Q_SLOTS:
+ bool setServiceObject(QtIVIServiceObject *so);
+ void setDiscoveryMode(QtIVIAbstractFeature::DiscoveryMode discoveryMode);
+ QtIVIAbstractFeature::DiscoveryResult startAutoDiscovery();
+
+Q_SIGNALS:
+ void serviceObjectChanged();
+ void discoveryModeChanged(QtIVIAbstractFeature::DiscoveryMode discoveryMode);
+ void discoveryResultChanged(QtIVIAbstractFeature::DiscoveryResult discoveryResult);
+ void isValidChanged(bool arg);
+ void errorChanged(QtIVIAbstractFeature::Error error, const QString &message);
+
+protected:
+ QtIVIAbstractFeatureListModel(QtIVIAbstractFeatureListModelPrivate &dd, QObject *parent = Q_NULLPTR);
+
+ virtual bool acceptServiceObject(QtIVIServiceObject*) = 0;
+ virtual void connectToServiceObject(QtIVIServiceObject*) = 0;
+ virtual void disconnectFromServiceObject(QtIVIServiceObject*) = 0;
+ virtual void clearServiceObject() = 0;
+
+ QString interfaceName() const;
+ QString errorText() const;
+ void setError(QtIVIAbstractFeature::Error error, const QString &message = QString());
+
+private:
+ Q_DECLARE_PRIVATE(QtIVIAbstractFeatureListModel)
+ friend class QtIVIHelperFeature;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTIVIABSTRACTFEATURELISTMODEL_H
diff --git a/src/ivicore/qtiviabstractfeaturelistmodel_p.h b/src/ivicore/qtiviabstractfeaturelistmodel_p.h
new file mode 100644
index 0000000..08ddd49
--- /dev/null
+++ b/src/ivicore/qtiviabstractfeaturelistmodel_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** 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 QTIVIABSTRACTFEATURELISTMODEL_P_H
+#define QTIVIABSTRACTFEATURELISTMODEL_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 <private/qabstractitemmodel_p.h>
+
+#include "qtiviabstractfeaturelistmodel.h"
+
+QT_BEGIN_NAMESPACE
+
+class QtIVIHelperFeature : public QtIVIAbstractFeature
+{
+public:
+ QtIVIHelperFeature(const QString &interface, QtIVIAbstractFeatureListModel *model);
+
+ bool acceptServiceObject(QtIVIServiceObject *so);
+ void connectToServiceObject(QtIVIServiceObject *so);
+ void disconnectFromServiceObject(QtIVIServiceObject *so);
+ void clearServiceObject();
+
+ using QtIVIAbstractFeature::interfaceName;
+ using QtIVIAbstractFeature::errorText;
+ using QtIVIAbstractFeature::setError;
+
+ QtIVIAbstractFeatureListModel *m_model;
+};
+
+class Q_QTIVICORE_EXPORT QtIVIAbstractFeatureListModelPrivate : public QAbstractItemModelPrivate
+{
+public:
+ QtIVIAbstractFeatureListModelPrivate(const QString &interface, QtIVIAbstractFeatureListModel *model);
+ virtual ~QtIVIAbstractFeatureListModelPrivate();
+
+ QtIVIHelperFeature *m_feature;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTIVIABSTRACTFEATURELISTMODEL_P_H