From f49cff62775b6699a6a2edcdcfe0c9f6b3ecc7d2 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Wed, 13 May 2015 11:47:14 +0200 Subject: Fix documenation in 'places' example Change-Id: Id224d73d2b68a947bc6c7121175a2f83bd0059fa Reviewed-by: Alex Blasche --- examples/location/places/places.qml | 17 ++++++++------ .../location/places/views/CategoryDelegate.qml | 27 +++++++++++----------- examples/location/places/views/CategoryView.qml | 20 +++++++--------- 3 files changed, 31 insertions(+), 33 deletions(-) (limited to 'examples') diff --git a/examples/location/places/places.qml b/examples/location/places/places.qml index f5586268..5598fdc7 100644 --- a/examples/location/places/places.qml +++ b/examples/location/places/places.qml @@ -158,8 +158,10 @@ ApplicationWindow { } } + //! [PlaceSearchSuggestionModel search text changed 1] SearchBar { id: searchBar + //! [PlaceSearchSuggestionModel search text changed 1] width: appWindow.width searchBarVisbile: stackView.depth > 1 && stackView.currentItem && @@ -171,21 +173,22 @@ ApplicationWindow { } } onGoBack: stackView.pop() + //! [PlaceSearchSuggestionModel search text changed 2] onSearchTextChanged: { - if (searchText.length >= 3) { - if (suggestionModel != null) { - suggestionModel.searchTerm = searchText; - suggestionModel.update(); - } + if (searchText.length >= 3 && suggestionModel != null) { + suggestionModel.searchTerm = searchText; + suggestionModel.update(); } } + //! [PlaceSearchSuggestionModel search text changed 2] onDoSearch: { if (searchText.length > 0) placeSearchModel.searchForText(searchText); } onShowMap: stackView.pop(page) - + //! [PlaceSearchSuggestionModel search text changed 3] } + //! [PlaceSearchSuggestionModel search text changed 3] StackView { id: stackView @@ -217,7 +220,7 @@ ApplicationWindow { properties: { "categoryModel": categoryModel, "rootIndex" : index }}) - currentItem.enterCategory.connect(stackView.enterCategory) + currentItem.showSubcategories.connect(stackView.enterCategory) currentItem.searchCategory.connect(placeSearchModel.searchForCategory) } diff --git a/examples/location/places/views/CategoryDelegate.qml b/examples/location/places/views/CategoryDelegate.qml index 2ac0a339..75f7060e 100644 --- a/examples/location/places/views/CategoryDelegate.qml +++ b/examples/location/places/views/CategoryDelegate.qml @@ -45,15 +45,14 @@ import QtLocation 5.5 Item { id: root - property alias text: textItem.text + property alias text: labelItem.text property bool checked: false signal searchCategory() - signal showSubcategory() + signal showSubcategories() width: parent.width - height: Math.max(icon.height, textItem.height * 2) + height: Math.max(icon.height, labelItem.height * 2) - //! [CategoryModel delegate icon] Image { id: icon anchors.left: parent.left @@ -61,7 +60,6 @@ Item { anchors.verticalCenter: parent.verticalCenter source: category.icon.url() } - //! [CategoryModel delegate icon] Rectangle { anchors.fill: parent @@ -71,12 +69,18 @@ Item { //! [CategoryModel delegate text] Label { - id: textItem + id: labelItem text: category.name anchors.left: icon.right anchors.verticalCenter: parent.verticalCenter anchors.right: arrow.left } + + MouseArea { + id: mouse + anchors.fill: parent + onClicked: root.searchCategory() + } //! [CategoryModel delegate text] Rectangle { @@ -86,13 +90,7 @@ Item { height: 1 color: "#46a2da" } - - MouseArea { - id: mouse - anchors.fill: parent - onClicked: root.searchCategory() - } - + //! [CategoryModel delegate arrow] ToolButton { id: arrow anchors.right: parent.right @@ -100,6 +98,7 @@ Item { anchors.rightMargin: 15 visible: model.hasModelChildren iconSource: "../../resources/right.png" - onClicked: root.showSubcategory() + onClicked: root.showSubcategories() } + //! [CategoryModel delegate arrow] } diff --git a/examples/location/places/views/CategoryView.qml b/examples/location/places/views/CategoryView.qml index d476300a..b17f3e79 100644 --- a/examples/location/places/views/CategoryView.qml +++ b/examples/location/places/views/CategoryView.qml @@ -40,32 +40,28 @@ import QtQuick 2.5 import QtLocation 5.5 +import QtQml.Models 2.1 -//! [CategoryModel view 1] +//! [CategoryModel view] ListView { id: root property variant categoryModel property variant rootIndex signal searchCategory(variant category) - signal enterCategory(variant index) -//! [CategoryModel view 1] - snapMode: ListView.SnapToItem - -//! [CategoryModel view 2] + signal showSubcategories(variant index) -//! [CategoryModel view 2] + snapMode: ListView.SnapToItem -//! [CategoryModel view 3] - model: VisualDataModel { - id: visalDataModel + model: DelegateModel { + id: delegeteDataModel model: root.categoryModel rootIndex: root.rootIndex delegate: CategoryDelegate { onSearchCategory: root.searchCategory(category); - onShowSubcategory: root.enterCategory(visalDataModel.modelIndex(index)) + onShowSubcategories: root.showSubcategories(delegeteDataModel.modelIndex(index)) } } } -//! [CategoryModel view 3] +//! [CategoryModel view] -- cgit v1.2.1