summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/places/content/places/PlaceDelegate.qml53
-rw-r--r--examples/declarative/places/places.qml5
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