summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorabcd <amos.choy@nokia.com>2011-12-08 22:29:58 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-12 07:46:07 +0100
commit09d7ecc4a49e1d04035732960f750619381cbe70 (patch)
treefdfb74fab9dee76722e75923c0703ec6af2bbfd8 /doc
parent37ae79556ca71a7c29f342abb5d4324f766fdf52 (diff)
downloadqtlocation-09d7ecc4a49e1d04035732960f750619381cbe70.tar.gz
Simplify saving a place between managers
For C++ we add a compatiblePlace() function which returns a pruned version of the original suitable for saving into the manager For QML there the Place has a copyFrom() method. Only data that is relevant to the current place's plugin is copied over. Change-Id: I97c3ed8f1c7e7f68165242a2d6f1d0b04e9ab9a0 Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/src/places.qdoc9
-rw-r--r--doc/src/snippets/declarative/places.qml8
-rw-r--r--doc/src/snippets/places/requesthandler.h9
3 files changed, 10 insertions, 16 deletions
diff --git a/doc/src/places.qdoc b/doc/src/places.qdoc
index 43d5c4a6..b1470a28 100644
--- a/doc/src/places.qdoc
+++ b/doc/src/places.qdoc
@@ -157,9 +157,12 @@
Some fields of a place such as the id, categories and icons are manager specific entities
e.g. the categories in one manager may not be recognised in another.
Therefore trying to save a place directly from one manager to another is not possible.
- The typical approach is to either clear the id, categories and icon
- or alternatively assign them with appropriate values of the new manager.
- The visibility scope may also need to be modified.
+
+ The typical approach is to use the QPlaceManager::compatiblePlace() function,
+ it creates a copy of a place, but only copies data that the manager supports.
+ Manager specific data such as the place id is not copied over. The new
+ copy is now suitable for saving into the manager.
+
\snippet snippets/places/requesthandler.h Save to different manager
\target Removing a place cpp
diff --git a/doc/src/snippets/declarative/places.qml b/doc/src/snippets/declarative/places.qml
index 3db685f6..c6304943 100644
--- a/doc/src/snippets/declarative/places.qml
+++ b/doc/src/snippets/declarative/places.qml
@@ -226,11 +226,9 @@ Item {
function saveToNewPlugin() {
//! [Place save to different plugin]
- myPlace.plugin = diffPlugin;
- place.placeId = "";
- place.categories = null;
- place.icon = null;
- place.visibility = QtLocation.UnspecifiedVisibility; //let the manager choose an appropriate default visibility
+ place = Qt.createQmlObject('import QtLocation 5.0; Place { }', parent);
+ place.plugin = destinationPlugin;
+ place.copyFrom(originalPlace);
place.save();
//! [Place save to different plugin]
}
diff --git a/doc/src/snippets/places/requesthandler.h b/doc/src/snippets/places/requesthandler.h
index ac370fe6..fecac023 100644
--- a/doc/src/snippets/places/requesthandler.h
+++ b/doc/src/snippets/places/requesthandler.h
@@ -301,14 +301,7 @@ public:
QPlaceIdReply *saveReply;
//! [ Save to different manager]
//result retrieved from a different manager
- QPlace place = result.place();
-
- //clear manager specific fields and
- //save to new manager
- place.setPlaceId(QString());
- place.setCategories(QList<QPlaceCategory>());
- place.setIcon(QPlaceIcon());
- place.setVisibility(QtLocation::UnspecifiedVisibility); //let the manager choose an appropriate default visibility
+ QPlace place = manager->compatiblePlace(result.place());
saveReply = manager->savePlace(place);
//! [ Save to different manager]
}