import QtQuick 2.0
import QtLocation 5.0
import QtLocation.examples 5.0
Item {
id: root
clip: true
function showSearchResults() {
view.currentIndex = 0;
placeContentList.source = "";
placeContentList.place = null;
}
function showPlaceDetails(data) {
placeDetails.place = data.place;
placeDetails.distance = data.distance;
view.currentIndex = 1;
}
ListView {
id: view
orientation: ListView.Horizontal
interactive: false
anchors.fill: parent
snapMode: ListView.SnapOneItem
model: VisualItemModel {
Item {
width: root.width
height: root.height
Connections {
target: placeSearchModel
onStatusChanged: searchView.visible = true
}
Connections {
target: recommendationModel
onStatusChanged: searchView.visible = false
}
ListView {
id: searchView
anchors.fill: parent
spacing: 20
model: placeSearchModel
delegate: SearchResultDelegate {
onDisplayPlaceDetails: showPlaceDetails(data)
onSearchFor: placeSearchModel.searchForText(query);
}
footer: Item {
width: searchView.width
height: childrenRect.height
Button {
text: qsTr("Previous")
onClicked: placeSearchModel.previousPage()
anchors.left: parent.left
}
Button {
text: qsTr("Clear")
onClicked: placeSearchModel.reset()
anchors.horizontalCenter: parent.horizontalCenter
}
Button {
text: qsTr("Next")
onClicked: placeSearchModel.nextPage()
anchors.right: parent.right
}
}
}
ListView {
id: similarView
anchors.fill: parent
spacing: 5
visible: !searchView.visible
model: recommendationModel
delegate: SearchResultDelegate {
onDisplayPlaceDetails: showPlaceDetails(data)
}
}
}
Item {
width: root.width
height: root.height
IconButton {
id: placeBackButton
anchors.left: parent.left
source: "../../resources/left.png"
pressedSource: "../../resources/left_pressed.png"
onClicked: showSearchResults()
}
PlaceDelegate {
id: placeDetails
anchors.top: placeBackButton.bottom
anchors.bottom: parent.bottom
width: parent.width
anchors.margins: 10
onShowEditorials: {
placeContentList.source = "";
placeContentList.place = place;
placeContentList.source = "PlaceEditorials.qml";
view.currentIndex = 2;
}
onShowReviews: {
placeContentList.source = "";
placeContentList.place = place;
placeContentList.source = "PlaceReviews.qml";
view.currentIndex = 2;
}
onShowImages: {
placeContentList.source = "";
placeContentList.place = place;
placeContentList.source = "PlaceImages.qml";
view.currentIndex = 2;
}
onSearchForSimilar: {
placeContentList.source = "";
recommendationModel.placeId = place.placeId;
recommendationModel.update();
view.currentIndex = 0;
}
onEditPlace: {
editPlaceDialog.prepareDialog(place);
page.state = "EditPlace"
}
onDeletePlace: {
place.remove();
showSearchResults();
}
}
}
Item {
width: root.width
height: root.height
IconButton {
id: contentListBackButton
source: "../../resources/left.png"
pressedSource: "../../resources/left_pressed.png"
onClicked: view.currentIndex = 1
}
Loader {
id: placeContentList
property Place place
anchors.top: contentListBackButton.bottom
anchors.bottom: parent.bottom
width: parent.width
anchors.margins: 10
onStatusChanged: {
if (status === Loader.Null)
place = null;
}
}
}
Item {
width: root.width
height: root.height
IconButton {
id: contentBackButton
source: "../../resources/left.png"
pressedSource: "../../resources/left_pressed.png"
onClicked: {
view.currentIndex = 2;
placeContent.source = "";
placeContent.data = null;
}
}
Loader {
id: placeContent
anchors.top: contentBackButton.bottom
anchors.bottom: parent.bottom
width: parent.width
anchors.margins: 10
onLoaded: view.currentIndex = 3
property variant data
}
}
}
}
}