blob: d47fcbc71ea61620ba40bf56013f73fa65a8490a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
import Qt 4.7
import "pagenavigation.js" as Navit
Rectangle {
id: page
width: gui.width; height: gui.height
color: "Black"
opacity: 0
function setSearchResult(listValue) {
if (search.searchContext=="country") {
search.countryName=listValue;
Navit.back;
}
if (search.searchContext=="town") {
search.townName=listValue;
Navit.back();
}
if (search.searchContext=="street") {
search.streetName=listValue;
search.setPointToResult();
Navit.returnSource="main.qml";
Navit.load("PageNavigate.qml");
}
}
function pageOpen() {
if (search.searchContext=="country") {
searchTxt.text=search.countryName;
countryBinding.when=true;
}
if (search.searchContext=="town") {
searchTxt.text=search.townName;
townBinding.when=true;
}
if (search.searchContext=="street") {
searchTxt.text=search.streetName;
streetBinding.when=true;
}
page.opacity = 1;
}
Component.onCompleted: pageOpen();
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
TextInput{
id: searchTxt;
anchors.top: parent.top; anchors.left: parent.left; anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
width: page.width; font.pointSize: 14; color: "White";focus: true; readOnly: false; cursorVisible: true;
}
Binding {id: countryBinding; target: search; property: "countryName"; value: searchTxt.text; when: false}
Binding {id: townBinding; target: search; property: "townName"; value: searchTxt.text; when: false}
Binding {id: streetBinding; target: search; property: "streetName"; value: searchTxt.text; when: false}
Connections { target: search; onCountryNameSignal: {listModel.xml=search.searchXml(); listModel.query="/search/item"; listModel.reload(); } }
Connections { target: search; onTownNameSignal: {listModel.xml=search.searchXml(); listModel.query="/search/item"; listModel.reload(); } }
Connections { target: search; onStreetNameSignal: {listModel.xml=search.searchXml(); listModel.query="/search/item"; listModel.reload(); } }
XmlListModel {
id: listModel
xml: search.searchXml();
query: "/search/item"
XmlRole { name: "itemId"; query: "id/string()" }
XmlRole { name: "itemName"; query: "name/string()" }
XmlRole { name: "itemIcon"; query: "icon/string()" }
}
Component {
id: listDelegate
Item {
id: wrapper
width: list.width; height: 20
Image {
id: imgIcon; source: gui.iconPath+itemIcon
width: 20; height: 20;
}
Text {
id: txtItemName; text: itemName; color: "White";
anchors.left: imgIcon.right;anchors.leftMargin: 5
width: list.width-imgIcon.width
}
MouseArea {
id:delegateMouse
anchors.fill: parent
onClicked: { setSearchResult(itemName); }
}
}
}
Component {
id: listHighlight
Rectangle {
opacity: 0
}
}
ListSelector {
id:layoutList; text: search.searchContext; onChanged: setSearchResult()
anchors.top: searchTxt.bottom; anchors.left: parent.left; anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
width: page.width; height: page.height/2-cellar.height
}
Cellar {id: cellar; anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width }
}
|