summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/imports/location/declarativeplaces/declarativeplaces.pri2
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativecategory.cpp99
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativecategory_p.h29
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplace.cpp63
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplace_p.h9
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp217
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplaceicon_p.h112
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativerecommendationmodel.cpp3
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp4
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesupplier.cpp57
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesupplier_p.h14
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp26
-rw-r--r--src/imports/location/location.cpp2
-rw-r--r--src/location/maps/qgeoserviceprovider.cpp3
-rw-r--r--src/location/places/places.pri3
-rw-r--r--src/location/places/qplacecategory.cpp34
-rw-r--r--src/location/places/qplacecategory.h6
-rw-r--r--src/location/places/qplacecategory_p.h6
-rw-r--r--src/location/places/qplaceicon.cpp209
-rw-r--r--src/location/places/qplaceicon.h106
-rw-r--r--src/location/places/qplaceicon_p.h80
-rw-r--r--src/location/places/qplacemanager.cpp8
-rw-r--r--src/location/places/qplacemanager.h3
-rw-r--r--src/location/places/qplacemanagerengine.cpp10
-rw-r--r--src/location/places/qplacemanagerengine.h5
-rw-r--r--src/location/places/qplacemanagerengine_p.h1
-rw-r--r--src/location/places/qplacesupplier.cpp16
-rw-r--r--src/location/places/qplacesupplier.h8
-rw-r--r--src/location/places/qplacesupplier_p.h4
-rw-r--r--src/location/qplace.cpp18
-rw-r--r--src/location/qplace.h4
-rw-r--r--src/location/qplace_p.h3
-rw-r--r--src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp6
-rw-r--r--src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h3
-rw-r--r--src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp4
-rw-r--r--src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.h3
-rw-r--r--src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp28
-rw-r--r--src/plugins/geoservices/nokia/places/qplacejsondetailsparser.h5
-rw-r--r--src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp6
-rw-r--r--src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.h5
-rw-r--r--src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp19
-rw-r--r--src/plugins/geoservices/nokia/places/qplacejsonreviewparser.h6
-rw-r--r--src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.cpp4
-rw-r--r--src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.h2
-rw-r--r--src/plugins/geoservices/nokia/places/qplacesuppliersrepository.cpp17
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp20
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h2
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.cpp21
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.h12
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp14
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h1
-rw-r--r--tests/auto/geotestplugin/qplacemanagerengine_test.h8
-rw-r--r--tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp53
-rw-r--r--tests/auto/qplacesupplier/tst_qplacesupplier.cpp28
54 files changed, 1298 insertions, 133 deletions
diff --git a/src/imports/location/declarativeplaces/declarativeplaces.pri b/src/imports/location/declarativeplaces/declarativeplaces.pri
index c559e7b6..fa6dcd3a 100644
--- a/src/imports/location/declarativeplaces/declarativeplaces.pri
+++ b/src/imports/location/declarativeplaces/declarativeplaces.pri
@@ -13,6 +13,7 @@ SOURCES += \
declarativeplaces/qdeclarativecategory.cpp \
declarativeplaces/qdeclarativeplace.cpp \
declarativeplaces/qdeclarativeplaceattribute.cpp \
+ declarativeplaces/qdeclarativeplaceicon.cpp \
declarativeplaces/qdeclarativerating.cpp \
declarativeplaces/qdeclarativesupplier.cpp \
declarativeplaces/qdeclarativesearchmodelbase.cpp
@@ -31,6 +32,7 @@ HEADERS += \
declarativeplaces/qdeclarativecategory_p.h \
declarativeplaces/qdeclarativeplace_p.h \
declarativeplaces/qdeclarativeplaceattribute_p.h \
+ declarativeplaces/qdeclarativeplaceicon_p.h \
declarativeplaces/qdeclarativerating_p.h \
declarativeplaces/qdeclarativesupplier_p.h \
declarativeplaces/qdeclarativesearchmodelbase.h
diff --git a/src/imports/location/declarativeplaces/qdeclarativecategory.cpp b/src/imports/location/declarativeplaces/qdeclarativecategory.cpp
index 567178ba..e7b29a9c 100644
--- a/src/imports/location/declarativeplaces/qdeclarativecategory.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativecategory.cpp
@@ -40,6 +40,11 @@
****************************************************************************/
#include "qdeclarativecategory_p.h"
+#include "qdeclarativeplaceicon_p.h"
+#include "qdeclarativegeoserviceprovider_p.h"
+
+#include <QtDeclarative/QDeclarativeInfo>
+#include <QtLocation/QGeoServiceProvider>
QT_USE_NAMESPACE
@@ -54,17 +59,56 @@ QT_USE_NAMESPACE
*/
QDeclarativeCategory::QDeclarativeCategory(QObject* parent)
- : QObject(parent) {}
+ : QObject(parent), m_icon(0)
+{
+}
QDeclarativeCategory::QDeclarativeCategory(const QPlaceCategory &category,
- QObject *parent)
+ QDeclarativeGeoServiceProvider *plugin,
+ QObject *parent)
: QObject(parent),
- m_category(category)
+ m_category(category),
+ m_icon(0), m_plugin(plugin)
{
+ Q_ASSERT(plugin);
+ if (!category.icon().isEmpty())
+ m_icon = new QDeclarativePlaceIcon(category.icon(), m_plugin, this);
}
QDeclarativeCategory::~QDeclarativeCategory() {}
+// From QDeclarativeParserStatus
+void QDeclarativeCategory::componentComplete()
+{
+ m_complete = true;
+}
+
+/*!
+ \qmlproperty Plugin Category::plugin
+
+ This property holds the plugin to which the category belongs.
+*/
+void QDeclarativeCategory::setPlugin(QDeclarativeGeoServiceProvider *plugin)
+{
+ if (m_plugin == plugin)
+ return;
+
+ m_plugin = plugin;
+ if (m_complete)
+ emit pluginChanged();
+ QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
+ QPlaceManager *placeManager = serviceProvider->placeManager();
+ if (!placeManager || serviceProvider->error() != QGeoServiceProvider::NoError) {
+ qmlInfo(this) << tr("Warning: Plugin does not support places.");
+ return;
+ }
+}
+
+QDeclarativeGeoServiceProvider* QDeclarativeCategory::plugin() const
+{
+ return m_plugin;
+}
+
void QDeclarativeCategory::setCategory(const QPlaceCategory &category)
{
QPlaceCategory previous = m_category;
@@ -76,10 +120,34 @@ void QDeclarativeCategory::setCategory(const QPlaceCategory &category)
if (category.categoryId() != previous.categoryId()) {
emit categoryIdChanged();
}
+
+ if (m_icon) {
+ if (m_icon->plugin() != m_plugin
+ || m_icon->baseUrl() != category.icon().baseUrl()
+ || m_icon->fullUrl() != category.icon().fullUrl()) {
+ if (m_icon->parent() == this) {
+ if (category.icon().isEmpty()) {
+ delete m_icon;
+ m_icon = 0;
+ } else {
+ m_icon->setPlugin(m_plugin);
+ m_icon->setBaseUrl(category.icon().baseUrl());
+ m_icon->setFullUrl(category.icon().fullUrl());
+ }
+ } else {
+ m_icon = new QDeclarativePlaceIcon(category.icon(), m_plugin, this);
+ }
+ emit iconChanged();
+ }
+ } else {
+ m_icon = new QDeclarativePlaceIcon(category.icon(), m_plugin, this);
+ emit iconChanged();
+ }
}
-QPlaceCategory QDeclarativeCategory::category() const
+QPlaceCategory QDeclarativeCategory::category()
{
+ m_category.setIcon(m_icon ? m_icon->icon() : QPlaceIcon());
return m_category;
}
@@ -88,7 +156,6 @@ QPlaceCategory QDeclarativeCategory::category() const
This property holds the id of the category
*/
-
void QDeclarativeCategory::setCategoryId(const QString &id)
{
if (m_category.categoryId() != id) {
@@ -134,3 +201,25 @@ void QDeclarativeCategory::setVisibility(Visibility visibility)
m_category.setVisibility(static_cast<QtLocation::Visibility>(visibility));
emit visibilityChanged();
}
+
+/*!
+ \qmlproperty PlaceIcon Category::icon
+
+ This property holds the icon of the category.
+*/
+QDeclarativePlaceIcon *QDeclarativeCategory::icon() const
+{
+ return m_icon;
+}
+
+void QDeclarativeCategory::setIcon(QDeclarativePlaceIcon *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/imports/location/declarativeplaces/qdeclarativecategory_p.h b/src/imports/location/declarativeplaces/qdeclarativecategory_p.h
index d4a04d06..1e201a65 100644
--- a/src/imports/location/declarativeplaces/qdeclarativecategory_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativecategory_p.h
@@ -47,21 +47,29 @@
#include <qplacecategory.h>
+#include "qdeclarativegeoserviceprovider_p.h"
+
QT_BEGIN_NAMESPACE
-class QDeclarativeCategory : public QObject
+class QDeclarativePlaceIcon;
+
+class QDeclarativeCategory : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
Q_ENUMS(Visibility)
+ Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
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_INTERFACES(QDeclarativeParserStatus)
public:
explicit QDeclarativeCategory(QObject* parent = 0);
- explicit QDeclarativeCategory(const QPlaceCategory &category, QObject* parent = 0);
+ QDeclarativeCategory(const QPlaceCategory &category, QDeclarativeGeoServiceProvider *plugin, QObject* parent = 0);
~QDeclarativeCategory();
enum Visibility {
@@ -71,7 +79,14 @@ public:
PublicVisibility = QtLocation::PublicVisibility
};
- QPlaceCategory category() const;
+ //From QDeclarativeParserStatus
+ virtual void classBegin() {}
+ virtual void componentComplete();
+
+ void setPlugin(QDeclarativeGeoServiceProvider *plugin);
+ QDeclarativeGeoServiceProvider* plugin() const;
+
+ QPlaceCategory category();
void setCategory(const QPlaceCategory &category);
QString categoryId() const;
@@ -82,13 +97,21 @@ public:
Visibility visibility() const;
void setVisibility(Visibility visibility);
+ QDeclarativePlaceIcon *icon() const;
+ void setIcon(QDeclarativePlaceIcon *icon);
+
signals:
+ void pluginChanged();
void categoryIdChanged();
void nameChanged();
void visibilityChanged();
+ void iconChanged();
private:
QPlaceCategory m_category;
+ QDeclarativePlaceIcon *m_icon;
+ QDeclarativeGeoServiceProvider *m_plugin;
+ bool m_complete;
};
QT_END_NAMESPACE
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
index 157a7b85..ef165cdd 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
@@ -42,6 +42,7 @@
#include "qdeclarativeplace_p.h"
#include "qdeclarativegeoserviceprovider_p.h"
#include "qdeclarativeplaceattribute_p.h"
+#include "qdeclarativeplaceicon_p.h"
#include <QtDeclarative/QDeclarativeInfo>
#include <QtLocation/QGeoServiceProvider>
@@ -65,20 +66,24 @@ QT_USE_NAMESPACE
*/
QDeclarativePlace::QDeclarativePlace(QObject* parent)
-: QObject(parent), m_location(0), m_rating(0), m_supplier(0),
+: QObject(parent), m_location(0), m_rating(0), m_supplier(0), m_icon(0),
m_reviewModel(0), m_imageModel(0), m_editorialModel(0),
m_extendedAttributes(new QDeclarativePropertyMap(this)),
m_reply(0), m_plugin(0),m_complete(false), m_status(QDeclarativePlace::Ready)
{
}
-QDeclarativePlace::QDeclarativePlace(const QPlace &src, QObject *parent)
-: QObject(parent), m_location(0), m_rating(0), m_supplier(0),
+QDeclarativePlace::QDeclarativePlace(const QPlace &src, QDeclarativeGeoServiceProvider *plugin, QObject *parent)
+: QObject(parent), m_location(0), m_rating(0), m_supplier(0), m_icon(0),
m_reviewModel(0), m_imageModel(0), m_editorialModel(0),
m_extendedAttributes(new QDeclarativePropertyMap(this)),
- m_src(src), m_reply(0), m_plugin(0), m_complete(false),
+ m_src(src), m_reply(0), m_plugin(plugin), m_complete(false),
m_status(QDeclarativePlace::Ready)
{
+ Q_ASSERT(plugin);
+ if (!m_src.icon().isEmpty())
+ m_icon = new QDeclarativePlaceIcon(m_src.icon(), m_plugin, this);
+
setPlace(src);
}
@@ -174,6 +179,29 @@ void QDeclarativePlace::setPlace(const QPlace &src)
emit supplierChanged();
}
+ if (m_icon) {
+ if (m_icon->plugin() != m_plugin
+ || m_icon->baseUrl() != m_src.icon().baseUrl()
+ || m_icon->fullUrl() != m_src.icon().fullUrl()) {
+ if (m_icon->parent() == this) {
+ if (m_src.icon().isEmpty()) {
+ delete m_icon;
+ m_icon = 0;
+ } else {
+ m_icon->setPlugin(m_plugin);
+ m_icon->setBaseUrl(m_src.icon().baseUrl());
+ m_icon->setFullUrl(m_src.icon().fullUrl());
+ }
+ } else {
+ m_icon = new QDeclarativePlaceIcon(m_src.icon(), m_plugin, this);
+ }
+ emit iconChanged();
+ }
+ } else {
+ m_icon = new QDeclarativePlaceIcon(m_src.icon(), m_plugin, this);
+ emit iconChanged();
+ }
+
if (previous.name() != m_src.name()) {
emit nameChanged();
}
@@ -239,6 +267,9 @@ QPlace QDeclarativePlace::place()
// Supplier
result.setSupplier(m_supplier ? m_supplier->supplier() : QPlaceSupplier());
+ // Icon
+ result.setIcon(m_icon ? m_icon->icon() : QPlaceIcon());
+
// Extended Attributes
return result;
}
@@ -317,6 +348,28 @@ QDeclarativeSupplier *QDeclarativePlace::supplier() const
}
/*!
+ \qmlproperty PlaceIcon Place::icon
+
+ This property holds the icon of the place.
+*/
+QDeclarativePlaceIcon *QDeclarativePlace::icon() const
+{
+ return m_icon;
+}
+
+void QDeclarativePlace::setIcon(QDeclarativePlaceIcon *icon)
+{
+ if (m_icon == icon)
+ return;
+
+ if (m_icon && m_icon->parent() == this)
+ delete m_icon;
+
+ m_icon = icon;
+ emit iconChanged();
+}
+
+/*!
\qmlproperty string Place::name
This property holds name.
@@ -692,7 +745,7 @@ void QDeclarativePlace::synchronizeCategories()
qDeleteAll(m_categories);
m_categories.clear();
foreach (QPlaceCategory value, m_src.categories()) {
- QDeclarativeCategory* declarativeValue = new QDeclarativeCategory(value, this);
+ QDeclarativeCategory* declarativeValue = new QDeclarativeCategory(value, m_plugin, this);
m_categories.append(declarativeValue);
}
}
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplace_p.h b/src/imports/location/declarativeplaces/qdeclarativeplace_p.h
index 3627c3c4..d379854f 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplace_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativeplace_p.h
@@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE
class QPlaceReply;
class QPlaceManager;
+class QDeclarativePlaceIcon;
class QDeclarativePlace : public QObject, public QDeclarativeParserStatus
{
@@ -71,6 +72,7 @@ class QDeclarativePlace : public QObject, public QDeclarativeParserStatus
Q_PROPERTY(QDeclarativeGeoLocation* location READ location WRITE setLocation NOTIFY locationChanged);
Q_PROPERTY(QDeclarativeRating* rating READ rating WRITE setRating NOTIFY ratingChanged);
Q_PROPERTY(QDeclarativeSupplier *supplier READ supplier WRITE setSupplier NOTIFY supplierChanged)
+ Q_PROPERTY(QDeclarativePlaceIcon* 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)
@@ -94,7 +96,7 @@ class QDeclarativePlace : public QObject, public QDeclarativeParserStatus
public:
explicit QDeclarativePlace(QObject* parent = 0);
- explicit QDeclarativePlace(const QPlace &src, QObject* parent = 0);
+ QDeclarativePlace(const QPlace &src, QDeclarativeGeoServiceProvider *plugin, QObject* parent = 0);
~QDeclarativePlace();
enum Status {Ready, Saving, Fetching, Removing, Error};
@@ -132,7 +134,8 @@ public:
void setRating(QDeclarativeRating *rating);
QDeclarativeSupplier *supplier() const;
void setSupplier(QDeclarativeSupplier *supplier);
-
+ QDeclarativePlaceIcon *icon() const;
+ void setIcon(QDeclarativePlaceIcon *icon);
QString name() const;
void setName(const QString &name);
QString placeId() const;
@@ -174,6 +177,7 @@ signals:
void locationChanged();
void ratingChanged();
void supplierChanged();
+ void iconChanged();
void nameChanged();
void placeIdChanged();
void attributionChanged();
@@ -205,6 +209,7 @@ private:
QDeclarativeGeoLocation *m_location;
QDeclarativeRating *m_rating;
QDeclarativeSupplier *m_supplier;
+ QDeclarativePlaceIcon *m_icon;
QDeclarativeReviewModel *m_reviewModel;
QDeclarativePlaceImageModel *m_imageModel;
QDeclarativePlaceEditorialModel *m_editorialModel;
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp b/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp
new file mode 100644
index 00000000..024c454f
--- /dev/null
+++ b/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeplaceicon_p.h"
+
+#include <QtLocation/QGeoServiceProvider>
+#include <QtLocation/QPlaceManager>
+#include <QtDeclarative/QDeclarativeInfo>
+
+
+QT_USE_NAMESPACE
+
+/*!
+ \qmlclass PlaceIcon
+
+ \brief The PlaceIcon element holds icon related information, most prominently the icon's urls.
+ \inherits QObject
+
+ \ingroup qml-places
+*/
+QDeclarativePlaceIcon::QDeclarativePlaceIcon(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QDeclarativePlaceIcon::QDeclarativePlaceIcon(const QPlaceIcon &icon, QDeclarativeGeoServiceProvider *plugin, QObject *parent)
+ :QObject(parent)
+{
+ m_baseUrl = icon.baseUrl();
+ m_fullUrl = icon.fullUrl();
+ m_plugin = plugin;
+}
+
+QDeclarativePlaceIcon::~QDeclarativePlaceIcon()
+{
+}
+
+QPlaceIcon QDeclarativePlaceIcon::icon() const
+{
+ QPlaceIcon icon;
+ if (m_plugin)
+ icon.setManager(manager());
+ icon.setBaseUrl(m_baseUrl);
+ icon.setFullUrl(m_fullUrl);
+ return icon;
+}
+
+void QDeclarativePlaceIcon::setIcon(const QPlaceIcon &src)
+{
+ if (m_baseUrl != src.baseUrl()) {
+ m_baseUrl = src.baseUrl();
+ emit baseUrlChanged();
+ }
+
+ if (m_fullUrl != src.fullUrl()) {
+ m_fullUrl = src.fullUrl();
+ emit fullUrlChanged();
+ }
+}
+
+/*!
+ \qmlmethod string PlaceIcon::url(size, PlaceIcon.IconFlags flags)
+
+ Returns a url for the icon best suited to the given size and flags.
+ Note that a manager may not explicitly support a given set of sizes and
+ flags, in thise case a 'closest match' url is returned.
+*/
+QUrl QDeclarativePlaceIcon::url(const QSize &size, QDeclarativePlaceIcon::IconFlags flags) const
+{
+ QPlaceManager *placeManager = manager();
+ if (placeManager) {
+ QPlaceIcon icon;
+ icon.setBaseUrl(m_baseUrl);
+ icon.setFullUrl(m_fullUrl);
+ icon.setManager(placeManager);
+ return placeManager->constructIconUrl(icon, size, QPlaceIcon::IconFlags(int(flags)));
+ }
+
+ return QUrl();
+}
+
+/*!
+ \qmlproperty url PlaceIcon::fullUrl
+
+ This property holds the full url of the icon of the place. Setting
+ the full url implies that the base url is cleared. If the full url
+ is set, the url() method will always return the full url regardless
+ of the specified size and flags.
+*/
+QUrl QDeclarativePlaceIcon::fullUrl() const
+{
+ return m_fullUrl;
+}
+
+void QDeclarativePlaceIcon::setFullUrl(const QUrl &url)
+{
+ if (m_fullUrl != url) {
+ m_fullUrl = url;
+ emit fullUrlChanged();
+ setBaseUrl(QUrl());
+ }
+}
+
+/*!
+ \qmlproperty url PlaceIcon::baseUrl
+
+ This property holds a base url which the complete url returned by
+ url() will be based off. Setting the base url implies that the full
+ url is cleared.
+
+ An example base url is http://example/icon. Depending on the
+ parameters specified, when url() is invoked the returned complete url
+ may be something like http://example/icon_32x32_selected.jpg.
+*/
+QUrl QDeclarativePlaceIcon::baseUrl() const
+{
+ return m_baseUrl;
+}
+
+void QDeclarativePlaceIcon::setBaseUrl(const QUrl &url)
+{
+ if (m_baseUrl != url) {
+ m_baseUrl = url;
+ emit baseUrlChanged();
+ setFullUrl(QUrl());
+ }
+}
+
+/*!
+ \qmlproperty Plugin PlaceIcon::plugin
+
+ The property holds plugin the that is reponsible 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();
+
+ QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
+ QPlaceManager *placeManager = serviceProvider->placeManager();
+ if (!placeManager || serviceProvider->error() != QGeoServiceProvider::NoError) {
+ qmlInfo(this) << tr("Warning: Plugin does not support places.");
+ return;
+ }
+}
+
+/*
+ Helper function to return the manager from the plugin
+*/
+QPlaceManager *QDeclarativePlaceIcon::manager() const
+{
+ if (!m_plugin) {
+ qmlInfo(this) << tr("Plugin not assigned to place icon");
+ return 0;
+ }
+
+ QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
+ if (!serviceProvider)
+ return 0;
+
+ QPlaceManager *placeManager = serviceProvider->placeManager();
+
+ if (!placeManager) {
+ qmlInfo(this) << tr("Places not supported by %1 Plugin.").arg(m_plugin->name());
+ return 0;
+ }
+
+ return placeManager;
+}
+
+
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceicon_p.h b/src/imports/location/declarativeplaces/qdeclarativeplaceicon_p.h
new file mode 100644
index 00000000..7c3b7f0c
--- /dev/null
+++ b/src/imports/location/declarativeplaces/qdeclarativeplaceicon_p.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEPLACEICON_P_H
+#define QDECLARATIVEPLACEICON_P_H
+
+#include "qdeclarativegeoserviceprovider_p.h"
+
+#include <qplaceicon.h>
+#include <QtDeclarative/qdeclarative.h>
+
+#include <QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativePlaceIcon : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(IconFlag)
+ Q_FLAGS(IconFlags)
+
+ Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl NOTIFY baseUrlChanged)
+ Q_PROPERTY(QUrl fullUrl READ fullUrl WRITE setFullUrl NOTIFY fullUrlChanged)
+ Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
+
+public:
+ enum IconFlag {
+ Normal = QPlaceIcon::Normal,
+ Disabled = QPlaceIcon::Disabled,
+ Active = QPlaceIcon::Active,
+ Selected = QPlaceIcon::Selected,
+
+ Map = QPlaceIcon::Map,
+ List = QPlaceIcon::List
+ };
+
+ Q_DECLARE_FLAGS(IconFlags, IconFlag)
+
+ 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(), QDeclarativePlaceIcon::IconFlags flags = Normal) const;
+
+ QUrl fullUrl() const;
+ void setFullUrl(const QUrl &fullUrl);
+
+ QUrl baseUrl() const;
+ void setBaseUrl(const QUrl &baseUrl);
+
+ void setPlugin(QDeclarativeGeoServiceProvider *plugin);
+ QDeclarativeGeoServiceProvider *plugin() const;
+
+signals:
+ void baseUrlChanged();
+ void fullUrlChanged();
+ void pluginChanged();
+
+private:
+ QPlaceManager *manager() const;
+ QUrl m_baseUrl;
+ QUrl m_fullUrl;
+ QDeclarativeGeoServiceProvider *m_plugin;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QT_PREPEND_NAMESPACE(QDeclarativePlaceIcon::IconFlags))
+
+#endif
+
diff --git a/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel.cpp
index a69177ee..b2211efb 100644
--- a/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel.cpp
@@ -213,8 +213,7 @@ void QDeclarativeRecommendationModel::processReply(QPlaceReply *reply)
m_results = searchReply->results();
foreach (const QPlaceSearchResult &result, m_results) {
- QDeclarativePlace *place = new QDeclarativePlace(result.place(), this);
- place->setPlugin(plugin());
+ QDeclarativePlace *place = new QDeclarativePlace(result.place(), plugin(), this);
m_places.insert(result.place().placeId(), place);
}
}
diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
index 6a85ebfe..70c82c1c 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
@@ -41,6 +41,7 @@
#include "qdeclarativesearchresultmodel_p.h"
#include "qdeclarativeplace_p.h"
+#include "qdeclarativeplaceicon_p.h"
#include <QtDeclarative/QDeclarativeInfo>
#include <QtLocation/QGeoServiceProvider>
@@ -343,8 +344,7 @@ void QDeclarativeSearchResultModel::processReply(QPlaceReply *reply)
m_results = searchReply->results();
foreach (const QPlaceSearchResult &result, m_results) {
- QDeclarativePlace *place = new QDeclarativePlace(result.place(), this);
- place->setPlugin(plugin());
+ QDeclarativePlace *place = new QDeclarativePlace(result.place(),plugin(), this);
m_places.insert(result.place().placeId(), place);
}
}
diff --git a/src/imports/location/declarativeplaces/qdeclarativesupplier.cpp b/src/imports/location/declarativeplaces/qdeclarativesupplier.cpp
index 7dfc3d6d..9f5d1e46 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesupplier.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesupplier.cpp
@@ -57,15 +57,19 @@ QT_USE_NAMESPACE
*/
QDeclarativeSupplier::QDeclarativeSupplier(QObject* parent)
- : QObject(parent)
+ : QObject(parent), m_icon(0)
{
}
QDeclarativeSupplier::QDeclarativeSupplier(const QPlaceSupplier &src,
QObject *parent)
: QObject(parent),
- m_src(src)
+ m_src(src),
+ m_icon(0)
{
+ //Note: icon needs to be assigned externally
+ //to the QDeclarativeSupplier since the icon needs
+ //to know which plugin it comes from.
}
QDeclarativeSupplier::~QDeclarativeSupplier()
@@ -86,13 +90,15 @@ void QDeclarativeSupplier::setSupplier(const QPlaceSupplier &src)
if (previous.url() != m_src.url()) {
emit urlChanged();
}
- if (previous.supplierIconUrl() != m_src.supplierIconUrl()) {
- emit supplierIconUrlChanged();
- }
+
+ //Note: icon needs to be assigned externally
+ //to the QDeclarativeSupplier since the icon needs
+ //to know which plugin it comes from.
}
-QPlaceSupplier QDeclarativeSupplier::supplier() const
+QPlaceSupplier QDeclarativeSupplier::supplier()
{
+ m_src.setIcon(m_icon ? m_icon->icon() : QPlaceIcon());
return m_src;
}
@@ -135,39 +141,42 @@ QString QDeclarativeSupplier::name() const
}
/*!
- \qmlproperty url Supplier::supplierIconUrl
+ \qmlproperty url Supplier::url
- This property holds icon URL.
+ This property holds supplier URL.
*/
-void QDeclarativeSupplier::setSupplierIconUrl(const QUrl &supplierIconUrl)
+void QDeclarativeSupplier::setUrl(const QUrl &url)
{
- if (m_src.supplierIconUrl() != supplierIconUrl) {
- m_src.setSupplierIconUrl(supplierIconUrl);
- emit supplierIconUrlChanged();
+ if (m_src.url() != url) {
+ m_src.setUrl(url);
+ emit urlChanged();
}
}
-QUrl QDeclarativeSupplier::supplierIconUrl() const
+QUrl QDeclarativeSupplier::url() const
{
- return m_src.supplierIconUrl();
+ return m_src.url();
}
/*!
- \qmlproperty url Supplier::url
+ \qmlproperty PlaceIcon Supplier::icon
- This property holds supplier URL.
+ This property holds the icon of the supplier.
*/
-
-void QDeclarativeSupplier::setUrl(const QUrl &url)
+QDeclarativePlaceIcon *QDeclarativeSupplier::icon() const
{
- if (m_src.url() != url) {
- m_src.setUrl(url);
- emit urlChanged();
- }
+ return m_icon;
}
-QUrl QDeclarativeSupplier::url() const
+void QDeclarativeSupplier::setIcon(QDeclarativePlaceIcon *icon)
{
- return m_src.url();
+ if (m_icon == icon)
+ return;
+
+ if (m_icon && m_icon->parent() == this)
+ delete m_icon;
+
+ m_icon = icon;
+ emit iconChanged();
}
diff --git a/src/imports/location/declarativeplaces/qdeclarativesupplier_p.h b/src/imports/location/declarativeplaces/qdeclarativesupplier_p.h
index 827c40c7..d51abe27 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesupplier_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativesupplier_p.h
@@ -47,6 +47,8 @@
#include <QtDeclarative/qdeclarative.h>
#include <qplacesupplier.h>
+#include "qdeclarativeplaceicon_p.h"
+
QT_BEGIN_NAMESPACE
class QDeclarativeSupplier : public QObject
@@ -56,14 +58,14 @@ class QDeclarativeSupplier : public QObject
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(QUrl supplierIconUrl READ supplierIconUrl WRITE setSupplierIconUrl NOTIFY supplierIconUrlChanged)
+ Q_PROPERTY(QDeclarativePlaceIcon* icon READ icon WRITE setIcon NOTIFY iconChanged)
public:
explicit QDeclarativeSupplier(QObject* parent = 0);
explicit QDeclarativeSupplier(const QPlaceSupplier &src, QObject* parent = 0);
~QDeclarativeSupplier();
- QPlaceSupplier supplier() const;
+ QPlaceSupplier supplier();
void setSupplier(const QPlaceSupplier &src);
QString name() const;
@@ -72,17 +74,19 @@ public:
void setSupplierId(const QString &data);
QUrl url() const;
void setUrl(const QUrl &data);
- QUrl supplierIconUrl() const;
- void setSupplierIconUrl(const QUrl &data);
+
+ QDeclarativePlaceIcon *icon() const;
+ void setIcon(QDeclarativePlaceIcon *icon);
signals:
void nameChanged();
void supplierIdChanged();
void urlChanged();
- void supplierIconUrlChanged();
+ void iconChanged();
private:
QPlaceSupplier m_src;
+ QDeclarativePlaceIcon *m_icon;
};
QT_END_NAMESPACE
diff --git a/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
index e0b1e3ec..9d292146 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
@@ -40,10 +40,12 @@
****************************************************************************/
#include "qdeclarativesupportedcategoriesmodel_p.h"
+#include "qdeclarativeplaceicon_p.h"
#include "qgeoserviceprovider.h"
#include <QtDeclarative/QDeclarativeInfo>
#include <QtLocation/QPlaceManager>
+#include <QtLocation/QPlaceIcon>
QT_USE_NAMESPACE
@@ -313,7 +315,8 @@ void QDeclarativeSupportedCategoriesModel::addedCategory(const QPlaceCategory &c
beginInsertRows(parentIndex, rowToBeAdded, rowToBeAdded);
PlaceCategoryNode *categoryNode = new PlaceCategoryNode;
categoryNode->parentId = parentId;
- categoryNode->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(category));
+ categoryNode->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(category, m_plugin, this));
+
m_categoriesTree.insert(category.categoryId(), categoryNode);
parentNode->childIds.insert(rowToBeAdded,category.categoryId());
endInsertRows();
@@ -342,6 +345,8 @@ void QDeclarativeSupportedCategoriesModel::updatedCategory(const QPlaceCategory
if (!categoryNode)
return;
+ categoryNode->declCategory->setCategory(category);
+
if (categoryNode->parentId == parentId) { //reparenting to same parent
QModelIndex parentIndex = index(parentId);
int rowToBeAdded = rowToAddChild(newParentNode, category);
@@ -355,11 +360,9 @@ void QDeclarativeSupportedCategoriesModel::updatedCategory(const QPlaceCategory
newParentNode->childIds.removeAll(categoryId);
newParentNode->childIds.insert(rowToBeAdded, categoryId);
- categoryNode->declCategory->setCategory(category);
endMoveRows();
} else {// if the position has not changed we modifying an existing row
QModelIndex categoryIndex = index(categoryId);
- categoryNode->declCategory->setCategory(category);
emit dataChanged(categoryIndex, categoryIndex);
}
} else { //reparenting to different parents
@@ -376,7 +379,6 @@ void QDeclarativeSupportedCategoriesModel::updatedCategory(const QPlaceCategory
oldParentNode->childIds.indexOf(categoryId), newParentIndex, rowToBeAdded);
oldParentNode->childIds.removeAll(oldCategory.categoryId());
newParentNode->childIds.insert(rowToBeAdded, categoryId);
- categoryNode->declCategory->setCategory(category);
categoryNode->parentId = parentId;
endMoveRows();
@@ -417,6 +419,16 @@ void QDeclarativeSupportedCategoriesModel::saveCategory(const QVariantMap &categ
if (categoryMap.contains(QLatin1String("name")))
category.setName(categoryMap.value(QLatin1String("name")).toString());
+
+ QDeclarativePlaceIcon *declIcon = qobject_cast<QDeclarativePlaceIcon *>(categoryMap.value(QLatin1String("icon")).value<QObject *>());
+ if (declIcon) {
+ QPlaceIcon icon;
+ icon.setBaseUrl(declIcon->baseUrl());
+ icon.setFullUrl(declIcon->fullUrl());
+ icon.setManager(placeManager);
+ category.setIcon(icon);
+ }
+
QPlaceCategory parentCategory;
if (m_categoriesTree.contains(parentId))
parentCategory = m_categoriesTree.value(parentId)->declCategory->category();
@@ -463,8 +475,8 @@ void QDeclarativeSupportedCategoriesModel::update()
PlaceCategoryNode *node = new PlaceCategoryNode;
node->childIds = populateCategories(placeManager, QPlaceCategory());
m_categoriesTree.insert(QString(), node);
- node->declCategory =
- QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(QPlaceCategory()));
+ node->declCategory = QSharedPointer<QDeclarativeCategory>
+ (new QDeclarativeCategory(QPlaceCategory(), m_plugin, this));
endResetModel();
}
@@ -519,7 +531,7 @@ QStringList QDeclarativeSupportedCategoriesModel::populateCategories(QPlaceManag
iter.next();
node = new PlaceCategoryNode;
node->parentId = parent.categoryId();
- node->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(iter.value()));
+ node->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(iter.value(), m_plugin ,this));
if (m_hierarchical)
node->childIds = populateCategories(manager, iter.value());
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index 44ca63fc..abf659af 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -68,6 +68,7 @@
#include "qdeclarativegeolocation_p.h"
#include "qdeclarativeplace_p.h"
#include "qdeclarativeplaceattribute_p.h"
+#include "qdeclarativeplaceicon_p.h"
#include "qdeclarativerating_p.h"
#include "qdeclarativesupplier_p.h"
@@ -129,6 +130,7 @@ public:
qmlRegisterType<QDeclarativeGeoLocation>(uri, 5, 0, "Location");
qmlRegisterType<QDeclarativePlaceImageModel>(uri, 5, 0, "ImageModel");
qmlRegisterType<QDeclarativePlace>(uri, 5, 0, "Place");
+ qmlRegisterType<QDeclarativePlaceIcon>(uri, 5, 0, "PlaceIcon");
qmlRegisterType<QDeclarativeRating>(uri, 5, 0, "Rating");
qmlRegisterType<QDeclarativeReviewModel>(uri, 5, 0, "ReviewModel");
qmlRegisterType<QDeclarativeSupplier>(uri, 5, 0, "Supplier");
diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp
index 624ef3c1..0a7bbbf8 100644
--- a/src/location/maps/qgeoserviceprovider.cpp
+++ b/src/location/maps/qgeoserviceprovider.cpp
@@ -51,6 +51,7 @@
#include "qgeomappingmanagerengine.h"
#include "qgeoroutingmanagerengine.h"
#include "qplacemanagerengine.h"
+#include "qplacemanagerengine_p.h"
#include <QList>
#include <QString>
@@ -337,6 +338,8 @@ QPlaceManager *QGeoServiceProvider::placeManager() const
engine->setManagerName(d_ptr->factory->providerName());
engine->setManagerVersion(d_ptr->factory->providerVersion());
d_ptr->placeManager = new QPlaceManager(engine);
+ engine->d_ptr->manager = d_ptr->placeManager;
+
} else {
d_ptr->placeError = QGeoServiceProvider::NotSupportedError;
d_ptr->placeErrorString = QLatin1String("The service provider does not support placeManager().");
diff --git a/src/location/places/places.pri b/src/location/places/places.pri
index 8ac97180..6e0a4896 100644
--- a/src/location/places/places.pri
+++ b/src/location/places/places.pri
@@ -10,6 +10,7 @@ PUBLIC_HEADERS += \
places/qplacecontentreply.h \
places/qplaceeditorial.h \
places/qplaceimage.h \
+ places/qplaceicon.h \
places/qplacerating.h \
places/qplacereview.h \
places/qplacesupplier.h \
@@ -34,6 +35,7 @@ PRIVATE_HEADERS += \
places/qplacecategory_p.h \
places/qplacecontent_p.h \
places/qplaceeditorial_p.h \
+ places/qplaceicon_p.h \
places/qplaceimage_p.h \
places/qplacerating_p.h \
places/qplacereview_p.h \
@@ -52,6 +54,7 @@ SOURCES += \
places/qplacecontentreply.cpp \
places/qplaceeditorial.cpp \
#result
+ places/qplaceicon.cpp \
places/qplaceimage.cpp \
places/qplacerating.cpp \
places/qplacereview.cpp \
diff --git a/src/location/places/qplacecategory.cpp b/src/location/places/qplacecategory.cpp
index e37bc89f..75cfd45a 100644
--- a/src/location/places/qplacecategory.cpp
+++ b/src/location/places/qplacecategory.cpp
@@ -50,7 +50,8 @@ QPlaceCategoryPrivate::QPlaceCategoryPrivate()
}
QPlaceCategoryPrivate::QPlaceCategoryPrivate(const QPlaceCategoryPrivate &other)
-: QSharedData(other), categoryId(other.categoryId), name(other.name), visibility(other.visibility)
+: QSharedData(other), categoryId(other.categoryId), name(other.name), visibility(other.visibility),
+ icon(other.icon)
{
}
@@ -58,6 +59,21 @@ QPlaceCategoryPrivate::~QPlaceCategoryPrivate()
{
}
+QPlaceCategoryPrivate &QPlaceCategoryPrivate::operator=(const QPlaceCategoryPrivate &other)
+{
+ categoryId = other.categoryId;
+ name = other.name;
+ icon = other.icon;
+ return *this;
+}
+
+bool QPlaceCategoryPrivate::operator==(const QPlaceCategoryPrivate &other) const
+{
+ return (categoryId == other.categoryId)
+ && (icon == other.icon)
+ && (name == other.name);
+}
+
/*!
\class QPlaceCategory
@@ -159,4 +175,20 @@ QtLocation::Visibility QPlaceCategory::visibility() const
return d->visibility;
}
+/*!
+ Returns the category icon
+*/
+QPlaceIcon QPlaceCategory::icon() const
+{
+ return d->icon;
+}
+
+/*!
+ Sets the category icon
+*/
+void QPlaceCategory::setIcon(const QPlaceIcon &icon)
+{
+ d->icon = icon;
+}
+
QT_END_NAMESPACE
diff --git a/src/location/places/qplacecategory.h b/src/location/places/qplacecategory.h
index 4a2e88d2..048efa43 100644
--- a/src/location/places/qplacecategory.h
+++ b/src/location/places/qplacecategory.h
@@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Location)
+class QPlaceIcon;
+
class QPlaceCategoryPrivate;
class Q_LOCATION_EXPORT QPlaceCategory
{
@@ -71,12 +73,16 @@ public:
QString categoryId() const;
void setCategoryId(const QString &catID);
+
QString name() const;
void setName(const QString &name);
QtLocation::Visibility visibility() const;
void setVisibility(QtLocation::Visibility visibility);
+ QPlaceIcon icon() const;
+ void setIcon(const QPlaceIcon &icon);
+
private:
QSharedDataPointer<QPlaceCategoryPrivate> d;
};
diff --git a/src/location/places/qplacecategory_p.h b/src/location/places/qplacecategory_p.h
index b856435d..2d8d8a4a 100644
--- a/src/location/places/qplacecategory_p.h
+++ b/src/location/places/qplacecategory_p.h
@@ -46,6 +46,8 @@
#include <QtCore/QString>
#include <QtLocation/qtlocation.h>
+#include "qplaceicon.h"
+
QT_BEGIN_NAMESPACE
class QPlaceCategoryPrivate : public QSharedData
@@ -55,10 +57,14 @@ public:
QPlaceCategoryPrivate(const QPlaceCategoryPrivate &other);
~QPlaceCategoryPrivate();
+ QPlaceCategoryPrivate &operator= (const QPlaceCategoryPrivate &other);
+ bool operator==(const QPlaceCategoryPrivate &other) const;
+
QString categoryId;
QString name;
QtLocation::Visibility visibility;
+ QPlaceIcon icon;
};
QT_END_NAMESPACE
diff --git a/src/location/places/qplaceicon.cpp b/src/location/places/qplaceicon.cpp
new file mode 100644
index 00000000..392c661c
--- /dev/null
+++ b/src/location/places/qplaceicon.cpp
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplaceicon.h"
+#include "qplaceicon_p.h"
+#include "qplacemanager.h"
+
+QT_USE_NAMESPACE
+
+
+QPlaceIconPrivate::QPlaceIconPrivate()
+ : QSharedData(), manager(0)
+{
+}
+
+QPlaceIconPrivate::QPlaceIconPrivate(const QPlaceIconPrivate&other)
+ : QSharedData(other),
+ manager(other.manager),
+ baseUrl(other.baseUrl),
+ fullUrl(other.fullUrl)
+{
+}
+
+QPlaceIconPrivate::~QPlaceIconPrivate()
+{
+}
+
+QPlaceIconPrivate &QPlaceIconPrivate::operator=(const QPlaceIconPrivate &other)
+{
+ manager = other.manager;
+ baseUrl = other.baseUrl;
+ fullUrl = other.fullUrl;
+ return *this;
+}
+
+bool QPlaceIconPrivate::operator == (const QPlaceIconPrivate &other) const
+{
+ return manager == other.manager
+ && baseUrl == other.baseUrl
+ && fullUrl == other.fullUrl;
+}
+
+/*!
+ Constructs an icon.
+*/
+QPlaceIcon::QPlaceIcon()
+ : d(new QPlaceIconPrivate)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QPlaceIcon::QPlaceIcon(const QPlaceIcon &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Destroys the icon.
+*/
+QPlaceIcon::~QPlaceIcon()
+{
+}
+
+/*!
+ Assigns \a other to this icon and returns a reference to this icon.
+*/
+QPlaceIcon &QPlaceIcon::operator=(const QPlaceIcon &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Returns true if this icon is equal to \a other. Otherwise returns false.
+*/
+bool QPlaceIcon::operator==(const QPlaceIcon &other) const
+{
+ return *d == *(other.d);
+}
+
+/*!
+ Returns an icon url according to the given \a size and \a flags.
+ If a base url has been set by setBaseUrl(), the url to the image that best
+ fits the specified parameters is returned.
+
+ If a full url has been set by setUrl(), the full url is returned.
+
+ If no manager has been assigned to the icon a default constructed QUrl
+ is returned.
+*/
+QUrl QPlaceIcon::url(const QSize &size, QPlaceIcon::IconFlags flags) const
+{
+ if (!d->manager)
+ return QUrl();
+
+ if (!d->fullUrl.isEmpty())
+ return d->fullUrl;
+
+
+ return d->manager->constructIconUrl(*this, size, flags);
+}
+
+/*!
+ Sets a full URL of the resource that represents the image of this
+ icon. Because a full URL is being set, specifying different
+ sizes and flags into the url() function will have no effect.
+
+ When calling the setUrl() function, the base url is implictly
+ cleared.
+*/
+void QPlaceIcon::setFullUrl(const QUrl &url)
+{
+ d->fullUrl = url;
+ d->baseUrl.clear();
+}
+
+QUrl QPlaceIcon::fullUrl() const
+{
+ return d->fullUrl;
+}
+
+/*!
+ Returns a base url that the comlete icon url is based off.
+ E.g. the base url may be http://example.com/icon
+ When calling the url() function the base url may be used as a hint
+ to construct http://example.com/icon_32x32_selected.png
+*/
+QUrl QPlaceIcon::baseUrl() const
+{
+ return d->baseUrl;
+}
+
+/*!
+ Sets a base url that the complete icon url returned by url() is based off.
+
+ When calling setBaseUrl() function, the full url set by
+ setUrl() is implicitly cleared.
+*/
+void QPlaceIcon::setBaseUrl(const QUrl &url)
+{
+ d->baseUrl = url;
+ d->fullUrl.clear();
+}
+
+/*!
+ Returns the manager that this icon is associated with.
+*/
+QPlaceManager *QPlaceIcon::manager() const
+{
+ return d->manager;
+}
+
+/*!
+ Sets the \a manager that this icon is associated with.
+*/
+void QPlaceIcon::setManager(QPlaceManager *manager)
+{
+ d->manager = manager;
+}
+
+/*!
+ Returns a boolean indicating whether the all the fields of the icon are empty or not.
+*/
+bool QPlaceIcon::isEmpty() const
+{
+ return (d->baseUrl.isEmpty()
+ && d->fullUrl.isEmpty()
+ && d->manager == 0);
+}
diff --git a/src/location/places/qplaceicon.h b/src/location/places/qplaceicon.h
new file mode 100644
index 00000000..9b2e94ca
--- /dev/null
+++ b/src/location/places/qplaceicon.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLACEICON_H
+#define QPLACEICON_H
+
+
+#include <QtCore/QUrl>
+#include <QtCore/QFlags>
+#include <QtCore/QMetaType>
+#include <QtCore/QSize>
+#include <QtCore/QSharedDataPointer>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceManager;
+
+class QPlaceIconPrivate;
+class Q_LOCATION_EXPORT QPlaceIcon
+{
+public:
+ Q_ENUMS(QPlaceIcon::IconType)
+
+ enum IconFlag {
+ Normal = 0,
+ Disabled = 1,
+ Active = 2,
+ Selected = 4,
+
+ Map = 8,
+ List = 16
+ };
+
+ Q_DECLARE_FLAGS(IconFlags, IconFlag)
+
+ QPlaceIcon();
+ QPlaceIcon(const QPlaceIcon &other);
+
+ ~QPlaceIcon();
+
+ QPlaceIcon &operator=(const QPlaceIcon &other);
+ bool operator == (const QPlaceIcon &other) const;
+ bool operator != (const QPlaceIcon &other) const {
+ return !(*this == other);
+ }
+
+ QUrl url(const QSize &size = QSize(), IconFlags flags = 0) const;
+
+ void setFullUrl(const QUrl &url);
+ QUrl fullUrl() const;
+
+ QUrl baseUrl() const;
+ void setBaseUrl(const QUrl &url);
+
+ QPlaceManager *manager() const;
+ void setManager(QPlaceManager *manager);
+
+ bool isEmpty() const;
+
+private:
+ QSharedDataPointer<QPlaceIconPrivate> d;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QT_PREPEND_NAMESPACE(QPlaceIcon::IconFlags))
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/location/places/qplaceicon_p.h b/src/location/places/qplaceicon_p.h
new file mode 100644
index 00000000..9d129991
--- /dev/null
+++ b/src/location/places/qplaceicon_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLACEICON_P_H
+#define QPLACEICON_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 <QMap>
+#include <QUrl>
+#include <QSharedData>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceManager;
+class QPlaceIconPrivate: public QSharedData
+{
+public:
+ QPlaceIconPrivate();
+ QPlaceIconPrivate(const QPlaceIconPrivate &other);
+ ~QPlaceIconPrivate();
+
+ QPlaceIconPrivate &operator=(const QPlaceIconPrivate &other);
+ bool operator == (const QPlaceIconPrivate &other) const;
+
+ QPlaceManager *manager;
+ QUrl baseUrl;
+ QUrl fullUrl;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/location/places/qplacemanager.cpp b/src/location/places/qplacemanager.cpp
index 69aa3150..9dbc9e13 100644
--- a/src/location/places/qplacemanager.cpp
+++ b/src/location/places/qplacemanager.cpp
@@ -270,6 +270,14 @@ void QPlaceManager::setLocale(const QLocale &locale)
}
/*!
+ Constructs an icon url from a given \a icon, \a size and \a flags.
+*/
+QUrl QPlaceManager::constructIconUrl(const QPlaceIcon &icon, const QSize &size, QPlaceIcon::IconFlags flags)
+{
+ return d->constructIconUrl(icon, size, flags);
+}
+
+/*!
\fn void QPlaceManager::finished(QPlaceReply* reply)
This signal is emitted when \a reply has finished processing.
diff --git a/src/location/places/qplacemanager.h b/src/location/places/qplacemanager.h
index 2840a86b..13d1dffa 100644
--- a/src/location/places/qplacemanager.h
+++ b/src/location/places/qplacemanager.h
@@ -55,6 +55,7 @@
#include <QString>
#include <QObject>
#include <QAuthenticator>
+#include <QtLocation/QPlaceIcon>
QT_BEGIN_HEADER
@@ -111,6 +112,8 @@ public:
QLocale locale() const;
void setLocale(const QLocale &locale);
+ QUrl constructIconUrl(const QPlaceIcon &icon, const QSize &size, QPlaceIcon::IconFlags flags);
+
Q_SIGNALS:
void finished(QPlaceReply *reply);
void error(QPlaceReply *, QPlaceReply::Error error, const QString &errorString = QString());
diff --git a/src/location/places/qplacemanagerengine.cpp b/src/location/places/qplacemanagerengine.cpp
index 78f5d4d3..5574d283 100644
--- a/src/location/places/qplacemanagerengine.cpp
+++ b/src/location/places/qplacemanagerengine.cpp
@@ -130,6 +130,14 @@ int QPlaceManagerEngine::managerVersion() const
}
/*!
+ Returns the manager instance used to create this engine.
+*/
+QPlaceManager *QPlaceManagerEngine::manager() const
+{
+ return d_ptr->manager;
+}
+
+/*!
\fn void QPlaceManagerEngine::authenticationRequired(QAuthenticator *authenticator)
This signal is emitted if authentication details are required by the manager engine
@@ -141,7 +149,7 @@ int QPlaceManagerEngine::managerVersion() const
*/
QPlaceManagerEnginePrivate::QPlaceManagerEnginePrivate()
-: managerVersion(-1)
+ : managerVersion(-1), manager(0)
{
}
diff --git a/src/location/places/qplacemanagerengine.h b/src/location/places/qplacemanagerengine.h
index 251afb9c..49f3eeb3 100644
--- a/src/location/places/qplacemanagerengine.h
+++ b/src/location/places/qplacemanagerengine.h
@@ -88,6 +88,8 @@ public:
virtual QLocale locale() const = 0;
virtual void setLocale(const QLocale &locale) = 0;
+ virtual QUrl constructIconUrl(const QPlaceIcon &icon, const QSize &size, QPlaceIcon::IconFlags flags) = 0;
+
Q_SIGNALS:
void finished(QPlaceReply *reply);
void error(QPlaceReply *, QPlaceReply::Error error, QString errorString = QString());
@@ -101,6 +103,9 @@ Q_SIGNALS:
void categoryUpdated(const QPlaceCategory &category, const QString &parentCategoryId);
void categoryRemoved(const QString &categoryId, const QString &parentCategoryId);
+protected:
+ QPlaceManager *manager() const;
+
private:
void setManagerName(const QString &managerName);
void setManagerVersion(int managerVersion);
diff --git a/src/location/places/qplacemanagerengine_p.h b/src/location/places/qplacemanagerengine_p.h
index 719df151..5b0d140b 100644
--- a/src/location/places/qplacemanagerengine_p.h
+++ b/src/location/places/qplacemanagerengine_p.h
@@ -66,6 +66,7 @@ public:
QString managerName;
int managerVersion;
+ QPlaceManager *manager;
private:
Q_DISABLE_COPY(QPlaceManagerEnginePrivate)
diff --git a/src/location/places/qplacesupplier.cpp b/src/location/places/qplacesupplier.cpp
index c3500f48..24dbb60f 100644
--- a/src/location/places/qplacesupplier.cpp
+++ b/src/location/places/qplacesupplier.cpp
@@ -54,7 +54,7 @@ QPlaceSupplierPrivate::QPlaceSupplierPrivate(const QPlaceSupplierPrivate &other)
this->name = other.name;
this->supplierId = other.supplierId;
this->url = other.url;
- this->supplierIconUrl = other.supplierIconUrl;
+ this->icon = other.icon;
}
QPlaceSupplierPrivate::~QPlaceSupplierPrivate()
@@ -67,7 +67,7 @@ bool QPlaceSupplierPrivate::operator==(const QPlaceSupplierPrivate &other) const
this->name == other.name
&& this->supplierId == other.supplierId
&& this->url == other.url
- && this->supplierIconUrl == other.supplierIconUrl
+ && this->icon == other.icon
);
}
@@ -165,17 +165,17 @@ void QPlaceSupplier::setUrl(const QUrl &url)
}
/*!
- Returns the supplier's icon URL.
+ Returns the supplier icon
*/
-QUrl QPlaceSupplier::supplierIconUrl() const
+QPlaceIcon QPlaceSupplier::icon() const
{
- return d->supplierIconUrl;
+ return d->icon;
}
/*!
- Sets \a url of the icon of the supplier.
+ Sets the supplier icon
*/
-void QPlaceSupplier::setSupplierIconUrl(const QUrl &url)
+void QPlaceSupplier::setIcon(const QPlaceIcon &icon)
{
- d->supplierIconUrl = url;
+ d->icon = icon;
}
diff --git a/src/location/places/qplacesupplier.h b/src/location/places/qplacesupplier.h
index d1d5b30e..c3cbdce6 100644
--- a/src/location/places/qplacesupplier.h
+++ b/src/location/places/qplacesupplier.h
@@ -43,6 +43,7 @@
#define QPLACESUPPLIER_H
#include <QSharedDataPointer>
+#include <QtLocation/QPlaceIcon>
QT_BEGIN_HEADER
@@ -69,12 +70,15 @@ public:
QString name() const;
void setName(const QString &data);
+
QString supplierId() const;
void setSupplierId(const QString &data);
+
QUrl url() const;
void setUrl(const QUrl &data);
- QUrl supplierIconUrl() const;
- void setSupplierIconUrl(const QUrl &data);
+
+ QPlaceIcon icon() const;
+ void setIcon(const QPlaceIcon &icon);
private:
QSharedDataPointer<QPlaceSupplierPrivate> d;
diff --git a/src/location/places/qplacesupplier_p.h b/src/location/places/qplacesupplier_p.h
index c8cf9e4e..7015ae0e 100644
--- a/src/location/places/qplacesupplier_p.h
+++ b/src/location/places/qplacesupplier_p.h
@@ -46,6 +46,8 @@
#include <QSharedData>
#include <QUrl>
+#include "qplaceicon.h"
+
QT_BEGIN_NAMESPACE
class QPlaceSupplierPrivate : public QSharedData
@@ -61,7 +63,7 @@ public:
QString name;
QString supplierId;
QUrl url;
- QUrl supplierIconUrl;
+ QPlaceIcon icon;
};
QT_END_NAMESPACE
diff --git a/src/location/qplace.cpp b/src/location/qplace.cpp
index b0ed80a5..825fb1f8 100644
--- a/src/location/qplace.cpp
+++ b/src/location/qplace.cpp
@@ -310,6 +310,24 @@ void QPlace::setAttribution(const QString &attribution)
}
/*!
+ Returns the icon of the place.
+*/
+QPlaceIcon QPlace::icon() const
+{
+ Q_D(const QPlace);
+ return d->icon;
+}
+
+/*!
+ Sets the icon of the place.
+*/
+void QPlace::setIcon(const QPlaceIcon &icon)
+{
+ Q_D(QPlace);
+ d->icon = icon;
+}
+
+/*!
Returns the primary phone number for this place.
*/
QString QPlace::primaryPhone() const
diff --git a/src/location/qplace.h b/src/location/qplace.h
index 6098c320..3f33ca06 100644
--- a/src/location/qplace.h
+++ b/src/location/qplace.h
@@ -62,6 +62,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Location)
class QString;
+class QPlaceIcon;
class QPlacePrivate;
class Q_LOCATION_EXPORT QPlace
@@ -90,6 +91,9 @@ public:
QString attribution() const;
void setAttribution(const QString &attribution);
+ QPlaceIcon icon() const;
+ void setIcon(const QPlaceIcon &icon);
+
QPlaceContent::Collection content(QPlaceContent::Type type) const;
void setContent(QPlaceContent::Type type, const QPlaceContent::Collection &content);
void insertContent(QPlaceContent::Type type, const QPlaceContent::Collection &content);
diff --git a/src/location/qplace_p.h b/src/location/qplace_p.h
index fba03329..00d57a67 100644
--- a/src/location/qplace_p.h
+++ b/src/location/qplace_p.h
@@ -61,6 +61,7 @@
#include "qgeoboundingbox.h"
#include "qgeocoordinate.h"
#include "qplacesupplier.h"
+#include <QtLocation/QPlaceIcon>
QT_BEGIN_NAMESPACE
@@ -94,7 +95,7 @@ public:
QPlace::ExtendedAttributes extendedAttributes;
QtLocation::Visibility visibility;
-
+ QPlaceIcon icon;
bool detailsFetched;
};
diff --git a/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp b/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp
index 24d705d8..7a008ad5 100644
--- a/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp
@@ -58,16 +58,16 @@ QT_USE_NAMESPACE
Constructor.
*/
QPlaceContentReplyImpl::QPlaceContentReplyImpl(QPlaceContent::Type type, QPlaceRestReply *reply,
- QObject *parent)
+ QPlaceManager *manager, QObject *parent)
: QPlaceContentReply(parent), restReply(reply), contentType(type), startNumber(0)
{
if (contentType == QPlaceContent::ImageType)
parser = new QPlaceJSonMediaParser(this);
else if (contentType == QPlaceContent::ReviewType)
- parser = new QPlaceJSonReviewParser(this);
+ parser = new QPlaceJSonReviewParser(manager, this);
else if (contentType == QPlaceContent::EditorialType)
- parser = new QPlaceJSonDetailsParser(this);
+ parser = new QPlaceJSonDetailsParser(manager, this);
else
parser = 0;
diff --git a/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h b/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h
index 5f140aaf..d34bdcf1 100644
--- a/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h
+++ b/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h
@@ -64,7 +64,8 @@ class QPlaceContentReplyImpl : public QPlaceContentReply
{
Q_OBJECT
public:
- QPlaceContentReplyImpl(QPlaceContent::Type type, QPlaceRestReply *reply, QObject *parent = 0);
+ QPlaceContentReplyImpl(QPlaceContent::Type type, QPlaceRestReply *reply,
+ QPlaceManager *manager, QObject *parent = 0);
~QPlaceContentReplyImpl();
void abort();
void setStartNumber(int number);
diff --git a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp b/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp
index 52eaa5d6..00f49324 100644
--- a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp
@@ -57,11 +57,11 @@ QT_USE_NAMESPACE
/*!
Constructor.
*/
-QPlaceDetailsReplyImpl::QPlaceDetailsReplyImpl(QPlaceRestReply *reply, QObject *parent) :
+QPlaceDetailsReplyImpl::QPlaceDetailsReplyImpl(QPlaceRestReply *reply, QPlaceManager *manager, QObject *parent) :
QPlaceDetailsReply(parent),
restReply(reply)
{
- parser = new QPlaceJSonDetailsParser(this);
+ parser = new QPlaceJSonDetailsParser(manager, this);
if (restReply) {
restReply->setParent(this);
diff --git a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.h b/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.h
index 94db02a8..d1787990 100644
--- a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.h
+++ b/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.h
@@ -55,6 +55,7 @@
#include <qplacedetailsreply.h>
#include "qplacerestreply.h"
#include "qplacejsondetailsparser.h"
+#include <QtLocation/QPlaceManager>
QT_BEGIN_NAMESPACE
@@ -62,7 +63,7 @@ class QPlaceDetailsReplyImpl : public QPlaceDetailsReply
{
Q_OBJECT
public:
- explicit QPlaceDetailsReplyImpl(QPlaceRestReply *reply, QObject *parent = 0);
+ QPlaceDetailsReplyImpl(QPlaceRestReply *reply, QPlaceManager *manager, QObject *parent = 0);
~QPlaceDetailsReplyImpl();
void abort();
diff --git a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp b/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp
index 0c04c3dd..a0e2f7ce 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp
@@ -185,8 +185,8 @@ static const char *place_premiumcontent_content_sunday = "SUN";
QT_USE_NAMESPACE
-QPlaceJSonDetailsParser::QPlaceJSonDetailsParser(QObject *parent) :
- QPlaceJSonParser(parent)
+QPlaceJSonDetailsParser::QPlaceJSonDetailsParser(QPlaceManager *manager, QObject *parent) :
+ QPlaceJSonParser(parent), m_manager(manager)
{
}
@@ -194,12 +194,19 @@ QPlaceJSonDetailsParser::~QPlaceJSonDetailsParser()
{
}
-QPlace QPlaceJSonDetailsParser::buildPlace(const QScriptValue &placeValue)
+QPlace QPlaceJSonDetailsParser::buildPlace(const QScriptValue &placeValue, QPlaceManager *manager)
{
QPlace newPlace;
if (placeValue.isValid()) {
buildPlace(placeValue, &newPlace);
}
+
+ if (!newPlace.icon().baseUrl().isEmpty() || !newPlace.icon().fullUrl().isEmpty()) {
+ QPlaceIcon icon = newPlace.icon();
+ icon.setManager(manager);
+ newPlace.setIcon(icon);
+ }
+
return newPlace;
}
@@ -213,7 +220,7 @@ void QPlaceJSonDetailsParser::processJSonData(const QScriptValue &sv)
if (sv.isValid()) {
QScriptValue placeProperty = sv.property(place_place_element);
if (placeProperty.isValid()) {
- buildPlace(placeProperty, &place);
+ place = buildPlace(placeProperty, m_manager);
emit finished(NoError, QString());
} else {
emit finished(ParsingError, QString("JSON data are invalid"));
@@ -278,7 +285,10 @@ void QPlaceJSonDetailsParser::processMainProvider(const QScriptValue &placeValue
}
value = placeValue.property(place_provider_url);
if (value.isValid() && !value.toString().isEmpty()){
- sup.setSupplierIconUrl(value.toString());
+ QPlaceIcon icon;
+ icon.setBaseUrl(value.toString());
+ //Note: the icon manager is set in QPlaceJSonDetailsParser::buildPlace()
+ sup.setIcon(icon);
}
targetPlace->setSupplier(QPlaceSuppliersRepository::instance()->addSupplier(sup));
@@ -584,7 +594,13 @@ void QPlaceJSonDetailsParser::processPremiumContent(const QScriptValue &content,
if (!name.isEmpty() || !id.isEmpty()) {
supplier.setName(name);
supplier.setSupplierId(id);
- supplier.setSupplierIconUrl(iconUrl);
+ if (!iconUrl.isEmpty()) {
+ QPlaceIcon icon;
+ icon.setBaseUrl(iconUrl);
+ //note: the icon manager is set in QPlaceJSonDetailsParser::buildPlace()
+ supplier.setIcon(icon);
+ }
+
supplier = QPlaceSuppliersRepository::instance()->addSupplier(supplier);
}
processPremiumContentDescription(content, supplier, targetPlace);
diff --git a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.h b/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.h
index 9dd1037b..6a1c15eb 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.h
+++ b/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.h
@@ -66,10 +66,10 @@ class QPlaceJSonDetailsParser : public QPlaceJSonParser
{
Q_OBJECT
public:
- explicit QPlaceJSonDetailsParser(QObject *parent = 0);
+ explicit QPlaceJSonDetailsParser(QPlaceManager *manager, QObject *parent = 0);
virtual ~QPlaceJSonDetailsParser();
- static QPlace buildPlace(const QScriptValue &place);
+ static QPlace buildPlace(const QScriptValue &place, QPlaceManager *manager);
QPlace result();
private:
@@ -113,6 +113,7 @@ private:
private:
QPlace place;
+ QPlaceManager *m_manager;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp b/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp
index 489778af..8973d555 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp
@@ -66,8 +66,8 @@ static const char *recommendations_place_element = "place";
QT_USE_NAMESPACE
-QPlaceJSonRecommendationParser::QPlaceJSonRecommendationParser(QObject *parent) :
- QPlaceJSonParser(parent)
+QPlaceJSonRecommendationParser::QPlaceJSonRecommendationParser(QPlaceManager *manager, QObject *parent) :
+ QPlaceJSonParser(parent), m_manager(manager)
{
}
@@ -118,7 +118,7 @@ void QPlaceJSonRecommendationParser::processResultElement(const QScriptValue &va
}
QScriptValue place = value.property(recommendations_place_element);
if (place.isValid()) {
- QPlace newPlace = QPlaceJSonDetailsParser::buildPlace(place);
+ QPlace newPlace = QPlaceJSonDetailsParser::buildPlace(place, m_manager);
result.setPlace(newPlace);
searchResults.append(result);
}
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.h b/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.h
index a9a224a7..39c711a3 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.h
+++ b/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.h
@@ -60,11 +60,13 @@ class QScriptValue;
QT_BEGIN_NAMESPACE
+class QPlaceManager;
+
class QPlaceJSonRecommendationParser : public QPlaceJSonParser
{
Q_OBJECT
public:
- explicit QPlaceJSonRecommendationParser(QObject *parent = 0);
+ explicit QPlaceJSonRecommendationParser(QPlaceManager *manager, QObject *parent = 0);
virtual ~QPlaceJSonRecommendationParser();
QList<QPlaceSearchResult> results();
@@ -75,6 +77,7 @@ private:
private:
QList<QPlaceSearchResult> searchResults;
+ QPlaceManager *m_manager;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp b/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp
index dcb3457f..a0bf281f 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp
@@ -53,6 +53,8 @@
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptValue>
#include <QtScript/QScriptValueIterator>
+#include <QtLocation/QPlaceIcon>
+#include <QtLocation/QPlaceManager>
#include <qplacereview.h>
#include <qplacesupplier.h>
@@ -81,9 +83,9 @@ static const char *review_vendoricon_element = "vendorIconUrl";
QT_USE_NAMESPACE
-QPlaceJSonReviewParser::QPlaceJSonReviewParser(QObject *parent) :
+QPlaceJSonReviewParser::QPlaceJSonReviewParser(QPlaceManager *manager, QObject *parent) :
QPlaceJSonParser(parent),
- allReviews(0)
+ allReviews(0),m_manager(manager)
{
}
@@ -101,7 +103,7 @@ int QPlaceJSonReviewParser::allReviewsCount()
return allReviews;
}
-QPlaceReview QPlaceJSonReviewParser::buildReview(const QScriptValue &review)
+QPlaceReview QPlaceJSonReviewParser::buildReview(const QScriptValue &review, QPlaceManager *manager)
{
QPlaceReview newReview;
QScriptValue value = review.property(review_id_element);
@@ -150,7 +152,12 @@ QPlaceReview QPlaceJSonReviewParser::buildReview(const QScriptValue &review)
QPlaceSupplier sup;
sup.setName(name);
sup.setSupplierId(id);
- sup.setSupplierIconUrl(QUrl::fromEncoded(icon.toAscii()));
+ if (!icon.toAscii().isEmpty()) {
+ QPlaceIcon supplierIcon;
+ supplierIcon.setBaseUrl(QUrl::fromEncoded(icon.toAscii()));
+ supplierIcon.setManager(manager);
+ sup.setIcon(supplierIcon);
+ }
newReview.setSupplier(QPlaceSuppliersRepository::instance()->addSupplier(sup));
}
@@ -192,11 +199,11 @@ void QPlaceJSonReviewParser::processReviews(const QScriptValue &reviewsElement)
it.next();
// array contains count as last element
if (it.name() != "length") {
- reviews.append(buildReview(it.value()));
+ reviews.append(buildReview(it.value(), m_manager));
}
}
} else {
- reviews.append(buildReview(value));
+ reviews.append(buildReview(value, m_manager));
}
}
value = reviewsElement.property(review_count);
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.h b/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.h
index 183545b6..78991be5 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.h
+++ b/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.h
@@ -59,17 +59,18 @@ class QScriptEngine;
class QScriptValue;
QT_BEGIN_NAMESPACE
+class QPlaceManager;
class QPlaceJSonReviewParser : public QPlaceJSonParser
{
Q_OBJECT
public:
- explicit QPlaceJSonReviewParser(QObject *parent = 0);
+ explicit QPlaceJSonReviewParser(QPlaceManager *manager, QObject *parent = 0);
virtual ~QPlaceJSonReviewParser();
QList<QPlaceReview> results();
int allReviewsCount();
- static QPlaceReview buildReview(const QScriptValue &place);
+ static QPlaceReview buildReview(const QScriptValue &place, QPlaceManager *manager);
private:
void processJSonData(const QScriptValue &sv);
@@ -78,6 +79,7 @@ private:
private:
QList<QPlaceReview> reviews;
int allReviews;
+ QPlaceManager *m_manager;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.cpp b/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.cpp
index 546cf3eb..a2ec8a3f 100644
--- a/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.cpp
@@ -57,11 +57,11 @@ QT_USE_NAMESPACE
/*!
Constructor.
*/
-QPlaceRecommendationReplyImpl::QPlaceRecommendationReplyImpl(QPlaceRestReply *reply, QObject *parent) :
+QPlaceRecommendationReplyImpl::QPlaceRecommendationReplyImpl(QPlaceRestReply *reply, QPlaceManager * manager, QObject *parent) :
QPlaceSearchReply(parent),
restReply(reply)
{
- parser = new QPlaceJSonRecommendationParser(this);
+ parser = new QPlaceJSonRecommendationParser(manager, this);
if (restReply) {
restReply->setParent(this);
diff --git a/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.h b/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.h
index 69f0d47f..de4bd68f 100644
--- a/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.h
+++ b/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.h
@@ -62,7 +62,7 @@ class QPlaceRecommendationReplyImpl : public QPlaceSearchReply
{
Q_OBJECT
public:
- explicit QPlaceRecommendationReplyImpl(QPlaceRestReply *reply, QObject *parent = 0);
+ QPlaceRecommendationReplyImpl(QPlaceRestReply *reply, QPlaceManager *manager, QObject *parent = 0);
~QPlaceRecommendationReplyImpl();
void abort();
diff --git a/src/plugins/geoservices/nokia/places/qplacesuppliersrepository.cpp b/src/plugins/geoservices/nokia/places/qplacesuppliersrepository.cpp
index 1f4ac22b..a2eada93 100644
--- a/src/plugins/geoservices/nokia/places/qplacesuppliersrepository.cpp
+++ b/src/plugins/geoservices/nokia/places/qplacesuppliersrepository.cpp
@@ -92,16 +92,15 @@ QPlaceSupplier QPlaceSuppliersRepository::addSupplier(const QPlaceSupplier &src)
void QPlaceSuppliersRepository::copyMissingData(const QPlaceSupplier &src,
QPlaceSupplier &target)
{
- if (target.name().isEmpty() && !src.name().isEmpty()) {
+ if (target.name().isEmpty() && !src.name().isEmpty())
target.setName(src.name());
- }
- if (target.supplierId().isEmpty() && !src.supplierId().isEmpty()) {
+
+ if (target.supplierId().isEmpty() && !src.supplierId().isEmpty())
target.setSupplierId(src.supplierId());
- }
- if (target.url().isEmpty() && !src.url().isEmpty()) {
+
+ if (target.url().isEmpty() && !src.url().isEmpty())
target.setUrl(src.url());
- }
- if (target.supplierIconUrl().isEmpty() && !src.supplierIconUrl().isEmpty()) {
- target.setSupplierIconUrl(src.supplierIconUrl());
- }
+
+ if (target.icon().isEmpty() && !src.icon().isEmpty())
+ target.setIcon(src.icon());
}
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
index b6dad2dd..a1b14bba 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
@@ -100,7 +100,7 @@ QPlaceDetailsReply *QPlaceManagerEngineNokia::getPlaceDetails(const QString &pla
QPlaceDetailsReplyImpl *reply = NULL;
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceRequest(placeId);
if (restReply) {
- reply = new QPlaceDetailsReplyImpl(restReply, this);
+ reply = new QPlaceDetailsReplyImpl(restReply, manager(), this);
connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
@@ -116,7 +116,7 @@ QPlaceContentReply *QPlaceManagerEngineNokia::getContent(const QPlace &place, co
case QPlaceContent::ImageType: {
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceImagesRequest(place.placeId(),
request);
- reply = new QPlaceContentReplyImpl(request.contentType(), restReply, this);
+ reply = new QPlaceContentReplyImpl(request.contentType(), restReply, manager(), this);
if (!restReply)
QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
@@ -127,7 +127,7 @@ QPlaceContentReply *QPlaceManagerEngineNokia::getContent(const QPlace &place, co
case QPlaceContent::ReviewType: {
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceReviewRequest(place.placeId(),
request);
- reply = new QPlaceContentReplyImpl(request.contentType(), restReply, this);
+ reply = new QPlaceContentReplyImpl(request.contentType(), restReply, manager(), this);
if (!restReply)
QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
@@ -139,7 +139,7 @@ QPlaceContentReply *QPlaceManagerEngineNokia::getContent(const QPlace &place, co
QPlaceRestReply *restReply =
QPlaceRestManager::instance()->sendPlaceRequest(place.placeId());
- reply = new QPlaceContentReplyImpl(request.contentType(), restReply, this);
+ reply = new QPlaceContentReplyImpl(request.contentType(), restReply, manager(), this);
if (!restReply) {
QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
@@ -150,7 +150,7 @@ QPlaceContentReply *QPlaceManagerEngineNokia::getContent(const QPlace &place, co
break;
}
default: {
- reply = new QPlaceContentReplyImpl(request.contentType(), 0, this);
+ reply = new QPlaceContentReplyImpl(request.contentType(), 0, manager(), this);
QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError),
Q_ARG(QString, QString("Retrieval of given content type not supported")));
@@ -207,7 +207,7 @@ QPlaceSearchReply *QPlaceManagerEngineNokia::recommendations(const QPlace &place
newQuery.setSearchTerm(place.placeId());
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendRecommendationRequest(newQuery, QString());
if (restReply) {
- reply = new QPlaceRecommendationReplyImpl(restReply, this);
+ reply = new QPlaceRecommendationReplyImpl(restReply, manager(), this);
connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
@@ -301,6 +301,14 @@ void QPlaceManagerEngineNokia::setLocale(const QLocale &locale)
QPlaceRestManager::instance()->setLocale(locale);
}
+QUrl QPlaceManagerEngineNokia::constructIconUrl(const QPlaceIcon &icon, const QSize &size, QPlaceIcon::IconFlags flags)
+{
+ Q_UNUSED(icon)
+ Q_UNUSED(size)
+ Q_UNUSED(flags)
+ return QUrl();
+}
+
void QPlaceManagerEngineNokia::processingError(QPlaceReply *reply,
const QPlaceReply::Error &errorId,
const QString &errorMessage)
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
index 676d2ee2..d88bee9c 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
@@ -90,6 +90,8 @@ public:
QLocale locale() const;
void setLocale(const QLocale &locale);
+ QUrl constructIconUrl(const QPlaceIcon &icon, const QSize &size, QPlaceIcon::IconFlags flags);
+
private slots:
void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage);
void processingFinished(QPlaceReply *reply);
diff --git a/src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.cpp b/src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.cpp
index 808843e6..f65e8e76 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.cpp
+++ b/src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.cpp
@@ -126,15 +126,21 @@ QVariant JsonDbHandler::convertToJsonVariant(const QPlace &place)
map.insert(COORDINATE, coordMap);
map.insert(ADDRESS, addressMap);
+ map.insert(ICON_URL, place.icon().fullUrl().toString());
+
return map;
}
QVariant JsonDbHandler::convertToJsonVariant(const QPlaceCategory &category, bool isTopLevel)
{
QVariantMap map;
+ if (!category.categoryId().isEmpty())
+ map.insert(UUID, category.categoryId());
+
map.insert(TYPE, PLACE_CATEGORY_TYPE);
map.insert(DISPLAY_NAME, category.name());
map.insert(TOP_LEVEL_CATEGORY, isTopLevel);
+ map.insert(ICON_URL, category.icon().fullUrl().toString());
return map;
}
@@ -211,6 +217,13 @@ QPlace JsonDbHandler::convertJsonVariantToPlace(const QVariant &variant)
place.setLocation(location);
+ if (placeJson.keys().contains(ICON_URL) && !placeJson.value(ICON_URL).toString().isEmpty()) {
+ QPlaceIcon icon;
+ icon.setFullUrl(QUrl(placeJson.value(ICON_URL).toUrl()));
+ icon.setManager(m_engine->manager());
+ place.setIcon(icon);
+ }
+
return place;
}
@@ -220,6 +233,14 @@ QPlaceCategory JsonDbHandler::convertJsonVariantToCategory(const QVariant &varia
QPlaceCategory category;
category.setName(categoryMap.value(DISPLAY_NAME).toString());
category.setCategoryId(categoryMap.value(UUID).toString());
+
+ if (categoryMap.keys().contains(ICON_URL) && !categoryMap.value(ICON_URL).toString().isEmpty()) {
+ QPlaceIcon icon;
+ icon.setFullUrl(QUrl(categoryMap.value(ICON_URL).toUrl()));
+ icon.setManager(m_engine->manager());
+ category.setIcon(icon);
+ }
+
return category;
}
diff --git a/src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.h b/src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.h
index f0d459a1..cf22f2a0 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.h
+++ b/src/plugins/geoservices/nokia_places_jsondb/jsondbhandler.h
@@ -73,6 +73,8 @@
#define COUNTY "county"
#define COUNTRY "country"
+#define ICON_URL "iconUrl"
+
Q_ADDON_JSONDB_BEGIN_NAMESPACE
class JsonDbClient;
Q_ADDON_JSONDB_END_NAMESPACE
@@ -86,7 +88,7 @@ class QPlaceCategory;
class JsonDbHandler : public QObject
{
Q_OBJECT
-#include <QVariant>
+
public:
JsonDbHandler(QPlaceManagerEngineJsonDb *manager);
@@ -102,10 +104,10 @@ public:
static QVariant convertToJsonVariant(const QPlaceCategory &category, bool isTopLevel);
static QString convertToQueryString(const QPlaceSearchRequest &query);
- static QList<QPlace> convertJsonResponseToPlaces(const QVariant &response);
- static QList<QPlaceCategory> convertJsonResponseToCategories(const QVariant &response);
- static QPlace convertJsonVariantToPlace(const QVariant &variant);
- static QPlaceCategory convertJsonVariantToCategory(const QVariant &variant);
+ QList<QPlace> convertJsonResponseToPlaces(const QVariant &response);
+ QList<QPlaceCategory> convertJsonResponseToCategories(const QVariant &response);
+ QPlace convertJsonVariantToPlace(const QVariant &variant);
+ QPlaceCategory convertJsonVariantToCategory(const QVariant &variant);
bool isConnected();
diff --git a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp
index fd51ca58..0eb65eeb 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp
+++ b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp
@@ -230,8 +230,7 @@ QPlaceIdReply *QPlaceManagerEngineJsonDb::saveCategory(const QPlaceCategory &cat
if (!isUpdate) {
reqId = m_jsonDbHandler.write(JsonDbHandler::convertToJsonVariant(category, isTopLevel));
} else {
- categoryMap.insert(DISPLAY_NAME, category.name());
- reqId = m_jsonDbHandler.update(categoryMap);
+ reqId = m_jsonDbHandler.update(JsonDbHandler::convertToJsonVariant(category, isTopLevel));
saveReply->setIsUpdate();
}
@@ -359,7 +358,7 @@ QList<QPlaceCategory> QPlaceManagerEngineJsonDb::childCategories(const QString &
}
QVariantMap responseMap = m_jsonDbHandler.waitForRequest(reqId);
- return JsonDbHandler::convertJsonResponseToCategories(responseMap);
+ return m_jsonDbHandler.convertJsonResponseToCategories(responseMap);
}
QLocale QPlaceManagerEngineJsonDb::locale() const
@@ -372,6 +371,11 @@ void QPlaceManagerEngineJsonDb::setLocale(const QLocale &locale)
Q_UNUSED(locale);
}
+QUrl QPlaceManagerEngineJsonDb::constructIconUrl(const QPlaceIcon &icon, const QSize &size, QPlaceIcon::IconFlags flags)
+{
+ return icon.fullUrl();
+}
+
void QPlaceManagerEngineJsonDb::processJsonDbResponse(int id, const QVariant &data)
{
QPlaceReply *reply = m_idReplyMap.value(id,0);
@@ -472,7 +476,7 @@ void QPlaceManagerEngineJsonDb::processJsonDbResponse(int id, const QVariant &da
}
case QPlaceReply::SearchReply: {
SearchReply *searchReply = qobject_cast<SearchReply *>(reply);
- QList<QPlace> places = JsonDbHandler::convertJsonResponseToPlaces(data);
+ QList<QPlace> places = m_jsonDbHandler.convertJsonResponseToPlaces(data);
QList<QPlaceSearchResult> results;
QPlaceSearchResult result;
result.setType(QPlaceSearchResult::PlaceResult);
@@ -561,7 +565,7 @@ void QPlaceManagerEngineJsonDb::processJsonDbResponse(int id, const QVariant &da
detailsReply->triggerDone(QPlaceReply::PlaceDoesNotExistError,
tr("Specified place does not exist"));
} else {
- QList<QPlace> places = JsonDbHandler::convertJsonResponseToPlaces(data);
+ QList<QPlace> places = m_jsonDbHandler.convertJsonResponseToPlaces(data);
Q_ASSERT(!places.isEmpty());
detailsReply->setPlace(places.first());
detailsReply->triggerDone();
diff --git a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h
index 01b26f1f..37dc3b74 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h
+++ b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h
@@ -83,6 +83,7 @@ public:
QLocale locale() const;
void setLocale(const QLocale &locale);
+ QUrl constructIconUrl(const QPlaceIcon &icon, const QSize &size, QPlaceIcon::IconFlags flags);
public slots:
void processJsonDbResponse(int id, const QVariant &data);
void processJsonDbError(int id, int code, const QString &data);
diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h
index 9a0e07ee..deb89a3c 100644
--- a/tests/auto/geotestplugin/qplacemanagerengine_test.h
+++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h
@@ -258,6 +258,14 @@ public:
m_locale = locale;
}
+ QUrl constructIconUrl(const QPlaceIcon &icon, const QSize &size, QPlaceIcon::IconFlags flags) {
+ Q_UNUSED(icon)
+ Q_UNUSED(size)
+ Q_UNUSED(flags)
+
+ return QUrl();
+ }
+
private:
QLocale m_locale;
QMap<QString, QPlace> m_places;
diff --git a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
index c86ec7cf..994fa32c 100644
--- a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
+++ b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
@@ -110,6 +110,7 @@ private Q_SLOTS:
void searchByCircle();
void searchWithLexicalPlaceNameHint();
void searchWithDistanceHint();
+ void icons();
void unsupportedFunctions();
private:
@@ -963,6 +964,58 @@ void tst_QPlaceManagerJsonDb::searchWithDistanceHint()
}
+void tst_QPlaceManagerJsonDb::icons()
+{
+ QPlaceIcon icon;
+ icon.setManager(placeManager);
+ icon.setFullUrl(QUrl(QLatin1String("/icons/placeicon.jpg")));
+
+ //check that we can get the url from the icon
+ QCOMPARE(icon.url(), QUrl(QLatin1String("/icons/placeicon.jpg")));
+
+ //check that we can save and retrieve a place with the icon
+ //intact.
+ QPlace place;
+ place.setIcon(icon);
+ QString placeId;
+ QVERIFY(doSavePlace(place,QPlaceReply::NoError, &placeId));
+
+ QPlace retrievedPlace;
+ QVERIFY(doFetchDetails(placeId, &retrievedPlace));
+ QCOMPARE(retrievedPlace.icon().url(), QUrl(QLatin1String("/icons/placeicon.jpg")));
+
+ QPlaceIcon categoryIcon;
+ categoryIcon.setManager(placeManager);
+ categoryIcon.setFullUrl(QUrl(QLatin1String("/icons/motel.jpg")));
+
+ QPlaceCategory motel;
+ motel.setIcon(categoryIcon);
+ QString categoryId;
+ QVERIFY(doSaveCategory(motel, "", QPlaceReply::NoError, &categoryId));
+ motel.setCategoryId(categoryId);
+
+ QList<QPlaceCategory> categories = placeManager->childCategories();
+ QCOMPARE(categories.count(), 1);
+ QCOMPARE(categories.at(0).icon().url(), QUrl(QLatin1String("/icons/motel.jpg")));
+
+ //test modification of an icon of an existin category
+ categoryIcon.setFullUrl(QUrl(QLatin1String("/icons/motel2.jpg")));
+ motel.setIcon(categoryIcon);
+ QVERIFY(doSaveCategory(motel, "", QPlaceReply::NoError, &categoryId));
+
+ categories = placeManager->childCategories();
+ QCOMPARE(categories.count(), 1);
+ QCOMPARE(categories.at(0).icon().url(), QUrl(QLatin1String("/icons/motel2.jpg")));
+
+ //try saving an empty icon to the category
+ motel.setIcon(QPlaceIcon());
+ QVERIFY(doSaveCategory(motel, "", QPlaceReply::NoError, &categoryId));
+ categories = placeManager->childCategories();
+ QCOMPARE(categories.count(), 1);
+ QCOMPARE(categories.at(0).icon().url(), QUrl());
+ QVERIFY(categories.at(0).icon().isEmpty());
+}
+
void tst_QPlaceManagerJsonDb::unsupportedFunctions()
{
QPlace place;
diff --git a/tests/auto/qplacesupplier/tst_qplacesupplier.cpp b/tests/auto/qplacesupplier/tst_qplacesupplier.cpp
index 296cf6e6..cf759264 100644
--- a/tests/auto/qplacesupplier/tst_qplacesupplier.cpp
+++ b/tests/auto/qplacesupplier/tst_qplacesupplier.cpp
@@ -58,7 +58,7 @@ private Q_SLOTS:
void nameTest();
void supplierIdTest();
void urlTest();
- void supplierIconUrlTest();
+ void iconTest();
void operatorsTest();
};
@@ -102,24 +102,34 @@ void tst_QPlaceSupplier::urlTest()
QVERIFY2(testObj.url() == testUrl, "Wrong value returned");
}
-void tst_QPlaceSupplier::supplierIconUrlTest()
+void tst_QPlaceSupplier::iconTest()
{
QPlaceSupplier testObj;
- const QUrl testUrl = QUrl::fromEncoded("http://example.com/testUrl");
- QVERIFY2(testObj.supplierIconUrl() == QString(), "Wrong default value");
- testObj.setSupplierIconUrl(testUrl);
- QVERIFY2(testObj.supplierIconUrl() == testUrl, "Wrong value returned");
+ QVERIFY(testObj.icon().isEmpty());
+ QPlaceIcon icon;
+ icon.setFullUrl(QUrl::fromEncoded("http://example.com/icon.png"));
+ testObj.setIcon(icon);
+ QCOMPARE(testObj.icon(), icon);
+ QCOMPARE(testObj.icon().fullUrl(), QUrl::fromEncoded("http://example.com/icon.png"));
+
+ testObj.setIcon(QPlaceIcon());
+ QVERIFY(testObj.icon().isEmpty());
+ QCOMPARE(testObj.icon().fullUrl(), QUrl());
}
void tst_QPlaceSupplier::operatorsTest()
{
QPlaceSupplier testObj;
- const QUrl testUrl = QUrl::fromEncoded("http://example.com/testUrl");
- testObj.setSupplierIconUrl(testUrl);
+ testObj.setName(QLatin1String("Acme"));
+ QPlaceIcon icon;
+ icon.setFullUrl(QUrl::fromEncoded("http://example.com/testUrl"));
+ testObj.setIcon(icon);
+ testObj.setSupplierId(QLatin1String("34292"));
+
QPlaceSupplier testObj2;
testObj2 = testObj;
QVERIFY2(testObj == testObj2, "Not copied correctly");
- testObj2.setSupplierId("testValue2");
+ testObj2.setSupplierId(QLatin1String("testValue2"));
QVERIFY2(testObj != testObj2, "Object should be different");
}