The LandmarkModel element provides access to landmarks. More...
Inherits LandmarkAbstractModel
This element is part of the QtMobility.location 1.1 module.
LandmarkModel provides a model of landmarks from the landmarks store. The contents of the model can be specified with a filter, and sorted with the LandmarkAbstractModel::sortBy and LandmarkAbstractModel::sortOrder properties. Whether the model is automatically updated when the store or filter changes, can be controlled with LandmarkAbstractModel::autoUpdate property.
There are two ways of accessing the landmark data: through model by using views and delegates, or alternatively via landmarks list property. Of the two, the model access is preferred. Direct list access (i.e. non-model) is not guaranteed to be in order set by sortBy and sortOrder.
At the moment only data role provided by the model is landmark (Landmark). Through that one can access any data provided by the Landmark element.
The following example illustrates fetching of all landmarks in ascending name order. Example illustrates both model access as well as direct list access.
Rectangle {
width: 350
height: 350
// The model
LandmarkModel {
id: myLandmarkModel
sortBy: LandmarkModel.NameSort;
sortOrder: LandmarkModel.AscendingOrder
limit: 15
onLandmarksChanged: {
// Direct list access
for (var index = 0; index < landmarks.length; index++) {
console.log("Index, name:" + index + " , " + landmarks[index].name);
}
}
}
// The view
ListView {
id: myLandmarkListView
model: landmarkModel
delegate: myLandmarkListDelegate
width: parent.width; height: parent.height
highlightFollowsCurrentItem: false
focus: true
anchors.fill: parent
keyNavigationWraps: true
}
// The delegate
Component {
id: myLandmarkListDelegate
Item {
width: 200; height: 20
Text {id: nameField; text: landmark.name }
Text { id: phoneField; text: " tel:" + landmark.phoneNumber; anchors.left: nameField.right;}
}
}
}
See also LandmarkAbstractModel, LandmarkCategoryModel, and QLandmarkManager.
The filter for filtering landmarks.
LandmarkNameFilter {
id: coralFilter
name: "Flinders Reef"
}
LandmarkModel {
id: landmarkModel
filter: coralFilter
// Alternatively filter could be declared directly, e.g:
/*
filter: LandmarkIntersectionFilter {
LandmarkNameFilter {
...
}
LandmarkUnionFilter {
LandmarkIntersectionFilter {
LandmarkNameFilter {
...
}
LandmarkProximityFilter {
...
}
}
}
}
*/
limit: 100
}
See also LandmarkUnionFilter, LandmarkIntersectionFilter, LandmarkNameFilter, LandmarkProximityFilter, LandmarkBoxFilter, and LandmarkCategoryFilter.
Landmarks and their related categories can be imported by setting the import file. If LandmarkAbstractModel::autoUpdate is true, the import will be done automatically and as a result model updates. Alternatively importLandmarks() can be invoked.
For supported file formats, refer to QLandmarkManager and QLandmarkImportRequest.
LandmarkModel {
id: landmarkModelForImport
importFile: "mylandmarkfile.gpx"
}
read-onlylandmarks : QDeclarativeListProperty |
This element holds the list of Landmark elements that the model currently has. Accessing landmarks by iterating over this list is not guaranteed to be in the order set by LandmarkAbstractModel::sortBy or LandmarkAbstractModel::sortOrder
LandmarkModel {
id: landmarkModelForIteration
onLandmarksChanged: {
console.log("log: Landmark count is: "+ count);
for (var index = 0; index < landmarks.length; index++) {
console.log("Index, name:" + index + " , " + landmarks[index].name);
}
}
}
Imports landmarks (and categories) in importFile.