diff options
author | abcd <amos.choy@nokia.com> | 2011-12-07 18:27:32 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-13 07:28:16 +0100 |
commit | efd322b77b76f1bfa75b7f2d4bb572b0e469484e (patch) | |
tree | 234d6f31377fd0256eb36c824fb8ef44be399873 /examples | |
parent | 3da20d82152d7c40a89a53add44d392dc6a5f00a (diff) | |
download | qtlocation-efd322b77b76f1bfa75b7f2d4bb572b0e469484e.tar.gz |
Add ability to save an existing place as a favorite to example
Change-Id: Ibfc78a37e2109e9df70df17e30b9234b9c97443c
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/declarative/places/content/places/PlaceDelegate.qml | 53 | ||||
-rw-r--r-- | examples/declarative/places/places.qml | 5 |
2 files changed, 58 insertions, 0 deletions
diff --git a/examples/declarative/places/content/places/PlaceDelegate.qml b/examples/declarative/places/content/places/PlaceDelegate.qml index 8cead610..f29a1095 100644 --- a/examples/declarative/places/content/places/PlaceDelegate.qml +++ b/examples/declarative/places/content/places/PlaceDelegate.qml @@ -43,6 +43,8 @@ import QtLocation 5.0 import QtLocation.examples 5.0 Item { + id: placeDelegate + property Place place property real distance @@ -182,6 +184,57 @@ Item { onClicked: deletePlace(place) visible: placesPlugin.supportedPlacesFeatures & Plugin.RemovePlaceFeature } + + Item { + width: parent.width + height: childrenRect.height + Button { + id: saveButton; + property Place favoritePlace + function updateSaveStatus() { + if (updateSaveStatus.prevStatus === Place.Saving) { + switch (favoritePlace.status) { + case Place.Ready: + visible = false; + saveStatus.text = "Save Successful"; + saveStatus.visible = true; + break; + case Place.Error: + saveStatus.anchors.top = saveButton.bottom + saveStatus.text = "Save Failed"; + saveStatus.visible = true; + break; + default: + } + } + updateSaveStatus.prevStatus = favoritePlace.status; + } + + function reset() + { + saveButton.visible = (placesPlugin.name !== "nokia_places_jsondb"); + saveStatus.visible = false; + } + + Component.onCompleted: { + reset(); + placeDelegate.placeChanged.connect(reset); + } + + text: qsTr("Save as Favorite"); + onClicked: { + favoritePlace = Qt.createQmlObject('import QtLocation 5.0; Place { }', saveButton); + favoritePlace.plugin = jsonDbPlugin; + favoritePlace.copyFrom(place); + favoritePlace.statusChanged.connect(updateSaveStatus); + favoritePlace.save(); + } + } + + Text { + id: saveStatus + } + } } } } diff --git a/examples/declarative/places/places.qml b/examples/declarative/places/places.qml index d7c9ec9e..242e958a 100644 --- a/examples/declarative/places/places.qml +++ b/examples/declarative/places/places.qml @@ -272,6 +272,11 @@ Item { onNameChanged: createMap(placesPlugin); } + Plugin { + id: jsonDbPlugin + name: "nokia_places_jsondb" + } + Item { id: searchResultTab |