summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-09-09 14:21:51 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-09-14 13:20:15 +0200
commit517e4f284e1808ecddc998d73b4b554880733381 (patch)
tree52e01d085fb0d7ca997ee1d25e1f9fa856fcd112
parent1d8897b32148057246a779ad7cf18aeed1c2acc3 (diff)
downloadqtlocation-517e4f284e1808ecddc998d73b4b554880733381.tar.gz
Register QPlaceIcon as a QML value type
Make QPlaceIcon a gadget, and register it as a value type with the QML engine. Remove declarative wrapper, and consolidate the documentation. Adjust the tests and remove tests that verify that the type behaves like an object. Initialize placeIcon properties as a grouped property, or via a converter from QJSValue. That converter is a temporary solution to enable tests, and can hopefully be removed once the QML engine supports property-initialization of value types. Task-number: QTBUG-106482 Change-Id: I2aa29102ee232afb3d71396bcd3288e2f99c0fc6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-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/qdeclarativecategory.cpp28
-rw-r--r--src/location/declarativeplaces/qdeclarativecategory_p.h12
-rw-r--r--src/location/declarativeplaces/qdeclarativeplace.cpp18
-rw-r--r--src/location/declarativeplaces/qdeclarativeplace_p.h11
-rw-r--r--src/location/declarativeplaces/qdeclarativeplaceicon.cpp253
-rw-r--r--src/location/declarativeplaces/qdeclarativeplaceicon_p.h107
-rw-r--r--src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp1
-rw-r--r--src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp8
-rw-r--r--src/location/declarativeplaces/qdeclarativesearchresultmodel_p.h4
-rw-r--r--src/location/declarativeplaces/qdeclarativesupplier.cpp23
-rw-r--r--src/location/declarativeplaces/qdeclarativesupplier_p.h12
-rw-r--r--src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp1
-rw-r--r--src/location/places/qplaceicon.cpp8
-rw-r--r--src/location/places/qplaceicon.h7
-rw-r--r--tests/auto/declarative_location_core/tst_category.qml12
-rw-r--r--tests/auto/declarative_location_core/tst_place.qml58
-rw-r--r--tests/auto/declarative_location_core/tst_placeicon.qml57
-rw-r--r--tests/auto/declarative_location_core/tst_supplier.qml23
-rw-r--r--tests/auto/qmlinterface/data/TestIcon.qml7
-rw-r--r--tests/auto/qmlinterface/data/TestPlace.qml2
-rw-r--r--tests/auto/qmlinterface/data/TestSupplier.qml2
24 files changed, 78 insertions, 590 deletions
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index 4eedef01..e09062a4 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/qdeclarativeplaceicon_p.h>
#include <QtLocation/private/qdeclarativesupplier_p.h>
#include <QtLocation/private/qdeclarativecontactdetail_p.h>
@@ -188,7 +187,6 @@ public:
qmlRegisterType<QDeclarativePlaceEditorialModel >(uri, major, minor, "EditorialModel");
qmlRegisterType<QDeclarativePlaceImageModel >(uri, major, minor, "ImageModel");
qmlRegisterType<QDeclarativePlace >(uri, major, minor, "Place");
- qmlRegisterType<QDeclarativePlaceIcon >(uri, major, minor, "Icon");
qmlRegisterType<QDeclarativeReviewModel >(uri, major, minor, "ReviewModel");
qmlRegisterType<QDeclarativeSupplier >(uri, major, minor, "Supplier");
qmlRegisterType<QDeclarativeRectangleMapItem >(uri, major, minor, "MapRectangle");
@@ -270,11 +268,11 @@ public:
//registrations below are version independent
qRegisterMetaType<QPlaceCategory>();
qRegisterMetaType<QPlace>();
- qRegisterMetaType<QPlaceIcon>();
qRegisterMetaType<QPlaceSupplier>();
qRegisterMetaType<QPlaceContactDetail>();
registerConverterToGadget<QPlaceRatings>();
+ registerConverterToGadget<QPlaceIcon>();
} 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 f42abac5..162b572b 100644
--- a/src/imports/location/location.h
+++ b/src/imports/location/location.h
@@ -56,6 +56,7 @@
#include <QPlaceAttribute>
#include <QPlaceUser>
#include <QPlaceRatings>
+#include <QPlaceIcon>
#include <QtLocation/private/qgeomaptype_p.h>
@@ -119,6 +120,13 @@ struct QPlaceAttributeForeign
QML_NAMED_ELEMENT(placeAttribute)
};
+struct QPlaceIconForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QPlaceIcon)
+ QML_NAMED_ELEMENT(icon)
+};
+
QT_END_NAMESPACE
#endif // QTLOCATION_QMLTYPES_H
diff --git a/src/location/CMakeLists.txt b/src/location/CMakeLists.txt
index 0f655842..bb532e75 100644
--- a/src/location/CMakeLists.txt
+++ b/src/location/CMakeLists.txt
@@ -137,8 +137,6 @@ qt_internal_add_module(Location
declarativeplaces/qdeclarativeplace.cpp
declarativeplaces/qdeclarativeplaceeditorialmodel.cpp
declarativeplaces/qdeclarativeplaceeditorialmodel_p.h
- declarativeplaces/qdeclarativeplaceicon.cpp
- declarativeplaces/qdeclarativeplaceicon_p.h
declarativeplaces/qdeclarativeplaceimagemodel.cpp
declarativeplaces/qdeclarativeplaceimagemodel_p.h
declarativeplaces/qdeclarativeplace_p.h
diff --git a/src/location/declarativeplaces/qdeclarativecategory.cpp b/src/location/declarativeplaces/qdeclarativecategory.cpp
index a2136ab9..e4ca6168 100644
--- a/src/location/declarativeplaces/qdeclarativecategory.cpp
+++ b/src/location/declarativeplaces/qdeclarativecategory.cpp
@@ -38,12 +38,12 @@
****************************************************************************/
#include "qdeclarativecategory_p.h"
-#include "qdeclarativeplaceicon_p.h"
#include "qdeclarativegeoserviceprovider_p.h"
#include "error_messages_p.h"
#include <QtQml/QQmlInfo>
#include <QtLocation/QGeoServiceProvider>
+#include <QtLocation/QPlaceIcon>
#include <QtLocation/QPlaceManager>
#include <QtLocation/QPlaceIdReply>
#include <QCoreApplication>
@@ -99,12 +99,6 @@ QDeclarativeCategory::~QDeclarativeCategory() {}
// From QQmlParserStatus
void QDeclarativeCategory::componentComplete()
{
- // delayed instantiation of QObject based properties.
- if (!m_icon) {
- m_icon = new QDeclarativePlaceIcon(this);
- m_icon->setPlugin(m_plugin);
- }
-
m_complete = true;
}
@@ -122,9 +116,6 @@ void QDeclarativeCategory::setPlugin(QDeclarativeGeoServiceProvider *plugin)
if (m_complete)
emit pluginChanged();
- if (m_icon && m_icon->parent() == this && !m_icon->plugin())
- m_icon->setPlugin(m_plugin);
-
if (!m_plugin)
return;
@@ -174,18 +165,12 @@ void QDeclarativeCategory::setCategory(const QPlaceCategory &category)
if (category.categoryId() != previous.categoryId())
emit categoryIdChanged();
- if (m_icon && m_icon->parent() == this) {
- m_icon->setPlugin(m_plugin);
- m_icon->setIcon(m_category.icon());
- } else if (!m_icon || m_icon->parent() != this) {
- m_icon = new QDeclarativePlaceIcon(m_category.icon(), m_plugin, this);
- emit iconChanged();
- }
+ setIcon(m_category.icon());
}
QPlaceCategory QDeclarativeCategory::category()
{
- m_category.setIcon(m_icon ? m_icon->icon() : QPlaceIcon());
+ m_category.setIcon(m_icon);
return m_category;
}
@@ -275,19 +260,16 @@ void QDeclarativeCategory::setVisibility(Visibility visibility)
This property holds the image source associated with the category. To display the icon you can use
the \l Image type.
*/
-QDeclarativePlaceIcon *QDeclarativeCategory::icon() const
+QPlaceIcon QDeclarativeCategory::icon() const
{
return m_icon;
}
-void QDeclarativeCategory::setIcon(QDeclarativePlaceIcon *icon)
+void QDeclarativeCategory::setIcon(const QPlaceIcon &icon)
{
if (m_icon == icon)
return;
- if (m_icon && m_icon->parent() == this)
- delete m_icon;
-
m_icon = icon;
emit iconChanged();
}
diff --git a/src/location/declarativeplaces/qdeclarativecategory_p.h b/src/location/declarativeplaces/qdeclarativecategory_p.h
index 57fb49b5..e1d1dcc9 100644
--- a/src/location/declarativeplaces/qdeclarativecategory_p.h
+++ b/src/location/declarativeplaces/qdeclarativecategory_p.h
@@ -57,14 +57,12 @@
#include <QObject>
#include <QtLocation/qplacecategory.h>
+#include <QtLocation/qplaceicon.h>
#include <QtLocation/private/qdeclarativegeoserviceprovider_p.h>
-Q_MOC_INCLUDE(<QtLocation/private/qdeclarativeplaceicon_p.h>)
-
QT_BEGIN_NAMESPACE
-class QDeclarativePlaceIcon;
class QPlaceReply;
class QPlaceManager;
@@ -80,7 +78,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeCategory : public QObject, public QQ
Q_PROPERTY(QString categoryId READ categoryId WRITE setCategoryId NOTIFY categoryIdChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged)
- Q_PROPERTY(QDeclarativePlaceIcon *icon READ icon WRITE setIcon NOTIFY iconChanged)
+ Q_PROPERTY(QPlaceIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_INTERFACES(QQmlParserStatus)
@@ -116,8 +114,8 @@ public:
Visibility visibility() const;
void setVisibility(Visibility visibility);
- QDeclarativePlaceIcon *icon() const;
- void setIcon(QDeclarativePlaceIcon *icon);
+ QPlaceIcon icon() const;
+ void setIcon(const QPlaceIcon &icon);
Q_INVOKABLE QString errorString() const;
@@ -143,7 +141,7 @@ private:
QPlaceManager *manager();
QPlaceCategory m_category;
- QDeclarativePlaceIcon *m_icon = nullptr;
+ QPlaceIcon m_icon;
QDeclarativeGeoServiceProvider *m_plugin = nullptr;
QPlaceReply *m_reply = nullptr;
bool m_complete = false;
diff --git a/src/location/declarativeplaces/qdeclarativeplace.cpp b/src/location/declarativeplaces/qdeclarativeplace.cpp
index cd0696bb..c25c5f36 100644
--- a/src/location/declarativeplaces/qdeclarativeplace.cpp
+++ b/src/location/declarativeplaces/qdeclarativeplace.cpp
@@ -40,7 +40,6 @@
#include "qdeclarativeplace_p.h"
#include "qdeclarativecontactdetail_p.h"
#include "qdeclarativegeoserviceprovider_p.h"
-#include "qdeclarativeplaceicon_p.h"
#include "error_messages_p.h"
#include <QtCore/QCoreApplication>
@@ -334,13 +333,7 @@ void QDeclarativePlace::setPlace(const QPlace &src)
emit supplierChanged();
}
- if (m_icon && m_icon->parent() == this) {
- m_icon->setPlugin(m_plugin);
- m_icon->setIcon(m_src.icon());
- } else if (!m_icon || m_icon->parent() != this) {
- m_icon = new QDeclarativePlaceIcon(m_src.icon(), m_plugin, this);
- emit iconChanged();
- }
+ setIcon(m_src.icon());
if (previous.name() != m_src.name()) {
emit nameChanged();
@@ -407,7 +400,7 @@ QPlace QDeclarativePlace::place() const
result.setSupplier(m_supplier ? m_supplier->supplier() : QPlaceSupplier());
// Icon
- result.setIcon(m_icon ? m_icon->icon() : QPlaceIcon());
+ result.setIcon(m_icon);
//contact details
QList<QPlaceContactDetail> cppDetails;
@@ -503,19 +496,16 @@ QDeclarativeSupplier *QDeclarativePlace::supplier() const
This property holds a graphical icon which can be used to represent the place.
*/
-QDeclarativePlaceIcon *QDeclarativePlace::icon() const
+QPlaceIcon QDeclarativePlace::icon() const
{
return m_icon;
}
-void QDeclarativePlace::setIcon(QDeclarativePlaceIcon *icon)
+void QDeclarativePlace::setIcon(const QPlaceIcon &icon)
{
if (m_icon == icon)
return;
- if (m_icon && m_icon->parent() == this)
- delete m_icon;
-
m_icon = icon;
emit iconChanged();
}
diff --git a/src/location/declarativeplaces/qdeclarativeplace_p.h b/src/location/declarativeplaces/qdeclarativeplace_p.h
index e69d3d7e..0a070253 100644
--- a/src/location/declarativeplaces/qdeclarativeplace_p.h
+++ b/src/location/declarativeplaces/qdeclarativeplace_p.h
@@ -58,6 +58,7 @@
#include <QtQml/QQmlPropertyMap>
#include <QtLocation/QPlace>
#include <QtLocation/QPlaceRatings>
+#include <QtLocation/QPlaceIcon>
#include <QtPositioningQuick/private/qdeclarativegeolocation_p.h>
#include <QtLocation/private/qdeclarativecategory_p.h>
@@ -70,9 +71,7 @@
QT_BEGIN_NAMESPACE
class QPlaceReply;
-
class QPlaceManager;
-class QDeclarativePlaceIcon;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativePlace : public QObject, public QQmlParserStatus
{
@@ -86,7 +85,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativePlace : public QObject, public QQmlP
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(QDeclarativePlaceIcon *icon READ icon WRITE setIcon NOTIFY iconChanged)
+ 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)
Q_PROPERTY(QString attribution READ attribution WRITE setAttribution NOTIFY attributionChanged)
@@ -150,8 +149,8 @@ public:
void setRatings(const QPlaceRatings &ratings);
QDeclarativeSupplier *supplier() const;
void setSupplier(QDeclarativeSupplier *supplier);
- QDeclarativePlaceIcon *icon() const;
- void setIcon(QDeclarativePlaceIcon *icon);
+ QPlaceIcon icon() const;
+ void setIcon(const QPlaceIcon &icon);
QString name() const;
void setName(const QString &name);
QString placeId() const;
@@ -231,7 +230,7 @@ private:
QDeclarativeGeoLocation *m_location = nullptr;
QPlaceRatings m_ratings;
QDeclarativeSupplier *m_supplier = nullptr;
- QDeclarativePlaceIcon *m_icon = nullptr;
+ QPlaceIcon m_icon;
QDeclarativeReviewModel *m_reviewModel = nullptr;
QDeclarativePlaceImageModel *m_imageModel = nullptr;
QDeclarativePlaceEditorialModel *m_editorialModel = nullptr;
diff --git a/src/location/declarativeplaces/qdeclarativeplaceicon.cpp b/src/location/declarativeplaces/qdeclarativeplaceicon.cpp
deleted file mode 100644
index afe9cc21..00000000
--- a/src/location/declarativeplaces/qdeclarativeplaceicon.cpp
+++ /dev/null
@@ -1,253 +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 "qdeclarativeplaceicon_p.h"
-#include "error_messages_p.h"
-
-#include <QtLocation/QGeoServiceProvider>
-#include <QtLocation/QPlaceManager>
-#include <QtQml/QQmlInfo>
-#include <QCoreApplication>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype Icon
- \instantiates QDeclarativePlaceIcon
- \inqmlmodule QtLocation
- \ingroup qml-QtLocation5-places
- \ingroup qml-QtLocation5-places-data
- \since QtLocation 5.5
-
- \brief The Icon type represents an icon image source which can have multiple sizes.
-
- The Icon type can be used in conjunction with an \l Image type to display an icon.
- The \l url() function is used to construct an icon URL of a requested size,
- the icon which most closely matches the requested size is returned.
-
- The Icon type also has a parameters map which is a set of key value pairs. The precise
- keys to use depend on the
- \l {Qt Location#Plugin References and Parameters}{plugin} being used.
- The parameters map is used by the \l Plugin to determine which URL to return.
-
- In the case where an icon can only possibly have one image URL, the
- parameter key of \c "singleUrl" can be used with a QUrl value. Any Icon with this
- parameter will always return the specified URL regardless of the requested icon
- size and not defer to any Plugin.
-
- The following code shows how to display a 64x64 pixel icon:
-
- \snippet declarative/places.qml QtQuick import
- \snippet declarative/maps.qml QtLocation import
- \codeline
- \snippet declarative/places.qml Icon
-
- Alternatively, a default sized icon can be specified like so:
- \snippet declarative/places.qml Icon default
-*/
-
-QDeclarativePlaceIcon::QDeclarativePlaceIcon(QObject *parent)
-: QObject(parent), m_plugin(0), m_parameters(new QQmlPropertyMap(this))
-{
-}
-
-QDeclarativePlaceIcon::QDeclarativePlaceIcon(const QPlaceIcon &icon, QDeclarativeGeoServiceProvider *plugin, QObject *parent)
-: QObject(parent), m_parameters(new QQmlPropertyMap(this))
-{
- if (icon.isEmpty())
- m_plugin = 0;
- else
- m_plugin = plugin;
-
- initParameters(icon.parameters());
-}
-
-QDeclarativePlaceIcon::~QDeclarativePlaceIcon()
-{
-}
-
-/*!
- \qmlproperty QPlaceIcon Icon::icon
-
- For details on how to use this property to interface between C++ and QML see
- "\l {Icon - QPlaceIcon} {Interfaces between C++ and QML Code}".
-*/
-QPlaceIcon QDeclarativePlaceIcon::icon() const
-{
- QPlaceIcon result;
-
- if (m_plugin)
- result.setManager(manager());
- else
- result.setManager(0);
-
- QVariantMap params;
- for (const QString &key : m_parameters->keys()) {
- const QVariant value = m_parameters->value(key);
- if (value.isValid()) {
- params.insert(key, value);
- }
- }
-
- result.setParameters(params);
-
- return result;
-}
-
-void QDeclarativePlaceIcon::setIcon(const QPlaceIcon &src)
-{
- initParameters(src.parameters());
-}
-
-/*!
- \qmlmethod url Icon::url(size size)
-
- Returns a URL for the icon image that most closely matches the given \a size.
-
- If no plugin has been assigned to the icon, and the parameters do not contain the 'singleUrl' key, a default constructed URL
- is returned.
-
-*/
-QUrl QDeclarativePlaceIcon::url(const QSize &size) const
-{
- return icon().url(size);
-}
-
-/*!
- \qmlproperty Object Icon::parameters
-
- This property holds the parameters of the icon and is a map. These parameters
- are used by the plugin to return the appropriate URL when url() is called and to
- specify locations to save to when saving icons.
-
- Consult the \l {Qt Location#Plugin References and Parameters}{plugin documentation}
- for what parameters are supported and how they should be used.
-
- Note, due to limitations of the QQmlPropertyMap, it is not possible
- to declaratively specify the parameters in QML, assignment of parameters keys
- and values can only be accomplished by JavaScript.
-
-*/
-QQmlPropertyMap *QDeclarativePlaceIcon::parameters() const
-{
- return m_parameters;
-}
-
-/*!
- \qmlproperty Plugin Icon::plugin
-
- The property holds the plugin that is responsible for managing this icon.
-*/
-QDeclarativeGeoServiceProvider *QDeclarativePlaceIcon::plugin() const
-{
- return m_plugin;
-}
-
-void QDeclarativePlaceIcon::setPlugin(QDeclarativeGeoServiceProvider *plugin)
-{
- if (m_plugin == plugin)
- return;
-
- m_plugin = plugin;
- emit pluginChanged();
-
- if (!m_plugin)
- return;
-
- if (m_plugin->isAttached()) {
- pluginReady();
- } else {
- connect(m_plugin, &QDeclarativeGeoServiceProvider::attached,
- this, &QDeclarativePlaceIcon::pluginReady);
- }
-}
-
-/*!
- \internal
-*/
-void QDeclarativePlaceIcon::pluginReady()
-{
- QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
- QPlaceManager *placeManager = serviceProvider->placeManager();
- if (!placeManager || serviceProvider->error() != QGeoServiceProvider::NoError) {
- qmlWarning(this) << QCoreApplication::translate(CONTEXT_NAME, PLUGIN_ERROR)
- .arg(m_plugin->name()).arg(serviceProvider->errorString());
- return;
- }
-}
-
-/*!
- \internal
- Helper function to return the manager from the plugin
-*/
-QPlaceManager *QDeclarativePlaceIcon::manager() const
-{
- if (!m_plugin) {
- qmlWarning(this) << QStringLiteral("Plugin is not assigned to place.");
- return 0;
- }
-
- QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
- if (!serviceProvider)
- return 0;
-
- QPlaceManager *placeManager = serviceProvider->placeManager();
-
- if (!placeManager)
- return 0;
-
- return placeManager;
-}
-
-/*!
- \internal
-*/
-void QDeclarativePlaceIcon::initParameters(const QVariantMap &parameterMap)
-{
- //clear out old parameters
- for (const QString &key : m_parameters->keys())
- m_parameters->clear(key);
-
- for (const QString &key : parameterMap.keys()) {
- QVariant value = parameterMap.value(key);
- m_parameters->insert(key, value);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/location/declarativeplaces/qdeclarativeplaceicon_p.h b/src/location/declarativeplaces/qdeclarativeplaceicon_p.h
deleted file mode 100644
index ea3808e8..00000000
--- a/src/location/declarativeplaces/qdeclarativeplaceicon_p.h
+++ /dev/null
@@ -1,107 +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 QDECLARATIVEPLACEICON_P_H
-#define QDECLARATIVEPLACEICON_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 <QtLocation/private/qdeclarativegeoserviceprovider_p.h>
-
-#include <QtLocation/qplaceicon.h>
-#include <QtQml/qqml.h>
-#include <QtQml/QQmlPropertyMap>
-
-#include <QObject>
-
-QT_BEGIN_NAMESPACE
-
-class QQmlPropertyMap;
-
-class Q_LOCATION_PRIVATE_EXPORT QDeclarativePlaceIcon : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QPlaceIcon icon READ icon WRITE setIcon)
- Q_PROPERTY(QObject *parameters READ parameters NOTIFY parametersChanged)
- Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
-
-public:
- explicit QDeclarativePlaceIcon(QObject *parent = 0);
- QDeclarativePlaceIcon(const QPlaceIcon &src, QDeclarativeGeoServiceProvider *plugin, QObject *parent = 0);
- ~QDeclarativePlaceIcon();
-
- QPlaceIcon icon() const;
- void setIcon(const QPlaceIcon &src);
-
- Q_INVOKABLE QUrl url(const QSize &size = QSize()) const;
-
- QQmlPropertyMap *parameters() const;
-
- void setPlugin(QDeclarativeGeoServiceProvider *plugin);
- QDeclarativeGeoServiceProvider *plugin() const;
-
-Q_SIGNALS:
- void pluginChanged();
- void parametersChanged(); //in practice is never emitted since parameters cannot be re-assigned
- //the declaration is needed to avoid warnings about non-notifyable properties
-
-private Q_SLOTS:
- void pluginReady();
-
-private:
- QPlaceManager *manager() const;
- void initParameters(const QVariantMap &parameterMap);
- QDeclarativeGeoServiceProvider *m_plugin;
- QQmlPropertyMap *m_parameters;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp b/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp
index 36ea99cf..2bbe363e 100644
--- a/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp
+++ b/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp
@@ -44,6 +44,7 @@
#include <QtCore/QCoreApplication>
#include <QtQml/QQmlInfo>
#include <QtLocation/QGeoServiceProvider>
+#include <QtLocation/QPlaceIcon>
#include <QtLocation/QPlaceManager>
#include <QtLocation/QPlaceSearchRequest>
#include <QtLocation/QPlaceSearchReply>
diff --git a/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp b/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
index 93e83ce1..68b2f2f4 100644
--- a/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
@@ -39,7 +39,6 @@
#include "qdeclarativesearchresultmodel_p.h"
#include "qdeclarativeplace_p.h"
-#include "qdeclarativeplaceicon_p.h"
#include <QtQml/QQmlEngine>
#include <QtQml/QQmlInfo>
@@ -612,7 +611,6 @@ void QDeclarativeSearchResultModel::clearData(bool suppressSignal)
qDeleteAll(m_places);
m_places.clear();
- qDeleteAll(m_icons);
m_icons.clear();
if (!m_results.isEmpty()) {
m_results.clear();
@@ -636,7 +634,7 @@ QVariant QDeclarativeSearchResultModel::data(const QModelIndex &index, int role)
case TitleRole:
return result.title();
case IconRole:
- return QVariant::fromValue(static_cast<QObject *>(m_icons.at(index.row())));
+ return QVariant::fromValue(m_icons.at(index.row()));
case DistanceRole:
if (result.type() == QPlaceSearchResult::PlaceResult) {
QPlaceResult placeResult = result;
@@ -924,10 +922,8 @@ void QDeclarativeSearchResultModel::updateLayout(const QList<QPlace> &favoritePl
m_places.append(0);
}
- QDeclarativePlaceIcon *icon = 0;
if (!result.icon().isEmpty())
- icon = new QDeclarativePlaceIcon(result.icon(), plugin(), this);
- m_icons.append(icon);
+ m_icons.append(result.icon());
}
if (m_incremental)
diff --git a/src/location/declarativeplaces/qdeclarativesearchresultmodel_p.h b/src/location/declarativeplaces/qdeclarativesearchresultmodel_p.h
index 4ecd36ec..be46e82e 100644
--- a/src/location/declarativeplaces/qdeclarativesearchresultmodel_p.h
+++ b/src/location/declarativeplaces/qdeclarativesearchresultmodel_p.h
@@ -55,10 +55,10 @@
#include <QtLocation/private/qdeclarativesearchmodelbase_p.h>
#include <QtLocation/private/qdeclarativecategory_p.h>
#include <QtLocation/private/qdeclarativeplace_p.h>
-#include <QtLocation/private/qdeclarativeplaceicon_p.h>
QT_BEGIN_NAMESPACE
+class QPlaceIcon;
class QDeclarativeGeoServiceProvider;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeSearchResultModel : public QDeclarativeSearchModelBase
@@ -179,7 +179,7 @@ private:
QList<QPlaceSearchResult> m_results;
QList<QPlaceSearchResult> m_resultsBuffer;
QList<QDeclarativePlace *> m_places;
- QList<QDeclarativePlaceIcon *> m_icons;
+ QList<QPlaceIcon> m_icons;
QDeclarativeGeoServiceProvider *m_favoritesPlugin = nullptr;
QVariantMap m_matchParameters;
diff --git a/src/location/declarativeplaces/qdeclarativesupplier.cpp b/src/location/declarativeplaces/qdeclarativesupplier.cpp
index 54df840b..91e2eb77 100644
--- a/src/location/declarativeplaces/qdeclarativesupplier.cpp
+++ b/src/location/declarativeplaces/qdeclarativesupplier.cpp
@@ -39,6 +39,7 @@
#include "qdeclarativesupplier_p.h"
+#include <QtLocation/QPlaceIcon>
#include <QtCore/QUrl>
QT_BEGIN_NAMESPACE
@@ -94,9 +95,6 @@ QDeclarativeSupplier::~QDeclarativeSupplier()
*/
void QDeclarativeSupplier::componentComplete()
{
- // delayed instantiation of QObject based properties.
- if (!m_icon)
- m_icon = new QDeclarativePlaceIcon(this);
}
/*!
@@ -105,7 +103,7 @@ void QDeclarativeSupplier::componentComplete()
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 *plugin)
+void QDeclarativeSupplier::setSupplier(const QPlaceSupplier &src, QDeclarativeGeoServiceProvider *)
{
QPlaceSupplier previous = m_src;
m_src = src;
@@ -119,18 +117,12 @@ void QDeclarativeSupplier::setSupplier(const QPlaceSupplier &src, QDeclarativeGe
if (previous.url() != m_src.url())
emit urlChanged();
- if (m_icon && m_icon->parent() == this) {
- m_icon->setPlugin(plugin);
- m_icon->setIcon(m_src.icon());
- } else if (!m_icon || m_icon->parent() != this) {
- m_icon = new QDeclarativePlaceIcon(m_src.icon(), plugin, this);
- emit iconChanged();
- }
+ setIcon(m_src.icon());
}
QPlaceSupplier QDeclarativeSupplier::supplier()
{
- m_src.setIcon(m_icon ? m_icon->icon() : QPlaceIcon());
+ m_src.setIcon(m_icon);
return m_src;
}
@@ -203,19 +195,16 @@ QUrl QDeclarativeSupplier::url() const
This property holds the icon of the supplier.
*/
-QDeclarativePlaceIcon *QDeclarativeSupplier::icon() const
+QPlaceIcon QDeclarativeSupplier::icon() const
{
return m_icon;
}
-void QDeclarativeSupplier::setIcon(QDeclarativePlaceIcon *icon)
+void QDeclarativeSupplier::setIcon(const QPlaceIcon &icon)
{
if (m_icon == icon)
return;
- if (m_icon && m_icon->parent() == this)
- delete m_icon;
-
m_icon = icon;
emit iconChanged();
}
diff --git a/src/location/declarativeplaces/qdeclarativesupplier_p.h b/src/location/declarativeplaces/qdeclarativesupplier_p.h
index 0c807218..7e6b2a5c 100644
--- a/src/location/declarativeplaces/qdeclarativesupplier_p.h
+++ b/src/location/declarativeplaces/qdeclarativesupplier_p.h
@@ -56,12 +56,14 @@
#include <QtCore/QUrl>
#include <QtQml/qqml.h>
#include <QtQml/QQmlParserStatus>
+#include <QtLocation/qplaceicon.h>
#include <QtLocation/qplacesupplier.h>
-#include <QtLocation/private/qdeclarativeplaceicon_p.h>
QT_BEGIN_NAMESPACE
+class QDeclarativeGeoServiceProvider;
+
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeSupplier : public QObject, public QQmlParserStatus
{
Q_OBJECT
@@ -70,7 +72,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeSupplier : public QObject, public QQ
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(QDeclarativePlaceIcon *icon READ icon WRITE setIcon NOTIFY iconChanged)
+ Q_PROPERTY(QPlaceIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
Q_INTERFACES(QQmlParserStatus)
@@ -93,8 +95,8 @@ public:
QUrl url() const;
void setUrl(const QUrl &data);
- QDeclarativePlaceIcon *icon() const;
- void setIcon(QDeclarativePlaceIcon *icon);
+ QPlaceIcon icon() const;
+ void setIcon(const QPlaceIcon &icon);
Q_SIGNALS:
void nameChanged();
@@ -104,7 +106,7 @@ Q_SIGNALS:
private:
QPlaceSupplier m_src;
- QDeclarativePlaceIcon *m_icon = nullptr;
+ QPlaceIcon m_icon;
};
QT_END_NAMESPACE
diff --git a/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp b/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
index 74e4b15f..a7a74a80 100644
--- a/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
@@ -39,7 +39,6 @@
****************************************************************************/
#include "qdeclarativesupportedcategoriesmodel_p.h"
-#include "qdeclarativeplaceicon_p.h"
#include "qgeoserviceprovider.h"
#include "error_messages_p.h"
#include <QtCore/private/qobject_p.h>
diff --git a/src/location/places/qplaceicon.cpp b/src/location/places/qplaceicon.cpp
index 50bbef6c..aea3935a 100644
--- a/src/location/places/qplaceicon.cpp
+++ b/src/location/places/qplaceicon.cpp
@@ -43,6 +43,7 @@
#include "qplacemanagerengine.h"
#include <QtCore/QVariant>
+#include <QtQml/QJSValue>
QT_USE_NAMESPACE
@@ -138,6 +139,11 @@ bool QPlaceIcon::isEqual(const QPlaceIcon &other) const noexcept
return *d == *(other.d);
}
+/* ### Need to evaluate whether we need this at all (or perhaps only for tests)
+ \qmlproperty Plugin Icon::plugin
+
+ The property holds the plugin that is responsible for managing this icon.
+*/
/*!
Returns an icon URL according to the given \a size.
@@ -210,3 +216,5 @@ bool QPlaceIcon::isEmpty() const
return (d->manager == 0
&& d->parameters.isEmpty());
}
+
+#include "moc_qplaceicon.cpp"
diff --git a/src/location/places/qplaceicon.h b/src/location/places/qplaceicon.h
index cacd4d19..6ae4d636 100644
--- a/src/location/places/qplaceicon.h
+++ b/src/location/places/qplaceicon.h
@@ -51,10 +51,15 @@ QT_BEGIN_NAMESPACE
class QUrl;
class QPlaceManager;
class QPlaceIconPrivate;
+
QT_DECLARE_QSDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPlaceIconPrivate, Q_LOCATION_EXPORT)
class Q_LOCATION_EXPORT QPlaceIcon
{
+ Q_GADGET
+ Q_PROPERTY(QVariantMap parameters READ parameters WRITE setParameters)
+ Q_PROPERTY(QPlaceManager *manager READ manager WRITE setManager)
+
public:
static const QString SingleUrl;
@@ -73,7 +78,7 @@ public:
friend inline bool operator!=(const QPlaceIcon &lhs, const QPlaceIcon &rhs) noexcept
{ return !lhs.isEqual(rhs); }
- QUrl url(const QSize &size = QSize()) const;
+ Q_INVOKABLE QUrl url(const QSize &size = QSize()) const;
QPlaceManager *manager() const;
void setManager(QPlaceManager *manager);
diff --git a/tests/auto/declarative_location_core/tst_category.qml b/tests/auto/declarative_location_core/tst_category.qml
index afecafe6..4c9b72c7 100644
--- a/tests/auto/declarative_location_core/tst_category.qml
+++ b/tests/auto/declarative_location_core/tst_category.qml
@@ -57,11 +57,7 @@ TestCase {
name: "Test Category"
visibility: Category.DeviceVisibility
- icon: Icon {
- Component.onCompleted: {
- parameters.singleUrl = "http://example.com/icons/test-category.png"
- }
- }
+ icon: ({ parameters: { singleUrl: "http://example.com/icons/test-category.png" }})
}
function test_qmlConstructedCategory() {
@@ -73,7 +69,6 @@ TestCase {
verify(qmlCategory.icon);
compare(qmlCategory.icon.url(), "http://example.com/icons/test-category.png");
compare(qmlCategory.icon.parameters.singleUrl, "http://example.com/icons/test-category.png");
- compare(qmlCategory.icon.plugin, qmlCategory.plugin);
}
Category {
@@ -90,9 +85,7 @@ TestCase {
id: invalidPlugin
}
- Icon {
- id: testIcon
- }
+ property icon testIcon: ({ parameters: { singleUrl: "example.com" } })
Category {
id: saveCategory
@@ -116,7 +109,6 @@ TestCase {
{ tag: "categoryId", property: "categoryId", signal: "categoryIdChanged", value: "test-category-id-1", reset: "" },
{ tag: "visibility", property: "visibility", signal: "visibilityChanged", value: Place.PublicVisibility, reset: Place.UnspecifiedVisibility },
{ tag: "plugin", property: "plugin", signal: "pluginChanged", value: testPlugin },
- { tag: "icon", property: "icon", signal: "iconChanged", value: testIcon }
];
}
diff --git a/tests/auto/declarative_location_core/tst_place.qml b/tests/auto/declarative_location_core/tst_place.qml
index 871f10c1..ef0baa93 100644
--- a/tests/auto/declarative_location_core/tst_place.qml
+++ b/tests/auto/declarative_location_core/tst_place.qml
@@ -88,12 +88,7 @@ TestCase {
name: "Supplier 1"
supplierId: "supplier-id-1"
url: "http://www.example.com/supplier-id-1/"
- icon: Icon{
- plugin: testPlugin
- Component.onCompleted: {
- parameters.singleUrl = "http://www.example.com/supplier-id-1/icon"
- }
- }
+ icon: ({ parameters: { singleUrl: "http://www.example.com/supplier-id-1/icon" }})
}
categories: [
@@ -109,11 +104,7 @@ TestCase {
}
]
- icon: Icon {
- Component.onCompleted: {
- savePlace.icon.parameters.singleUrl = "http://example.com/test-place.png";
- }
- }
+ icon: ({ parameters: { singleUrl: "http://example.com/test-place.png" } })
}
Place {
@@ -158,24 +149,8 @@ TestCase {
return false;
// check supplier icon
- if (place1.supplier.icon === null && place2.supplier.icon !== null)
- return false;
- if (place1.supplier.icon !== null && place2.supplier.icon === null)
+ if (place1.supplier.icon !== place2.supplier.icon) {
return false;
- if (place1.supplier.icon !== null && place2.supplier.icon !== null) {
- if (place1.supplier.icon.parameters.keys().length !== place2.supplier.icon.parameters.keys().length) {
- return false;
- }
-
- var keys = place1.supplier.icon.parameters.keys() + place2.supplier.icon.parameters.keys();
- for (var i = 0; i < keys.length; ++i) {
- if (place1.supplier.icon.parameters[keys[i]] != place2.supplier.icon.parameters[keys[i]]) {
- return false;
- }
- }
-
- if (place1.supplier.icon.plugin !== place2.supplier.icon.plugin)
- return false;
}
}
@@ -214,30 +189,9 @@ TestCase {
}
// check icon
- if (place1.icon === null && place2.icon !== null) {
+ if (place1.icon !== place2.icon) {
return false;
}
- if (place1.icon !== null && place2.icon === null) {
- return false;
- }
- if (place1.icon !== null && place2.icon !== null) {
- if (place1.icon.plugin !== place2.icon.plugin) {
- console.log(place1.icon.plugin + " " + place2.icon.plugin);
- return false;
- }
-
- if (place1.icon.parameters.keys().length !== place2.icon.parameters.keys().length) {
- return false;
- }
-
- var keys = place1.icon.parameters.keys() + place2.icon.parameters.keys();
- for (var i = 0; i < keys.length; ++i) {
- if (place1.icon.parameters[keys[i]]
- != place2.icon.parameters[keys[i]]) {
- return false;
- }
- }
- }
// check extended attributes
@@ -268,14 +222,10 @@ TestCase {
compare(emptyPlace.location.address.state, '');
compare(emptyPlace.location.address.country, '');
- compare(emptyPlace.icon.plugin, null);
-
compare(emptyPlace.supplier.name, '');
compare(emptyPlace.supplier.supplierId, '');
compare(emptyPlace.supplier.url, '');
- compare(emptyPlace.supplier.icon.plugin, null);
-
compare(emptyPlace.reviewModel.totalCount, -1);
compare(emptyPlace.imageModel.totalCount, -1);
compare(emptyPlace.editorialModel.totalCount, -1);
diff --git a/tests/auto/declarative_location_core/tst_placeicon.qml b/tests/auto/declarative_location_core/tst_placeicon.qml
index e8597bb7..9d97962a 100644
--- a/tests/auto/declarative_location_core/tst_placeicon.qml
+++ b/tests/auto/declarative_location_core/tst_placeicon.qml
@@ -36,71 +36,26 @@ TestCase {
name: "Icon"
- Icon { id: emptyIcon }
+ property icon emptyIcon
function test_empty() {
- compare(emptyIcon.plugin, null);
- compare(emptyIcon.parameters.keys().length, 0)
+ compare(emptyIcon.parameters, {})
}
- Icon {
- id: qmlIconSingleUrl
- }
+ property icon qmlIconSingleUrl: ({ parameters: { singleUrl: "http://example.com/icon.png" }})
function test_qmlSingleUrlIcon() {
- qmlIconSingleUrl.parameters.singleUrl = "http://example.com/icon.png"
-
var u = qmlIconSingleUrl.url(Qt.size(64, 64));
compare(u, "http://example.com/icon.png");
u = qmlIconSingleUrl.url(Qt.size(20, 20));
compare(u, "http://example.com/icon.png");
- qmlIconSingleUrl.parameters.singleUrl = "/home/user/icon.png"
+ var params = qmlIconSingleUrl.parameters
+ params.singleUrl = "/home/user/icon.png"
+ qmlIconSingleUrl.parameters = params
u = qmlIconSingleUrl.url(Qt.size(20, 20));
compare(u, "file:///home/user/icon.png");
}
-
- Plugin {
- id: testPlugin
- name: "qmlgeo.test.plugin"
- allowExperimental: true
- }
-
- Icon {
- id: qmlIconParams
- plugin: testPlugin
- }
-
- function test_qmlIconParams() {
- compare(qmlIconParams.plugin, testPlugin);
- qmlIconParams.parameters.s = "http://example.com/icon_small.png"
- qmlIconParams.parameters.m = "http://example.com/icon_medium.png"
- qmlIconParams.parameters.l = "http://example.com/icon_large.png"
-
- compare(qmlIconParams.url(Qt.size(10, 10)), "http://example.com/icon_small.png");
- compare(qmlIconParams.url(Qt.size(20, 20)), "http://example.com/icon_small.png");
- compare(qmlIconParams.url(Qt.size(24, 24)), "http://example.com/icon_small.png");
- compare(qmlIconParams.url(Qt.size(25, 25)), "http://example.com/icon_medium.png");
- compare(qmlIconParams.url(Qt.size(30, 30)), "http://example.com/icon_medium.png");
- compare(qmlIconParams.url(Qt.size(39, 39)), "http://example.com/icon_medium.png");
- compare(qmlIconParams.url(Qt.size(40, 40)), "http://example.com/icon_large.png");
- compare(qmlIconParams.url(Qt.size(50, 50)), "http://example.com/icon_large.png");
- compare(qmlIconParams.url(Qt.size(60, 60)), "http://example.com/icon_large.png");
- }
-
- Icon {
- id: testIcon
- }
-
- function test_setAndGet_data() {
- return [
- { tag: "plugin", property: "plugin", signal: "pluginChanged", value: testPlugin },
- ];
- }
-
- function test_setAndGet(data) {
- Utils.testObjectProperties(testCase, testIcon, data);
- }
}
diff --git a/tests/auto/declarative_location_core/tst_supplier.qml b/tests/auto/declarative_location_core/tst_supplier.qml
index 8cb6f584..226cde54 100644
--- a/tests/auto/declarative_location_core/tst_supplier.qml
+++ b/tests/auto/declarative_location_core/tst_supplier.qml
@@ -52,11 +52,7 @@ TestCase {
name: "Test Supplier"
url: "http://example.com/test-supplier-id"
- icon: Icon {
- Component.onCompleted: {
- parameters.singleUrl = "http://example.com/icons/test-supplier.png"
- }
- }
+ icon: ({ parameters: { singleUrl: "http://example.com/icons/test-supplier.png" }})
}
function test_qmlConstructedSupplier() {
@@ -80,21 +76,4 @@ TestCase {
Plugin {
id: invalidPlugin
}
-
- Icon {
- id: testIcon
- }
-
- function test_setAndGet_data() {
- return [
- { tag: "name", property: "name", signal: "nameChanged", value: "Test Supplier", reset: "" },
- { tag: "supplierId", property: "supplierId", signal: "supplierIdChanged", value: "test-supplier-id-1", reset: "" },
- { tag: "url", property: "url", signal: "urlChanged", value: "http://example.com/test-supplier-id-1", reset: "" },
- { tag: "icon", property: "icon", signal: "iconChanged", value: testIcon }
- ];
- }
-
- function test_setAndGet(data) {
- Utils.testObjectProperties(testCase, testSupplier, data);
- }
}
diff --git a/tests/auto/qmlinterface/data/TestIcon.qml b/tests/auto/qmlinterface/data/TestIcon.qml
index 8053da61..1d8a10b6 100644
--- a/tests/auto/qmlinterface/data/TestIcon.qml
+++ b/tests/auto/qmlinterface/data/TestIcon.qml
@@ -29,8 +29,7 @@
import QtQuick
import QtLocation
-Icon {
- Component.onCompleted: {
- parameters.singleUrl = "http://www.example.com/test-icon.png"
- }
+Item {
+ id: testIcon
+ property icon icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }})
}
diff --git a/tests/auto/qmlinterface/data/TestPlace.qml b/tests/auto/qmlinterface/data/TestPlace.qml
index 1cce22af..a3c40c14 100644
--- a/tests/auto/qmlinterface/data/TestPlace.qml
+++ b/tests/auto/qmlinterface/data/TestPlace.qml
@@ -44,7 +44,7 @@ Place {
]
location: TestLocation { }
ratings: ({ average: 3.5, maximum: 5.0, count: 10 })
- icon: TestIcon { }
+ icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }})
supplier: TestSupplier { }
visibility: Place.PrivateVisibility
}
diff --git a/tests/auto/qmlinterface/data/TestSupplier.qml b/tests/auto/qmlinterface/data/TestSupplier.qml
index 0a682fdf..7f4cc451 100644
--- a/tests/auto/qmlinterface/data/TestSupplier.qml
+++ b/tests/auto/qmlinterface/data/TestSupplier.qml
@@ -32,5 +32,5 @@ Supplier {
name: "Test supplier"
supplierId: "test-supplier-id"
url: "http://www.example.com/test-supplier"
- icon: TestIcon { }
+ icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }})
}