summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorabcd <qt-info@nokia.com>2011-10-17 19:02:16 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-18 09:19:53 +0200
commit62c28a26f856c737902f5b0f6239157fd0be64f0 (patch)
treefce1974b6f9958a9582ffe31180092aa0e0753cf /src
parentc2863f69b7d8af33f88a42d1e77a6b393786a92e (diff)
downloadqtlocation-62c28a26f856c737902f5b0f6239157fd0be64f0.tar.gz
Fix unit test
Change-Id: I0793cf96bbfa323901f0e742bfbd2dd55ee355ca Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativecategory.cpp36
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplace.cpp31
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp4
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp7
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesupplier.cpp37
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesupplier_p.h4
6 files changed, 46 insertions, 73 deletions
diff --git a/src/imports/location/declarativeplaces/qdeclarativecategory.cpp b/src/imports/location/declarativeplaces/qdeclarativecategory.cpp
index 11b7c94d..ce3da77a 100644
--- a/src/imports/location/declarativeplaces/qdeclarativecategory.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativecategory.cpp
@@ -72,8 +72,7 @@ QDeclarativeCategory::QDeclarativeCategory(const QPlaceCategory &category,
m_icon(0), m_plugin(plugin), m_reply(0)
{
Q_ASSERT(plugin);
- if (!category.icon().isEmpty())
- m_icon = new QDeclarativePlaceIcon(category.icon(), m_plugin, this);
+ setCategory(category);
}
QDeclarativeCategory::~QDeclarativeCategory() {}
@@ -115,33 +114,18 @@ void QDeclarativeCategory::setCategory(const QPlaceCategory &category)
QPlaceCategory previous = m_category;
m_category = category;
- if (category.name() != previous.name()) {
+ if (category.name() != previous.name())
emit nameChanged();
- }
- if (category.categoryId() != previous.categoryId()) {
+
+ 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);
+ if (m_icon && m_icon->parent() == this) {
+ m_icon->setPlugin(m_plugin);
+ m_icon->setBaseUrl(m_category.icon().baseUrl());
+ m_icon->setFullUrl(m_category.icon().fullUrl());
+ } else if (!m_icon || m_icon->parent() != this){
+ m_icon = new QDeclarativePlaceIcon(m_category.icon(), m_plugin, this);
emit iconChanged();
}
}
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
index 93e84d3e..4c4b8895 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
@@ -82,9 +82,6 @@ QDeclarativePlace::QDeclarativePlace(const QPlace &src, QDeclarativeGeoServicePr
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,31 +171,17 @@ void QDeclarativePlace::setPlace(const QPlace &src)
}
if (m_supplier && m_supplier->parent() == this) {
- m_supplier->setSupplier(m_src.supplier());
+ m_supplier->setSupplier(m_src.supplier(), m_plugin);
} else if (!m_supplier || m_supplier->parent() != this) {
- m_supplier = new QDeclarativeSupplier(m_src.supplier(), this);
+ m_supplier = new QDeclarativeSupplier(m_src.supplier(), m_plugin, this);
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 {
+ if (m_icon && m_icon->parent() == this) {
+ m_icon->setPlugin(m_plugin);
+ m_icon->setBaseUrl(m_src.icon().baseUrl());
+ m_icon->setFullUrl(m_src.icon().fullUrl());
+ } else if (!m_icon || m_icon->parent() != this) {
m_icon = new QDeclarativePlaceIcon(m_src.icon(), m_plugin, this);
emit iconChanged();
}
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
index 3b23137f..7db96d58 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
@@ -302,7 +302,7 @@ void QDeclarativePlaceContentModel::fetchFinished()
m_content.insert(i, content);
if (!m_suppliers.contains(content.supplier().supplierId())) {
m_suppliers.insert(content.supplier().supplierId(),
- new QDeclarativeSupplier(content.supplier(), this));
+ new QDeclarativeSupplier(content.supplier(), m_place->plugin(), this));
}
if (!m_users.contains(content.user().userId())) {
m_users.insert(content.user().userId(),
@@ -329,7 +329,7 @@ void QDeclarativePlaceContentModel::fetchFinished()
m_content.insert(i, content);
if (!m_suppliers.contains(content.supplier().supplierId())) {
m_suppliers.insert(content.supplier().supplierId(),
- new QDeclarativeSupplier(content.supplier(), this));
+ new QDeclarativeSupplier(content.supplier(), m_place->plugin(), this));
}
if (!m_users.contains(content.user().userId())) {
m_users.insert(content.user().userId(),
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp b/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp
index 024c454f..e2ff0c02 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp
@@ -57,7 +57,7 @@ QT_USE_NAMESPACE
\ingroup qml-places
*/
QDeclarativePlaceIcon::QDeclarativePlaceIcon(QObject *parent)
- : QObject(parent)
+ : QObject(parent), m_plugin(0)
{
}
@@ -66,7 +66,10 @@ QDeclarativePlaceIcon::QDeclarativePlaceIcon(const QPlaceIcon &icon, QDeclarativ
{
m_baseUrl = icon.baseUrl();
m_fullUrl = icon.fullUrl();
- m_plugin = plugin;
+ if (icon.isEmpty())
+ m_plugin = 0;
+ else
+ m_plugin = plugin;
}
QDeclarativePlaceIcon::~QDeclarativePlaceIcon()
diff --git a/src/imports/location/declarativeplaces/qdeclarativesupplier.cpp b/src/imports/location/declarativeplaces/qdeclarativesupplier.cpp
index 9f5d1e46..17fc3c87 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesupplier.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesupplier.cpp
@@ -62,38 +62,41 @@ QDeclarativeSupplier::QDeclarativeSupplier(QObject* parent)
}
QDeclarativeSupplier::QDeclarativeSupplier(const QPlaceSupplier &src,
- QObject *parent)
- : QObject(parent),
- m_src(src),
- m_icon(0)
+ QDeclarativeGeoServiceProvider *plugin,
+ QObject *parent)
+ : QObject(parent),
+ 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.
+ setSupplier(src, plugin);
}
QDeclarativeSupplier::~QDeclarativeSupplier()
{
}
-void QDeclarativeSupplier::setSupplier(const QPlaceSupplier &src)
+void QDeclarativeSupplier::setSupplier(const QPlaceSupplier &src, QDeclarativeGeoServiceProvider *plugin)
{
QPlaceSupplier previous = m_src;
m_src = src;
- if (previous.name() != m_src.name()) {
+ if (previous.name() != m_src.name())
emit nameChanged();
- }
- if (previous.supplierId() != m_src.supplierId()) {
+
+ if (previous.supplierId() != m_src.supplierId())
emit supplierIdChanged();
- }
- if (previous.url() != m_src.url()) {
+
+ if (previous.url() != m_src.url())
emit urlChanged();
- }
- //Note: icon needs to be assigned externally
- //to the QDeclarativeSupplier since the icon needs
- //to know which plugin it comes from.
+ if (m_icon && m_icon->parent() == this) {
+ m_icon->setPlugin(plugin);
+ m_icon->setBaseUrl(m_src.icon().baseUrl());
+ m_icon->setFullUrl(m_src.icon().fullUrl());
+ } else if (!m_icon || m_icon->parent() != this) {
+ m_icon = new QDeclarativePlaceIcon(m_src.icon(), plugin, this);
+ emit iconChanged();
+ }
}
QPlaceSupplier QDeclarativeSupplier::supplier()
diff --git a/src/imports/location/declarativeplaces/qdeclarativesupplier_p.h b/src/imports/location/declarativeplaces/qdeclarativesupplier_p.h
index d51abe27..98993d1b 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesupplier_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativesupplier_p.h
@@ -62,11 +62,11 @@ class QDeclarativeSupplier : public QObject
public:
explicit QDeclarativeSupplier(QObject* parent = 0);
- explicit QDeclarativeSupplier(const QPlaceSupplier &src, QObject* parent = 0);
+ explicit QDeclarativeSupplier(const QPlaceSupplier &src, QDeclarativeGeoServiceProvider *plugin, QObject* parent = 0);
~QDeclarativeSupplier();
QPlaceSupplier supplier();
- void setSupplier(const QPlaceSupplier &src);
+ void setSupplier(const QPlaceSupplier &src, QDeclarativeGeoServiceProvider *plugin);
QString name() const;
void setName(const QString &data);