summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorabcd <qt-info@nokia.com>2011-07-21 15:04:17 +1000
committerabcd <qt_abcd1@ovi.com>2011-07-25 07:26:25 +0200
commit136a47b097810b16972c64b7254da08e15e823aa (patch)
tree6a75f2932d296b074ec5ae0b3dc82449d3d9cbd4 /examples
parent5c498446c27e5da18d0afcbfe7c69f5c99d2b0ac (diff)
downloadqtlocation-136a47b097810b16972c64b7254da08e15e823aa.tar.gz
Add detailsFetched field to QGeoPlace
The details fetched field indicates whether the details of this place have been retrieved or not. An alternative may be to return a timestamp of when the place has been retrieved, but this may add extra complexity for no real benefit. Also simplify the qmlplaces example so that only a single delegate is used to how results. Also change the default search location to Paris for easier testing. Le Marfil is populated with nearly all place data fields. Change-Id: Ifc879258669c9f17b3002d6d4caf3c1b861eedbf Reviewed-on: http://codereview.qt.nokia.com/1914 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com> Reviewed-by: abcd <qt_abcd1@ovi.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/qmlplaces/SearchResultDelegate.qml109
-rw-r--r--examples/declarative/qmlplaces/qmlplaces.pro5
-rw-r--r--examples/declarative/qmlplaces/qmlplaces.qml59
-rw-r--r--examples/declarative/qmlplaces/qmlplaces.qrc3
4 files changed, 116 insertions, 60 deletions
diff --git a/examples/declarative/qmlplaces/SearchResultDelegate.qml b/examples/declarative/qmlplaces/SearchResultDelegate.qml
new file mode 100644
index 00000000..79c99d8a
--- /dev/null
+++ b/examples/declarative/qmlplaces/SearchResultDelegate.qml
@@ -0,0 +1,109 @@
+import QtQuick 1.0
+import Qt.location 5.0
+
+Rectangle {
+ property SearchResult result
+ id: thisItem
+ width: parent.width
+ radius: 10
+ height: textFields.height
+ Behavior on height { PropertyAnimation{} }
+
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightgray" }
+ GradientStop { id: gradStop; position: 1.0; color: 'gray'
+ Behavior on color { ColorAnimation{} }
+ }
+ }
+
+ function categoryNames(categories) {
+ var result = "";
+
+ for (var i = 0; i < categories.length; ++i) {
+ if (result == "") {
+ result = categories[i].name;
+ } else {
+ result = result + ", " + categories[i].name;
+ }
+ }
+
+ return result;
+ }
+
+ Component {
+ id: placeFields
+ Item {
+ focus:true
+ height: col.height + 10
+ Column {
+ id: col
+ Text { text: '<b>Name: </b> ' + result.place.name; font.pixelSize: 16 }
+ Text { text: '<b>Street: </b> ' + result.place.location.address.street; font.pixelSize: 16 }
+ Text { text: '<b>Latitude: </b> ' + result.place.location.coordinate.latitude; font.pixelSize: 16 }
+ Text { text: '<b>Longitude: </b> ' + result.place.location.coordinate.longitude; font.pixelSize: 16 }
+ Text { text: '<b>Categories: </b> ' + categoryNames(result.place.categories); font.pixelSize: 16 }
+ Text { text: '<b>Media count: </b> ' + result.place.media.data.length; font.pixelSize: 16 }
+ //Text { text: '<b>All media count: </b> ' + place.mediaCount; font.pixelSize: 16 }
+ Text { text: '<b>Descriptions count: </b> ' + result.place.descriptions.length; font.pixelSize: 16 }
+ //Text { text: '<b>Reviews count: </b> ' + place.reviews.data.length; font.pixelSize: 16 }
+ //Text { text: '<b>All reviews count: </b> ' + place.reviewCount; font.pixelSize: 16 }
+ Text { text: '<b>Tags: </b> ' + result.place.tags; font.pixelSize: 16 }
+ //Text { text: '<b>Suppliers: </b> ' + JSON.stringify(place.suppliers); font.pixelSize: 16 }
+ Text { id: detailsFetched; text:'<b>Details Fetched: </b> ' + result.place.detailsFetched; font.pixelSize: 16 }
+ Text { id: paymentMethods; font.pixelSize: 16 }
+ }
+
+ state: 'place-core'
+ states: [
+ State {
+ name: "place-core"
+ },
+ State {
+ name: "place-details"
+ PropertyChanges { target: gradStop; color:"lightskyblue" }
+ PropertyChanges { target: paymentMethods; text: '<b>Payment methods: </b> ' + result.place.businessInformation.paymentMethods}
+ }
+ ]
+ }
+ }
+
+ Component {
+ id: didYouMeanField
+ Item {
+ height: didYouMeanField.height
+ Text { id:didYouMeanField; text:'<b>Did you mean ' + result.didYouMeanSuggestion + '?</b>'; font.pixelSize: 16 }
+ state: 'didYouMean'
+ states: [
+ State {
+ name: 'didYouMean'
+ PropertyChanges { target:gradStop; color: 'palegreen'}
+ }
+ ]
+ }
+ }
+
+ Loader {
+ id: textFields
+ sourceComponent: (result.type == SearchResult.Place) ? placeFields : didYouMeanField
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (textFields.item.state == 'place-core') {
+ textFields.item.state = 'place-details'
+ if (!result.place.detailsFetched)
+ placeManager.getPlaceDetails(result.place)
+ } else if (textFields.item.state == 'place-details') {
+ textFields.item.state = 'place-core'
+ }
+ }
+ onPressAndHold: {
+ if (textFields.item.state != 'didYouMean') {
+ placesList.model = recommendationModel
+ recommendationModel.placeId = result.place.placeId
+ recommendationModel.executeQuery()
+ }
+ }
+ }
+}
diff --git a/examples/declarative/qmlplaces/qmlplaces.pro b/examples/declarative/qmlplaces/qmlplaces.pro
index c79b3d71..47916707 100644
--- a/examples/declarative/qmlplaces/qmlplaces.pro
+++ b/examples/declarative/qmlplaces/qmlplaces.pro
@@ -7,10 +7,9 @@ TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES = qmlplaces.qml \
- PlaceDelegate.qml \
- DidYouMeanDelegate.qml \
Button.qml \
- CategoryDelegate.qml
+ CategoryDelegate.qml \
+ SearchResultDelegate.qml
RESOURCES += qmlplaces.qrc
diff --git a/examples/declarative/qmlplaces/qmlplaces.qml b/examples/declarative/qmlplaces/qmlplaces.qml
index 3f502cee..36748584 100644
--- a/examples/declarative/qmlplaces/qmlplaces.qml
+++ b/examples/declarative/qmlplaces/qmlplaces.qml
@@ -71,58 +71,7 @@ Rectangle {
clip: true
snapMode: ListView.SnapToItem
model: resultModel
- delegate: Component {
- Item {
- id: thisItem
- width: parent.width
-
- Component.onCompleted: {
- var object;
- if (searchResult.type == SearchResult.Place) {
- object = placeDelegate.createObject(thisItem, { "place": searchResult.place });
- } else {
- object = didYouMeanDelegate.createObject(thisItem, { "text": searchResult.didYouMeanSuggestion });
- }
- height = object.height;
- }
-
- MouseArea {
- anchors.fill: parent
-
- onClicked: {
- if (searchResult.type == SearchResult.Place) {
- console.log("clicked " + searchResult.place.name)
- placeManager.getPlaceDetails(searchResult.place)
- //placeManager.getPlaceReviews(searchResult.place, 10, 50)
- //placeManager.getPlaceMedia(searchResult.place)
- } else if (searchResult.type == SearchResult.DidYouMeanSuggestion) {
- search_term.text = searchResult.didYouMeanSuggestion;
- searchTerm(searchResult.didYouMeanSuggestion);
- }
- }
-
- onPressAndHold: {
- if (searchResult.type == SearchResult.Place) {
- console.log("longpress " + searchResult.place.name);
- placesList.model = recommendationModel;
- recommendationModel.placeId = searchResult.place.placeId;
- recommendationModel.executeQuery();
- }
- }
- }
- }
- }
-
- Component {
- id: placeDelegate
-
- PlaceDelegate { }
- }
- Component {
- id: didYouMeanDelegate
- DidYouMeanDelegate { }
- }
-
+ delegate: SearchResultDelegate { result: searchResult }
}
Text {
@@ -200,9 +149,9 @@ Rectangle {
id: proximity
center: Coordinate {
id: searchCoordinate
- // Brisbane
- longitude: 153.02778
- latitude: -27.46778
+ // Paris
+ longitude: 2.296
+ latitude: 48.87
}
radius:5000
}
diff --git a/examples/declarative/qmlplaces/qmlplaces.qrc b/examples/declarative/qmlplaces/qmlplaces.qrc
index bca23d02..dc8592c9 100644
--- a/examples/declarative/qmlplaces/qmlplaces.qrc
+++ b/examples/declarative/qmlplaces/qmlplaces.qrc
@@ -1,9 +1,8 @@
<RCC>
<qresource prefix="/">
<file>qmlplaces.qml</file>
- <file>PlaceDelegate.qml</file>
- <file>DidYouMeanDelegate.qml</file>
<file>Button.qml</file>
<file>CategoryDelegate.qml</file>
+ <file>SearchResultDelegate.qml</file>
</qresource>
</RCC>