diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2011-10-07 10:06:03 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-10 05:25:50 +0200 |
commit | 9639f9485164ffb2a03d5edf6d5972d4048ea00c (patch) | |
tree | fed05f74a2a73583eaeb68d844200b3c92c17e54 /src | |
parent | 6f7d4efc56e33f49ae4289e93e26c38eb632fe5f (diff) | |
download | qtlocation-9639f9485164ffb2a03d5edf6d5972d4048ea00c.tar.gz |
Improve naming consistency in Places API.
Change-Id: Ic902592c3367a76fc0e23c237712224abbf31703
Reviewed-on: http://codereview.qt-project.org/6206
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src')
92 files changed, 616 insertions, 1114 deletions
diff --git a/src/imports/location/declarativeplaces/qdeclarativecategory.cpp b/src/imports/location/declarativeplaces/qdeclarativecategory.cpp index 488f016c..567178ba 100644 --- a/src/imports/location/declarativeplaces/qdeclarativecategory.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativecategory.cpp @@ -78,7 +78,7 @@ void QDeclarativeCategory::setCategory(const QPlaceCategory &category) } } -QPlaceCategory QDeclarativeCategory::category() +QPlaceCategory QDeclarativeCategory::category() const { return m_category; } diff --git a/src/imports/location/declarativeplaces/qdeclarativecategory_p.h b/src/imports/location/declarativeplaces/qdeclarativecategory_p.h index dc544be7..d4a04d06 100644 --- a/src/imports/location/declarativeplaces/qdeclarativecategory_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativecategory_p.h @@ -71,7 +71,7 @@ public: PublicVisibility = QtLocation::PublicVisibility }; - QPlaceCategory category(); + QPlaceCategory category() const; void setCategory(const QPlaceCategory &category); QString categoryId() const; diff --git a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp index f752e511..157a7b85 100644 --- a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp @@ -65,7 +65,7 @@ QT_USE_NAMESPACE */ QDeclarativePlace::QDeclarativePlace(QObject* parent) -: QObject(parent), m_location(0), m_rating(0), +: QObject(parent), m_location(0), m_rating(0), m_supplier(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) @@ -73,15 +73,13 @@ QDeclarativePlace::QDeclarativePlace(QObject* parent) } QDeclarativePlace::QDeclarativePlace(const QPlace &src, QObject *parent) -: QObject(parent), m_location(0), m_rating(0), +: QObject(parent), m_location(0), m_rating(0), m_supplier(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_status(QDeclarativePlace::Ready) { - synchronizeCategories(); - synchronizeSuppliers(); - synchronizeExtendedAttributes(); + setPlace(src); } QDeclarativePlace::~QDeclarativePlace() @@ -169,10 +167,13 @@ void QDeclarativePlace::setPlace(const QPlace &src) emit ratingChanged(); } - if (previous.suppliers() != m_src.suppliers()) { - synchronizeSuppliers(); - emit suppliersChanged(); + if (m_supplier && m_supplier->parent() == this) { + m_supplier->setSupplier(m_src.supplier()); + } else if (!m_supplier || m_supplier->parent() != this) { + m_supplier = new QDeclarativeSupplier(m_src.supplier(), this); + emit supplierChanged(); } + if (previous.name() != m_src.name()) { emit nameChanged(); } @@ -235,12 +236,8 @@ QPlace QDeclarativePlace::place() // Rating result.setRating(m_rating ? m_rating->rating() : QPlaceRating()); - // Suppliers - QList<QPlaceSupplier> suppliers; - foreach (QDeclarativeSupplier *value, m_suppliers) - suppliers.append(value->supplier()); - - result.setSuppliers(suppliers); + // Supplier + result.setSupplier(m_supplier ? m_supplier->supplier() : QPlaceSupplier()); // Extended Attributes return result; @@ -298,6 +295,28 @@ QDeclarativeRating *QDeclarativePlace::rating() } /*! + \qmlproperty Supplier Place::supplier + + This property holds the supplier of the place data. +*/ +void QDeclarativePlace::setSupplier(QDeclarativeSupplier *supplier) +{ + if (m_supplier == supplier) + return; + + if (m_supplier && m_supplier->parent() == this) + delete m_supplier; + + m_supplier = supplier; + emit supplierChanged(); +} + +QDeclarativeSupplier *QDeclarativePlace::supplier() const +{ + return m_supplier; +} + +/*! \qmlproperty string Place::name This property holds name. @@ -427,9 +446,9 @@ void QDeclarativePlace::finished() } break; } - case (QPlaceReply::PlaceDetailsReply): { + case (QPlaceReply::DetailsReply): { QPlaceDetailsReply *detailsReply = qobject_cast<QPlaceDetailsReply *>(m_reply); - setPlace(detailsReply->result()); + setPlace(detailsReply->place()); break; } default: @@ -469,21 +488,12 @@ void QDeclarativePlace::getDetails() setStatus(QDeclarativePlace::Fetching); } -void QDeclarativePlace::ratePlace(qreal rating) -{ - QPlaceManager *placeManager = manager(); - if (!placeManager) - return; - - placeManager->postRating(placeId(), rating); -} - /*! - \qmlmethod void Place::savePlace() + \qmlmethod void Place::save() This method performs a save operation on the place. */ -void QDeclarativePlace::savePlace() +void QDeclarativePlace::save() { QPlaceManager *placeManager = manager(); if (!placeManager) @@ -495,11 +505,11 @@ void QDeclarativePlace::savePlace() } /*! - \qmlmethod void Place::removePlace() + \qmlmethod void Place::remove() This method performs a remove operation on the place. */ -void QDeclarativePlace::removePlace() +void QDeclarativePlace::remove() { QPlaceManager *placeManager = manager(); if (!placeManager) @@ -687,65 +697,6 @@ void QDeclarativePlace::synchronizeCategories() } } -/*! - \qmlproperty QDeclarativeListProperty<QDeclarativeSupplier> Place::suppliers - - This property suppliers list. - - Note: this property's changed() signal is currently emitted only if the - whole element changes, not if only the contents of the element change. -*/ -QDeclarativeListProperty<QDeclarativeSupplier> QDeclarativePlace::suppliers() -{ - return QDeclarativeListProperty<QDeclarativeSupplier>(this, - 0, // opaque data parameter - suppliers_append, - suppliers_count, - suppliers_at, - suppliers_clear); -} - -void QDeclarativePlace::suppliers_append(QDeclarativeListProperty<QDeclarativeSupplier> *prop, - QDeclarativeSupplier *value) -{ - QDeclarativePlace* object = static_cast<QDeclarativePlace*>(prop->object); - QDeclarativeSupplier *altValue = new QDeclarativeSupplier(object); - altValue->setSupplier(value->supplier()); - object->m_suppliers.append(altValue); - QList<QPlaceSupplier> list = object->m_src.suppliers(); - list.append(value->supplier()); - object->m_src.setSuppliers(list); - emit object->suppliersChanged(); -} - -int QDeclarativePlace::suppliers_count(QDeclarativeListProperty<QDeclarativeSupplier> *prop) -{ - return static_cast<QDeclarativePlace*>(prop->object)->m_suppliers.count(); -} - -QDeclarativeSupplier* QDeclarativePlace::suppliers_at(QDeclarativeListProperty<QDeclarativeSupplier> *prop, - int index) -{ - QDeclarativePlace* object = static_cast<QDeclarativePlace*>(prop->object); - QDeclarativeSupplier *res = NULL; - if (object->m_suppliers.count() > index && index > -1) { - res = object->m_suppliers[index]; - } - return res; -} - -void QDeclarativePlace::suppliers_clear(QDeclarativeListProperty<QDeclarativeSupplier> *prop) -{ - QDeclarativePlace* object = static_cast<QDeclarativePlace*>(prop->object); - if (object->m_suppliers.isEmpty()) - return; - - qDeleteAll(object->m_suppliers); - object->m_suppliers.clear(); - object->m_src.setSuppliers(QList<QPlaceSupplier>()); - emit object->suppliersChanged(); -} - QDeclarativePlace::Visibility QDeclarativePlace::visibility() const { return static_cast<QDeclarativePlace::Visibility>(m_src.visibility()); @@ -760,16 +711,6 @@ void QDeclarativePlace::setVisibility(Visibility visibility) emit visibilityChanged(); } -void QDeclarativePlace::synchronizeSuppliers() -{ - qDeleteAll(m_suppliers); - m_suppliers.clear(); - foreach (QPlaceSupplier value, m_src.suppliers()) { - QDeclarativeSupplier* declarativeValue = new QDeclarativeSupplier(value, this); - m_suppliers.append(declarativeValue); - } -} - void QDeclarativePlace::synchronizeExtendedAttributes() { QStringList keys = m_extendedAttributes->keys(); diff --git a/src/imports/location/declarativeplaces/qdeclarativeplace_p.h b/src/imports/location/declarativeplaces/qdeclarativeplace_p.h index bd09d36c..3627c3c4 100644 --- a/src/imports/location/declarativeplaces/qdeclarativeplace_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativeplace_p.h @@ -70,7 +70,7 @@ class QDeclarativePlace : public QObject, public QDeclarativeParserStatus Q_PROPERTY(QDeclarativeListProperty<QDeclarativeCategory> categories READ categories NOTIFY categoriesChanged) Q_PROPERTY(QDeclarativeGeoLocation* location READ location WRITE setLocation NOTIFY locationChanged); Q_PROPERTY(QDeclarativeRating* rating READ rating WRITE setRating NOTIFY ratingChanged); - Q_PROPERTY(QDeclarativeListProperty<QDeclarativeSupplier> suppliers READ suppliers NOTIFY suppliersChanged) + Q_PROPERTY(QDeclarativeSupplier *supplier READ supplier WRITE setSupplier NOTIFY supplierChanged) 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) @@ -130,12 +130,9 @@ public: void setLocation(QDeclarativeGeoLocation *location); QDeclarativeRating *rating(); void setRating(QDeclarativeRating *rating); - QDeclarativeListProperty<QDeclarativeSupplier> suppliers(); - static void suppliers_append(QDeclarativeListProperty<QDeclarativeSupplier> *prop, - QDeclarativeSupplier* value); - static int suppliers_count(QDeclarativeListProperty<QDeclarativeSupplier> *prop); - static QDeclarativeSupplier* suppliers_at(QDeclarativeListProperty<QDeclarativeSupplier> *prop, int index); - static void suppliers_clear(QDeclarativeListProperty<QDeclarativeSupplier> *prop); + QDeclarativeSupplier *supplier() const; + void setSupplier(QDeclarativeSupplier *supplier); + QString name() const; void setName(const QString &name); QString placeId() const; @@ -149,9 +146,8 @@ public: void setStatus(Status status); Q_INVOKABLE void getDetails(); - Q_INVOKABLE void ratePlace(qreal rating); - Q_INVOKABLE void savePlace(); - Q_INVOKABLE void removePlace(); + Q_INVOKABLE void save(); + Q_INVOKABLE void remove(); Q_INVOKABLE QString errorString() const; QString primaryPhone() const; @@ -177,13 +173,11 @@ signals: void categoriesChanged(); void locationChanged(); void ratingChanged(); - void suppliersChanged(); + void supplierChanged(); void nameChanged(); void placeIdChanged(); - void businessInformationChanged(); void attributionChanged(); void detailsFetchedChanged(); - void fetchingDetailsChanged(); void reviewModelChanged(); void imageModelChanged(); void editorialModelChanged(); @@ -202,7 +196,6 @@ private slots: private: void synchronizeCategories(); - void synchronizeSuppliers(); void synchronizeExtendedAttributes(); private: @@ -211,7 +204,7 @@ private: QList<QDeclarativeCategory*> m_categories; QDeclarativeGeoLocation *m_location; QDeclarativeRating *m_rating; - QList<QDeclarativeSupplier*> m_suppliers; + QDeclarativeSupplier *m_supplier; QDeclarativeReviewModel *m_reviewModel; QDeclarativePlaceImageModel *m_imageModel; QDeclarativePlaceEditorialModel *m_editorialModel; diff --git a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp index 906be508..f12cc93b 100644 --- a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp @@ -55,6 +55,12 @@ QDeclarativePlaceContentModel::QDeclarativePlaceContentModel(QPlaceContent::Type : QAbstractListModel(parent), m_place(0), m_type(type), m_batchSize(1), m_contentCount(-1), m_reply(0), m_complete(false) { + QHash<int, QByteArray> roles = roleNames(); + roles.insert(SupplierRole, "supplier"); + roles.insert(SourceUrlRole, "sourceUrl"); + roles.insert(UserIdRole, "userId"); + roles.insert(UserNameRole, "username"); + setRoleNames(roles); } QDeclarativePlaceContentModel::~QDeclarativePlaceContentModel() @@ -170,6 +176,12 @@ QVariant QDeclarativePlaceContentModel::data(const QModelIndex &index, int role) switch (role) { case SupplierRole: return QVariant::fromValue(static_cast<QObject *>(m_suppliers.value(content.supplier().supplierId()))); + case SourceUrlRole: + return content.sourceUrl(); + case UserIdRole: + return content.userId(); + case UserNameRole: + return content.userName(); default: return QVariant(); } diff --git a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h index 2c39daac..5d3bc6f8 100644 --- a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h +++ b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h @@ -84,7 +84,10 @@ public: QVariant data(const QModelIndex &index, int role) const; enum Roles { SupplierRole = Qt::UserRole, - UserRole + SourceUrlRole, + UserIdRole, + UserNameRole, + UserRole //indicator for next conten type specific role }; bool canFetchMore(const QModelIndex &parent) const; @@ -103,7 +106,7 @@ private slots: void fetchFinished(); protected: - QMap<int, QPlaceContent> m_content; + QPlaceContent::Collection m_content; QMap<QString, QDeclarativeSupplier *> m_suppliers; private: diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceeditorialmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativeplaceeditorialmodel.cpp index efdcd17e..b63ea30f 100644 --- a/src/imports/location/declarativeplaces/qdeclarativeplaceeditorialmodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativeplaceeditorialmodel.cpp @@ -113,7 +113,7 @@ QDeclarativePlaceEditorialModel::QDeclarativePlaceEditorialModel(QObject *parent roleNames.insert(ContentRole, "content"); roleNames.insert(TitleRole, "title"); roleNames.insert(SupplierRole, "supplier"); - roleNames.insert(UrlRole, "url"); + roleNames.insert(SourceUrlRole, "url"); roleNames.insert(LanguageRole, "language"); setRoleNames(roleNames); } @@ -137,7 +137,7 @@ QVariant QDeclarativePlaceEditorialModel::data(const QModelIndex &index, int rol return description.content(); case TitleRole: return description.title(); - case UrlRole: + case SourceUrlRole: return description.sourceUrl(); case LanguageRole: return description.language(); diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceeditorialmodel.h b/src/imports/location/declarativeplaces/qdeclarativeplaceeditorialmodel.h index a16ab1de..6ab254fa 100644 --- a/src/imports/location/declarativeplaces/qdeclarativeplaceeditorialmodel.h +++ b/src/imports/location/declarativeplaces/qdeclarativeplaceeditorialmodel.h @@ -62,7 +62,6 @@ public: enum Roles { ContentRole = UserRole, TitleRole, - UrlRole, LanguageRole }; }; diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp b/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp index ccce002d..b7f2fb73 100644 --- a/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel.cpp @@ -115,14 +115,11 @@ QT_BEGIN_NAMESPACE QDeclarativePlaceImageModel::QDeclarativePlaceImageModel(QObject* parent) : QDeclarativePlaceContentModel(QPlaceContent::ImageType, parent) { - QHash<int, QByteArray> roleNames; - roleNames.insert(UrlRole, "url"); - roleNames.insert(ThumbnailUrlRole, "thumbnailUrl"); - roleNames.insert(ImageIdRole, "imageId"); - roleNames.insert(MetaInfoRole, "metaInfo"); - roleNames.insert(MimeTypeRole, "mimeType"); - roleNames.insert(SupplierRole, "supplier"); - setRoleNames(roleNames); + QHash<int, QByteArray> roles = roleNames(); + roles.insert(UrlRole, "url"); + roles.insert(ImageIdRole, "imageId"); + roles.insert(MimeTypeRole, "mimeType"); + setRoleNames(roles); } QDeclarativePlaceImageModel::~QDeclarativePlaceImageModel() @@ -143,12 +140,8 @@ QVariant QDeclarativePlaceImageModel::data(const QModelIndex &index, int role) c switch (role) { case UrlRole: return image.url(); - case ThumbnailUrlRole: - return image.thumbnailUrl(); case ImageIdRole: - return image.id(); - case MetaInfoRole: - return image.metaInfo(); + return image.imageId(); case MimeTypeRole: return image.mimeType(); } diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel_p.h b/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel_p.h index d2cac9fb..b4796e24 100644 --- a/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativeplaceimagemodel_p.h @@ -59,9 +59,7 @@ public: QVariant data(const QModelIndex &index, int role) const; enum Roles { UrlRole = UserRole, - ThumbnailUrlRole, ImageIdRole, - MetaInfoRole, MimeTypeRole }; }; diff --git a/src/imports/location/declarativeplaces/qdeclarativerating.cpp b/src/imports/location/declarativeplaces/qdeclarativerating.cpp index 443990ef..3da972ce 100644 --- a/src/imports/location/declarativeplaces/qdeclarativerating.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativerating.cpp @@ -86,7 +86,7 @@ QPlaceRating QDeclarativeRating::rating() const This property holds the value of rating */ -void QDeclarativeRating::setValue(const qreal &value) +void QDeclarativeRating::setValue(qreal value) { if (m_rating.value() != value) { m_rating.setValue(value); @@ -100,12 +100,31 @@ qreal QDeclarativeRating::value() const } /*! + \qmlproperty qreal Rating::maximum + + This property holds the maximum rating value. +*/ +void QDeclarativeRating::setMaximum(qreal max) +{ + if (m_rating.maximum() == max) + return; + + m_rating.setMaximum(max); + emit maximumChanged(); +} + +qreal QDeclarativeRating::maximum() const +{ + return m_rating.maximum(); +} + +/*! \qmlproperty int Rating::count This property holds number of votes with rate. */ -void QDeclarativeRating::setCount(const int &count) +void QDeclarativeRating::setCount(int count) { if (m_rating.count() != count) { m_rating.setCount(count); diff --git a/src/imports/location/declarativeplaces/qdeclarativerating_p.h b/src/imports/location/declarativeplaces/qdeclarativerating_p.h index 59db9788..d7e697db 100644 --- a/src/imports/location/declarativeplaces/qdeclarativerating_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativerating_p.h @@ -54,6 +54,7 @@ class QDeclarativeRating : public QObject Q_OBJECT Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY(qreal maximum READ maximum WRITE setMaximum NOTIFY maximumChanged) Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged) public: @@ -65,12 +66,17 @@ public: void setRating(const QPlaceRating &src); qreal value() const; - void setValue(const qreal &data); + void setValue(qreal value); + + qreal maximum() const; + void setMaximum(qreal max); + int count() const; - void setCount(const int &data); + void setCount(int count); signals: void valueChanged(); + void maximumChanged(); void countChanged(); private: diff --git a/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel.cpp index e14b2fad..a69177ee 100644 --- a/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel.cpp @@ -69,33 +69,13 @@ QT_USE_NAMESPACE \o Type \o Description \row - \o type - \o RecommendationModel.SearchResultType - \o The type of search result. - \row - \o relevance - \o real - \o The relevence score of the result. - \row \o distance \o real \o The distance to the place. \row - \o heading - \o real - \o The heading to the place. - \row - \o additionalData - \o - \o Additional data related to the search result. - \row \o place \o Place \o The Place. - \row - \o didYouMean - \o string - \o Valid only for did you mean search results, a suggested corrected search term. \endtable The following example shows how to use the RecommendationModel to search for recommendations @@ -123,7 +103,7 @@ QT_USE_NAMESPACE } ... - resultModel.executeQuery() + resultModel.execute() ... ListView { @@ -167,7 +147,7 @@ QT_USE_NAMESPACE /*! - \qmlmethod RecommendationModel::executeQuery() + \qmlmethod RecommendationModel::execute() Parameter placeId should contain string for which search should be started. Updates the items represented by the model from the underlying proivider. @@ -175,23 +155,17 @@ QT_USE_NAMESPACE /*! - \qmlmethod RecommendationModel::cancelRequest() + \qmlmethod RecommendationModel::cancel() Cancels ongoing request. */ QDeclarativeRecommendationModel::QDeclarativeRecommendationModel(QObject *parent) : QDeclarativeSearchModelBase(parent) { - QHash<int, QByteArray> roleNames; - roleNames = QAbstractItemModel::roleNames(); - roleNames.insert(SearchResultType, "type"); - roleNames.insert(SearchResultRelevance, "relevance"); - roleNames.insert(SearchResultDistance, "distance"); - roleNames.insert(SearchResultHeading, "heading"); - roleNames.insert(SearchResultAdditionalData, "additionalData"); - roleNames.insert(SearchResultPlace, "place"); - roleNames.insert(SearchResultDidYouMean, "didYouMean"); - setRoleNames(roleNames); + QHash<int, QByteArray> roles = roleNames(); + roles.insert(DistanceRole, "distance"); + roles.insert(PlaceRole, "place"); + setRoleNames(roles); } QDeclarativeRecommendationModel::~QDeclarativeRecommendationModel() @@ -259,35 +233,18 @@ QVariant QDeclarativeRecommendationModel::data(const QModelIndex& index, int rol const QPlaceSearchResult &result = m_results.at(index.row()); - if (result.type() == QPlaceSearchResult::Place) { - switch (role) { - case Qt::DisplayRole: - return result.place().name(); - case SearchResultType: - return result.type(); - case SearchResultRelevance: - return result.relevance(); - case SearchResultDistance: - return result.distance(); - case SearchResultHeading: - return result.heading(); - case SearchResultAdditionalData: - return result.additionalData(); - case SearchResultPlace: - return QVariant::fromValue(static_cast<QObject *>(m_places.value(result.place().placeId()))); - default: - return QVariant(); - } - } else if (result.type() == QPlaceSearchResult::DidYouMeanSuggestion) { - switch (role) { - case Qt::DisplayRole: - case SearchResultDidYouMean: - return result.didYouMeanSuggestion(); - case SearchResultType: - return result.type(); - default: - return QVariant(); - } + if (result.type() != QPlaceSearchResult::PlaceResult) + return QVariant(); + + switch (role) { + case Qt::DisplayRole: + return result.place().name(); + case DistanceRole: + return result.distance(); + case PlaceRole: + return QVariant::fromValue(static_cast<QObject *>(m_places.value(result.place().placeId()))); + default: + return QVariant(); } return QVariant(); diff --git a/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel_p.h b/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel_p.h index 117d35a8..4c33d5a3 100644 --- a/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativerecommendationmodel_p.h @@ -52,17 +52,9 @@ class QDeclarativeRecommendationModel : public QDeclarativeSearchModelBase Q_PROPERTY(QString placeId READ placeId WRITE setPlaceId NOTIFY placeIdChanged) - Q_ENUMS(SearchResultType) - Q_INTERFACES(QDeclarativeParserStatus) public: - enum SearchResultType { - Place = QPlaceSearchResult::Place, - DidYouMeanSuggestion = QPlaceSearchResult::DidYouMeanSuggestion, - UnknownSearchResult = QPlaceSearchResult::UnknownSearchResult - }; - explicit QDeclarativeRecommendationModel(QObject *parent = 0); ~QDeclarativeRecommendationModel(); @@ -77,13 +69,8 @@ public: int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; enum Roles { - SearchResultType = Qt::UserRole, - SearchResultRelevance, - SearchResultDistance, - SearchResultHeading, - SearchResultAdditionalData, - SearchResultPlace, - SearchResultDidYouMean + DistanceRole = Qt::UserRole, + PlaceRole }; signals: diff --git a/src/imports/location/declarativeplaces/qdeclarativereviewmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativereviewmodel.cpp index 4b74f8c0..4c7f657e 100644 --- a/src/imports/location/declarativeplaces/qdeclarativereviewmodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativereviewmodel.cpp @@ -42,6 +42,7 @@ #include "qdeclarativereviewmodel_p.h" #include "qdeclarativesupplier_p.h" +#include <QtCore/QDateTime> #include <QtLocation/QPlaceReview> QT_BEGIN_NAMESPACE @@ -140,21 +141,14 @@ QT_BEGIN_NAMESPACE QDeclarativeReviewModel::QDeclarativeReviewModel(QObject* parent) : QDeclarativePlaceContentModel(QPlaceContent::ReviewType, parent) { - QHash<int, QByteArray> roleNames; - roleNames.insert(DateRole, "date"); - roleNames.insert(DescriptionRole, "description"); - roleNames.insert(LanguageRole, "language"); - roleNames.insert(HelpfulVotingsRole, "helpfulVotings"); - roleNames.insert(UnhelpfulVotingsRole, "unhelpfulVotings"); - roleNames.insert(RatingRole, "rating"); - roleNames.insert(MediaIdsRole, "mediaIds"); - roleNames.insert(ReviewIdRole, "reviewId"); - roleNames.insert(SupplierRole, "supplier"); - roleNames.insert(TitleRole, "title"); - roleNames.insert(UserIdRole, "userId"); - roleNames.insert(UserNameRole, "userName"); - roleNames.insert(OriginatorUrlRole, "originatorUrl"); - setRoleNames(roleNames); + QHash<int, QByteArray> roles = roleNames(); + roles.insert(DateTimeRole, "dateTime"); + roles.insert(ContentRole, "content"); + roles.insert(LanguageRole, "language"); + roles.insert(RatingRole, "rating"); + roles.insert(ReviewIdRole, "reviewId"); + roles.insert(TitleRole, "title"); + setRoleNames(roles); } QDeclarativeReviewModel::~QDeclarativeReviewModel() @@ -173,30 +167,18 @@ QVariant QDeclarativeReviewModel::data(const QModelIndex &index, int role) const const QPlaceReview &review = m_content.value(index.row()); switch (role) { - case DateRole: - return review.date(); - case DescriptionRole: - return review.description(); + case DateTimeRole: + return review.dateTime(); + case ContentRole: + return review.content(); case LanguageRole: return review.language(); - case HelpfulVotingsRole: - return review.helpfulVotings(); - case UnhelpfulVotingsRole: - return review.unhelpfulVotings(); case RatingRole: return review.rating(); - case MediaIdsRole: - return review.mediaIds(); case ReviewIdRole: return review.reviewId(); case TitleRole: return review.title(); - case UserIdRole: - return review.userId(); - case UserNameRole: - return review.userName(); - case OriginatorUrlRole: - return review.originatorUrl(); } return QDeclarativePlaceContentModel::data(index, role); diff --git a/src/imports/location/declarativeplaces/qdeclarativereviewmodel_p.h b/src/imports/location/declarativeplaces/qdeclarativereviewmodel_p.h index 33489531..ec1a42c2 100644 --- a/src/imports/location/declarativeplaces/qdeclarativereviewmodel_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativereviewmodel_p.h @@ -56,18 +56,12 @@ public: QVariant data(const QModelIndex &index, int role) const; enum Roles { - DateRole = UserRole, - DescriptionRole, + DateTimeRole = UserRole, + ContentRole, LanguageRole, - HelpfulVotingsRole, - UnhelpfulVotingsRole, RatingRole, - MediaIdsRole, ReviewIdRole, - TitleRole, - UserIdRole, - UserNameRole, - OriginatorUrlRole + TitleRole }; }; diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp index c6f57ecd..abb44f20 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.cpp @@ -49,8 +49,8 @@ #include <QtLocation/QPlaceSearchReply> QDeclarativeSearchModelBase::QDeclarativeSearchModelBase(QObject *parent) - : QAbstractListModel(parent), m_plugin(0), m_reply(0), m_searchArea(0), - m_complete(false) +: QAbstractListModel(parent), m_plugin(0), m_reply(0), m_searchArea(0), m_complete(false), + m_status(Ready) { } @@ -124,12 +124,21 @@ void QDeclarativeSearchModelBase::setLimit(int limit) emit limitChanged(); } -bool QDeclarativeSearchModelBase::executing() const +QDeclarativeSearchModelBase::Status QDeclarativeSearchModelBase::status() const { - return m_reply; + return m_status; } -void QDeclarativeSearchModelBase::executeQuery() +void QDeclarativeSearchModelBase::setStatus(Status status) +{ + if (m_status == status) + return; + + m_status = status; + emit statusChanged(); +} + +void QDeclarativeSearchModelBase::execute() { if (!m_plugin) { qmlInfo(this) << "plugin not set."; @@ -146,22 +155,24 @@ void QDeclarativeSearchModelBase::executeQuery() return; } - cancelRequest(); + cancel(); updateSearchRequest(); m_reply = sendQuery(placeManager, m_request); - if (!m_reply) + if (!m_reply) { + setStatus(Error); return; + } m_reply->setParent(this); connect(m_reply, SIGNAL(finished()), this, SLOT(queryFinished())); connect(m_reply, SIGNAL(error(QPlaceReply::Error,QString)), this, SLOT(queryError(QPlaceReply::Error,QString))); - emit executingChanged(); + setStatus(Executing); } -void QDeclarativeSearchModelBase::cancelRequest() +void QDeclarativeSearchModelBase::cancel() { if (!m_reply) return; @@ -173,7 +184,12 @@ void QDeclarativeSearchModelBase::cancelRequest() reply->deleteLater(); reply = 0; - emit executingChanged(); + setStatus(Ready); +} + +QString QDeclarativeSearchModelBase::errorString() const +{ + return m_errorString; } void QDeclarativeSearchModelBase::clearData() @@ -219,10 +235,12 @@ void QDeclarativeSearchModelBase::queryFinished() endResetModel(); reply->deleteLater(); - emit executingChanged(); + setStatus(Ready); } void QDeclarativeSearchModelBase::queryError(QPlaceReply::Error error, const QString &errorString) { - qmlInfo(this) << error << errorString; + Q_UNUSED(error) + + m_errorString = errorString; } diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h index 6a8fe139..a4d12f00 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h +++ b/src/imports/location/declarativeplaces/qdeclarativesearchmodelbase.h @@ -66,11 +66,19 @@ class QDeclarativeSearchModelBase : public QAbstractListModel, public QDeclarati Q_PROPERTY(QDeclarativeGeoBoundingArea *searchArea READ searchArea WRITE setSearchArea NOTIFY searchAreaChanged) Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged) Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged) - Q_PROPERTY(bool executing READ executing NOTIFY executingChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + + Q_ENUMS(Status) Q_INTERFACES(QDeclarativeParserStatus) public: + enum Status { + Ready, + Executing, + Error + }; + explicit QDeclarativeSearchModelBase(QObject *parent = 0); ~QDeclarativeSearchModelBase(); @@ -86,9 +94,13 @@ public: int limit() const; void setLimit(int limit); - bool executing() const; - Q_INVOKABLE void executeQuery(); - Q_INVOKABLE void cancelRequest(); + Status status() const; + void setStatus(Status status); + + Q_INVOKABLE void execute(); + Q_INVOKABLE void cancel(); + + Q_INVOKABLE QString errorString() const; virtual void clearData(); virtual void updateSearchRequest(); @@ -103,7 +115,7 @@ signals: void searchAreaChanged(); void offsetChanged(); void limitChanged(); - void executingChanged(); + void statusChanged(); protected: virtual void initializePlugin(QDeclarativeGeoServiceProvider *oldPlugin, @@ -124,7 +136,10 @@ private: QDeclarativeGeoBoundingArea *m_searchArea; + QString m_errorString; + bool m_complete; + Status m_status; }; QT_END_NAMESPACE diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp index 5972dd41..6a85ebfe 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp @@ -59,9 +59,9 @@ QT_USE_NAMESPACE \l searchTerm and \l searchCategory properties can be set to restrict the search results to places matching those criteria. - The \l didYouMean property can be used to limit the maximum number of "did you mean" results - that may be returned. Settings \l didYouMean to 0 will prevent any "did you mean" results from - being returned. + The \l correction property can be used to limit the maximum number of search term correction + results that may be returned. Settings \l correction to 0 will prevent any search term + correction results from being returned. The \l executing property indicates whether a query is currently executing. @@ -77,27 +77,15 @@ QT_USE_NAMESPACE \o SearchResultModel.SearchResultType \o The type of search result. \row - \o relevance - \o real - \o The relevence score of the result. - \row \o distance \o real \o The distance to the place. \row - \o heading - \o real - \o The heading to the place. - \row - \o additionalData - \o - \o Additional data related to the search result. - \row \o place \o Place \o The Place. \row - \o didYouMean + \o correction \o string \o Valid only for did you mean search results, a suggested corrected search term. \endtable @@ -120,7 +108,7 @@ QT_USE_NAMESPACE radius:5000 } - Component.onCompleted: executeQuery() + Component.onCompleted: execute() } ListView { @@ -163,14 +151,14 @@ QT_USE_NAMESPACE */ /*! - \qmlmethod SearchResultModel::executeQuery() + \qmlmethod SearchResultModel::execute() Parameter searchTerm should contain string for which search should be started. Updates the items represented by the model from the underlying proivider. */ /*! - \qmlmethod SearchResultModel::cancelRequest() + \qmlmethod SearchResultModel::cancel() Cancels ongoing request. */ @@ -178,16 +166,12 @@ QT_USE_NAMESPACE QDeclarativeSearchResultModel::QDeclarativeSearchResultModel(QObject *parent) : QDeclarativeSearchModelBase(parent), m_placeManager(0) { - QHash<int, QByteArray> roleNames; - roleNames = QAbstractItemModel::roleNames(); - roleNames.insert(SearchResultType, "type"); - roleNames.insert(SearchResultRelevance, "relevance"); - roleNames.insert(SearchResultDistance, "distance"); - roleNames.insert(SearchResultHeading, "heading"); - roleNames.insert(SearchResultAdditionalData, "additionalData"); - roleNames.insert(SearchResultPlace, "place"); - roleNames.insert(SearchResultDidYouMean, "didYouMean"); - setRoleNames(roleNames); + QHash<int, QByteArray> roles = roleNames(); + roles.insert(SearchResultTypeRole, "type"); + roles.insert(DistanceRole, "distance"); + roles.insert(PlaceRole, "place"); + roles.insert(CorrectionRole, "correction"); + setRoleNames(roles); } QDeclarativeSearchResultModel::~QDeclarativeSearchResultModel() @@ -299,22 +283,22 @@ void QDeclarativeSearchResultModel::setRelevanceHint(QDeclarativeSearchResultMod } /*! - \qmlproperty int SearchResultModel::didYouMean + \qmlproperty int SearchResultModel::maximumCorrections - This element holds maximum number of "did you mean" suggestions returned by search query. + This element holds maximum number of search term corrections that may be returned. */ -int QDeclarativeSearchResultModel::didYouMean() const +int QDeclarativeSearchResultModel::maximumCorrections() const { - return m_request.didYouMeanSuggestionNumber(); + return m_request.maximumCorrections(); } -void QDeclarativeSearchResultModel::setDidYouMean(int didYouMeanSuggestionNumber) +void QDeclarativeSearchResultModel::setMaximumCorrections(int corrections) { - if (m_request.didYouMeanSuggestionNumber() == didYouMeanSuggestionNumber) + if (m_request.maximumCorrections() == corrections) return; - m_request.setDidYouMeanSuggestionNumber(didYouMeanSuggestionNumber); - emit didYouMeanChanged(); + m_request.setMaximumCorrections(corrections); + emit maximumCorrectionsChanged(); } /*! @@ -379,31 +363,25 @@ QVariant QDeclarativeSearchResultModel::data(const QModelIndex &index, int role) const QPlaceSearchResult &result = m_results.at(index.row()); - if (result.type() == QPlaceSearchResult::Place) { + if (result.type() == QPlaceSearchResult::PlaceResult) { switch (role) { case Qt::DisplayRole: return result.place().name(); - case SearchResultType: + case SearchResultTypeRole: return result.type(); - case SearchResultRelevance: - return result.relevance(); - case SearchResultDistance: + case DistanceRole: return result.distance(); - case SearchResultHeading: - return result.heading(); - case SearchResultAdditionalData: - return result.additionalData(); - case SearchResultPlace: + case PlaceRole: return QVariant::fromValue(static_cast<QObject *>(m_places.value(result.place().placeId()))); default: return QVariant(); } - } else if (result.type() == QPlaceSearchResult::DidYouMeanSuggestion) { + } else if (result.type() == QPlaceSearchResult::CorrectionResult) { switch (role) { case Qt::DisplayRole: - case SearchResultDidYouMean: - return result.didYouMeanSuggestion(); - case SearchResultType: + case CorrectionRole: + return result.correction(); + case SearchResultTypeRole: return result.type(); default: return QVariant(); @@ -417,7 +395,7 @@ QPlaceReply *QDeclarativeSearchResultModel::sendQuery(QPlaceManager *manager, const QPlaceSearchRequest &request) { Q_ASSERT(manager); - return manager->searchForPlaces(request); + return manager->search(request); } void QDeclarativeSearchResultModel::initializePlugin(QDeclarativeGeoServiceProvider *oldPlugin, @@ -432,12 +410,9 @@ void QDeclarativeSearchResultModel::initializePlugin(QDeclarativeGeoServiceProvi if (serviceProvider) { QPlaceManager *placeManager = serviceProvider->placeManager(); if (placeManager) { - disconnect(placeManager, SIGNAL(placeAdded(QString)), - this, SLOT(executeQuery())); - disconnect(placeManager, SIGNAL(placeUpdated(QString)), - this, SLOT(executeQuery())); - disconnect(placeManager, SIGNAL(placeRemoved(QString)), - this, SLOT(executeQuery())); + disconnect(placeManager, SIGNAL(placeAdded(QString)), this, SLOT(execute())); + disconnect(placeManager, SIGNAL(placeUpdated(QString)), this, SLOT(execute())); + disconnect(placeManager, SIGNAL(placeRemoved(QString)), this, SLOT(execute())); } } } @@ -448,12 +423,9 @@ void QDeclarativeSearchResultModel::initializePlugin(QDeclarativeGeoServiceProvi if (serviceProvider) { QPlaceManager *placeManager = serviceProvider->placeManager(); if (placeManager) { - connect(placeManager, SIGNAL(placeAdded(QString)), - this, SLOT(executeQuery())); - connect(placeManager, SIGNAL(placeUpdated(QString)), - this, SLOT(executeQuery())); - connect(placeManager, SIGNAL(placeRemoved(QString)), - this, SLOT(executeQuery())); + connect(placeManager, SIGNAL(placeAdded(QString)), this, SLOT(execute())); + connect(placeManager, SIGNAL(placeUpdated(QString)), this, SLOT(execute())); + connect(placeManager, SIGNAL(placeRemoved(QString)), this, SLOT(execute())); } } } diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel_p.h b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel_p.h index d294e5bb..36533baf 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel_p.h @@ -56,21 +56,21 @@ class QDeclarativeSearchResultModel : public QDeclarativeSearchModelBase Q_PROPERTY(QString searchTerm READ searchTerm WRITE setSearchTerm NOTIFY searchTermChanged) Q_PROPERTY(QDeclarativeCategory *searchCategory READ searchCategory WRITE setSearchCategory NOTIFY searchCategoryChanged) - Q_PROPERTY(int didYouMean READ didYouMean WRITE setDidYouMean NOTIFY didYouMeanChanged) + Q_PROPERTY(int maximumCorrections READ maximumCorrections WRITE setMaximumCorrections NOTIFY maximumCorrectionsChanged) Q_PROPERTY(RelevanceHint relevanceHint READ relevanceHint WRITE setRelevanceHint NOTIFY relevanceHintChanged) Q_PROPERTY(QDeclarativePlace::Visibility visibilityScope READ visibilityScope WRITE setVisibilityScope NOTIFY visibilityScopeChanged) - Q_ENUMS(SearchResultType RelevanceHint) + Q_ENUMS(SearchResultTypeRole RelevanceHint) public: - enum SearchResultType { - Place = QPlaceSearchResult::Place, - DidYouMeanSuggestion = QPlaceSearchResult::DidYouMeanSuggestion, + enum SearchResultTypeRole { + PlaceResult = QPlaceSearchResult::PlaceResult, + CorrectionResult = QPlaceSearchResult::CorrectionResult, UnknownSearchResult = QPlaceSearchResult::UnknownSearchResult }; enum RelevanceHint { - NoHint = QPlaceSearchRequest::NoHint, + UnspecifiedHint = QPlaceSearchRequest::UnspecifiedHint, DistanceHint = QPlaceSearchRequest::DistanceHint, LexicalPlaceNameHint = QPlaceSearchRequest::LexicalPlaceNameHint }; @@ -89,8 +89,8 @@ public: QDeclarativeSearchResultModel::RelevanceHint relevanceHint() const; void setRelevanceHint(QDeclarativeSearchResultModel::RelevanceHint hint); - int didYouMean() const; - void setDidYouMean(int dym); + int maximumCorrections() const; + void setMaximumCorrections(int corrections); QDeclarativePlace::Visibility visibilityScope() const; void setVisibilityScope(QDeclarativePlace::Visibility visibilityScope); @@ -103,19 +103,16 @@ public: int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; enum Roles { - SearchResultType = Qt::UserRole, - SearchResultRelevance, - SearchResultDistance, - SearchResultHeading, - SearchResultAdditionalData, - SearchResultPlace, - SearchResultDidYouMean + SearchResultTypeRole = Qt::UserRole, + DistanceRole, + PlaceRole, + CorrectionRole }; signals: void searchTermChanged(); void searchCategoryChanged(); - void didYouMeanChanged(); + void maximumCorrectionsChanged(); void relevanceHintChanged(); void visibilityScopeChanged(); diff --git a/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp index 93a9665f..e0b1e3ec 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp @@ -101,12 +101,10 @@ QT_USE_NAMESPACE QDeclarativeSupportedCategoriesModel::QDeclarativeSupportedCategoriesModel(QObject *parent) : QAbstractItemModel(parent), m_plugin(0), m_hierarchical(true), m_complete(false) { - QHash<int, QByteArray> roleNames; - roleNames = QAbstractItemModel::roleNames(); - roleNames.insert(CategoryRole, "category"); - roleNames.insert(CategoryIdRole, "categoryId"); - roleNames.insert(NameRole, "name"); - setRoleNames(roleNames); + QHash<int, QByteArray> roles = roleNames(); + roles = QAbstractItemModel::roleNames(); + roles.insert(CategoryRole, "category"); + setRoleNames(roles); } QDeclarativeSupportedCategoriesModel::~QDeclarativeSupportedCategoriesModel() @@ -182,12 +180,9 @@ QVariant QDeclarativeSupportedCategoriesModel::data(const QModelIndex &index, in switch (role) { case Qt::DisplayRole: - case NameRole: return category->name(); case CategoryRole: return QVariant::fromValue(category); - case CategoryIdRole: - return category->categoryId(); default: return QVariant(); } @@ -269,7 +264,7 @@ void QDeclarativeSupportedCategoriesModel::setHierarchical(bool hierarchical) m_hierarchical = hierarchical; emit hierarchicalChanged(); - updateCategories(); + update(); } bool QDeclarativeSupportedCategoriesModel::hierarchical() const @@ -288,7 +283,7 @@ void QDeclarativeSupportedCategoriesModel::replyFinished() m_response->deleteLater(); m_response = 0; - updateCategories(); + update(); setStatus(QDeclarativeSupportedCategoriesModel::Ready); } else { m_errorString = m_response->errorString(); @@ -318,7 +313,7 @@ void QDeclarativeSupportedCategoriesModel::addedCategory(const QPlaceCategory &c beginInsertRows(parentIndex, rowToBeAdded, rowToBeAdded); PlaceCategoryNode *categoryNode = new PlaceCategoryNode; categoryNode->parentId = parentId; - categoryNode->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(category, this)); + categoryNode->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(category)); m_categoriesTree.insert(category.categoryId(), categoryNode); parentNode->childIds.insert(rowToBeAdded,category.categoryId()); endInsertRows(); @@ -447,7 +442,7 @@ void QDeclarativeSupportedCategoriesModel::removeCategory(const QModelIndex &ind placeManager->removeCategory(node->declCategory->category().categoryId()); } -void QDeclarativeSupportedCategoriesModel::updateCategories() +void QDeclarativeSupportedCategoriesModel::update() { if (!m_plugin) return; @@ -468,8 +463,8 @@ void QDeclarativeSupportedCategoriesModel::updateCategories() PlaceCategoryNode *node = new PlaceCategoryNode; node->childIds = populateCategories(placeManager, QPlaceCategory()); m_categoriesTree.insert(QString(), node); - node->declCategory = QSharedPointer<QDeclarativeCategory> - (new QDeclarativeCategory(QPlaceCategory(), this)); + node->declCategory = + QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(QPlaceCategory())); endResetModel(); } @@ -524,7 +519,7 @@ QStringList QDeclarativeSupportedCategoriesModel::populateCategories(QPlaceManag iter.next(); node = new PlaceCategoryNode; node->parentId = parent.categoryId(); - node->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(iter.value(), this)); + node->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(iter.value())); if (m_hierarchical) node->childIds = populateCategories(manager, iter.value()); diff --git a/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel_p.h b/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel_p.h index fc7b8fd9..9868a9af 100644 --- a/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel_p.h @@ -97,12 +97,8 @@ public: Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const; - // Roles for exposing data via model. Only one role because - // everything can be accessed via QDeclarativeCategory enum Roles { - CategoryRole = Qt::UserRole, - CategoryIdRole, - NameRole + CategoryRole = Qt::UserRole }; enum Status {Ready, Saving, Updating, Removing, Error}; @@ -113,10 +109,9 @@ public: void setHierarchical(bool hierarchical); bool hierarchical() const; - Q_INVOKABLE void saveCategory(const QVariantMap &categoryMap, - const QString &parentId); + Q_INVOKABLE void saveCategory(const QVariantMap &categoryMap, const QString &parentId); Q_INVOKABLE void removeCategory(const QModelIndex &index); - Q_INVOKABLE void updateCategories(); + Q_INVOKABLE void update(); Q_INVOKABLE QString errorString() const; Status status() const; diff --git a/src/imports/location/declarativeplaces/qdeclarativetextpredictionmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativetextpredictionmodel.cpp index 4da30ff8..e4a63d34 100644 --- a/src/imports/location/declarativeplaces/qdeclarativetextpredictionmodel.cpp +++ b/src/imports/location/declarativeplaces/qdeclarativetextpredictionmodel.cpp @@ -131,14 +131,14 @@ QT_USE_NAMESPACE */ /*! - \qmlmethod TextPredictionModel::executeQuery() + \qmlmethod TextPredictionModel::execute() Parameter searchTerm should contain string for which suggestion search should be started. Updates the items represented by the model from the underlying provider. */ /*! - \qmlmethod TextPredictionModel::cancelRequest() + \qmlmethod TextPredictionModel::cancel() Cancels ongoing request. */ @@ -180,7 +180,7 @@ void QDeclarativeTextPredictionModel::setSearchTerm(const QString &searchTerm) This element holds the list of string that the model currently has. */ -QStringList QDeclarativeTextPredictionModel::predictions() const +QStringList QDeclarativeTextPredictionModel::textPredictions() const { return m_predictions; } @@ -199,7 +199,7 @@ void QDeclarativeTextPredictionModel::processReply(QPlaceReply *reply) { QPlaceTextPredictionReply *predictionReply = qobject_cast<QPlaceTextPredictionReply *>(reply); m_predictions = predictionReply->textPredictions(); - emit predictionsChanged(); + emit textPredictionsChanged(); } int QDeclarativeTextPredictionModel::rowCount(const QModelIndex& parent) const diff --git a/src/imports/location/declarativeplaces/qdeclarativetextpredictionmodel_p.h b/src/imports/location/declarativeplaces/qdeclarativetextpredictionmodel_p.h index 37796008..6028bc2a 100644 --- a/src/imports/location/declarativeplaces/qdeclarativetextpredictionmodel_p.h +++ b/src/imports/location/declarativeplaces/qdeclarativetextpredictionmodel_p.h @@ -44,6 +44,8 @@ #include "qdeclarativesearchmodelbase.h" +#include <QtCore/QStringList> + QT_BEGIN_NAMESPACE class QDeclarativeGeoServiceProvider; @@ -54,7 +56,7 @@ class QDeclarativeTextPredictionModel : public QDeclarativeSearchModelBase Q_OBJECT Q_PROPERTY(QString searchTerm READ searchTerm WRITE setSearchTerm NOTIFY searchTermChanged) - Q_PROPERTY(QStringList predictions READ predictions NOTIFY predictionsChanged) + Q_PROPERTY(QStringList textPredictions READ textPredictions NOTIFY textPredictionsChanged) public: explicit QDeclarativeTextPredictionModel(QObject *parent = 0); @@ -63,7 +65,7 @@ public: QString searchTerm() const; void setSearchTerm(const QString &searchTerm); - QStringList predictions() const; + QStringList textPredictions() const; void clearData(); void updateSearchRequest(); @@ -78,7 +80,7 @@ public: signals: void searchTermChanged(); - void predictionsChanged(); + void textPredictionsChanged(); protected: QPlaceReply *sendQuery(QPlaceManager *manager, const QPlaceSearchRequest &request); diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp index c4cfb78a..44ca63fc 100644 --- a/src/imports/location/location.cpp +++ b/src/imports/location/location.cpp @@ -127,15 +127,15 @@ public: qmlRegisterType<QDeclarativeCategory>(uri, 5, 0, "Category"); qmlRegisterType<QDeclarativePlaceEditorialModel>(uri, 5, 0, "EditorialModel"); qmlRegisterType<QDeclarativeGeoLocation>(uri, 5, 0, "Location"); - qmlRegisterType<QDeclarativePlaceImageModel>(uri, 5, 0, "PlaceImageModel"); + qmlRegisterType<QDeclarativePlaceImageModel>(uri, 5, 0, "ImageModel"); qmlRegisterType<QDeclarativePlace>(uri, 5, 0, "Place"); qmlRegisterType<QDeclarativeRating>(uri, 5, 0, "Rating"); qmlRegisterType<QDeclarativeReviewModel>(uri, 5, 0, "ReviewModel"); qmlRegisterType<QDeclarativeSupplier>(uri, 5, 0, "Supplier"); qmlRegisterType<QDeclarativeRecommendationModel>(uri, 5, 0, "RecommendationModel"); - qmlRegisterType<QDeclarativeSupportedCategoriesModel>(uri, 5, 0, "SupportedCategoriesModel"); - qmlRegisterType<QDeclarativeSearchResultModel>(uri, 5, 0, "SearchResultModel"); + qmlRegisterType<QDeclarativeSupportedCategoriesModel>(uri, 5, 0, "CategoriesModel"); + qmlRegisterType<QDeclarativeSearchResultModel>(uri, 5, 0, "PlaceSearchModel"); qmlRegisterType<QDeclarativeTextPredictionModel>(uri, 5, 0, "TextPredictionModel"); qmlRegisterType<QDeclarativePropertyMap>(uri, 5,0,"ExtendedAttributes"); qmlRegisterType<QDeclarativePlaceAttribute>(uri, 5,0, "PlaceAttribute"); diff --git a/src/imports/location/qdeclarativegeolocation.cpp b/src/imports/location/qdeclarativegeolocation.cpp index 676cd56f..87cf4c18 100644 --- a/src/imports/location/qdeclarativegeolocation.cpp +++ b/src/imports/location/qdeclarativegeolocation.cpp @@ -65,7 +65,7 @@ QDeclarativeGeoLocation::QDeclarativeGeoLocation(const QGeoLocation &src, : QObject(parent), m_address(src.address()), m_coordinate(src.coordinate()), - m_boundingBox(src.viewport()), + m_boundingBox(src.boundingBox()), m_src(src) { } @@ -90,8 +90,8 @@ void QDeclarativeGeoLocation::setLocation(const QGeoLocation &src) if (previous.locationId() != m_src.locationId()) { emit locationIdChanged(); } - if (previous.viewport() != m_src.viewport()) { - emit viewport(); + if (previous.boundingBox() != m_src.boundingBox()) { + emit boundingBox(); } } @@ -99,7 +99,7 @@ QGeoLocation QDeclarativeGeoLocation::location() { m_src.setAddress(m_address.address()); m_src.setCoordinate(m_coordinate.coordinate()); - m_src.setViewport(m_boundingBox.box()); + m_src.setBoundingBox(m_boundingBox.box()); return m_src; } @@ -163,23 +163,24 @@ QString QDeclarativeGeoLocation::locationId() const } /*! - \qmlproperty BoundingBox Location::viewport + \qmlproperty BoundingBox Location::boundingBox This property holds bouding box of area on map ocupied by location. Note: this property's changed() signal is currently emitted only if the whole element changes, not if only the contents of the element change. */ -void QDeclarativeGeoLocation::setViewport(QDeclarativeGeoBoundingBox *viewport) +void QDeclarativeGeoLocation::setBoundingBox(QDeclarativeGeoBoundingBox *boundingBox) { - if (m_src.viewport() != viewport->box()) { - m_boundingBox.setBox(viewport->box()); - m_src.setViewport(viewport->box()); - emit viewportChanged(); - } + if (m_src.boundingBox() == boundingBox->box()) + return; + + m_boundingBox.setBox(boundingBox->box()); + m_src.setBoundingBox(boundingBox->box()); + emit boundingBoxChanged(); } -QDeclarativeGeoBoundingBox *QDeclarativeGeoLocation::viewport() +QDeclarativeGeoBoundingBox *QDeclarativeGeoLocation::boundingBox() { return &m_boundingBox; } diff --git a/src/imports/location/qdeclarativegeolocation_p.h b/src/imports/location/qdeclarativegeolocation_p.h index a9650d5b..7a1ade44 100644 --- a/src/imports/location/qdeclarativegeolocation_p.h +++ b/src/imports/location/qdeclarativegeolocation_p.h @@ -58,7 +58,7 @@ class QDeclarativeGeoLocation : public QObject Q_PROPERTY(QDeclarativeGeoAddress* address READ address WRITE setAddress NOTIFY addressChanged); Q_PROPERTY(QDeclarativeCoordinate* coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged); Q_PROPERTY(QString locationId READ locationId WRITE setLocationId NOTIFY locationIdChanged); - Q_PROPERTY(QDeclarativeGeoBoundingBox* viewport READ viewport WRITE setViewport NOTIFY viewportChanged); + Q_PROPERTY(QDeclarativeGeoBoundingBox *boundingBox READ boundingBox WRITE setBoundingBox NOTIFY boundingBoxChanged) public: explicit QDeclarativeGeoLocation(QObject* parent = 0); @@ -74,14 +74,15 @@ public: void setCoordinate(QDeclarativeCoordinate *coordinate); QString locationId() const; void setLocationId(const QString &locationId); - QDeclarativeGeoBoundingBox *viewport(); - void setViewport(QDeclarativeGeoBoundingBox *boundingBox); + + QDeclarativeGeoBoundingBox *boundingBox(); + void setBoundingBox(QDeclarativeGeoBoundingBox *boundingBox); signals: void addressChanged(); void coordinateChanged(); void locationIdChanged(); - void viewportChanged(); + void boundingBoxChanged(); private: QDeclarativeGeoAddress m_address; diff --git a/src/location/location.pro b/src/location/location.pro index f4f5b43a..4a8841b8 100644 --- a/src/location/location.pro +++ b/src/location/location.pro @@ -187,4 +187,3 @@ simulator { INCLUDEPATH += ../mobilitysimulator qtAddLibrary(QtMobilitySimulator) } - diff --git a/src/location/places/placemacro.h b/src/location/places/placemacro.h index 28e60914..09de78f4 100644 --- a/src/location/places/placemacro.h +++ b/src/location/places/placemacro.h @@ -65,12 +65,11 @@ QT_MODULE(Location) #define Q_IMPLEMENT_COPY_CTOR(Class, BaseClass) \ Class::Class(const BaseClass& other) : BaseClass() { Class##Private::copyIfPossible(d_ptr, other); } -#define Q_DEFINE_PRIVATE_HELPER(Class, BaseClass, ClassType, basename) \ +#define Q_DEFINE_PRIVATE_HELPER(Class, BaseClass, ClassType) \ BaseClass##Private* clone() const { return new Class##Private(*this); } \ - virtual BaseClass::Type type() const {return ClassType;} \ static void copyIfPossible(QSharedDataPointer<BaseClass##Private>& d_ptr, const BaseClass &other) \ { \ - if (other.basename##Type() == ClassType) \ + if (other.type() == ClassType) \ d_ptr = extract_d(other); \ else \ d_ptr = new Class##Private; \ diff --git a/src/location/places/places.pri b/src/location/places/places.pri index faad2d1d..8ac97180 100644 --- a/src/location/places/places.pri +++ b/src/location/places/places.pri @@ -35,7 +35,6 @@ PRIVATE_HEADERS += \ places/qplacecontent_p.h \ places/qplaceeditorial_p.h \ places/qplaceimage_p.h \ - places/qplaceperiod_p.h \ places/qplacerating_p.h \ places/qplacereview_p.h \ places/qplacesupplier_p.h \ diff --git a/src/location/places/qplaceattribute.cpp b/src/location/places/qplaceattribute.cpp index d4112f22..b0c1f674 100644 --- a/src/location/places/qplaceattribute.cpp +++ b/src/location/places/qplaceattribute.cpp @@ -66,20 +66,6 @@ bool QPlaceAttributePrivate::operator== (const QPlaceAttributePrivate &other) co } /*! - \variable QPlaceAttribute::OpeningNote - The key for the attribute that holds special instructions during opening hours - e.g. "use buzzer for entry" -*/ -Q_DEFINE_LATIN1_CONSTANT(QPlaceAttribute::OpeningNote, "openingNote"); - -/*! - \variable QPlaceAttribute::PaymentMethods - The key for the attribute that holds accepted payment methods such - as visa or mastercard. -*/ -Q_DEFINE_LATIN1_CONSTANT(QPlaceAttribute::PaymentMethods, "paymentMethods"); - -/*! \class QPlaceAttribute \brief The QPlaceAttribute class represents generic attribute information about a place. \inmodule QtLocation diff --git a/src/location/places/qplaceattribute.h b/src/location/places/qplaceattribute.h index 785a3319..cd39964d 100644 --- a/src/location/places/qplaceattribute.h +++ b/src/location/places/qplaceattribute.h @@ -58,14 +58,6 @@ class QPlaceAttributePrivate; class Q_LOCATION_EXPORT QPlaceAttribute { public: -#ifdef Q_QDOC - static const QLatin1Constant OpeningNote; - static const QLatin1Constant PaymentMethods; -#else - Q_DECLARE_LATIN1_CONSTANT(OpeningNote, "openingNote"); - Q_DECLARE_LATIN1_CONSTANT(PaymentMethods, "paymentMethods"); -#endif - QPlaceAttribute(); QPlaceAttribute(const QPlaceAttribute &other); virtual ~QPlaceAttribute(); diff --git a/src/location/places/qplacecontent.cpp b/src/location/places/qplacecontent.cpp index cab1d9f5..db4c5618 100644 --- a/src/location/places/qplacecontent.cpp +++ b/src/location/places/qplacecontent.cpp @@ -42,6 +42,8 @@ #include "qplacecontent.h" #include "qplacecontent_p.h" +#include <QtCore/QUrl> + #if !defined(Q_CC_MWERKS) template<> QT_PREPEND_NAMESPACE(QPlaceContentPrivate) *QSharedDataPointer<QT_PREPEND_NAMESPACE(QPlaceContentPrivate)>::clone() { @@ -51,6 +53,16 @@ template<> QT_PREPEND_NAMESPACE(QPlaceContentPrivate) *QSharedDataPointer<QT_PRE QT_USE_NAMESPACE +inline QPlaceContentPrivate *QPlaceContent::d_func() +{ + return static_cast<QPlaceContentPrivate *>(d_ptr.data()); +} + +inline const QPlaceContentPrivate *QPlaceContent::d_func() const +{ + return static_cast<const QPlaceContentPrivate *>(d_ptr.constData()); +} + /* Constructs an empty content object */ QPlaceContent::QPlaceContent() :d_ptr(0) @@ -114,17 +126,83 @@ bool QPlaceContent::operator!=(const QPlaceContent &other) const return !(*this == other); } +/*! + Returns the supplier of the content. +*/ QPlaceSupplier QPlaceContent::supplier() const { - return d_ptr->supplier; + Q_D(const QPlaceContent); + + return d->supplier; } +/*! + Sets the supplier of the content to \a supplier. +*/ void QPlaceContent::setSupplier(const QPlaceSupplier &supplier) { - d_ptr->supplier = supplier; + Q_D(QPlaceContent); + + d->supplier = supplier; } /*! + Returns the source url of the content. +*/ +QUrl QPlaceContent::sourceUrl() const +{ + Q_D(const QPlaceContent); + + return d->sourceUrl; +} + +/*! + Sets source url of the content to \a url. +*/ +void QPlaceContent::setSourceUrl(const QUrl &url) +{ + Q_D(QPlaceContent); + d->sourceUrl = url; +} + +/*! + Returns user id of the user who contributed this content. +*/ +QString QPlaceContent::userId() const +{ + Q_D(const QPlaceContent); + return d->userId; +} + +/*! + Sets user id to \a id. +*/ +void QPlaceContent::setUserId(const QString &id) +{ + Q_D(QPlaceContent); + d->userId = id; +} + +/*! + Returns user name of the user who contributed this content. +*/ +QString QPlaceContent::userName() const +{ + Q_D(const QPlaceContent); + return d->userName; +} + +/*! + Sets user name to \a name. +*/ +void QPlaceContent::setUserName(const QString &name) +{ + Q_D(QPlaceContent); + d->userName = name; +} + + +/*! \internal Constructs a new content object from the given pointer \a d. */ diff --git a/src/location/places/qplacecontent.h b/src/location/places/qplacecontent.h index d7d598b6..567d4467 100644 --- a/src/location/places/qplacecontent.h +++ b/src/location/places/qplacecontent.h @@ -87,9 +87,22 @@ public: QPlaceSupplier supplier() const; void setSupplier(const QPlaceSupplier &supplier); + QUrl sourceUrl() const; + void setSourceUrl(const QUrl &url); + + QString userId() const; + void setUserId(const QString &id); + QString userName() const; + void setUserName(const QString &name); + protected: explicit QPlaceContent(QPlaceContentPrivate *d); QSharedDataPointer<QPlaceContentPrivate> d_ptr; + +private: + inline QPlaceContentPrivate *d_func(); + inline const QPlaceContentPrivate *d_func() const; + friend class QPlaceContentPrivate; }; diff --git a/src/location/places/qplacecontent_p.h b/src/location/places/qplacecontent_p.h index eb1c0764..15ae2968 100644 --- a/src/location/places/qplacecontent_p.h +++ b/src/location/places/qplacecontent_p.h @@ -56,8 +56,9 @@ #include "qplacecontent.h" #include "qplacesupplier.h" -#include <QSharedData> -#include <QString> +#include <QtCore/QSharedData> +#include <QtCore/QString> +#include <QtCore/QUrl> QT_BEGIN_NAMESPACE @@ -94,6 +95,9 @@ public: static const QSharedDataPointer<QPlaceContentPrivate>& extract_d(const QPlaceContent& other) {return other.d_ptr;} QPlaceSupplier supplier; + QUrl sourceUrl; + QString userId; + QString userName; }; #if defined(Q_CC_MWERKS) diff --git a/src/location/places/qplacecontentreply.h b/src/location/places/qplacecontentreply.h index c549a8e7..cb45981e 100644 --- a/src/location/places/qplacecontentreply.h +++ b/src/location/places/qplacecontentreply.h @@ -56,7 +56,7 @@ class Q_LOCATION_EXPORT QPlaceContentReply : public QPlaceReply { Q_OBJECT public: - QPlaceContentReply(QObject *parent =0); + explicit QPlaceContentReply(QObject *parent = 0); virtual ~QPlaceContentReply(); QPlaceReply::Type type() const; diff --git a/src/location/places/qplacecontentrequest.cpp b/src/location/places/qplacecontentrequest.cpp index f51287dd..e439ecd7 100644 --- a/src/location/places/qplacecontentrequest.cpp +++ b/src/location/places/qplacecontentrequest.cpp @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE QPlaceContentRequestPrivate::QPlaceContentRequestPrivate() - : QPlaceRequestPrivate(), contentType(QPlaceContent::InvalidType) +: QPlaceRequestPrivate(QPlaceRequest::ContentRequest), contentType(QPlaceContent::InvalidType) { } @@ -63,8 +63,7 @@ QPlaceContentRequestPrivate::QPlaceContentRequestPrivate(const QPlaceContentRequ bool QPlaceContentRequestPrivate::compare(const QPlaceRequestPrivate *other) const { const QPlaceContentRequestPrivate *od = static_cast<const QPlaceContentRequestPrivate *>(other); - return (QPlaceRequestPrivate::compare(other) - && this->contentType ==od->contentType); + return contentType == od->contentType && QPlaceRequestPrivate::compare(other); } void QPlaceContentRequestPrivate::clear() diff --git a/src/location/places/qplacecontentrequest.h b/src/location/places/qplacecontentrequest.h index ea12ee84..06040790 100644 --- a/src/location/places/qplacecontentrequest.h +++ b/src/location/places/qplacecontentrequest.h @@ -61,8 +61,7 @@ class Q_LOCATION_EXPORT QPlaceContentRequest : public QPlaceRequest public: QPlaceContentRequest(); Q_DECLARE_COPY_CTOR(QPlaceContentRequest, QPlaceRequest) - - virtual ~QPlaceContentRequest(); + ~QPlaceContentRequest(); QPlaceContent::Type contentType() const; void setContentType(QPlaceContent::Type type); diff --git a/src/location/places/qplacecontentrequest_p.h b/src/location/places/qplacecontentrequest_p.h index 896dee8c..0795b3fe 100644 --- a/src/location/places/qplacecontentrequest_p.h +++ b/src/location/places/qplacecontentrequest_p.h @@ -56,7 +56,7 @@ public: ~QPlaceContentRequestPrivate(); bool compare(const QPlaceRequestPrivate *other) const; - Q_DEFINE_PRIVATE_HELPER(QPlaceContentRequest, QPlaceRequest, QPlaceRequest::ContentType, request) + Q_DEFINE_PRIVATE_HELPER(QPlaceContentRequest, QPlaceRequest, QPlaceRequest::ContentRequest) void clear(); QPlaceContent::Type contentType; diff --git a/src/location/places/qplacedetailsreply.cpp b/src/location/places/qplacedetailsreply.cpp index 36fcccf3..b45fde43 100644 --- a/src/location/places/qplacedetailsreply.cpp +++ b/src/location/places/qplacedetailsreply.cpp @@ -86,13 +86,13 @@ QPlaceDetailsReply::~QPlaceDetailsReply() */ QPlaceReply::Type QPlaceDetailsReply::type() const { - return QPlaceReply::PlaceDetailsReply; + return QPlaceReply::DetailsReply; } /*! Returns a place result */ -QPlace QPlaceDetailsReply::result() const +QPlace QPlaceDetailsReply::place() const { Q_D(const QPlaceDetailsReply); return d->result; @@ -101,7 +101,7 @@ QPlace QPlaceDetailsReply::result() const /*! Sets the \a place */ -void QPlaceDetailsReply::setResult(const QPlace &place) +void QPlaceDetailsReply::setPlace(const QPlace &place) { Q_D(QPlaceDetailsReply); d->result = place; diff --git a/src/location/places/qplacedetailsreply.h b/src/location/places/qplacedetailsreply.h index eed7b618..52bbf343 100644 --- a/src/location/places/qplacedetailsreply.h +++ b/src/location/places/qplacedetailsreply.h @@ -56,15 +56,16 @@ class Q_LOCATION_EXPORT QPlaceDetailsReply : public QPlaceReply { Q_OBJECT public: - QPlaceDetailsReply(QObject *parent =0); + explicit QPlaceDetailsReply(QObject *parent = 0); virtual ~QPlaceDetailsReply(); QPlaceReply::Type type() const; - QPlace result() const; + QPlace place() const; protected: - void setResult(const QPlace &result); + void setPlace(const QPlace &place); + private: Q_DISABLE_COPY(QPlaceDetailsReply) Q_DECLARE_PRIVATE(QPlaceDetailsReply) diff --git a/src/location/places/qplaceeditorial.cpp b/src/location/places/qplaceeditorial.cpp index 1cd006af..e2394f54 100644 --- a/src/location/places/qplaceeditorial.cpp +++ b/src/location/places/qplaceeditorial.cpp @@ -51,7 +51,7 @@ QPlaceEditorialPrivate::QPlaceEditorialPrivate() QPlaceEditorialPrivate::QPlaceEditorialPrivate(const QPlaceEditorialPrivate &other) : QPlaceContentPrivate(), content(other.content), contentTitle(other.contentTitle), - supplier(other.supplier), sourceUrl(other.sourceUrl), language(other.language) + language(other.language) { } @@ -139,42 +139,6 @@ void QPlaceEditorial::setTitle(const QString &data) } /*! - Returns supplier. Do not remove it. -*/ -QPlaceSupplier QPlaceEditorial::supplier() const -{ - Q_D(const QPlaceEditorial); - return d->supplier; -} - -/*! - Sets supplier. -*/ -void QPlaceEditorial::setSupplier(const QPlaceSupplier &data) -{ - Q_D(QPlaceEditorial); - d->supplier = data; -} - -/*! - Returns source url. -*/ -QUrl QPlaceEditorial::sourceUrl() const -{ - Q_D(const QPlaceEditorial); - return d->sourceUrl; -} - -/*! - Sets source url. -*/ -void QPlaceEditorial::setSourceUrl(const QUrl &data) -{ - Q_D(QPlaceEditorial); - d->sourceUrl = data; -} - -/*! Returns language. */ QString QPlaceEditorial::language() const diff --git a/src/location/places/qplaceeditorial.h b/src/location/places/qplaceeditorial.h index 28d66f71..a6df4c02 100644 --- a/src/location/places/qplaceeditorial.h +++ b/src/location/places/qplaceeditorial.h @@ -64,10 +64,6 @@ public: void setContent(const QString &data); QString title() const; void setTitle(const QString &data); - QPlaceSupplier supplier() const; - void setSupplier(const QPlaceSupplier &data); - QUrl sourceUrl() const; - void setSourceUrl(const QUrl &data); QString language() const; void setLanguage(const QString &data); diff --git a/src/location/places/qplaceeditorial_p.h b/src/location/places/qplaceeditorial_p.h index 0ba6993d..6aeee4c1 100644 --- a/src/location/places/qplaceeditorial_p.h +++ b/src/location/places/qplaceeditorial_p.h @@ -63,8 +63,6 @@ public: QString content; QString contentTitle; - QPlaceSupplier supplier; - QUrl sourceUrl; QString language; }; diff --git a/src/location/places/qplaceidreply.h b/src/location/places/qplaceidreply.h index f3512f48..54bd4a22 100644 --- a/src/location/places/qplaceidreply.h +++ b/src/location/places/qplaceidreply.h @@ -64,8 +64,7 @@ public: RemoveCategory }; - QPlaceIdReply(OperationType operationType, - QObject *parent =0); + explicit QPlaceIdReply(OperationType operationType, QObject *parent = 0); virtual ~QPlaceIdReply(); QPlaceReply::Type type() const; diff --git a/src/location/places/qplaceimage.cpp b/src/location/places/qplaceimage.cpp index 0f72c139..101d6a23 100644 --- a/src/location/places/qplaceimage.cpp +++ b/src/location/places/qplaceimage.cpp @@ -51,12 +51,9 @@ QPlaceImagePrivate::QPlaceImagePrivate() : QPlaceContentPrivate() QPlaceImagePrivate::QPlaceImagePrivate(const QPlaceImagePrivate &other) : QPlaceContentPrivate(other) { - this->url = other.url; - this->thumbnailUrl = other.thumbnailUrl; - this->id = other.id; - this->metaInfo = other.metaInfo; - this->mimeType = other.mimeType; - this->supplier = other.supplier; + url = other.url; + id = other.id; + mimeType = other.mimeType; } QPlaceImagePrivate::~QPlaceImagePrivate() @@ -66,13 +63,7 @@ QPlaceImagePrivate::~QPlaceImagePrivate() bool QPlaceImagePrivate::compare(const QPlaceContentPrivate *other) const { const QPlaceImagePrivate *od = static_cast<const QPlaceImagePrivate *>(other); - return (this->url == od->url - && this->thumbnailUrl == od->thumbnailUrl - && this->id == od->id - && this->metaInfo == od->metaInfo - && this->mimeType == od->mimeType - && this->supplier == od->supplier - ); + return url == od->url && id == od->id && mimeType == od->mimeType; } /*! @@ -127,27 +118,9 @@ void QPlaceImage::setUrl(const QUrl &url) } /*! - Returns the thumbnail url. -*/ -QUrl QPlaceImage::thumbnailUrl() const -{ - Q_D(const QPlaceImage); - return d->thumbnailUrl; -} - -/*! - Sets the thumbnail \a url. -*/ -void QPlaceImage::setThumbnailUrl(const QUrl &url) -{ - Q_D(QPlaceImage); - d->thumbnailUrl = url; -} - -/*! Returns image id. */ -QString QPlaceImage::id() const +QString QPlaceImage::imageId() const { Q_D(const QPlaceImage); return d->id; @@ -156,31 +129,13 @@ QString QPlaceImage::id() const /*! Sets image id. */ -void QPlaceImage::setId(const QString &data) +void QPlaceImage::setImageId(const QString &data) { Q_D(QPlaceImage); d->id = data; } /*! - Returns image meta info. -*/ -QString QPlaceImage::metaInfo() const -{ - Q_D(const QPlaceImage); - return d->metaInfo; -} - -/*! - Sets image meta info. -*/ -void QPlaceImage::setMetaInfo(const QString &data) -{ - Q_D(QPlaceImage); - d->metaInfo = data; -} - -/*! Returns image mime type. */ QString QPlaceImage::mimeType() const diff --git a/src/location/places/qplaceimage.h b/src/location/places/qplaceimage.h index 3ca25756..72949b9b 100644 --- a/src/location/places/qplaceimage.h +++ b/src/location/places/qplaceimage.h @@ -66,12 +66,10 @@ public: QUrl url() const; void setUrl(const QUrl &url); - QUrl thumbnailUrl() const; - void setThumbnailUrl(const QUrl &url); - QString id() const; - void setId(const QString &data); - QString metaInfo() const; - void setMetaInfo(const QString &data); + + QString imageId() const; + void setImageId(const QString &id); + QString mimeType() const; void setMimeType(const QString &data); diff --git a/src/location/places/qplaceimage_p.h b/src/location/places/qplaceimage_p.h index 91aae8d4..19e1a4a4 100644 --- a/src/location/places/qplaceimage_p.h +++ b/src/location/places/qplaceimage_p.h @@ -63,9 +63,7 @@ public: Q_DEFINE_CONTENT_PRIVATE_HELPER(QPlaceImage, QPlaceContent::ImageType) QUrl url; - QUrl thumbnailUrl; QString id; - QString metaInfo; QString mimeType; }; diff --git a/src/location/places/qplacemanager.cpp b/src/location/places/qplacemanager.cpp index d21973ef..69aa3150 100644 --- a/src/location/places/qplacemanager.cpp +++ b/src/location/places/qplacemanager.cpp @@ -153,19 +153,11 @@ QPlaceContentReply *QPlaceManager::getContent(const QPlace &place, const QPlaceC } /*! - Posts a \a rating to a \a place. -*/ -QPlaceReply* QPlaceManager::postRating(const QString &placeId, qreal rating) -{ - return d->postRating(placeId, rating); -} - -/*! Searches for places according to a given \a request. */ -QPlaceSearchReply *QPlaceManager::searchForPlaces(const QPlaceSearchRequest &request) const +QPlaceSearchReply *QPlaceManager::search(const QPlaceSearchRequest &request) const { - return d->searchForPlaces(request); + return d->search(request); } /*! diff --git a/src/location/places/qplacemanager.h b/src/location/places/qplacemanager.h index 9006c0a0..2840a86b 100644 --- a/src/location/places/qplacemanager.h +++ b/src/location/places/qplacemanager.h @@ -71,20 +71,13 @@ class Q_LOCATION_EXPORT QPlaceManager : public QObject Q_OBJECT public: enum ManagerFeature { - ImportFeature, - ExportFeature, - CheckInFeature, - PostRatingFeature, SuggestionFeature, - ReportPlaceFeature, AuthenticationFeature, - CreatePlaceFeature, - UpdatePlaceFeature - }; - - enum Error { - NoError, - NotSupportedError + PlaceEditingFeature, + SavePlaceFeature, + SaveCategoryFeature, + RecommendationsFeature, + LocaleFeature }; ~QPlaceManager(); @@ -93,11 +86,10 @@ public: int managerVersion() const; QPlaceDetailsReply *getPlaceDetails(const QString &placeId) const; - QPlaceReply *postRating(const QString &placeId, qreal value); QPlaceContentReply *getContent(const QPlace &place, const QPlaceContentRequest &request) const; - QPlaceSearchReply *searchForPlaces(const QPlaceSearchRequest &query) const; + QPlaceSearchReply *search(const QPlaceSearchRequest &query) const; QPlaceSearchReply *recommendations(const QPlace &place, const QPlaceSearchRequest &request) const; diff --git a/src/location/places/qplacemanagerengine.h b/src/location/places/qplacemanagerengine.h index ec6c6a8a..251afb9c 100644 --- a/src/location/places/qplacemanagerengine.h +++ b/src/location/places/qplacemanagerengine.h @@ -67,9 +67,7 @@ public: virtual QPlaceContentReply *getContent(const QPlace &place, const QPlaceContentRequest &request) = 0; - virtual QPlaceReply *postRating(const QString &placeId, qreal value) = 0; - - virtual QPlaceSearchReply *searchForPlaces(const QPlaceSearchRequest &request) = 0; + virtual QPlaceSearchReply *search(const QPlaceSearchRequest &request) = 0; virtual QPlaceSearchReply *recommendations(const QPlace &place, const QPlaceSearchRequest &request) = 0; virtual QPlaceTextPredictionReply *textPredictions(const QPlaceSearchRequest &request) = 0; diff --git a/src/location/places/qplaceperiod_p.h b/src/location/places/qplaceperiod_p.h deleted file mode 100644 index dbf51587..00000000 --- a/src/location/places/qplaceperiod_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** 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 QPLACEPERIOD_P_H -#define QPLACEPERIOD_P_H - -#include <QSharedData> - -#include "qplaceperiod.h" - -QT_BEGIN_NAMESPACE - -class QPlacePeriodPrivate : public QSharedData -{ -public: - QPlacePeriodPrivate(); - QPlacePeriodPrivate(const QPlacePeriodPrivate &other); - - ~QPlacePeriodPrivate(); - - bool operator==(const QPlacePeriodPrivate &other) const; - - QDateTime begin; - QDateTime end; -}; - -QT_END_NAMESPACE - -#endif // QPLACEPERIOD_P_H diff --git a/src/location/places/qplacerating.cpp b/src/location/places/qplacerating.cpp index 133c35b5..a93369d7 100644 --- a/src/location/places/qplacerating.cpp +++ b/src/location/places/qplacerating.cpp @@ -45,17 +45,13 @@ QT_USE_NAMESPACE QPlaceRatingPrivate::QPlaceRatingPrivate() - : QSharedData(), - value(0), - count(0) +: QSharedData(), value(0), maximum(0), count(0) { } QPlaceRatingPrivate::QPlaceRatingPrivate(const QPlaceRatingPrivate &other) - : QSharedData() +: QSharedData(), value(other.value), maximum(other.maximum), count(other.count) { - this->value = other.value; - this->count = other.count; } QPlaceRatingPrivate::~QPlaceRatingPrivate() @@ -64,10 +60,7 @@ QPlaceRatingPrivate::~QPlaceRatingPrivate() bool QPlaceRatingPrivate::operator==(const QPlaceRatingPrivate &other) const { - return ( - this->value == other.value - && this->count == other.count - ); + return value == other.value && maximum == other.maximum && count == other.count; } /*! @@ -126,12 +119,28 @@ qreal QPlaceRating::value() const /*! Sets the \a value. */ -void QPlaceRating::setValue(const qreal &value) +void QPlaceRating::setValue(qreal value) { d->value = value; } /*! + Returns the maximum possible rating value. +*/ +qreal QPlaceRating::maximum() const +{ + return d->maximum; +} + +/*! + Sets the maximum possible rating value to \a max. +*/ +void QPlaceRating::setMaximum(qreal max) +{ + d->maximum = max; +} + +/*! Returns count. */ int QPlaceRating::count() const @@ -142,7 +151,7 @@ int QPlaceRating::count() const /*! Sets the \a count. */ -void QPlaceRating::setCount(const int &count) +void QPlaceRating::setCount(int count) { d->count = count; } diff --git a/src/location/places/qplacerating.h b/src/location/places/qplacerating.h index cbd72f29..b1e4e5a6 100644 --- a/src/location/places/qplacerating.h +++ b/src/location/places/qplacerating.h @@ -58,7 +58,7 @@ public: QPlaceRating(); QPlaceRating(const QPlaceRating &other); - virtual ~QPlaceRating(); + ~QPlaceRating(); QPlaceRating &operator=(const QPlaceRating &other); @@ -68,9 +68,13 @@ public: } qreal value() const; - void setValue(const qreal &value); + void setValue(qreal value); + int count() const; - void setCount(const int &count); + void setCount(int count); + + qreal maximum() const; + void setMaximum(qreal max); private: QSharedDataPointer<QPlaceRatingPrivate> d; diff --git a/src/location/places/qplacerating_p.h b/src/location/places/qplacerating_p.h index 5f917c0e..1c61aa78 100644 --- a/src/location/places/qplacerating_p.h +++ b/src/location/places/qplacerating_p.h @@ -58,7 +58,8 @@ public: bool operator==(const QPlaceRatingPrivate &other) const; - double value; + qreal value; + qreal maximum; int count; }; diff --git a/src/location/places/qplacereply.h b/src/location/places/qplacereply.h index a138579f..081857f6 100644 --- a/src/location/places/qplacereply.h +++ b/src/location/places/qplacereply.h @@ -65,22 +65,22 @@ public: PermissionsError, UnsupportedError, BadArgumentError, + AuthenticationFailedError, CancelError, UnknownError }; enum Type { Reply, - PlaceDetailsReply, - PlaceSearchReply, + DetailsReply, + SearchReply, TextPredictionReply, - ReviewReply, ContentReply, IdReply }; - QPlaceReply(QObject *parent); - virtual ~QPlaceReply(); + explicit QPlaceReply(QObject *parent = 0); + ~QPlaceReply(); bool isFinished() const; @@ -101,6 +101,7 @@ protected: void setFinished(bool finished); void setError(QPlaceReply::Error error, const QString &errorString); QPlaceReplyPrivate *d_ptr; + private: Q_DISABLE_COPY(QPlaceReply) }; diff --git a/src/location/places/qplacerequest.cpp b/src/location/places/qplacerequest.cpp index 4c6ad0f1..82d9e802 100644 --- a/src/location/places/qplacerequest.cpp +++ b/src/location/places/qplacerequest.cpp @@ -51,10 +51,8 @@ template<> QT_PREPEND_NAMESPACE(QPlaceRequestPrivate) *QSharedDataPointer<QT_PRE } #endif -QPlaceRequestPrivate::QPlaceRequestPrivate() - : QSharedData(), - offset(0), - limit(-1) +QPlaceRequestPrivate::QPlaceRequestPrivate(QPlaceRequest::Type type) +: QSharedData(), offset(0), limit(-1), requestType(type) { } @@ -98,7 +96,7 @@ void QPlaceRequestPrivate::clear() Default constructor. Constructs an new query object. */ QPlaceRequest::QPlaceRequest() - : d_ptr(new QPlaceRequestPrivate) +: d_ptr(new QPlaceRequestPrivate(QPlaceRequest::Request)) { } @@ -127,15 +125,15 @@ bool QPlaceRequest::operator==(const QPlaceRequest &other) const if (!d_ptr) return !other.d_ptr; - if (requestType() != other.requestType()) + if (d_ptr->requestType != other.d_ptr->requestType) return false; return d_ptr->compare(other.d_ptr); } -QPlaceRequest::Type QPlaceRequest::requestType() const +QPlaceRequest::Type QPlaceRequest::type() const { - return d_ptr->type(); + return d_ptr->requestType; } /*! diff --git a/src/location/places/qplacerequest.h b/src/location/places/qplacerequest.h index d96ef711..b5592cd7 100644 --- a/src/location/places/qplacerequest.h +++ b/src/location/places/qplacerequest.h @@ -57,15 +57,14 @@ class Q_LOCATION_EXPORT QPlaceRequest { public: enum Type { - DefaultType, - ContentType, - SearchType + Request, + ContentRequest, + SearchRequest }; QPlaceRequest(); QPlaceRequest(const QPlaceRequest &other); - - ~QPlaceRequest(); + virtual ~QPlaceRequest(); QPlaceRequest &operator=(const QPlaceRequest &other); @@ -79,7 +78,7 @@ public: int limit() const; void setLimit(int limit); - QPlaceRequest::Type requestType() const; + QPlaceRequest::Type type() const; void clear(); diff --git a/src/location/places/qplacerequest_p.h b/src/location/places/qplacerequest_p.h index 13432957..e731cf36 100644 --- a/src/location/places/qplacerequest_p.h +++ b/src/location/places/qplacerequest_p.h @@ -49,19 +49,19 @@ QT_BEGIN_NAMESPACE class QPlaceRequestPrivate : public QSharedData { public: - QPlaceRequestPrivate(); + QPlaceRequestPrivate(QPlaceRequest::Type type); QPlaceRequestPrivate(const QPlaceRequestPrivate &other); virtual ~QPlaceRequestPrivate(); virtual bool compare(const QPlaceRequestPrivate *other) const; virtual QPlaceRequestPrivate *clone() const; - virtual QPlaceRequest::Type type() const { return QPlaceRequest::ContentType; } virtual void clear(); /* Helper functions for C++ protection rules */ static const QSharedDataPointer<QPlaceRequestPrivate>& extract_d(const QPlaceRequest& other) {return other.d_ptr;} int offset; int limit; + QPlaceRequest::Type requestType; }; #if defined(Q_CC_MWERKS) diff --git a/src/location/places/qplacereview.cpp b/src/location/places/qplacereview.cpp index 4b2d969b..e9529396 100644 --- a/src/location/places/qplacereview.cpp +++ b/src/location/places/qplacereview.cpp @@ -42,32 +42,22 @@ #include "qplacereview.h" #include "qplacereview_p.h" -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE QPlaceReviewPrivate::QPlaceReviewPrivate() - : QPlaceContentPrivate(), - helpfulVotings(0), - unhelpfulVotings(0), - rating(0) +: QPlaceContentPrivate(), rating(0) { } QPlaceReviewPrivate::QPlaceReviewPrivate(const QPlaceReviewPrivate &other) : QPlaceContentPrivate(other) { - this->date = other.date; - this->description = other.description; - this->language = other.language; - this->helpfulVotings = other.helpfulVotings; - this->mediaIds = other.mediaIds; - this->unhelpfulVotings = other.unhelpfulVotings; - this->rating = other.rating; - this->reviewId = other.reviewId; - this->supplier = other.supplier; - this->title = other.title; - this->userId = other.userId; - this->userName = other.userName; - this->originatorUrl = other.originatorUrl; + dateTime = other.dateTime; + content = other.content; + language = other.language; + rating = other.rating; + reviewId = other.reviewId; + title = other.title; } QPlaceReviewPrivate::~QPlaceReviewPrivate() @@ -77,21 +67,12 @@ QPlaceReviewPrivate::~QPlaceReviewPrivate() bool QPlaceReviewPrivate::compare(const QPlaceContentPrivate *other) const { const QPlaceReviewPrivate *od = static_cast<const QPlaceReviewPrivate *>(other); - return ( - this->date == od->date - && this->description == od->description - && this->language == od->language - && this->helpfulVotings == od->helpfulVotings - && this->mediaIds == od->mediaIds - && this->unhelpfulVotings == od->unhelpfulVotings - && this->rating == od->rating - && this->reviewId == od->reviewId - && this->supplier == od->supplier - && this->title == od->title - && this->userId == od->userId - && this->userName == od->userName - && this->originatorUrl == od->originatorUrl - ); + return dateTime == od->dateTime && + content == od->content && + language == od->language && + rating == od->rating && + reviewId == od->reviewId && + title == od->title; } /*! @@ -134,39 +115,39 @@ QPlaceReview::~QPlaceReview() Q_IMPLEMENT_CONTENT_D_FUNC(QPlaceReview) /*! - Returns review date. + Returns the date and time that the review was written. */ -QString QPlaceReview::date() const +QDateTime QPlaceReview::dateTime() const { Q_D(const QPlaceReview); - return d->date; + return d->dateTime; } /*! - Sets review date. + Sets the date and time that the review was written to \a dt. */ -void QPlaceReview::setDate(const QString &data) +void QPlaceReview::setDateTime(const QDateTime &dt) { Q_D(QPlaceReview); - d->date = data; + d->dateTime = dt; } /*! Returns description. */ -QString QPlaceReview::description() const +QString QPlaceReview::content() const { Q_D(const QPlaceReview); - return d->description; + return d->content; } /*! Sets description. */ -void QPlaceReview::setDescription(const QString &data) +void QPlaceReview::setContent(const QString &data) { Q_D(QPlaceReview); - d->description = data; + d->content = data; } /*! @@ -188,60 +169,6 @@ void QPlaceReview::setLanguage(const QString &data) } /*! - Returns the number of helpful votings or "thumbs up" -*/ -int QPlaceReview::helpfulVotings() const -{ - Q_D(const QPlaceReview); - return d->helpfulVotings; -} - -/*! - Sets the number of helpful \a votes or "thumbs up". -*/ -void QPlaceReview::setHelpfulVotings(const int &votes) -{ - Q_D(QPlaceReview); - d->helpfulVotings = votes; -} - -/*! - Returns media ids associated with review. -*/ -QStringList QPlaceReview::mediaIds() const -{ - Q_D(const QPlaceReview); - return d->mediaIds; -} - -/*! - Sets media ids. -*/ -void QPlaceReview::setMediaIds(const QStringList &data) -{ - Q_D(QPlaceReview); - d->mediaIds = data; -} - -/*! - Returns the number of uhelpful votings or "thumbs down". -*/ -int QPlaceReview::unhelpfulVotings() const -{ - Q_D(const QPlaceReview); - return d->unhelpfulVotings; -} - -/*! - Sets the number of unhelpful votings or "thumbs down" -*/ -void QPlaceReview::setUnhelpfulVotings(const int &votes) -{ - Q_D(QPlaceReview); - d->unhelpfulVotings = votes; -} - -/*! Returns rating. */ qreal QPlaceReview::rating() const @@ -253,7 +180,7 @@ qreal QPlaceReview::rating() const /*! Sets rating. */ -void QPlaceReview::setRating(const qreal &data) +void QPlaceReview::setRating(qreal data) { Q_D(QPlaceReview); d->rating = data; @@ -295,56 +222,4 @@ void QPlaceReview::setTitle(const QString &data) d->title = data; } -/*! - Returns user id. -*/ -QString QPlaceReview::userId() const -{ - Q_D(const QPlaceReview); - return d->userId; -} - -/*! - Sets user id. -*/ -void QPlaceReview::setUserId(const QString &data) -{ - Q_D(QPlaceReview); - d->userId = data; -} - -/*! - Returns user name. -*/ -QString QPlaceReview::userName() const -{ - Q_D(const QPlaceReview); - return d->userName; -} - -/*! - Sets user name. -*/ -void QPlaceReview::setUserName(const QString &data) -{ - Q_D(QPlaceReview); - d->userName = data; -} - -/*! - Returns originator URL. -*/ -QUrl QPlaceReview::originatorUrl() const -{ - Q_D(const QPlaceReview); - return d->originatorUrl; -} - -/*! - Sets originator \a url of the review. -*/ -void QPlaceReview::setOriginatorUrl(const QUrl &url) -{ - Q_D(QPlaceReview); - d->originatorUrl = url; -} +QT_END_NAMESPACE diff --git a/src/location/places/qplacereview.h b/src/location/places/qplacereview.h index b4546182..559e359f 100644 --- a/src/location/places/qplacereview.h +++ b/src/location/places/qplacereview.h @@ -42,9 +42,6 @@ #ifndef QPLACEREVIEW_H #define QPLACEREVIEW_H -#include <QSharedDataPointer> -#include <QStringList> -#include "qplacesupplier.h" #include "qplacecontent.h" QT_BEGIN_HEADER @@ -53,6 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Location) +class QDateTime; class QPlaceReviewPrivate; class Q_LOCATION_EXPORT QPlaceReview : public QPlaceContent @@ -63,30 +61,19 @@ public: virtual ~QPlaceReview(); - QString date() const; - void setDate(const QString &data); - QString description() const; - void setDescription(const QString &data); + QDateTime dateTime() const; + void setDateTime(const QDateTime &dt); + QString content() const; + void setContent(const QString &content); QString language() const; void setLanguage(const QString &data); - int helpfulVotings() const; - void setHelpfulVotings(const int &votes); - QStringList mediaIds() const; - void setMediaIds(const QStringList &data); - int unhelpfulVotings() const; - void setUnhelpfulVotings(const int &votes); + qreal rating() const; - void setRating(const qreal &data); + void setRating(qreal data); QString reviewId() const; void setReviewId(const QString &data); QString title() const; void setTitle(const QString &data); - QString userId() const; - void setUserId(const QString &data); - QString userName() const; - void setUserName(const QString &data); - QUrl originatorUrl() const; - void setOriginatorUrl(const QUrl &data); private: Q_DECLARE_CONTENT_D_FUNC(QPlaceReview) diff --git a/src/location/places/qplacereview_p.h b/src/location/places/qplacereview_p.h index 316cd5cc..a49b678b 100644 --- a/src/location/places/qplacereview_p.h +++ b/src/location/places/qplacereview_p.h @@ -43,7 +43,7 @@ #define QPLACEREVIEW_P_H #include <QtCore/QUrl> -#include <QtCore/QSharedData> +#include <QtCore/QDateTime> #include "qplacecontent_p.h" @@ -61,18 +61,12 @@ public: Q_DEFINE_CONTENT_PRIVATE_HELPER(QPlaceReview, QPlaceContent::ReviewType); - QString date; - QString description; + QDateTime dateTime; + QString content; QString language; - int helpfulVotings; - QStringList mediaIds; - int unhelpfulVotings; qreal rating; QString reviewId; QString title; - QString userId; - QString userName; - QUrl originatorUrl; }; QT_END_NAMESPACE diff --git a/src/location/places/qplacesearchreply.cpp b/src/location/places/qplacesearchreply.cpp index 6cc19a33..5b47bfca 100644 --- a/src/location/places/qplacesearchreply.cpp +++ b/src/location/places/qplacesearchreply.cpp @@ -87,7 +87,7 @@ QPlaceSearchReply::~QPlaceSearchReply() */ QPlaceReply::Type QPlaceSearchReply::type() const { - return QPlaceReply::PlaceSearchReply; + return QPlaceReply::SearchReply; } /*! diff --git a/src/location/places/qplacesearchreply.h b/src/location/places/qplacesearchreply.h index b44159ce..04d66806 100644 --- a/src/location/places/qplacesearchreply.h +++ b/src/location/places/qplacesearchreply.h @@ -57,8 +57,8 @@ class Q_LOCATION_EXPORT QPlaceSearchReply : public QPlaceReply { Q_OBJECT public: - QPlaceSearchReply(QObject *parent =0); - virtual ~QPlaceSearchReply(); + explicit QPlaceSearchReply(QObject *parent = 0); + ~QPlaceSearchReply(); QPlaceReply::Type type() const; diff --git a/src/location/places/qplacesearchrequest.cpp b/src/location/places/qplacesearchrequest.cpp index 69f451a5..af9080fa 100644 --- a/src/location/places/qplacesearchrequest.cpp +++ b/src/location/places/qplacesearchrequest.cpp @@ -54,7 +54,7 @@ public: ~QPlaceSearchRequestPrivate(); bool compare(const QPlaceRequestPrivate *other) const; - Q_DEFINE_PRIVATE_HELPER(QPlaceSearchRequest, QPlaceRequest, QPlaceRequest::SearchType, request) + Q_DEFINE_PRIVATE_HELPER(QPlaceSearchRequest, QPlaceRequest, QPlaceRequest::SearchRequest) void clear(); QString searchTerm; @@ -66,8 +66,8 @@ public: }; QPlaceSearchRequestPrivate::QPlaceSearchRequestPrivate() -: QPlaceRequestPrivate(), searchArea(0), dymNumber(0), - visibilityScope(QtLocation::UnspecifiedVisibility), relevanceHint(QPlaceSearchRequest::NoHint) +: QPlaceRequestPrivate(QPlaceRequest::SearchRequest), searchArea(0), dymNumber(0), + visibilityScope(QtLocation::UnspecifiedVisibility), relevanceHint(QPlaceSearchRequest::UnspecifiedHint) { } @@ -124,7 +124,7 @@ void QPlaceSearchRequestPrivate::clear() searchArea = 0; dymNumber = 0; visibilityScope = QtLocation::UnspecifiedVisibility; - relevanceHint = QPlaceSearchRequest::NoHint; + relevanceHint = QPlaceSearchRequest::UnspecifiedHint; } /*! @@ -238,18 +238,18 @@ void QPlaceSearchRequest::setSearchArea(QGeoBoundingArea *area) } /*! - Returns maximum number of "did you mean" suggestions returned by search request. + Returns the maximum number of search term corrections that may be returned. */ -int QPlaceSearchRequest::didYouMeanSuggestionNumber() const +int QPlaceSearchRequest::maximumCorrections() const { Q_D(const QPlaceSearchRequest); return d->dymNumber; } /*! - Sets maximum \a number of "did you mean" suggestions returned by search request. + Sets maximum \a number of search term corrections that may be returned. */ -void QPlaceSearchRequest::setDidYouMeanSuggestionNumber(const int &number) +void QPlaceSearchRequest::setMaximumCorrections(int number) { Q_D(QPlaceSearchRequest); d->dymNumber = number; diff --git a/src/location/places/qplacesearchrequest.h b/src/location/places/qplacesearchrequest.h index fef4a936..e2f6d894 100644 --- a/src/location/places/qplacesearchrequest.h +++ b/src/location/places/qplacesearchrequest.h @@ -61,14 +61,14 @@ class Q_LOCATION_EXPORT QPlaceSearchRequest : public QPlaceRequest { public: enum RelevanceHint { - NoHint, + UnspecifiedHint, DistanceHint, LexicalPlaceNameHint }; QPlaceSearchRequest(); Q_DECLARE_COPY_CTOR(QPlaceSearchRequest, QPlaceRequest) - virtual ~QPlaceSearchRequest(); + ~QPlaceSearchRequest(); QString searchTerm() const; void setSearchTerm(const QString &term); @@ -79,8 +79,8 @@ public: QGeoBoundingArea *searchArea() const; void setSearchArea(QGeoBoundingArea *area); - int didYouMeanSuggestionNumber() const; - void setDidYouMeanSuggestionNumber(const int &number); + int maximumCorrections() const; + void setMaximumCorrections(int number); QtLocation::VisibilityScope visibilityScope() const; void setVisibilityScope(QtLocation::VisibilityScope visibilityScopes); diff --git a/src/location/places/qplacesearchresult.cpp b/src/location/places/qplacesearchresult.cpp index 673abf9d..f4eeec50 100644 --- a/src/location/places/qplacesearchresult.cpp +++ b/src/location/places/qplacesearchresult.cpp @@ -45,24 +45,17 @@ QT_USE_NAMESPACE QPlaceSearchResultPrivate::QPlaceSearchResultPrivate() - : QSharedData(), - relevance(0), - distance(0), - heading(0), - type(QPlaceSearchResult::UnknownSearchResult) +: QSharedData(), distance(0), type(QPlaceSearchResult::UnknownSearchResult) { } QPlaceSearchResultPrivate::QPlaceSearchResultPrivate(const QPlaceSearchResultPrivate &other) : QSharedData() { - this->additionalData = other.additionalData; - this->relevance = other.relevance; - this->distance = other.distance; - this->heading = other.heading; - this->type = other.type; - this->place = other.place; - this->dymString = other.dymString; + distance = other.distance; + type = other.type; + place = other.place; + correction = other.correction; } QPlaceSearchResultPrivate::~QPlaceSearchResultPrivate() @@ -71,15 +64,10 @@ QPlaceSearchResultPrivate::~QPlaceSearchResultPrivate() bool QPlaceSearchResultPrivate::operator==(const QPlaceSearchResultPrivate &other) const { - return ( - this->additionalData == other.additionalData - && this->relevance == other.relevance - && this->distance == other.distance - && this->heading == other.heading - && this->type == other.type - && this->place == other.place - && this->dymString == other.dymString - ); + return distance == other.distance && + type == other.type && + place == other.place && + correction == other.correction; } /*! @@ -129,22 +117,6 @@ bool QPlaceSearchResult::operator==(const QPlaceSearchResult &other) const } /*! - Returns relevance. -*/ -qreal QPlaceSearchResult::relevance() const -{ - return d->relevance; -} - -/*! - Sets the \a relevance. -*/ -void QPlaceSearchResult::setRelevance(const qreal &relevance) -{ - d->relevance = relevance; -} - -/*! Returns the distance. */ qreal QPlaceSearchResult::distance() const @@ -155,44 +127,12 @@ qreal QPlaceSearchResult::distance() const /*! Sets the \a distance. */ -void QPlaceSearchResult::setDistance(const qreal &distance) +void QPlaceSearchResult::setDistance(qreal distance) { d->distance = distance; } /*! - Returns heading. -*/ -qreal QPlaceSearchResult::heading() const -{ - return d->heading; -} - -/*! - Sets the \a heading. -*/ -void QPlaceSearchResult::setHeading(const qreal &heading) -{ - d->heading = heading; -} - -/*! - Returns additional data. -*/ -QVariantHash QPlaceSearchResult::additionalData() const -{ - return d->additionalData; -} - -/*! - Sets additional \a data. -*/ -void QPlaceSearchResult::setAdditionalData(const QVariantHash &data) -{ - d->additionalData = data; -} - -/*! Returns the place. */ QPlaceSearchResult::SearchResultType QPlaceSearchResult::type() const @@ -203,7 +143,7 @@ QPlaceSearchResult::SearchResultType QPlaceSearchResult::type() const /*! Sets the \a place. */ -void QPlaceSearchResult::setType(const QPlaceSearchResult::SearchResultType &type) +void QPlaceSearchResult::setType(QPlaceSearchResult::SearchResultType type) { d->type = type; } @@ -225,17 +165,17 @@ void QPlaceSearchResult::setPlace(const QPlace &place) } /*! - Returns the "did you mean" string. + Returns the suggested search term correction. */ -QString QPlaceSearchResult::didYouMeanSuggestion() const +QString QPlaceSearchResult::correction() const { - return d->dymString; + return d->correction; } /*! Sets the "did you mean" \a string. */ -void QPlaceSearchResult::setDidYouMeanSuggestion(const QString &dymString) +void QPlaceSearchResult::setCorrection(const QString &correction) { - d->dymString = dymString; + d->correction = correction; } diff --git a/src/location/places/qplacesearchresult.h b/src/location/places/qplacesearchresult.h index 050f7b01..67357568 100644 --- a/src/location/places/qplacesearchresult.h +++ b/src/location/places/qplacesearchresult.h @@ -71,31 +71,22 @@ public: } enum SearchResultType { - Place, - DidYouMeanSuggestion, + PlaceResult, + CorrectionResult, UnknownSearchResult }; - qreal relevance() const; - void setRelevance(const qreal &relevance); - qreal distance() const; - void setDistance(const qreal &distance); - - qreal heading() const; - void setHeading(const qreal &heading); - - QVariantHash additionalData() const; - void setAdditionalData(const QVariantHash &data); + void setDistance(qreal distance); SearchResultType type() const; - void setType(const SearchResultType &type); + void setType(SearchResultType type); QPlace place() const; void setPlace(const QPlace &place); - QString didYouMeanSuggestion() const; - void setDidYouMeanSuggestion(const QString &didYouMeanSuggestion); + QString correction() const; + void setCorrection(const QString &correction); private: QSharedDataPointer<QPlaceSearchResultPrivate> d; diff --git a/src/location/places/qplacesearchresult_p.h b/src/location/places/qplacesearchresult_p.h index 9bf004ef..a58fcfe6 100644 --- a/src/location/places/qplacesearchresult_p.h +++ b/src/location/places/qplacesearchresult_p.h @@ -58,13 +58,10 @@ public: bool operator==(const QPlaceSearchResultPrivate &other) const; - qreal relevance; qreal distance; - qreal heading; - QVariantHash additionalData; QPlaceSearchResult::SearchResultType type; QPlace place; - QString dymString; + QString correction; }; QT_END_NAMESPACE diff --git a/src/location/places/qplacesupplier.h b/src/location/places/qplacesupplier.h index d6476527..d1d5b30e 100644 --- a/src/location/places/qplacesupplier.h +++ b/src/location/places/qplacesupplier.h @@ -58,8 +58,7 @@ class Q_LOCATION_EXPORT QPlaceSupplier public: QPlaceSupplier(); QPlaceSupplier(const QPlaceSupplier &other); - - virtual ~QPlaceSupplier(); + ~QPlaceSupplier(); QPlaceSupplier &operator=(const QPlaceSupplier &other); diff --git a/src/location/places/qplacetextpredictionreply.h b/src/location/places/qplacetextpredictionreply.h index 053fc5f8..0df0e7a5 100644 --- a/src/location/places/qplacetextpredictionreply.h +++ b/src/location/places/qplacetextpredictionreply.h @@ -58,8 +58,8 @@ class Q_LOCATION_EXPORT QPlaceTextPredictionReply : public QPlaceReply { Q_OBJECT public: - QPlaceTextPredictionReply(QObject *parent =0); - virtual ~QPlaceTextPredictionReply(); + explicit QPlaceTextPredictionReply(QObject *parent = 0); + ~QPlaceTextPredictionReply(); QStringList textPredictions() const; Type type() const; diff --git a/src/location/qgeoaddress.h b/src/location/qgeoaddress.h index 3b558ab8..69e771b6 100644 --- a/src/location/qgeoaddress.h +++ b/src/location/qgeoaddress.h @@ -89,16 +89,6 @@ public: QString street() const; void setStreet(const QString &street); -// QString streetNumber() const; -// void setStreetNumber(QString &streetNumber); - -// TODO: -// QString floor() const; -// void setFloor(const QString &floor); - -// QString suite() const; -// void setSuite(const QString &suite); - bool isEmpty() const; void clear(); diff --git a/src/location/qgeolocation.cpp b/src/location/qgeolocation.cpp index 823335a0..8ca90b6e 100644 --- a/src/location/qgeolocation.cpp +++ b/src/location/qgeolocation.cpp @@ -168,7 +168,7 @@ void QGeoLocation::setLocationId(const QString &locationId) /*! Returns view port. */ -QGeoBoundingBox QGeoLocation::viewport() const +QGeoBoundingBox QGeoLocation::boundingBox() const { return d->viewport; } @@ -176,7 +176,7 @@ QGeoBoundingBox QGeoLocation::viewport() const /*! Sets view port. */ -void QGeoLocation::setViewport(const QGeoBoundingBox &viewport) +void QGeoLocation::setBoundingBox(const QGeoBoundingBox &viewport) { d->viewport = viewport; } diff --git a/src/location/qgeolocation.h b/src/location/qgeolocation.h index d7fd0725..78b419fa 100644 --- a/src/location/qgeolocation.h +++ b/src/location/qgeolocation.h @@ -64,7 +64,7 @@ public: QGeoLocation(); QGeoLocation(const QGeoLocation &other); - virtual ~QGeoLocation(); + ~QGeoLocation(); QGeoLocation &operator=(const QGeoLocation &other); @@ -79,8 +79,8 @@ public: void setCoordinate(const QGeoCoordinate &position); QString locationId() const; void setLocationId(const QString &locationId); - QGeoBoundingBox viewport() const; - void setViewport(const QGeoBoundingBox &coordinate); + QGeoBoundingBox boundingBox() const; + void setBoundingBox(const QGeoBoundingBox &box); private: QSharedDataPointer<QGeoLocationPrivate> d; diff --git a/src/location/qplace.cpp b/src/location/qplace.cpp index 7912357a..b0ed80a5 100644 --- a/src/location/qplace.cpp +++ b/src/location/qplace.cpp @@ -46,13 +46,6 @@ #include <QDebug> #endif -#if !defined(Q_CC_MWERKS) -template<> QT_PREPEND_NAMESPACE(QPlacePrivate) *QSharedDataPointer<QT_PREPEND_NAMESPACE(QPlacePrivate)>::clone() -{ - return d->clone(); -} -#endif - QT_BEGIN_NAMESPACE /*! @@ -102,12 +95,12 @@ QPlace &QPlace::operator= (const QPlace & other) inline QPlacePrivate* QPlace::d_func() { - return reinterpret_cast<QPlacePrivate*>(d_ptr.data()); + return static_cast<QPlacePrivate *>(d_ptr.data()); } inline const QPlacePrivate* QPlace::d_func() const { - return reinterpret_cast<const QPlacePrivate*>(d_ptr.constData()); + return static_cast<const QPlacePrivate *>(d_ptr.constData()); } /*! @@ -117,7 +110,8 @@ inline const QPlacePrivate* QPlace::d_func() const */ bool QPlace::operator== (const QPlace &other) const { - return ( *(d_ptr.constData()) == *(other.d_ptr.constData())); + Q_D(const QPlace); + return *d == *other.d_func(); } /*! @@ -127,7 +121,8 @@ bool QPlace::operator== (const QPlace &other) const */ bool QPlace::operator!= (const QPlace &other) const { - return (!this->operator ==(other)); + Q_D(const QPlace); + return !(*d == *other.d_func()); } /*! @@ -185,21 +180,21 @@ void QPlace::setRating(const QPlaceRating &rating) } /*! - Returns suppliers. + Returns the supplier of this place data. */ -QList<QPlaceSupplier> QPlace::suppliers() const +QPlaceSupplier QPlace::supplier() const { Q_D(const QPlace); - return d->suppliers; + return d->supplier; } /*! - Sets suppliers. + Sets the supplier of this place data to \a supplier. */ -void QPlace::setSuppliers(const QList<QPlaceSupplier> &data) +void QPlace::setSupplier(const QPlaceSupplier &supplier) { Q_D(QPlace); - d->suppliers = data; + d->supplier = supplier; } /*! @@ -228,7 +223,7 @@ void QPlace::setContent(QPlaceContent::Type type, const QPlaceContent::Collectio Adds a collection of \a content of the given \a type to the place. Any index in \a content that already exists is overwritten. */ -void QPlace::addContent(QPlaceContent::Type type, const QPlaceContent::Collection &content) +void QPlace::insertContent(QPlaceContent::Type type, const QPlaceContent::Collection &content) { Q_D(QPlace); QMapIterator<int, QPlaceContent> iter(content); @@ -244,7 +239,7 @@ void QPlace::addContent(QPlaceContent::Type type, const QPlaceContent::Collectio (As opposed to how many objects this place instance is currently assigned). A negative count indicates that the total number of items is unknown. */ -int QPlace::contentCount(QPlaceContent::Type type) const +int QPlace::totalContentCount(QPlaceContent::Type type) const { Q_D(const QPlace); return d->contentCounts.value(type, 0); @@ -253,7 +248,7 @@ int QPlace::contentCount(QPlaceContent::Type type) const /*! Sets the \a totalCount of content objects of the given \a type. */ -void QPlace::setContentCount(QPlaceContent::Type type, int totalCount) +void QPlace::setTotalContentCount(QPlaceContent::Type type, int totalCount) { Q_D(QPlace); d->contentCounts.insert(type, totalCount); @@ -463,7 +458,7 @@ QPlacePrivate::QPlacePrivate(const QPlacePrivate &other) categories(other.categories), location(other.location), rating(other.rating), - suppliers(other.suppliers), + supplier(other.supplier), name(other.name), placeId(other.placeId), attribution(other.attribution), @@ -486,7 +481,7 @@ QPlacePrivate& QPlacePrivate::operator= (const QPlacePrivate & other) categories = other.categories; location = other.location; rating = other.rating; - suppliers = other.suppliers; + supplier = other.supplier; name = other.name; placeId = other.placeId; attribution = other.attribution; @@ -526,7 +521,7 @@ bool QPlacePrivate::operator== (const QPlacePrivate &other) const return (categories == other.categories && location == other.location && rating == other.rating - && suppliers == other.suppliers + && supplier == other.supplier && contentCollections == other.contentCollections && contentCounts == other.contentCounts && name == other.name diff --git a/src/location/qplace.h b/src/location/qplace.h index ec916ca9..6098c320 100644 --- a/src/location/qplace.h +++ b/src/location/qplace.h @@ -84,17 +84,18 @@ public: void setLocation(const QGeoLocation &location); QPlaceRating rating() const; void setRating(const QPlaceRating &rating); - QList<QPlaceSupplier> suppliers() const; - void setSuppliers(const QList<QPlaceSupplier> &data); + QPlaceSupplier supplier() const; + void setSupplier(const QPlaceSupplier &supplier); QString attribution() const; void setAttribution(const QString &attribution); QPlaceContent::Collection content(QPlaceContent::Type type) const; void setContent(QPlaceContent::Type type, const QPlaceContent::Collection &content); - void addContent(QPlaceContent::Type type, const QPlaceContent::Collection &content); - int contentCount(QPlaceContent::Type type) const; - void setContentCount(QPlaceContent::Type type, int); + void insertContent(QPlaceContent::Type type, const QPlaceContent::Collection &content); + + int totalContentCount(QPlaceContent::Type type) const; + void setTotalContentCount(QPlaceContent::Type type, int total); QString name() const; void setName(const QString &name); @@ -123,12 +124,11 @@ public: QtLocation::Visibility visibility() const; void setVisibility(QtLocation::Visibility visibility); -protected: +private: QSharedDataPointer<QPlacePrivate> d_ptr; -private: - QPlacePrivate* d_func(); - const QPlacePrivate* d_func() const; + inline QPlacePrivate *d_func(); + inline const QPlacePrivate *d_func() const; }; QT_END_NAMESPACE diff --git a/src/location/qplace_p.h b/src/location/qplace_p.h index b27fe54a..fba03329 100644 --- a/src/location/qplace_p.h +++ b/src/location/qplace_p.h @@ -53,7 +53,6 @@ // We mean it. // -#include <QRectF> #include <QSharedData> #include <QUrl> @@ -61,6 +60,7 @@ #include "qgeoaddress.h" #include "qgeoboundingbox.h" #include "qgeocoordinate.h" +#include "qplacesupplier.h" QT_BEGIN_NAMESPACE @@ -69,18 +69,16 @@ class QPlacePrivate : public QSharedData public: QPlacePrivate(); QPlacePrivate(const QPlacePrivate &other); - virtual ~QPlacePrivate(); + ~QPlacePrivate(); QPlacePrivate &operator= (const QPlacePrivate &other); - virtual bool operator== (const QPlacePrivate &other) const; - - virtual QPlacePrivate *clone() const { return new QPlacePrivate(*this); } + bool operator==(const QPlacePrivate &other) const; QList<QPlaceCategory> categories; QGeoLocation location; QPlaceRating rating; - QList<QPlaceSupplier> suppliers; + QPlaceSupplier supplier; QString name; QString placeId; QString attribution; @@ -100,19 +98,7 @@ public: bool detailsFetched; }; - -#if defined(Q_CC_MWERKS) -// This results in multiple symbol definition errors on all other compilers -// but not having a definition here results in an attempt to use the unspecialized -// clone (which fails because of the pure virtuals above) -template<> QPlacePrivate *QSharedDataPointer<QPlacePrivate>::clone() -{ - return d->clone(); -} -#else -template<> QPlacePrivate *QSharedDataPointer<QPlacePrivate>::clone(); -#endif - QT_END_NAMESPACE + #endif diff --git a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp b/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp index bd91fb70..52eaa5d6 100644 --- a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp @@ -106,7 +106,7 @@ void QPlaceDetailsReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId, if (errorId == QPlaceJSonParser::NoError) { QPlace place = parser->result(); place.setDetailsFetched(true); - setResult(place); + setPlace(place); } else if (errorId == QPlaceJSonParser::ParsingError) { setError(ParseError, errorMessage); emit error(this->error(), this->errorString()); diff --git a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp b/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp index 48432156..0c04c3dd 100644 --- a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp +++ b/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp @@ -280,9 +280,8 @@ void QPlaceJSonDetailsParser::processMainProvider(const QScriptValue &placeValue if (value.isValid() && !value.toString().isEmpty()){ sup.setSupplierIconUrl(value.toString()); } - QList<QPlaceSupplier> list; - list.append(QPlaceSuppliersRepository::instance()->addSupplier(sup)); - targetPlace->setSuppliers(list); + + targetPlace->setSupplier(QPlaceSuppliersRepository::instance()->addSupplier(sup)); } void QPlaceJSonDetailsParser::processContacts(const QScriptValue &contactsValue, QPlace *targetPlace) @@ -685,7 +684,7 @@ QPlaceImage *QPlaceJSonDetailsParser::processPremiumContentMediaObject(const QSc if (value.isValid() && !value.toString().isEmpty()) { obj = new QPlaceImage(); obj->setUrl(QUrl::fromEncoded(value.toString().toAscii())); - obj->setId(value.toString()); + obj->setImageId(value.toString()); value = content.property(place_premiumcontent_content_mediamimetype_element); if (value.isValid() && !value.toString().isEmpty()) { obj->setMimeType(value.toString()); @@ -831,7 +830,7 @@ QPlaceImage *QPlaceJSonDetailsParser::processAdContentMediaObject(const QScriptV if (!mediaMimeType.isEmpty() || !mediaUrl.isEmpty()) { obj = new QPlaceImage(); obj->setUrl(QUrl::fromEncoded(mediaUrl.toAscii())); - obj->setId(mediaUrl); + obj->setImageId(mediaUrl); obj->setMimeType(mediaMimeType); } return obj; @@ -864,7 +863,7 @@ void QPlaceJSonDetailsParser::processAdContentPaymentMethods(const QScriptValue QPlaceAttribute paymentMethods; paymentMethods.setLabel(tr("Payment methods")); paymentMethods.setText(list.join(",")); - targetPlace->insertExtendedAttribute(QPlaceAttribute::PaymentMethods, paymentMethods); + targetPlace->insertExtendedAttribute(QLatin1String("paymentMethods"), paymentMethods); } } } @@ -1016,7 +1015,7 @@ void QPlaceJSonDetailsParser::processAdContentOpeningNotes(const QScriptValue &c QPlaceAttribute openingNote; openingNote.setLabel(tr("Opening note")); openingNote.setText(obj); - targetPlace->insertExtendedAttribute(QPlaceAttribute::OpeningNote, openingNote); + targetPlace->insertExtendedAttribute(QLatin1String("openingNote"), openingNote); //! @todo only one is used break; } @@ -1028,7 +1027,7 @@ void QPlaceJSonDetailsParser::processAdContentOpeningNotes(const QScriptValue &c QPlaceAttribute openingNote; openingNote.setLabel(tr("Opening note")); openingNote.setText(obj); - targetPlace->insertExtendedAttribute(QPlaceAttribute::OpeningNote, openingNote); + targetPlace->insertExtendedAttribute(QLatin1String("openingNote"), openingNote); } } } diff --git a/src/plugins/geoservices/nokia/places/qplacejsonmediaparser.cpp b/src/plugins/geoservices/nokia/places/qplacejsonmediaparser.cpp index 08a46544..d661a080 100644 --- a/src/plugins/geoservices/nokia/places/qplacejsonmediaparser.cpp +++ b/src/plugins/geoservices/nokia/places/qplacejsonmediaparser.cpp @@ -97,7 +97,7 @@ QPlaceImage QPlaceJSonMediaParser::buildMediaObject(const QScriptValue &media) QScriptValue value = media.property(media_url); if (value.isValid() && !value.toString().isEmpty()) { newMedia.setUrl(QUrl::fromEncoded(value.toString().toAscii())); - newMedia.setId(value.toString()); + newMedia.setImageId(value.toString()); } QString name, id, icon; diff --git a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp b/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp index b0dfab70..489778af 100644 --- a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp +++ b/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp @@ -105,7 +105,7 @@ void QPlaceJSonRecommendationParser::processJSonData(const QScriptValue &sv) void QPlaceJSonRecommendationParser::processResultElement(const QScriptValue &value) { QPlaceSearchResult result; - result.setType(QPlaceSearchResult::Place); + result.setType(QPlaceSearchResult::PlaceResult); // Processing properties QScriptValue distance = value.property(recommendations_distance_element); diff --git a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp b/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp index ead89b0e..dcb3457f 100644 --- a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp +++ b/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp @@ -49,6 +49,7 @@ #include "qplacejsonreviewparser.h" #include <QtCore/QUrl> +#include <QtCore/QDateTime> #include <QtScript/QScriptEngine> #include <QtScript/QScriptValue> #include <QtScript/QScriptValueIterator> @@ -109,31 +110,15 @@ QPlaceReview QPlaceJSonReviewParser::buildReview(const QScriptValue &review) } value = review.property(review_date_element); if (value.isValid() && !value.toString().isEmpty()) { - newReview.setDate(value.toString()); - } - value = review.property(review_minus_element); - if (value.isValid() && !value.toString().isEmpty()) { - bool isConverted; - int number = value.toString().toInt(&isConverted); - if (isConverted) { - newReview.setUnhelpfulVotings(number); - } - } - value = review.property(review_plus_element); - if (value.isValid() && !value.toString().isEmpty()) { - bool isConverted; - int number = value.toString().toInt(&isConverted); - if (isConverted) { - newReview.setHelpfulVotings(number); - } + newReview.setDateTime(QDateTime::fromString(value.toString())); } value = review.property(review_originator_element); if (value.isValid() && !value.toString().isEmpty()) { - newReview.setOriginatorUrl(value.toString()); + newReview.setSourceUrl(value.toString()); } value = review.property(review_description_element); if (value.isValid() && !value.toString().isEmpty()) { - newReview.setDescription(value.toString()); + newReview.setContent(value.toString()); } value = review.property(review_title_element); if (value.isValid() && !value.toString().isEmpty()) { diff --git a/src/plugins/geoservices/nokia/places/qplacejsonsearchparser.cpp b/src/plugins/geoservices/nokia/places/qplacejsonsearchparser.cpp index f6e1386a..1217c69a 100644 --- a/src/plugins/geoservices/nokia/places/qplacejsonsearchparser.cpp +++ b/src/plugins/geoservices/nokia/places/qplacejsonsearchparser.cpp @@ -159,8 +159,8 @@ void QPlaceJSonSearchParser::processResultElement(const QScriptValue &value) if (type.isValid()) { result = processPlaceElement(value); } - result.setType(QPlaceSearchResult::DidYouMeanSuggestion); - result.setDidYouMeanSuggestion(title.toString()); + result.setType(QPlaceSearchResult::CorrectionResult); + result.setCorrection(title.toString()); searchResultsList.append(result); } } @@ -173,7 +173,7 @@ void QPlaceJSonSearchParser::processResultElement(const QScriptValue &value) QPlaceSearchResult QPlaceJSonSearchParser::processPlaceElement(const QScriptValue &results) { QPlaceSearchResult result; - result.setType(QPlaceSearchResult::Place); + result.setType(QPlaceSearchResult::PlaceResult); QPlace newPlace; // Processing properties @@ -207,9 +207,7 @@ QPlaceSearchResult QPlaceJSonSearchParser::processPlaceElement(const QScriptValu if (value.isValid() && !value.toString().isEmpty()) { QPlaceSupplier sup; sup.setName(value.toString()); - QList<QPlaceSupplier> list; - list.append(QPlaceSuppliersRepository::instance()->addSupplier(sup)); - newPlace.setSuppliers(list); + newPlace.setSupplier(QPlaceSuppliersRepository::instance()->addSupplier(sup)); } processContacts(properties, &newPlace); processRating(properties, &newPlace); @@ -378,7 +376,7 @@ void QPlaceJSonSearchParser::processLocation(const QScriptValue &properties, QPl QGeoBoundingBox boundingBox; boundingBox.setTopLeft(topLeft); boundingBox.setBottomRight(bottomRight); - location.setViewport(boundingBox); + location.setBoundingBox(boundingBox); } processAddress(properties, &location); diff --git a/src/plugins/geoservices/nokia/places/qplacerestmanager.cpp b/src/plugins/geoservices/nokia/places/qplacerestmanager.cpp index c9cf352e..f27887a8 100644 --- a/src/plugins/geoservices/nokia/places/qplacerestmanager.cpp +++ b/src/plugins/geoservices/nokia/places/qplacerestmanager.cpp @@ -202,7 +202,7 @@ QPlaceRestReply *QPlaceRestManager::sendSearchRequest(const QPlaceSearchRequest + const_query + query.searchTerm()); } -QPlaceRestReply *QPlaceRestManager::postRatingRequest(const QString &placeId, const QString &userId, const int &value) +QPlaceRestReply *QPlaceRestManager::postRatingRequest(const QString &placeId, const QString &userId, int value) { QNetworkRequest request; @@ -295,8 +295,8 @@ QString QPlaceRestManager::prepareSearchRequest(const QPlaceSearchRequest &query searchString += const_offset + QString::number(query.offset()); } // process DYM - if (query.didYouMeanSuggestionNumber() > 0){ - searchString += const_dym + QString::number(query.didYouMeanSuggestionNumber()); + if (query.maximumCorrections() > 0){ + searchString += const_dym + QString::number(query.maximumCorrections()); } #if defined(QPLACES_LOGGING) diff --git a/src/plugins/geoservices/nokia/places/qplacerestmanager.h b/src/plugins/geoservices/nokia/places/qplacerestmanager.h index e8b1ab55..a88ae8c4 100644 --- a/src/plugins/geoservices/nokia/places/qplacerestmanager.h +++ b/src/plugins/geoservices/nokia/places/qplacerestmanager.h @@ -77,7 +77,7 @@ public: QPlaceRestReply *sendSearchRequest(const QPlaceSearchRequest &query); QPlaceRestReply *sendSuggestionRequest(const QPlaceSearchRequest &query); - QPlaceRestReply *postRatingRequest(const QString &placeId, const QString &userId, const int &value); + QPlaceRestReply *postRatingRequest(const QString &placeId, const QString &userId, int value); QLocale locale() const; void setLocale(const QLocale &locale); diff --git a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp b/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp index 10d58abd..407fa741 100644 --- a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp @@ -134,7 +134,7 @@ QList<QPlaceSearchResult> QPlaceSearchReplyImpl::filterSecondSearchCenter(const { QList<QPlaceSearchResult> newList; foreach (QPlaceSearchResult res, list) { - if (res.type() == QPlaceSearchResult::Place) { + if (res.type() == QPlaceSearchResult::PlaceResult) { bool isNotSeconSearchCenter = true; foreach (QPlaceCategory cat, res.place().categories()) { if (cat.categoryId() == "second-search-center") { @@ -145,7 +145,7 @@ QList<QPlaceSearchResult> QPlaceSearchReplyImpl::filterSecondSearchCenter(const if (isNotSeconSearchCenter) { newList.append(res); } - } else if (res.type() == QPlaceSearchResult::DidYouMeanSuggestion) { + } else if (res.type() == QPlaceSearchResult::CorrectionResult) { newList.append(res); } } diff --git a/src/plugins/geoservices/nokia/qgeocodexmlparser.cpp b/src/plugins/geoservices/nokia/qgeocodexmlparser.cpp index 77389b3d..c5c02c12 100644 --- a/src/plugins/geoservices/nokia/qgeocodexmlparser.cpp +++ b/src/plugins/geoservices/nokia/qgeocodexmlparser.cpp @@ -311,7 +311,7 @@ bool QGeoCodeXmlParser::parseLocation(QGeoLocation *location) if (!parseBoundingBox(&bounds)) return false; - location->setViewport(bounds); + location->setBoundingBox(bounds); parsedBounds = true; } else { diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp index 9ba45df7..b6dad2dd 100644 --- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp +++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp @@ -165,24 +165,8 @@ QPlaceContentReply *QPlaceManagerEngineNokia::getContent(const QPlace &place, co return reply; } -QPlaceReply *QPlaceManagerEngineNokia::postRating(const QString &placeId, qreal value) -{ - QPlaceRatingReplyImpl *reply = NULL; - //TODO: need to post user name - QPlaceRestReply *restReply = QPlaceRestManager::instance()->postRatingRequest(placeId, - QString(), - value); - if (restReply) { - reply = new QPlaceRatingReplyImpl(restReply, this); - connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)), - this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString))); - connect(reply, SIGNAL(processingFinished(QPlaceReply*)), - this, SLOT(processingFinished(QPlaceReply*))); - } - return reply; -} -QPlaceSearchReply *QPlaceManagerEngineNokia::searchForPlaces(const QPlaceSearchRequest &query) +QPlaceSearchReply *QPlaceManagerEngineNokia::search(const QPlaceSearchRequest &query) { //TODO: handling of scope QPlaceSearchReplyImpl *reply = NULL; diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h index 99e4d4aa..676d2ee2 100644 --- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h +++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h @@ -70,9 +70,7 @@ public: QPlaceContentReply *getContent(const QPlace &place, const QPlaceContentRequest &request); - QPlaceReply *postRating(const QString &placeId, qreal value); - - QPlaceSearchReply *searchForPlaces(const QPlaceSearchRequest &query); + QPlaceSearchReply *search(const QPlaceSearchRequest &query); QPlaceSearchReply *recommendations(const QPlace &place, const QPlaceSearchRequest &query); QPlaceTextPredictionReply *textPredictions(const QPlaceSearchRequest &query); diff --git a/src/plugins/geoservices/nokia_places_jsondb/detailsreply.cpp b/src/plugins/geoservices/nokia_places_jsondb/detailsreply.cpp index 15573cca..b453a3bd 100644 --- a/src/plugins/geoservices/nokia_places_jsondb/detailsreply.cpp +++ b/src/plugins/geoservices/nokia_places_jsondb/detailsreply.cpp @@ -51,7 +51,7 @@ DetailsReply::~DetailsReply() { } -void DetailsReply::setResult(const QPlace &place) +void DetailsReply::setPlace(const QPlace &place) { - QPlaceDetailsReply::setResult(place); + QPlaceDetailsReply::setPlace(place); } diff --git a/src/plugins/geoservices/nokia_places_jsondb/detailsreply.h b/src/plugins/geoservices/nokia_places_jsondb/detailsreply.h index 44201179..39effd07 100644 --- a/src/plugins/geoservices/nokia_places_jsondb/detailsreply.h +++ b/src/plugins/geoservices/nokia_places_jsondb/detailsreply.h @@ -54,7 +54,7 @@ class DetailsReply : public QPlaceDetailsReply public: DetailsReply(QPlaceManagerEngineJsonDb *engine); virtual ~DetailsReply(); - void setResult(const QPlace &place); + void setPlace(const QPlace &place); DECLARE_TRIGGER_DONE_FN diff --git a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp index 9a51e404..85929463 100644 --- a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp +++ b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp @@ -477,12 +477,12 @@ void QPlaceManagerEngineJsonDb::processJsonDbResponse(int id, const QVariant &da } break; } - case QPlaceReply::PlaceSearchReply: { + case QPlaceReply::SearchReply: { SearchReply *searchReply = qobject_cast<SearchReply *>(reply); QList<QPlace> places = JsonDbHandler::convertJsonResponseToPlaces(data); QList<QPlaceSearchResult> results; QPlaceSearchResult result; - result.setType(QPlaceSearchResult::Place); + result.setType(QPlaceSearchResult::PlaceResult); bool resultsAlreadySet = false; if (searchReply->request().searchArea() != 0) { @@ -561,7 +561,7 @@ void QPlaceManagerEngineJsonDb::processJsonDbResponse(int id, const QVariant &da searchReply->triggerDone(); break; } - case QPlaceReply::PlaceDetailsReply: { + case QPlaceReply::DetailsReply: { QVariantMap jsonMap = data.toMap(); DetailsReply *detailsReply = qobject_cast<DetailsReply *>(reply); if (jsonMap.value("length").toInt() <= 0) { @@ -570,7 +570,7 @@ void QPlaceManagerEngineJsonDb::processJsonDbResponse(int id, const QVariant &da } else { QList<QPlace> places = JsonDbHandler::convertJsonResponseToPlaces(data); Q_ASSERT(!places.isEmpty()); - detailsReply->setResult(places.first()); + detailsReply->setPlace(places.first()); detailsReply->triggerDone(); } break; @@ -613,7 +613,7 @@ void QPlaceManagerEngineJsonDb::processJsonDbError(int id, int code, const QStri idReply->triggerDone(error, errorString); break; } - case QPlaceReply::PlaceSearchReply: { + case QPlaceReply::SearchReply: { SearchReply *searchReply = qobject_cast<SearchReply*>(placeReply); searchReply->triggerDone(error, errorString); break; |