diff options
45 files changed, 500 insertions, 82 deletions
diff --git a/src/location/places/places.pri b/src/location/places/places.pri index f3ef3212..2a68f9d0 100644 --- a/src/location/places/places.pri +++ b/src/location/places/places.pri @@ -57,7 +57,8 @@ PRIVATE_HEADERS += \ places/qplacesupplier_p.h \ places/qplaceweekdayhours_p.h \ places/qplacesearchresult_p.h \ - places/qplacereply_p.h + places/qplacereply_p.h \ + places/qplacemanager_p.h SOURCES += \ #data classes @@ -92,4 +93,5 @@ SOURCES += \ places/qplacetextpredictionreply.cpp \ #manager and engine places/qplacemanager.cpp \ - places/qplacemanagerengine.cpp + places/qplacemanagerengine.cpp \ + places/qplacemanager_p.cpp diff --git a/src/location/places/qplacecategory.cpp b/src/location/places/qplacecategory.cpp index d4637796..d4309358 100644 --- a/src/location/places/qplacecategory.cpp +++ b/src/location/places/qplacecategory.cpp @@ -171,5 +171,5 @@ void QPlaceCategory::setName(const QString &name) */ bool QPlaceCategory::isEmpty() const { - return !d->categoryId.isEmpty(); + return d->categoryId.isEmpty(); } diff --git a/src/location/places/qplacegeoboundingbox.cpp b/src/location/places/qplacegeoboundingbox.cpp index cc396e4b..da0b7d6d 100644 --- a/src/location/places/qplacegeoboundingbox.cpp +++ b/src/location/places/qplacegeoboundingbox.cpp @@ -106,7 +106,7 @@ void QPlaceGeoBoundingBox::setBottomRight(const QPlaceGeoCoordinate &coordinate) /*! Returns true if bounding box is valid. */ -bool QPlaceGeoBoundingBox::isValid() +bool QPlaceGeoBoundingBox::isValid() const { return (d->bottomRight.isValid() && d->topLeft.isValid()); } diff --git a/src/location/places/qplacegeoboundingbox.h b/src/location/places/qplacegeoboundingbox.h index 4ddf8b68..b26ac9b7 100644 --- a/src/location/places/qplacegeoboundingbox.h +++ b/src/location/places/qplacegeoboundingbox.h @@ -29,7 +29,7 @@ public: QPlaceGeoCoordinate bottomRight() const; void setBottomRight(const QPlaceGeoCoordinate &coordinate); - bool isValid(); + bool isValid() const; private: QSharedDataPointer<QPlaceGeoBoundingBoxPrivate> d; diff --git a/src/location/places/qplacemanager.cpp b/src/location/places/qplacemanager.cpp index b68497c6..7e17806b 100644 --- a/src/location/places/qplacemanager.cpp +++ b/src/location/places/qplacemanager.cpp @@ -1,21 +1,7 @@ #include "qplacemanager.h" +#include "qplacemanager_p.h" #include "qplacemanagerengine.h" -QTM_BEGIN_NAMESPACE -class QPlaceManagerEngine; - -class QPlaceManagerPrivate -{ -public: - QPlaceManagerPrivate(){} - ~QPlaceManagerPrivate(){ delete engine; } - - QPlaceManagerEngine *engine; -}; - -QTM_END_NAMESPACE - -QTM_USE_NAMESPACE /*! \class QPlaceManager @@ -71,6 +57,9 @@ QTM_USE_NAMESPACE QPlaceManager::QPlaceManager(QObject *parent) : QObject(parent),d(new QPlaceManagerPrivate) { + QString managerName = "nokia"; + d->q_ptr = this; + d->createEngine(managerName); } /*! @@ -212,6 +201,14 @@ QList<QPlaceCategory> QPlaceManager::categories() const } /*! + Returns a list of names of available managers that + can be used to instantiate manager instances. +*/ +QStringList QPlaceManager::availableManagers() { + return QPlaceManagerPrivate::factories().keys(); +} + +/*! \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 10b4aaae..3b350acc 100644 --- a/src/location/places/qplacemanager.h +++ b/src/location/places/qplacemanager.h @@ -83,6 +83,8 @@ public: QList<QPlaceCategory> categories() const; QPlaceCategory createCategory() const; + static QStringList availableManagers(); + Q_SIGNALS: void finished(QPlaceReply *reply); void error(QPlaceReply *, QPlaceReply::Error error, const QString &errorString = QString()); @@ -90,6 +92,7 @@ Q_SIGNALS: private: Q_DISABLE_COPY(QPlaceManager) QPlaceManagerPrivate* d; + Q_DECLARE_PRIVATE(QPlaceManager) }; QTM_END_NAMESPACE diff --git a/src/location/places/qplacemanager_p.cpp b/src/location/places/qplacemanager_p.cpp new file mode 100644 index 00000000..e73b4901 --- /dev/null +++ b/src/location/places/qplacemanager_p.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 "qplacemanager_p.h" +#include "qplacemanagerengine.h" +#include "qplacemanagerenginefactory.h" +#include <QPluginLoader> +#include <QDebug> +#include <QStringList> +#include <QCoreApplication> +#include <QObject> +#include <QProcess> +#include <QEventLoop> + +#include "qmobilitypluginsearch.h" + +QTM_USE_NAMESPACE + +QPlaceManagerPrivate::QPlaceManagerPrivate() + : engine(0), + errorCode(QPlaceManager::NoError), + isConnected(false), + q_ptr(0) +{ +} + +void QPlaceManagerPrivate::createEngine(const QString &managerName, const QMap<QString,QString> ¶meters) +{ + Q_Q(QPlaceManager); + + if (!q->availableManagers().contains(managerName)) { + errorCode = QPlaceManager::NotSupportedError; + errorString = QString("The places manager, %1, was not found").arg(managerName); + qWarning() << errorString; + engine = 0; + return; + } + + QList<QPlaceManagerEngineFactory *> candidates = QPlaceManagerPrivate::factories().values(managerName); + + bool ok; + + foreach (QPlaceManagerEngineFactory *f, candidates) + { + engine = f->engine(parameters, &errorCode, &errorString); + if (engine) + break; + } + + if (!engine) { + if (errorCode == QPlaceManager::NoError) { + errorCode = QPlaceManager::NotSupportedError; + errorString = "The place manager could not return the requested engine instance"; + } + } +} + +QPlaceManagerEngine* QPlaceManagerPrivate::getEngine(const QPlaceManager* manager) +{ + if (manager) + return manager->d->engine; + return 0; +} + + QHash<QString, QPlaceManagerEngineFactory*> QPlaceManagerPrivate::factories(bool reload) + { + static QHash<QString, QPlaceManagerEngineFactory*> factories; + static bool alreadyDiscovered = false; + + if (reload == true) + alreadyDiscovered = false; + + if (!alreadyDiscovered) { + loadStaticFactories(&factories); + loadDynamicFactories(&factories); + alreadyDiscovered = true; + } + return factories; + } + +void QPlaceManagerPrivate::loadDynamicFactories(QHash<QString, QPlaceManagerEngineFactory*> *factories) +{ + QStringList paths; + paths << mobilityPlugins(QLatin1String("places")); + + QPluginLoader qpl; + for (int i=0;i < paths.count(); ++i) { + qpl.setFileName(paths.at(i)); + + QPlaceManagerEngineFactory *f = qobject_cast<QPlaceManagerEngineFactory*>(qpl.instance()); + if (f) { + QString name = f->managerName(); + +#if !defined QT_NO_DEBUG + const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; + if (showDebug) + qDebug() << "Dynamic: found an engine plugin with name" << name; +#endif + factories->insertMulti(name,f); + } + } +} + +void QPlaceManagerPrivate::loadStaticFactories(QHash<QString, QPlaceManagerEngineFactory*> *factories) +{ +#if !defined QT_NO_DEBUG + const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; +#endif + + QObjectList staticPlugins = QPluginLoader::staticInstances(); + for (int i=0; i < staticPlugins.count(); ++i) { + QPlaceManagerEngineFactory *f = qobject_cast<QPlaceManagerEngineFactory*>(staticPlugins.at(i)); + if (f){ + QString name = f->managerName(); + +#if !defined QT_NO_DEBUG + if (showDebug) + qDebug() << "Static: found an engine plugin with name" << name; +#endif + if (!name.isEmpty()) { + factories->insertMulti(name, f); + } + } + + } +} diff --git a/src/location/places/qplacemanager_p.h b/src/location/places/qplacemanager_p.h new file mode 100644 index 00000000..0f047eb5 --- /dev/null +++ b/src/location/places/qplacemanager_p.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 QPLACEMANAGER_P_H +#define QPLACEMANAGER_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 "qmobilityglobal.h" +#include "qplacemanager.h" +#include <QHash> +#include <QString> +#include <QMap> + +QTM_BEGIN_NAMESPACE + +class QPlaceManagerEngine; +class QPlaceManagerEngineFactory; + +class QPlaceManagerPrivate +{ +public: + QPlaceManagerPrivate(); + void createEngine(const QString &managerName, const QMap<QString,QString> ¶meters = (QMap<QString, QString>())); + + QPlaceManagerEngine *engine; + mutable QPlaceManager::Error errorCode; + mutable QString errorString; + mutable QMap<int, QPlaceManager::Error> errorMap; + static QPlaceManagerEngine *getEngine(const QPlaceManager* manager); + static void loadFactories(); + static QHash<QString, QPlaceManagerEngineFactory*> factories(bool reload = false); + static void loadDynamicFactories (QHash<QString, QPlaceManagerEngineFactory*> *factories); + static void loadStaticFactories (QHash<QString, QPlaceManagerEngineFactory*> *factories); + bool isConnected;//identifies whether connections have been made to the notification signals + + QPlaceManager *q_ptr; + Q_DECLARE_PUBLIC(QPlaceManager) +}; + +QTM_END_NAMESPACE + +#endif // QPLACEMANAGER_P_H diff --git a/src/location/places/qplacemanagerenginefactory.h b/src/location/places/qplacemanagerenginefactory.h index e14b8ca1..3c2fec86 100644 --- a/src/location/places/qplacemanagerenginefactory.h +++ b/src/location/places/qplacemanagerenginefactory.h @@ -53,7 +53,7 @@ class QPlaceManagerEngine; class Q_LOCATION_EXPORT QPlaceManagerEngineFactory { public: - virtual ~QPlaceManagerEngineFactory(); + virtual ~QPlaceManagerEngineFactory(){} virtual QPlaceManagerEngine *engine(const QMap<QString, QString> ¶meters, QPlaceManager::Error *error, QString *errorString) = 0; diff --git a/src/location/places/qplacemediareply.cpp b/src/location/places/qplacemediareply.cpp index b1b2e729..40fec8ec 100644 --- a/src/location/places/qplacemediareply.cpp +++ b/src/location/places/qplacemediareply.cpp @@ -1,5 +1,6 @@ #include "qplacemediareply.h" #include "qplacereply_p.h" +#include "qplacepaginationlist.h" #include "qplace.h" @@ -8,7 +9,7 @@ class QPlaceMediaReplyPrivate : public QPlaceReplyPrivate { public: QPlaceMediaReplyPrivate() {} - QList<QPlaceMediaObject> mediaObjects; + QPlacePaginationList<QPlaceMediaObject> mediaObjects; int totalCount; }; @@ -45,7 +46,7 @@ QPlaceMediaReply::~QPlaceMediaReply() /*! Returns the media objects. */ -QList<QPlaceMediaObject> QPlaceMediaReply::mediaObjects() const +QPlacePaginationList<QPlaceMediaObject> QPlaceMediaReply::mediaObjects() const { Q_D(const QPlaceMediaReply); return d->mediaObjects; @@ -65,7 +66,16 @@ QPlaceReply::Type QPlaceMediaReply::type() const void QPlaceMediaReply::setMediaObjects(const QList<QPlaceMediaObject> &objects) { Q_D(QPlaceMediaReply); - d->mediaObjects = objects; + d->mediaObjects.setData(objects); +} + +/*! + Set the \a offst number of the first media objects on the current page. +*/ +void QPlaceMediaReply::setOffset(int offset) +{ + Q_D(QPlaceMediaReply); + d->mediaObjects.setStart(offset); } /*! diff --git a/src/location/places/qplacemediareply.h b/src/location/places/qplacemediareply.h index a882362a..a9e5cb6f 100644 --- a/src/location/places/qplacemediareply.h +++ b/src/location/places/qplacemediareply.h @@ -3,6 +3,7 @@ #include "qplacereply.h" #include "qplacemediaobject.h" +#include "qplacepaginationlist.h" #include <QStringList> @@ -18,13 +19,14 @@ public: QPlaceReply::Type type() const; - QList<QPlaceMediaObject> mediaObjects() const; + QPlacePaginationList<QPlaceMediaObject> mediaObjects() const; int totalCount() const; protected: void setMediaObjects(const QList<QPlaceMediaObject> &objects); void setTotalCount(int total); + void setOffset(int offset); private: Q_DISABLE_COPY(QPlaceMediaReply) diff --git a/src/location/places/qplacereply.cpp b/src/location/places/qplacereply.cpp index f623bd23..14798f16 100644 --- a/src/location/places/qplacereply.cpp +++ b/src/location/places/qplacereply.cpp @@ -64,6 +64,11 @@ QTM_USE_NAMESPACE /*! Constructs a reply object with a given \a parent. */ +QPlaceReply::QPlaceReply(QObject *parent) + : QObject(parent),d_ptr(new QPlaceReplyPrivate) +{ +} + QPlaceReply::QPlaceReply(QPlaceReplyPrivate *dd, QObject *parent) : QObject(parent),d_ptr(dd) { diff --git a/src/location/places/qplacereply.h b/src/location/places/qplacereply.h index 6cacd6be..273cb51d 100644 --- a/src/location/places/qplacereply.h +++ b/src/location/places/qplacereply.h @@ -33,6 +33,7 @@ public: MediaReply }; + QPlaceReply(QObject *parent); virtual ~QPlaceReply(); bool isFinished() const; diff --git a/src/location/places/qplacereply_p.h b/src/location/places/qplacereply_p.h new file mode 100644 index 00000000..7ad93dae --- /dev/null +++ b/src/location/places/qplacereply_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 QPLACEREPLY_P_H +#define QPLACEREPLY_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 "qplacereply.h" + +QTM_BEGIN_NAMESPACE + +class QPlaceReplyPrivate +{ +public: + QPlaceReplyPrivate() : isFinished(false) {} + QPlaceReply::Error error; + QString errorString; + bool isFinished; +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/places/qplacereviewreply.cpp b/src/location/places/qplacereviewreply.cpp index e78c3791..4da312a8 100644 --- a/src/location/places/qplacereviewreply.cpp +++ b/src/location/places/qplacereviewreply.cpp @@ -8,7 +8,7 @@ class QPlaceReviewReplyPrivate : public QPlaceReplyPrivate { public: QPlaceReviewReplyPrivate() {} - QList<QPlaceReview> reviews; + QPlacePaginationList<QPlaceReview> reviews; int totalCount; }; @@ -53,7 +53,7 @@ QPlaceReply::Type QPlaceReviewReply::type() const /*! Returns the reviews. */ -QList<QPlaceReview> QPlaceReviewReply::reviews() const +QPlacePaginationList<QPlaceReview> QPlaceReviewReply::reviews() const { Q_D(const QPlaceReviewReply); return d->reviews; @@ -65,7 +65,16 @@ QList<QPlaceReview> QPlaceReviewReply::reviews() const void QPlaceReviewReply::setReviews(const QList<QPlaceReview> &reviews) { Q_D(QPlaceReviewReply); - d->reviews = reviews; + d->reviews.setData(reviews); +} + +/*! + Sets the \a offset number of the first media objects on the current page. +*/ +void QPlaceReviewReply::setOffset(int offset) +{ + Q_D(QPlaceReviewReply); + d->reviews.setStart(offset); } /*! diff --git a/src/location/places/qplacereviewreply.h b/src/location/places/qplacereviewreply.h index eed226d1..22ae763a 100644 --- a/src/location/places/qplacereviewreply.h +++ b/src/location/places/qplacereviewreply.h @@ -3,6 +3,7 @@ #include "qplacereply.h" #include "qplacereview.h" +#include "qplacepaginationlist.h" #include <QStringList> @@ -18,11 +19,12 @@ public: QPlaceReply::Type type() const; - QList<QPlaceReview> reviews() const; + QPlacePaginationList<QPlaceReview> reviews() const; int totalCount() const; protected: + void setOffset(int offset); void setReviews(const QList<QPlaceReview> &objects); void setTotalCount(int total); private: diff --git a/src/location/places/qplacesearchquery.cpp b/src/location/places/qplacesearchquery.cpp index ea28b44b..5af588d2 100644 --- a/src/location/places/qplacesearchquery.cpp +++ b/src/location/places/qplacesearchquery.cpp @@ -139,7 +139,7 @@ void QPlaceSearchQuery::setSearchTerm(const QString &term) Places need only to belong to one of the categories to be considered a match by the query. */ -QList<QPlaceCategory> QPlaceSearchQuery::categories() +QList<QPlaceCategory> QPlaceSearchQuery::categories() const { return d->categories; } @@ -150,7 +150,8 @@ QList<QPlaceCategory> QPlaceSearchQuery::categories() void QPlaceSearchQuery::setCategory(const QPlaceCategory &category) { d->categories.clear(); - d->categories.append(category); + if (!category.isEmpty()) + d->categories.append(category); } /*! diff --git a/src/location/places/qplacesearchquery.h b/src/location/places/qplacesearchquery.h index 6960496f..bd816a5d 100644 --- a/src/location/places/qplacesearchquery.h +++ b/src/location/places/qplacesearchquery.h @@ -37,7 +37,7 @@ public: QString searchTerm() const; void setSearchTerm(const QString &term); - QList<QPlaceCategory> categories(); + QList<QPlaceCategory> categories() const; void setCategory(const QPlaceCategory &category); QPlaceGeoCoordinate searchCenter() const; diff --git a/src/location/places/qplacesearchresult.cpp b/src/location/places/qplacesearchresult.cpp index f227eece..03313d99 100644 --- a/src/location/places/qplacesearchresult.cpp +++ b/src/location/places/qplacesearchresult.cpp @@ -143,7 +143,7 @@ QPlaceSearchResult::LocationMatchType QPlaceSearchResult::matchType() const /*! Sets the location \a matchType. */ -void QPlaceSearchResult::setLocationMatchType(const QPlaceSearchResult::LocationMatchType &matchType) +void QPlaceSearchResult::setMatchType(const QPlaceSearchResult::LocationMatchType &matchType) { d->matchType = matchType; } diff --git a/src/location/places/qplacesearchresult.h b/src/location/places/qplacesearchresult.h index 1aa51c57..7979bd80 100644 --- a/src/location/places/qplacesearchresult.h +++ b/src/location/places/qplacesearchresult.h @@ -49,7 +49,7 @@ public: void setHeading(const qreal &heading); LocationMatchType matchType() const; - void setLocationMatchType(const LocationMatchType &matchType); + void setMatchType(const LocationMatchType &matchType); QVariantHash additionalData() const; void setAdditionalData(const QVariantHash &data); diff --git a/src/plugins/places/nokia/nokia.pro b/src/plugins/places/nokia/nokia.pro index cdee54ab..18b17ee3 100644 --- a/src/plugins/places/nokia/nokia.pro +++ b/src/plugins/places/nokia/nokia.pro @@ -23,7 +23,7 @@ HEADERS += \ qplacemediareplyimpl.h \ qplacedetailsreplyimpl.h \ qplaceratingreplyimpl.h \ - pqplacerecommendationreplyimpl.h \ + qplacerecommendationreplyimpl.h \ qplacereviewreplyimpl.h \ qplacesearchreplyimpl.h \ qplacetextpredictionreplyimpl.h \ diff --git a/src/plugins/places/nokia/placemanagerenginefactory_nokia.cpp b/src/plugins/places/nokia/placemanagerenginefactory_nokia.cpp index a7502aa9..ae9fc22b 100644 --- a/src/plugins/places/nokia/placemanagerenginefactory_nokia.cpp +++ b/src/plugins/places/nokia/placemanagerenginefactory_nokia.cpp @@ -47,9 +47,8 @@ ****************************************************************************/ #include "placemanagerenginefactory_nokia.h" - #include <QtPlugin> - +#include "qplacemanagerengineimpl.h" PlaceManagerEngineFactoryNokia::PlaceManagerEngineFactoryNokia() {} @@ -63,8 +62,7 @@ QString PlaceManagerEngineFactoryNokia::managerName() const QPlaceManagerEngine * PlaceManagerEngineFactoryNokia::engine(const QMap<QString, QString> ¶meters, QPlaceManager::Error *error, QString *errorString) { - //TODO: AMOS Replace with realimplementation - return NULL; + return new QPlaceManagerEngineImpl; } diff --git a/src/plugins/places/nokia/qplacecategoriesrepository.cpp b/src/plugins/places/nokia/qplacecategoriesrepository.cpp index a13cefc1..0ac41cf3 100644 --- a/src/plugins/places/nokia/qplacecategoriesrepository.cpp +++ b/src/plugins/places/nokia/qplacecategoriesrepository.cpp @@ -27,8 +27,8 @@ QPlaceCategoriesRepository::QPlaceCategoriesRepository(QObject *parent) if (!categoriesParser) { categoriesParser = new QPlaceJSonCategoriesParser(this); } - connect(categoriesParser, SIGNAL(finished(const QPlaceJSonCategoriesParser::Error &error, const QString &errorMessage)), - this, SLOT(categoriesReady(const QPlaceJSonCategoriesParser::Error &error, const QString &errorMessage))); + connect(categoriesParser, SIGNAL(finished(const QPlaceJSonCategoriesParser::Error &, const QString &)), + this, SLOT(categoriesReady(const QPlaceJSonCategoriesParser::Error &, const QString &))); categoriesParser->processData(supportedCategories); } diff --git a/src/plugins/places/nokia/qplacedetailsreplyimpl.cpp b/src/plugins/places/nokia/qplacedetailsreplyimpl.cpp index ace41188..db3f57b6 100644 --- a/src/plugins/places/nokia/qplacedetailsreplyimpl.cpp +++ b/src/plugins/places/nokia/qplacedetailsreplyimpl.cpp @@ -35,7 +35,8 @@ QPlaceDetailsReplyImpl::~QPlaceDetailsReplyImpl() void QPlaceDetailsReplyImpl::abort() { - restReply->cancelProcessing(); + if (restReply) + restReply->cancelProcessing(); } void QPlaceDetailsReplyImpl::restError(QPlaceRestReply::Error errorId) @@ -47,6 +48,7 @@ void QPlaceDetailsReplyImpl::restError(QPlaceRestReply::Error errorId) } emit error(this->error(), this->errorString()); emit processingError(this, this->error(), this->errorString()); + setFinished(true); emit finished(); emit processingFinished(this); } @@ -61,6 +63,7 @@ void QPlaceDetailsReplyImpl::predictionsReady(const QPlaceJSonDetailsParser::Err emit error(this->error(), this->errorString()); emit processingError(this, ParseError, errorMessage); } + setFinished(true); emit finished(); emit processingFinished(this); delete parser; diff --git a/src/plugins/places/nokia/qplacedetailsreplyimpl.h b/src/plugins/places/nokia/qplacedetailsreplyimpl.h index e8d33822..25122e51 100644 --- a/src/plugins/places/nokia/qplacedetailsreplyimpl.h +++ b/src/plugins/places/nokia/qplacedetailsreplyimpl.h @@ -20,7 +20,7 @@ public: Q_SIGNALS: void processingFinished(QPlaceReply *reply); - void processingError(QPlaceReply *reply, const Error &error, const QString &errorMessage); + void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage); private slots: void restError(QPlaceRestReply::Error error); diff --git a/src/plugins/places/nokia/qplacejsoncategoriesparser.h b/src/plugins/places/nokia/qplacejsoncategoriesparser.h index 4c652528..855607bd 100644 --- a/src/plugins/places/nokia/qplacejsoncategoriesparser.h +++ b/src/plugins/places/nokia/qplacejsoncategoriesparser.h @@ -29,7 +29,7 @@ public: QList<QPlaceCategory> resultCategories(); signals: - void finished(const Error &error, const QString &errorMessage); + void finished(const QPlaceJSonCategoriesParser::Error &error, const QString &errorMessage); public slots: void processData(const QString &data); diff --git a/src/plugins/places/nokia/qplacejsondetailsparser.cpp b/src/plugins/places/nokia/qplacejsondetailsparser.cpp index d6efa6b6..c0109d61 100644 --- a/src/plugins/places/nokia/qplacejsondetailsparser.cpp +++ b/src/plugins/places/nokia/qplacejsondetailsparser.cpp @@ -174,7 +174,7 @@ void QPlaceJSonDetailsParser::processData(const QString &data) QScriptValue sv = engine->evaluate("(" + data + ")"); if (sv.isValid()) { buildPlace(sv.property(place_place_element), &place); - emit finished(NoError, QString()); + emit finished(QPlaceJSonDetailsParser::NoError, QString()); } else { emit finished(ParsingError, QString("JSON data are invalid")); } diff --git a/src/plugins/places/nokia/qplacejsondetailsparser.h b/src/plugins/places/nokia/qplacejsondetailsparser.h index 8b3dc690..d52f9973 100644 --- a/src/plugins/places/nokia/qplacejsondetailsparser.h +++ b/src/plugins/places/nokia/qplacejsondetailsparser.h @@ -27,7 +27,7 @@ public: QPlace result(); signals: - void finished(const Error &error, const QString &errorMessage); + void finished(const QPlaceJSonDetailsParser::Error &error, const QString &errorMessage); public slots: void processData(const QString &data); diff --git a/src/plugins/places/nokia/qplacejsonmediaparser.h b/src/plugins/places/nokia/qplacejsonmediaparser.h index c3d63f96..7cd15820 100644 --- a/src/plugins/places/nokia/qplacejsonmediaparser.h +++ b/src/plugins/places/nokia/qplacejsonmediaparser.h @@ -28,7 +28,7 @@ public: static QPlaceMediaObject buildMediaObject(const QScriptValue &place); signals: - void finished(const Error &error, const QString &errorMessage); + void finished(const QPlaceJSonMediaParser::Error &error, const QString &errorMessage); public slots: void processData(const QString &data); diff --git a/src/plugins/places/nokia/qplacejsonrecommendationparser.h b/src/plugins/places/nokia/qplacejsonrecommendationparser.h index 168d1369..d6f1ebaa 100644 --- a/src/plugins/places/nokia/qplacejsonrecommendationparser.h +++ b/src/plugins/places/nokia/qplacejsonrecommendationparser.h @@ -26,7 +26,7 @@ public: QList<QPlaceSearchResult> results(); signals: - void finished(const Error &error, const QString &errorMessage); + void finished(const QPlaceJSonRecommendationParser::Error &error, const QString &errorMessage); public slots: void processData(const QString &data); diff --git a/src/plugins/places/nokia/qplacejsonreviewparser.h b/src/plugins/places/nokia/qplacejsonreviewparser.h index 70adcbfd..181a9c29 100644 --- a/src/plugins/places/nokia/qplacejsonreviewparser.h +++ b/src/plugins/places/nokia/qplacejsonreviewparser.h @@ -28,7 +28,7 @@ public: static QPlaceReview buildReview(const QScriptValue &place); signals: - void finished(const Error &error, const QString &errorMessage); + void finished(const QPlaceJSonReviewParser::Error &error, const QString &errorMessage); public slots: void processData(const QString &data); diff --git a/src/plugins/places/nokia/qplacejsonsearchparser.cpp b/src/plugins/places/nokia/qplacejsonsearchparser.cpp index 109da7a7..94d74fc0 100644 --- a/src/plugins/places/nokia/qplacejsonsearchparser.cpp +++ b/src/plugins/places/nokia/qplacejsonsearchparser.cpp @@ -128,7 +128,6 @@ QPlaceSearchResult QPlaceJSonSearchParser::processPlaceElement(const QScriptValu QPlaceSearchResult result; result.setType(QPlaceSearchResult::Place); QPlace newPlace; - result.setPlace(newPlace); // Processing properties QScriptValue properties = results.property(search_properties_element); @@ -179,6 +178,7 @@ QPlaceSearchResult QPlaceJSonSearchParser::processPlaceElement(const QScriptValu processCategories(value, &newPlace); } } + result.setPlace(newPlace); return result; } diff --git a/src/plugins/places/nokia/qplacejsonsearchparser.h b/src/plugins/places/nokia/qplacejsonsearchparser.h index 6a87f9ff..08bb4276 100644 --- a/src/plugins/places/nokia/qplacejsonsearchparser.h +++ b/src/plugins/places/nokia/qplacejsonsearchparser.h @@ -27,7 +27,7 @@ public: QList<QPlaceSearchResult> searchResults(); signals: - void finished(const Error &error, const QString &errorMessage); + void finished(const QPlaceJSonSearchParser::Error &error, const QString &errorMessage); public slots: void processData(const QString &data); diff --git a/src/plugins/places/nokia/qplacemanagerengineimpl.cpp b/src/plugins/places/nokia/qplacemanagerengineimpl.cpp index 77908477..21ae164a 100644 --- a/src/plugins/places/nokia/qplacemanagerengineimpl.cpp +++ b/src/plugins/places/nokia/qplacemanagerengineimpl.cpp @@ -50,6 +50,7 @@ QPlaceMediaReply *QPlaceManagerEngineImpl::getMedia(const QPlace &place, const Q query); if (restReply) { reply = new QPlaceMediaReplyImpl(restReply, this); + reply->setStartNumber(query.offset()); connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)), this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString))); connect(reply, SIGNAL(processingFinished(QPlaceReply*)), @@ -81,6 +82,7 @@ QPlaceReviewReply *QPlaceManagerEngineImpl::getReviews(const QPlace &place, cons query); if (restReply) { reply = new QPlaceReviewReplyImpl(restReply, this); + reply->setStartNumber(query.offset()); connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)), this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString))); connect(reply, SIGNAL(processingFinished(QPlaceReply*)), @@ -92,7 +94,13 @@ QPlaceReviewReply *QPlaceManagerEngineImpl::getReviews(const QPlace &place, cons QPlaceSearchReply *QPlaceManagerEngineImpl::searchForPlaces(const QPlaceSearchQuery &query) { QPlaceSearchReplyImpl *reply = NULL; - QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendSuggestionRequest(query); + QPlaceSearchQuery newQuery = query; + // search by category + if (newQuery.categories().count()) { + newQuery.setSearchTerm(query.categories().at(0).categoryId()); + } + QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendSearchRequest(newQuery); + if (restReply) { reply = new QPlaceSearchReplyImpl(restReply, this); connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)), diff --git a/src/plugins/places/nokia/qplacemediareplyimpl.cpp b/src/plugins/places/nokia/qplacemediareplyimpl.cpp index 3158ea78..7421bc01 100644 --- a/src/plugins/places/nokia/qplacemediareplyimpl.cpp +++ b/src/plugins/places/nokia/qplacemediareplyimpl.cpp @@ -17,9 +17,9 @@ QPlaceMediaReplyImpl::QPlaceMediaReplyImpl(QPlaceRestReply *reply, QObject *pare if (restReply) { restReply->setParent(this); - connect(restReply, SIGNAL(finished(const QString &reply)), - parser, SLOT(processData(const QString &data))); - connect(restReply, SIGNAL(error(QPlaceRestReply::Error error)), + connect(restReply, SIGNAL(finished(const QString &)), + parser, SLOT(processData(const QString &))); + connect(restReply, SIGNAL(error(QPlaceRestReply::Error)), this, SLOT(restError(QPlaceRestReply::Error))); connect(parser, SIGNAL(finished(QPlaceJSonMediaParser::Error,QString)), this, SLOT(predictionsReady(QPlaceJSonMediaParser::Error,QString))); @@ -35,7 +35,13 @@ QPlaceMediaReplyImpl::~QPlaceMediaReplyImpl() void QPlaceMediaReplyImpl::abort() { - restReply->cancelProcessing(); + if (restReply) + restReply->cancelProcessing(); +} + +void QPlaceMediaReplyImpl::setStartNumber(int number) +{ + setOffset(number); } void QPlaceMediaReplyImpl::restError(QPlaceRestReply::Error errorId) @@ -47,6 +53,7 @@ void QPlaceMediaReplyImpl::restError(QPlaceRestReply::Error errorId) } emit error(this->error(), this->errorString()); emit processingError(this, this->error(), this->errorString()); + setFinished(true); emit finished(); emit processingFinished(this); } @@ -62,6 +69,7 @@ void QPlaceMediaReplyImpl::predictionsReady(const QPlaceJSonMediaParser::Error & emit error(this->error(), this->errorString()); emit processingError(this, ParseError, errorMessage); } + setFinished(true); emit finished(); emit processingFinished(this); delete parser; diff --git a/src/plugins/places/nokia/qplacemediareplyimpl.h b/src/plugins/places/nokia/qplacemediareplyimpl.h index e3a7845d..a51100c9 100644 --- a/src/plugins/places/nokia/qplacemediareplyimpl.h +++ b/src/plugins/places/nokia/qplacemediareplyimpl.h @@ -17,10 +17,11 @@ public: explicit QPlaceMediaReplyImpl(QPlaceRestReply *reply, QObject *parent = 0); ~QPlaceMediaReplyImpl(); void abort(); + void setStartNumber(int number); Q_SIGNALS: void processingFinished(QPlaceReply *reply); - void processingError(QPlaceReply *reply, const Error &error, const QString &errorMessage); + void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage); private slots: void restError(QPlaceRestReply::Error error); diff --git a/src/plugins/places/nokia/qplaceratingreplyimpl.cpp b/src/plugins/places/nokia/qplaceratingreplyimpl.cpp index 731ae6aa..52a9afc8 100644 --- a/src/plugins/places/nokia/qplaceratingreplyimpl.cpp +++ b/src/plugins/places/nokia/qplaceratingreplyimpl.cpp @@ -17,9 +17,9 @@ QPlaceRatingReplyImpl::QPlaceRatingReplyImpl(QPlaceRestReply *reply, QObject *pa { if (restReply) { restReply->setParent(this); - connect(restReply, SIGNAL(finished(const QString &reply)), - this, SLOT(processData(const QString &data))); - connect(restReply, SIGNAL(error(QPlaceRestReply::Error error)), + connect(restReply, SIGNAL(finished(const QString &)), + this, SLOT(restFinished(const QString &))); + connect(restReply, SIGNAL(error(QPlaceRestReply::Error)), this, SLOT(restError(QPlaceRestReply::Error))); } } @@ -33,7 +33,8 @@ QPlaceRatingReplyImpl::~QPlaceRatingReplyImpl() void QPlaceRatingReplyImpl::abort() { - restReply->cancelProcessing(); + if (restReply) + restReply->cancelProcessing(); } void QPlaceRatingReplyImpl::restError(QPlaceRestReply::Error errorId) @@ -45,6 +46,7 @@ void QPlaceRatingReplyImpl::restError(QPlaceRestReply::Error errorId) } emit error(this->error(), this->errorString()); emit processingError(this, this->error(), this->errorString()); + setFinished(true); emit finished(); emit processingFinished(this); } @@ -52,6 +54,7 @@ void QPlaceRatingReplyImpl::restError(QPlaceRestReply::Error errorId) void QPlaceRatingReplyImpl::restFinished(const QString &data) { Q_UNUSED(data); + setFinished(true); emit finished(); emit processingFinished(this); restReply->deleteLater(); diff --git a/src/plugins/places/nokia/qplaceratingreplyimpl.h b/src/plugins/places/nokia/qplaceratingreplyimpl.h index 741adfeb..446ce693 100644 --- a/src/plugins/places/nokia/qplaceratingreplyimpl.h +++ b/src/plugins/places/nokia/qplaceratingreplyimpl.h @@ -19,7 +19,7 @@ public: Q_SIGNALS: void processingFinished(QPlaceReply *reply); - void processingError(QPlaceReply *reply, const Error &error, const QString &errorMessage); + void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage); private slots: void restError(QPlaceRestReply::Error error); diff --git a/src/plugins/places/nokia/qplacerecommendationreplyimpl.cpp b/src/plugins/places/nokia/qplacerecommendationreplyimpl.cpp index b7e0b178..89482966 100644 --- a/src/plugins/places/nokia/qplacerecommendationreplyimpl.cpp +++ b/src/plugins/places/nokia/qplacerecommendationreplyimpl.cpp @@ -17,9 +17,9 @@ QPlaceRecommendationReplyImpl::QPlaceRecommendationReplyImpl(QPlaceRestReply *re if (restReply) { restReply->setParent(this); - connect(restReply, SIGNAL(finished(const QString &reply)), - parser, SLOT(processData(const QString &data))); - connect(restReply, SIGNAL(error(QPlaceRestReply::Error error)), + connect(restReply, SIGNAL(finished(const QString &)), + parser, SLOT(processData(const QString &))); + connect(restReply, SIGNAL(error(QPlaceRestReply::Error)), this, SLOT(restError(QPlaceRestReply::Error))); connect(parser, SIGNAL(finished(QPlaceJSonRecommendationParser::Error,QString)), this, SLOT(predictionsReady(QPlaceJSonRecommendationParser::Error,QString))); @@ -35,7 +35,8 @@ QPlaceRecommendationReplyImpl::~QPlaceRecommendationReplyImpl() void QPlaceRecommendationReplyImpl::abort() { - restReply->cancelProcessing(); + if (restReply) + restReply->cancelProcessing(); } void QPlaceRecommendationReplyImpl::restError(QPlaceRestReply::Error errorId) @@ -47,6 +48,7 @@ void QPlaceRecommendationReplyImpl::restError(QPlaceRestReply::Error errorId) } emit error(this->error(), this->errorString()); emit processingError(this, this->error(), this->errorString()); + setFinished(true); emit finished(); emit processingFinished(this); } @@ -61,6 +63,7 @@ void QPlaceRecommendationReplyImpl::predictionsReady(const QPlaceJSonRecommendat emit error(this->error(), this->errorString()); emit processingError(this, ParseError, errorMessage); } + setFinished(true); emit finished(); emit processingFinished(this); delete parser; diff --git a/src/plugins/places/nokia/qplacerecommendationreplyimpl.h b/src/plugins/places/nokia/qplacerecommendationreplyimpl.h index 525351c6..d973af16 100644 --- a/src/plugins/places/nokia/qplacerecommendationreplyimpl.h +++ b/src/plugins/places/nokia/qplacerecommendationreplyimpl.h @@ -20,7 +20,7 @@ public: Q_SIGNALS: void processingFinished(QPlaceReply *reply); - void processingError(QPlaceReply *reply, const Error &error, const QString &errorMessage); + void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage); private slots: void restError(QPlaceRestReply::Error error); diff --git a/src/plugins/places/nokia/qplacereviewreplyimpl.cpp b/src/plugins/places/nokia/qplacereviewreplyimpl.cpp index edb068c3..a268ed44 100644 --- a/src/plugins/places/nokia/qplacereviewreplyimpl.cpp +++ b/src/plugins/places/nokia/qplacereviewreplyimpl.cpp @@ -17,9 +17,9 @@ QPlaceReviewReplyImpl::QPlaceReviewReplyImpl(QPlaceRestReply *reply, QObject *pa if (restReply) { restReply->setParent(this); - connect(restReply, SIGNAL(finished(const QString &reply)), - parser, SLOT(processData(const QString &data))); - connect(restReply, SIGNAL(error(QPlaceRestReply::Error error)), + connect(restReply, SIGNAL(finished(const QString &)), + parser, SLOT(processData(const QString &))); + connect(restReply, SIGNAL(error(QPlaceRestReply::Error)), this, SLOT(restError(QPlaceRestReply::Error))); connect(parser, SIGNAL(finished(QPlaceJSonReviewParser::Error,QString)), this, SLOT(predictionsReady(QPlaceJSonReviewParser::Error,QString))); @@ -35,7 +35,13 @@ QPlaceReviewReplyImpl::~QPlaceReviewReplyImpl() void QPlaceReviewReplyImpl::abort() { - restReply->cancelProcessing(); + if (restReply) + restReply->cancelProcessing(); +} + +void QPlaceReviewReplyImpl::setStartNumber(int number) +{ + setOffset(number); } void QPlaceReviewReplyImpl::restError(QPlaceRestReply::Error errorId) @@ -47,6 +53,7 @@ void QPlaceReviewReplyImpl::restError(QPlaceRestReply::Error errorId) } emit error(this->error(), this->errorString()); emit processingError(this, this->error(), this->errorString()); + setFinished(true); emit finished(); emit processingFinished(this); } @@ -62,6 +69,7 @@ void QPlaceReviewReplyImpl::predictionsReady(const QPlaceJSonReviewParser::Error emit error(this->error(), this->errorString()); emit processingError(this, ParseError, errorMessage); } + setFinished(true); emit finished(); emit processingFinished(this); delete parser; diff --git a/src/plugins/places/nokia/qplacereviewreplyimpl.h b/src/plugins/places/nokia/qplacereviewreplyimpl.h index af439795..1607acce 100644 --- a/src/plugins/places/nokia/qplacereviewreplyimpl.h +++ b/src/plugins/places/nokia/qplacereviewreplyimpl.h @@ -17,10 +17,11 @@ public: explicit QPlaceReviewReplyImpl(QPlaceRestReply *reply, QObject *parent = 0); ~QPlaceReviewReplyImpl(); void abort(); + void setStartNumber(int number); Q_SIGNALS: void processingFinished(QPlaceReply *reply); - void processingError(QPlaceReply *reply, const Error &error, const QString &errorMessage); + void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage); private slots: void restError(QPlaceRestReply::Error error); diff --git a/src/plugins/places/nokia/qplacesearchreplyimpl.cpp b/src/plugins/places/nokia/qplacesearchreplyimpl.cpp index cf4c713d..9a3007d9 100644 --- a/src/plugins/places/nokia/qplacesearchreplyimpl.cpp +++ b/src/plugins/places/nokia/qplacesearchreplyimpl.cpp @@ -17,9 +17,9 @@ QPlaceSearchReplyImpl::QPlaceSearchReplyImpl(QPlaceRestReply *reply, QObject *pa if (restReply) { restReply->setParent(this); - connect(restReply, SIGNAL(finished(const QString &reply)), - parser, SLOT(processData(const QString &data))); - connect(restReply, SIGNAL(error(QPlaceRestReply::Error error)), + connect(restReply, SIGNAL(finished(const QString &)), + parser, SLOT(processData(const QString &))); + connect(restReply, SIGNAL(error(QPlaceRestReply::Error)), this, SLOT(restError(QPlaceRestReply::Error))); connect(parser, SIGNAL(finished(QPlaceJSonSearchParser::Error,QString)), this, SLOT(predictionsReady(QPlaceJSonSearchParser::Error,QString))); @@ -35,7 +35,8 @@ QPlaceSearchReplyImpl::~QPlaceSearchReplyImpl() void QPlaceSearchReplyImpl::abort() { - restReply->cancelProcessing(); + if (restReply) + restReply->cancelProcessing(); } void QPlaceSearchReplyImpl::restError(QPlaceRestReply::Error errorId) @@ -47,6 +48,7 @@ void QPlaceSearchReplyImpl::restError(QPlaceRestReply::Error errorId) } emit error(this->error(), this->errorString()); emit processingError(this, this->error(), this->errorString()); + setFinished(true); emit finished(); emit processingFinished(this); } @@ -55,12 +57,13 @@ void QPlaceSearchReplyImpl::predictionsReady(const QPlaceJSonSearchParser::Error const QString &errorMessage) { if (errorId == QPlaceJSonSearchParser::NoError) { - setResults(parser->searchResults()); + setResults(filterSecondSearchCenter(parser->searchResults())); } else if (errorId == QPlaceJSonSearchParser::ParsingError) { setError(ParseError, errorMessage); emit error(this->error(), this->errorString()); emit processingError(this, ParseError, errorMessage); } + setFinished(true); emit finished(); emit processingFinished(this); delete parser; @@ -68,3 +71,24 @@ void QPlaceSearchReplyImpl::predictionsReady(const QPlaceJSonSearchParser::Error restReply->deleteLater(); restReply = NULL; } + +QList<QPlaceSearchResult> QPlaceSearchReplyImpl::filterSecondSearchCenter(const QList<QPlaceSearchResult> &list) +{ + QList<QPlaceSearchResult> newList; + foreach (QPlaceSearchResult res, list) { + if (res.type() == QPlaceSearchResult::Place) { + bool isNotSeconSearchCenter = true; + foreach (QPlaceCategory cat, res.place().categories()) { + if (cat.categoryId() == "second-search-center") { + isNotSeconSearchCenter = false; + break; + } + } + if (isNotSeconSearchCenter) { + newList.append(res); + } + } + } + return newList; +} + diff --git a/src/plugins/places/nokia/qplacesearchreplyimpl.h b/src/plugins/places/nokia/qplacesearchreplyimpl.h index 5dfcb588..e9f241e7 100644 --- a/src/plugins/places/nokia/qplacesearchreplyimpl.h +++ b/src/plugins/places/nokia/qplacesearchreplyimpl.h @@ -20,7 +20,7 @@ public: Q_SIGNALS: void processingFinished(QPlaceReply *reply); - void processingError(QPlaceReply *reply, const Error &error, const QString &errorMessage); + void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage); private slots: void restError(QPlaceRestReply::Error error); @@ -28,6 +28,7 @@ private slots: const QString &errorMessage); private: + QList<QPlaceSearchResult> filterSecondSearchCenter(const QList<QPlaceSearchResult> &list); QPlaceRestReply *restReply; QPlaceJSonSearchParser *parser; }; diff --git a/src/plugins/places/nokia/qplacetextpredictionreplyimpl.cpp b/src/plugins/places/nokia/qplacetextpredictionreplyimpl.cpp index 45c54aa4..ae6166a9 100644 --- a/src/plugins/places/nokia/qplacetextpredictionreplyimpl.cpp +++ b/src/plugins/places/nokia/qplacetextpredictionreplyimpl.cpp @@ -19,9 +19,9 @@ QPlaceTextPreditionReplyImpl::QPlaceTextPreditionReplyImpl(QPlaceRestReply *repl if (restReply) { restReply->setParent(this); - connect(restReply, SIGNAL(finished(const QString &reply)), - parser, SLOT(processData(const QString &data))); - connect(restReply, SIGNAL(error(QPlaceRestReply::Error error)), + connect(restReply, SIGNAL(finished(const QString &)), + parser, SLOT(processData(const QString &))); + connect(restReply, SIGNAL(error(QPlaceRestReply::Error)), this, SLOT(restError(QPlaceRestReply::Error))); connect(parser, SIGNAL(finished(QPlaceJSonTextPredictionParser::Error,QString)), this, SLOT(predictionsReady(QPlaceJSonTextPredictionParser::Error,QString))); @@ -37,7 +37,8 @@ QPlaceTextPreditionReplyImpl::~QPlaceTextPreditionReplyImpl() void QPlaceTextPreditionReplyImpl::abort() { - restReply->cancelProcessing(); + if (restReply) + restReply->cancelProcessing(); } void QPlaceTextPreditionReplyImpl::restError(QPlaceRestReply::Error errorId) @@ -49,6 +50,7 @@ void QPlaceTextPreditionReplyImpl::restError(QPlaceRestReply::Error errorId) } emit error(this->error(), this->errorString()); emit processingError(this, this->error(), this->errorString()); + setFinished(true); emit finished(); emit processingFinished(this); } @@ -63,6 +65,7 @@ void QPlaceTextPreditionReplyImpl::predictionsReady(const QPlaceJSonTextPredicti emit error(this->error(), this->errorString()); emit processingError(this, ParseError, errorMessage); } + setFinished(true); emit finished(); emit processingFinished(this); delete parser; |