summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/imports/location/location.cpp4
-rw-r--r--src/imports/location/location.h8
-rw-r--r--src/location/CMakeLists.txt2
-rw-r--r--src/location/declarativeplaces/qdeclarativeplace.cpp18
-rw-r--r--src/location/declarativeplaces/qdeclarativeplace_p.h10
-rw-r--r--src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp23
-rw-r--r--src/location/declarativeplaces/qdeclarativeplacecontentmodel_p.h4
-rw-r--r--src/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp2
-rw-r--r--src/location/declarativeplaces/qdeclarativeplaceimagemodel_p.h2
-rw-r--r--src/location/declarativeplaces/qdeclarativereviewmodel.cpp2
-rw-r--r--src/location/declarativeplaces/qdeclarativesupplier.cpp212
-rw-r--r--src/location/declarativeplaces/qdeclarativesupplier_p.h116
-rw-r--r--src/location/places/qplacesupplier.cpp77
-rw-r--r--src/location/places/qplacesupplier.h8
-rw-r--r--tests/auto/declarative_location_core/tst_place.qml35
-rw-r--r--tests/auto/declarative_location_core/tst_supplier.qml22
-rw-r--r--tests/auto/qmlinterface/data/TestPlace.qml7
-rw-r--r--tests/auto/qmlinterface/data/TestSupplier.qml14
18 files changed, 133 insertions, 433 deletions
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index e09062a4..6efc7b2b 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -60,7 +60,6 @@
//Place includes
#include <QtLocation/private/qdeclarativecategory_p.h>
#include <QtLocation/private/qdeclarativeplace_p.h>
-#include <QtLocation/private/qdeclarativesupplier_p.h>
#include <QtLocation/private/qdeclarativecontactdetail_p.h>
#include <QtLocation/private/qdeclarativesupportedcategoriesmodel_p.h>
@@ -188,7 +187,6 @@ public:
qmlRegisterType<QDeclarativePlaceImageModel >(uri, major, minor, "ImageModel");
qmlRegisterType<QDeclarativePlace >(uri, major, minor, "Place");
qmlRegisterType<QDeclarativeReviewModel >(uri, major, minor, "ReviewModel");
- qmlRegisterType<QDeclarativeSupplier >(uri, major, minor, "Supplier");
qmlRegisterType<QDeclarativeRectangleMapItem >(uri, major, minor, "MapRectangle");
qmlRegisterType<QDeclarativeCircleMapItem >(uri, major, minor, "MapCircle");
qmlRegisterAnonymousType<QDeclarativeMapLineProperties >(uri, major);
@@ -268,11 +266,11 @@ public:
//registrations below are version independent
qRegisterMetaType<QPlaceCategory>();
qRegisterMetaType<QPlace>();
- qRegisterMetaType<QPlaceSupplier>();
qRegisterMetaType<QPlaceContactDetail>();
registerConverterToGadget<QPlaceRatings>();
registerConverterToGadget<QPlaceIcon>();
+ registerConverterToGadget<QPlaceSupplier>();
} else {
qDebug() << "Unsupported URI given to load location QML plugin: " << QLatin1String(uri);
}
diff --git a/src/imports/location/location.h b/src/imports/location/location.h
index 162b572b..faef0b9a 100644
--- a/src/imports/location/location.h
+++ b/src/imports/location/location.h
@@ -55,6 +55,7 @@
#include <QGeoRouteSegment>
#include <QPlaceAttribute>
#include <QPlaceUser>
+#include <QPlaceSupplier>
#include <QPlaceRatings>
#include <QPlaceIcon>
@@ -127,6 +128,13 @@ struct QPlaceIconForeign
QML_NAMED_ELEMENT(icon)
};
+struct QPlaceSupplierForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QPlaceSupplier)
+ QML_NAMED_ELEMENT(supplier)
+};
+
QT_END_NAMESPACE
#endif // QTLOCATION_QMLTYPES_H
diff --git a/src/location/CMakeLists.txt b/src/location/CMakeLists.txt
index 47c62b7f..f0fb2a46 100644
--- a/src/location/CMakeLists.txt
+++ b/src/location/CMakeLists.txt
@@ -147,8 +147,6 @@ qt_internal_add_module(Location
declarativeplaces/qdeclarativesearchresultmodel_p.h
declarativeplaces/qdeclarativesearchsuggestionmodel.cpp
declarativeplaces/qdeclarativesearchsuggestionmodel_p.h
- declarativeplaces/qdeclarativesupplier.cpp
- declarativeplaces/qdeclarativesupplier_p.h
declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
declarativeplaces/qdeclarativesupportedcategoriesmodel_p.h
labs/qgeojson_p.h labs/qgeojson.cpp
diff --git a/src/location/declarativeplaces/qdeclarativeplace.cpp b/src/location/declarativeplaces/qdeclarativeplace.cpp
index 54010656..146ab6ec 100644
--- a/src/location/declarativeplaces/qdeclarativeplace.cpp
+++ b/src/location/declarativeplaces/qdeclarativeplace.cpp
@@ -325,14 +325,7 @@ void QDeclarativePlace::setPlace(const QPlace &src)
}
setRatings(m_src.ratings());
-
- if (m_supplier && m_supplier->parent() == this) {
- m_supplier->setSupplier(m_src.supplier(), m_plugin);
- } else if (!m_supplier || m_supplier->parent() != this) {
- m_supplier = new QDeclarativeSupplier(m_src.supplier(), m_plugin, this);
- emit supplierChanged();
- }
-
+ setSupplier(m_src.supplier());
setIcon(m_src.icon());
if (previous.name() != m_src.name()) {
@@ -397,7 +390,7 @@ QPlace QDeclarativePlace::place() const
result.setRatings(m_ratings);
// Supplier
- result.setSupplier(m_supplier ? m_supplier->supplier() : QPlaceSupplier());
+ result.setSupplier(m_supplier);
// Icon
result.setIcon(m_icon);
@@ -474,19 +467,16 @@ QPlaceRatings QDeclarativePlace::ratings() const
This property holds the supplier of the place data.
The supplier is typically a business or organization that collected the data about the place.
*/
-void QDeclarativePlace::setSupplier(QDeclarativeSupplier *supplier)
+void QDeclarativePlace::setSupplier(const QPlaceSupplier &supplier)
{
if (m_supplier == supplier)
return;
- if (m_supplier && m_supplier->parent() == this)
- delete m_supplier;
-
m_supplier = supplier;
emit supplierChanged();
}
-QDeclarativeSupplier *QDeclarativePlace::supplier() const
+QPlaceSupplier QDeclarativePlace::supplier() const
{
return m_supplier;
}
diff --git a/src/location/declarativeplaces/qdeclarativeplace_p.h b/src/location/declarativeplaces/qdeclarativeplace_p.h
index 0a070253..53ac944a 100644
--- a/src/location/declarativeplaces/qdeclarativeplace_p.h
+++ b/src/location/declarativeplaces/qdeclarativeplace_p.h
@@ -63,7 +63,6 @@
#include <QtPositioningQuick/private/qdeclarativegeolocation_p.h>
#include <QtLocation/private/qdeclarativecategory_p.h>
#include <QtLocation/private/qdeclarativecontactdetail_p.h>
-#include <QtLocation/private/qdeclarativesupplier_p.h>
#include <QtLocation/private/qdeclarativereviewmodel_p.h>
#include <QtLocation/private/qdeclarativeplaceimagemodel_p.h>
#include <QtLocation/private/qdeclarativeplaceeditorialmodel_p.h>
@@ -72,6 +71,7 @@ QT_BEGIN_NAMESPACE
class QPlaceReply;
class QPlaceManager;
+class QPlaceSupplier;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativePlace : public QObject, public QQmlParserStatus
{
@@ -84,7 +84,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativePlace : public QObject, public QQmlP
Q_PROPERTY(QQmlListProperty<QDeclarativeCategory> categories READ categories NOTIFY categoriesChanged)
Q_PROPERTY(QDeclarativeGeoLocation *location READ location WRITE setLocation NOTIFY locationChanged)
Q_PROPERTY(QPlaceRatings ratings READ ratings WRITE setRatings NOTIFY ratingsChanged)
- Q_PROPERTY(QDeclarativeSupplier *supplier READ supplier WRITE setSupplier NOTIFY supplierChanged)
+ Q_PROPERTY(QPlaceSupplier supplier READ supplier WRITE setSupplier NOTIFY supplierChanged)
Q_PROPERTY(QPlaceIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString placeId READ placeId WRITE setPlaceId NOTIFY placeIdChanged)
@@ -147,8 +147,8 @@ public:
void setLocation(QDeclarativeGeoLocation *location);
QPlaceRatings ratings() const;
void setRatings(const QPlaceRatings &ratings);
- QDeclarativeSupplier *supplier() const;
- void setSupplier(QDeclarativeSupplier *supplier);
+ QPlaceSupplier supplier() const;
+ void setSupplier(const QPlaceSupplier &supplier);
QPlaceIcon icon() const;
void setIcon(const QPlaceIcon &icon);
QString name() const;
@@ -229,7 +229,7 @@ private:
QList<QDeclarativeCategory *> m_categories;
QDeclarativeGeoLocation *m_location = nullptr;
QPlaceRatings m_ratings;
- QDeclarativeSupplier *m_supplier = nullptr;
+ QPlaceSupplier m_supplier;
QPlaceIcon m_icon;
QDeclarativeReviewModel *m_reviewModel = nullptr;
QDeclarativePlaceImageModel *m_imageModel = nullptr;
diff --git a/src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp b/src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
index 3a567927..df619742 100644
--- a/src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
@@ -123,10 +123,7 @@ int QDeclarativePlaceContentModel::totalCount() const
void QDeclarativePlaceContentModel::clearData()
{
m_users.clear();
-
- qDeleteAll(m_suppliers);
m_suppliers.clear();
-
m_content.clear();
m_contentCount = -1;
@@ -156,10 +153,8 @@ void QDeclarativePlaceContentModel::initializeCollection(int totalCount, const Q
continue;
m_content.insert(i.key(), content);
- if (!m_suppliers.contains(content.supplier().supplierId())) {
- m_suppliers.insert(content.supplier().supplierId(),
- new QDeclarativeSupplier(content.supplier(), m_place->plugin(), this));
- }
+ if (!m_suppliers.contains(content.supplier().supplierId()))
+ m_suppliers.insert(content.supplier().supplierId(), content.supplier());
if (!m_users.contains(content.user().userId()))
m_users.insert(content.user().userId(), content.user());
}
@@ -198,7 +193,7 @@ QVariant QDeclarativePlaceContentModel::data(const QModelIndex &index, int role)
switch (role) {
case SupplierRole:
- return QVariant::fromValue(static_cast<QObject *>(m_suppliers.value(content.supplier().supplierId())));
+ return QVariant::fromValue(m_suppliers.value(content.supplier().supplierId()));
case PlaceUserRole:
return QVariant::fromValue(m_users.value(content.user().userId()));
case AttributionRole:
@@ -338,10 +333,8 @@ void QDeclarativePlaceContentModel::fetchFinished()
const QPlaceContent &content = contents.value(i);
m_content.insert(i, content);
- if (!m_suppliers.contains(content.supplier().supplierId())) {
- m_suppliers.insert(content.supplier().supplierId(),
- new QDeclarativeSupplier(content.supplier(), m_place->plugin(), this));
- }
+ if (!m_suppliers.contains(content.supplier().supplierId()))
+ m_suppliers.insert(content.supplier().supplierId(), content.supplier());
if (!m_users.contains(content.user().userId()))
m_users.insert(content.user().userId(), content.user());
}
@@ -363,10 +356,8 @@ void QDeclarativePlaceContentModel::fetchFinished()
for (int i = startIndex; i <= currentIndex; ++i) {
const QPlaceContent &content = contents.value(i);
m_content.insert(i, content);
- if (!m_suppliers.contains(content.supplier().supplierId())) {
- m_suppliers.insert(content.supplier().supplierId(),
- new QDeclarativeSupplier(content.supplier(), m_place->plugin(), this));
- }
+ if (!m_suppliers.contains(content.supplier().supplierId()))
+ m_suppliers.insert(content.supplier().supplierId(), content.supplier());
if (!m_users.contains(content.user().userId()))
m_users.insert(content.user().userId(), content.user());
}
diff --git a/src/location/declarativeplaces/qdeclarativeplacecontentmodel_p.h b/src/location/declarativeplaces/qdeclarativeplacecontentmodel_p.h
index 7beed04b..a46ac1a0 100644
--- a/src/location/declarativeplaces/qdeclarativeplacecontentmodel_p.h
+++ b/src/location/declarativeplaces/qdeclarativeplacecontentmodel_p.h
@@ -57,6 +57,7 @@
#include <QtLocation/QPlaceContent>
#include <QtLocation/QPlaceContentReply>
#include <QtLocation/QPlaceContentRequest>
+#include <QtLocation/QPlaceSupplier>
Q_MOC_INCLUDE(<QtLocation/private/qdeclarativeplace_p.h>)
@@ -65,7 +66,6 @@ QT_BEGIN_NAMESPACE
class QDeclarativePlace;
class QDeclarativeGeoServiceProvider;
class QGeoServiceProvider;
-class QDeclarativeSupplier;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativePlaceContentModel : public QAbstractListModel, public QQmlParserStatus
{
@@ -122,7 +122,7 @@ private Q_SLOTS:
protected:
QPlaceContent::Collection m_content;
- QMap<QString, QDeclarativeSupplier *> m_suppliers;
+ QMap<QString, QPlaceSupplier> m_suppliers;
QMap<QString, QPlaceUser>m_users;
private:
diff --git a/src/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp b/src/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp
index d141905d..54698928 100644
--- a/src/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qdeclarativeplaceimagemodel_p.h"
-#include "qdeclarativesupplier_p.h"
#include <QtCore/QUrl>
#include <QtLocation/QPlaceImage>
@@ -133,7 +132,6 @@ QDeclarativePlaceImageModel::QDeclarativePlaceImageModel(QObject *parent)
QDeclarativePlaceImageModel::~QDeclarativePlaceImageModel()
{
- qDeleteAll(m_suppliers);
}
/*!
diff --git a/src/location/declarativeplaces/qdeclarativeplaceimagemodel_p.h b/src/location/declarativeplaces/qdeclarativeplaceimagemodel_p.h
index 3e26c566..d13e26a6 100644
--- a/src/location/declarativeplaces/qdeclarativeplaceimagemodel_p.h
+++ b/src/location/declarativeplaces/qdeclarativeplaceimagemodel_p.h
@@ -56,8 +56,6 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeSupplier;
-
class Q_LOCATION_PRIVATE_EXPORT QDeclarativePlaceImageModel : public QDeclarativePlaceContentModel
{
Q_OBJECT
diff --git a/src/location/declarativeplaces/qdeclarativereviewmodel.cpp b/src/location/declarativeplaces/qdeclarativereviewmodel.cpp
index d4b002c8..e8c597ac 100644
--- a/src/location/declarativeplaces/qdeclarativereviewmodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativereviewmodel.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qdeclarativereviewmodel_p.h"
-#include "qdeclarativesupplier_p.h"
#include <QtCore/QDateTime>
#include <QtLocation/QPlaceReview>
@@ -137,7 +136,6 @@ QDeclarativeReviewModel::QDeclarativeReviewModel(QObject *parent)
QDeclarativeReviewModel::~QDeclarativeReviewModel()
{
- qDeleteAll(m_suppliers);
}
/*!
diff --git a/src/location/declarativeplaces/qdeclarativesupplier.cpp b/src/location/declarativeplaces/qdeclarativesupplier.cpp
deleted file mode 100644
index 91e2eb77..00000000
--- a/src/location/declarativeplaces/qdeclarativesupplier.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt 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$
-**
-****************************************************************************/
-
-#include "qdeclarativesupplier_p.h"
-
-#include <QtLocation/QPlaceIcon>
-#include <QtCore/QUrl>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype Supplier
- \instantiates QDeclarativeSupplier
- \inqmlmodule QtLocation
- \ingroup qml-QtLocation5-places
- \ingroup qml-QtLocation5-places-data
- \since QtLocation 5.5
-
- \brief Holds data regarding the supplier of a place, a place's image, review, or editorial.
-
- Each instance represents a set of data about a supplier, which can include
- supplier's name, url and icon. The supplier is typically a business or organization.
-
- Note: The Places API only supports suppliers as 'retrieve-only' objects. Submitting
- suppliers to a provider is not a supported use case.
-
- \sa ImageModel, ReviewModel, EditorialModel
-
- \section1 Example
-
- The following example shows how to create and display a supplier in QML:
-
- \snippet declarative/places.qml QtQuick import
- \snippet declarative/maps.qml QtLocation import
- \codeline
- \snippet declarative/places.qml Supplier
-*/
-
-QDeclarativeSupplier::QDeclarativeSupplier(QObject *parent)
- : QObject(parent)
-{
-}
-
-QDeclarativeSupplier::QDeclarativeSupplier(const QPlaceSupplier &src,
- QDeclarativeGeoServiceProvider *plugin,
- QObject *parent)
- : QObject(parent),
- m_src(src)
-{
- setSupplier(src, plugin);
-}
-
-QDeclarativeSupplier::~QDeclarativeSupplier()
-{
-}
-
-/*!
- \internal
-*/
-void QDeclarativeSupplier::componentComplete()
-{
-}
-
-/*!
- \qmlproperty QPlaceSupplier Supplier::supplier
-
- For details on how to use this property to interface between C++ and QML see
- "\l {Supplier - QPlaceSupplier} {Interfaces between C++ and QML Code}".
-*/
-void QDeclarativeSupplier::setSupplier(const QPlaceSupplier &src, QDeclarativeGeoServiceProvider *)
-{
- QPlaceSupplier previous = m_src;
- m_src = src;
-
- if (previous.name() != m_src.name())
- emit nameChanged();
-
- if (previous.supplierId() != m_src.supplierId())
- emit supplierIdChanged();
-
- if (previous.url() != m_src.url())
- emit urlChanged();
-
- setIcon(m_src.icon());
-}
-
-QPlaceSupplier QDeclarativeSupplier::supplier()
-{
- m_src.setIcon(m_icon);
- return m_src;
-}
-
-/*!
- \qmlproperty string Supplier::supplierId
-
- This property holds the identifier of the supplier. The identifier is unique
- to the Plugin backend which provided the supplier and is generally
- not suitable for displaying to the user.
-*/
-
-void QDeclarativeSupplier::setSupplierId(const QString &supplierId)
-{
- if (m_src.supplierId() != supplierId) {
- m_src.setSupplierId(supplierId);
- emit supplierIdChanged();
- }
-}
-
-QString QDeclarativeSupplier::supplierId() const
-{
- return m_src.supplierId();
-}
-
-/*!
- \qmlproperty string Supplier::name
-
- This property holds the name of the supplier which can be displayed
- to the user.
-
- The name can potentially be localized. The language is dependent on the
- entity that sets it, typically this is the \l Plugin. The \l {Plugin::locales}
- property defines what language is used.
-*/
-
-void QDeclarativeSupplier::setName(const QString &name)
-{
- if (m_src.name() != name) {
- m_src.setName(name);
- emit nameChanged();
- }
-}
-
-QString QDeclarativeSupplier::name() const
-{
- return m_src.name();
-}
-
-/*!
- \qmlproperty url Supplier::url
-
- This property holds the URL of the supplier's website.
-*/
-
-void QDeclarativeSupplier::setUrl(const QUrl &url)
-{
- if (m_src.url() != url) {
- m_src.setUrl(url);
- emit urlChanged();
- }
-}
-
-QUrl QDeclarativeSupplier::url() const
-{
- return m_src.url();
-}
-
-/*!
- \qmlproperty PlaceIcon Supplier::icon
-
- This property holds the icon of the supplier.
-*/
-QPlaceIcon QDeclarativeSupplier::icon() const
-{
- return m_icon;
-}
-
-void QDeclarativeSupplier::setIcon(const QPlaceIcon &icon)
-{
- if (m_icon == icon)
- return;
-
- m_icon = icon;
- emit iconChanged();
-}
-
-QT_END_NAMESPACE
diff --git a/src/location/declarativeplaces/qdeclarativesupplier_p.h b/src/location/declarativeplaces/qdeclarativesupplier_p.h
deleted file mode 100644
index 7e6b2a5c..00000000
--- a/src/location/declarativeplaces/qdeclarativesupplier_p.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt 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$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVESUPPLIER_P_H
-#define QDECLARATIVESUPPLIER_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 <QtLocation/private/qlocationglobal_p.h>
-#include <QObject>
-#include <QtCore/QUrl>
-#include <QtQml/qqml.h>
-#include <QtQml/QQmlParserStatus>
-#include <QtLocation/qplaceicon.h>
-#include <QtLocation/qplacesupplier.h>
-
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeGeoServiceProvider;
-
-class Q_LOCATION_PRIVATE_EXPORT QDeclarativeSupplier : public QObject, public QQmlParserStatus
-{
- Q_OBJECT
-
- Q_PROPERTY(QPlaceSupplier supplier READ supplier WRITE setSupplier)
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QString supplierId READ supplierId WRITE setSupplierId NOTIFY supplierIdChanged)
- Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
- Q_PROPERTY(QPlaceIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
-
- Q_INTERFACES(QQmlParserStatus)
-
-public:
- explicit QDeclarativeSupplier(QObject *parent = 0);
- explicit QDeclarativeSupplier(const QPlaceSupplier &src, QDeclarativeGeoServiceProvider *plugin, QObject *parent = 0);
- ~QDeclarativeSupplier();
-
- // From QQmlParserStatus
- void classBegin() override { }
- void componentComplete() override;
-
- QPlaceSupplier supplier();
- void setSupplier(const QPlaceSupplier &src, QDeclarativeGeoServiceProvider *plugin = 0);
-
- QString name() const;
- void setName(const QString &data);
- QString supplierId() const;
- void setSupplierId(const QString &data);
- QUrl url() const;
- void setUrl(const QUrl &data);
-
- QPlaceIcon icon() const;
- void setIcon(const QPlaceIcon &icon);
-
-Q_SIGNALS:
- void nameChanged();
- void supplierIdChanged();
- void urlChanged();
- void iconChanged();
-
-private:
- QPlaceSupplier m_src;
- QPlaceIcon m_icon;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeSupplier)
-
-#endif // QDECLARATIVESUPPLIER_P_H
diff --git a/src/location/places/qplacesupplier.cpp b/src/location/places/qplacesupplier.cpp
index 7b730f94..fc9d8f87 100644
--- a/src/location/places/qplacesupplier.cpp
+++ b/src/location/places/qplacesupplier.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtLocation module of the Qt Toolkit.
@@ -81,6 +81,33 @@ bool QPlaceSupplierPrivate::isEmpty() const
*/
/*!
+ \qmlvaluetype supplier
+ \inqmlmodule QtLocation
+ \ingroup qml-QtLocation5-places
+ \ingroup qml-QtLocation5-places-data
+ \since QtLocation 5.5
+
+ \brief Holds data regarding the supplier of a place, a place's image, review, or editorial.
+
+ Each instance represents a set of data about a supplier, which can include
+ supplier's name, url and icon. The supplier is typically a business or organization.
+
+ Note: The Places API only supports suppliers as 'retrieve-only' objects. Submitting
+ suppliers to a provider is not a supported use case.
+
+ \sa ImageModel, ReviewModel, EditorialModel
+
+ \section1 Example
+
+ The following example shows how to create and display a supplier in QML:
+
+ \snippet declarative/places.qml QtQuick import
+ \snippet declarative/maps.qml QtLocation import
+ \codeline
+ \snippet declarative/places.qml Supplier
+*/
+
+/*!
Constructs a new supplier object.
*/
QPlaceSupplier::QPlaceSupplier()
@@ -129,7 +156,19 @@ bool QPlaceSupplier::isEqual(const QPlaceSupplier &other) const noexcept
}
/*!
- Returns the name of the supplier which can be displayed to the user.
+ \qmlproperty string Supplier::name
+
+ This property holds the name of the supplier which can be displayed
+ to the user.
+
+ The name can potentially be localized. The language is dependent on the
+ entity that sets it, typically this is the \l Plugin. The \l {Plugin::locales}
+ property defines what language is used.
+*/
+
+/*!
+ \property QPlaceSupplier::name
+ \brief the name of the supplier which can be displayed to the user.
The name can potentially be localized. The language is dependent on the
entity that sets it, typically this is the QPlaceManager.
@@ -149,10 +188,20 @@ void QPlaceSupplier::setName(const QString &name)
}
/*!
- Returns the identifier of the supplier. The identifier is unique
- to the manager backend which provided the supplier and is generally
+ \qmlproperty string Supplier::supplierId
+
+ This property holds the identifier of the supplier. The identifier is unique
+ to the Plugin backend which provided the supplier and is generally
not suitable for displaying to the user.
*/
+
+/*!
+ \property QPlaceSupplier::supplierId
+ \brief the identifier of the supplier.
+
+ The identifier is unique to the manager backend which provided the supplier
+ and is generally not suitable for displaying to the user.
+*/
QString QPlaceSupplier::supplierId() const
{
return d->supplierId;
@@ -167,7 +216,14 @@ void QPlaceSupplier::setSupplierId(const QString &identifier)
}
/*!
- Returns the URL of the supplier's website.
+ \qmlproperty url Supplier::url
+
+ This property holds the URL of the supplier's website.
+*/
+
+/*!
+ \property QPlaceSupplier::url
+ \brief the URL of the supplier's website.
*/
QUrl QPlaceSupplier::url() const
{
@@ -183,7 +239,14 @@ void QPlaceSupplier::setUrl(const QUrl &url)
}
/*!
- Returns the icon of the supplier.
+ \qmlproperty PlaceIcon Supplier::icon
+
+ This property holds the icon of the supplier.
+*/
+
+/*!
+ \property QPlaceSupplier::icon
+ \brief the icon of the supplier.
*/
QPlaceIcon QPlaceSupplier::icon() const
{
@@ -205,3 +268,5 @@ bool QPlaceSupplier::isEmpty() const
{
return d->isEmpty();
}
+
+#include "moc_qplacesupplier.cpp"
diff --git a/src/location/places/qplacesupplier.h b/src/location/places/qplacesupplier.h
index 70a6143a..cf4421b2 100644
--- a/src/location/places/qplacesupplier.h
+++ b/src/location/places/qplacesupplier.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtLocation module of the Qt Toolkit.
@@ -53,6 +53,12 @@ QT_DECLARE_QSDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPlaceSupplierPrivate, Q_LOCATIO
class Q_LOCATION_EXPORT QPlaceSupplier
{
+ Q_GADGET
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString supplierId READ supplierId WRITE setSupplierId)
+ Q_PROPERTY(QUrl url READ url WRITE setUrl)
+ Q_PROPERTY(QPlaceIcon icon READ icon WRITE setIcon)
+
public:
QPlaceSupplier();
QPlaceSupplier(const QPlaceSupplier &other) noexcept;
diff --git a/tests/auto/declarative_location_core/tst_place.qml b/tests/auto/declarative_location_core/tst_place.qml
index ef0baa93..916b036e 100644
--- a/tests/auto/declarative_location_core/tst_place.qml
+++ b/tests/auto/declarative_location_core/tst_place.qml
@@ -84,13 +84,12 @@ TestCase {
ratings: ({ average: 3.5, count: 10 })
- supplier: Supplier {
- name: "Supplier 1"
- supplierId: "supplier-id-1"
- url: "http://www.example.com/supplier-id-1/"
- icon: ({ parameters: { singleUrl: "http://www.example.com/supplier-id-1/icon" }})
- }
-
+ supplier: ({
+ name: "Supplier 1",
+ supplierId: "supplier-id-1",
+ url: "http://www.example.com/supplier-id-1/",
+ icon: ({ parameters : { singleUrl: "http://www.example.com/supplier-id-1/icon" }})
+ })
categories: [
Category {
name: "Category 1"
@@ -136,22 +135,8 @@ TestCase {
}
// check supplier
- if (place1.supplier === null && place2.supplier !== null)
- return false;
- if (place1.supplier !== null && place2.supplier === null)
+ if (place1.supplier !== place2.supplier) {
return false;
- if (place1.supplier !== null && place2.supplier !== null) {
- if (place1.supplier.supplierId !== place2.supplier.supplierId)
- return false;
- if (place1.supplier.name !== place2.supplier.name)
- return false;
- if (place1.supplier.url !== place2.supplier.url)
- return false;
-
- // check supplier icon
- if (place1.supplier.icon !== place2.supplier.icon) {
- return false;
- }
}
// check ratings
@@ -289,7 +274,7 @@ TestCase {
}
function test_supplier() {
- var supplier = Qt.createQmlObject('import QtLocation 5.3; Supplier { supplierId: "sup-id-1"; name: "Category 1" }', testCase, "Supplier1");
+ var supplier = savePlace.supplier;
var signalSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy");
signalSpy.target = testPlace;
@@ -314,8 +299,8 @@ TestCase {
compare(signalSpy.count, 1);
// reset by assignment
- testPlace.supplier = null;
- compare(testPlace.supplier, null);
+ testPlace.supplier = emptyPlace.supplier;
+ compare(testPlace.supplier, emptyPlace.supplier);
compare(signalSpy.count, 2);
signalSpy.destroy();
diff --git a/tests/auto/declarative_location_core/tst_supplier.qml b/tests/auto/declarative_location_core/tst_supplier.qml
index 226cde54..eb0f8eb1 100644
--- a/tests/auto/declarative_location_core/tst_supplier.qml
+++ b/tests/auto/declarative_location_core/tst_supplier.qml
@@ -29,14 +29,13 @@
import QtQuick
import QtTest
import QtLocation
-import "utils.js" as Utils
TestCase {
id: testCase
name: "Supplier"
- Supplier { id: emptySupplier }
+ property supplier emptySupplier;
function test_empty() {
compare(emptySupplier.supplierId, "");
@@ -45,9 +44,8 @@ TestCase {
verify(emptySupplier.icon);
}
- Supplier {
- id: qmlSupplier
-
+ property supplier qmlSupplier
+ qmlSupplier {
supplierId: "test-supplier-id"
name: "Test Supplier"
url: "http://example.com/test-supplier-id"
@@ -62,18 +60,4 @@ TestCase {
verify(qmlSupplier.icon);
compare(qmlSupplier.icon.parameters.singleUrl, "http://example.com/icons/test-supplier.png");
}
-
- Supplier {
- id: testSupplier
- }
-
- Plugin {
- id: testPlugin
- name: "qmlgeo.test.plugin"
- allowExperimental: true
- }
-
- Plugin {
- id: invalidPlugin
- }
}
diff --git a/tests/auto/qmlinterface/data/TestPlace.qml b/tests/auto/qmlinterface/data/TestPlace.qml
index a3c40c14..0665435b 100644
--- a/tests/auto/qmlinterface/data/TestPlace.qml
+++ b/tests/auto/qmlinterface/data/TestPlace.qml
@@ -45,6 +45,11 @@ Place {
location: TestLocation { }
ratings: ({ average: 3.5, maximum: 5.0, count: 10 })
icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }})
- supplier: TestSupplier { }
+ supplier: ({
+ name: "Test supplier",
+ supplierId: "test-supplier-id",
+ url: "http://www.example.com/test-supplier",
+ icon: ({ parameters : { singleUrl: "http://www.example.com/test-icon.png" }})
+ })
visibility: Place.PrivateVisibility
}
diff --git a/tests/auto/qmlinterface/data/TestSupplier.qml b/tests/auto/qmlinterface/data/TestSupplier.qml
index 7f4cc451..f94f7f7b 100644
--- a/tests/auto/qmlinterface/data/TestSupplier.qml
+++ b/tests/auto/qmlinterface/data/TestSupplier.qml
@@ -27,10 +27,14 @@
****************************************************************************/
import QtLocation
+import QtQuick
-Supplier {
- name: "Test supplier"
- supplierId: "test-supplier-id"
- url: "http://www.example.com/test-supplier"
- icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }})
+Item {
+ property supplier supplier
+ supplier {
+ name: "Test supplier"
+ supplierId: "test-supplier-id"
+ url: "http://www.example.com/test-supplier"
+ icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }})
+ }
}