fix ReferenceError: campi ricerca fuori dall'header della lista (scope chiuso)
This commit is contained in:
+55
-46
@@ -7,50 +7,58 @@ Page {
|
||||
|
||||
property var customPorts: [] // porti creati dalla ricerca libera (sessione)
|
||||
|
||||
// Campi di ricerca FUORI dal header della lista: gli id dichiarati nel
|
||||
// componente header hanno scope chiuso e le funzioni del Page non li
|
||||
// vedono (ReferenceError "filter is not defined").
|
||||
Column {
|
||||
id: topCol
|
||||
width: parent.width
|
||||
|
||||
PageHeader { title: "Tide" }
|
||||
|
||||
SearchField {
|
||||
id: filter
|
||||
placeholderText: qsTr("Filter ports…")
|
||||
onTextChanged: rebuild()
|
||||
}
|
||||
|
||||
Item { width: parent.width; height: Theme.paddingMedium }
|
||||
|
||||
TextField {
|
||||
id: geoField
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
placeholderText: qsTr("Free search: any city (online)…")
|
||||
EnterKey.enabled: text.length > 0
|
||||
EnterKey.onClicked: findCity()
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("Find")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onClicked: findCity()
|
||||
}
|
||||
|
||||
Label {
|
||||
id: geoMsg
|
||||
visible: false
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
wrapMode: Text.Wrap
|
||||
color: Theme.errorColor
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
}
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
id: list
|
||||
anchors.fill: parent
|
||||
anchors.top: topCol.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
model: ListModel { id: portModel }
|
||||
|
||||
header: Column {
|
||||
width: parent.width
|
||||
PageHeader { title: "Tide" }
|
||||
|
||||
SearchField {
|
||||
id: filter
|
||||
placeholderText: qsTr("Filter ports…")
|
||||
onTextChanged: rebuild()
|
||||
}
|
||||
|
||||
Item { width: parent.width; height: Theme.paddingMedium }
|
||||
|
||||
TextField {
|
||||
id: geoField
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
placeholderText: qsTr("Free search: any city (online)…")
|
||||
EnterKey.enabled: text.length > 0
|
||||
EnterKey.onClicked: findCity()
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("Find")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onClicked: findCity()
|
||||
}
|
||||
|
||||
Label {
|
||||
id: geoMsg
|
||||
visible: false
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
wrapMode: Text.Wrap
|
||||
color: Theme.errorColor
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Ports") }
|
||||
}
|
||||
header: SectionHeader { text: qsTr("Ports") }
|
||||
|
||||
delegate: ListItem {
|
||||
contentHeight: Theme.itemSizeMedium
|
||||
@@ -84,8 +92,8 @@ Page {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
onClicked: {
|
||||
pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
||||
{ port: model.port, portIndex: model.realIndex, custom: model.custom })
|
||||
page.pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
||||
{ port: model.port, portIndex: model.realIndex, custom: model.custom })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +133,7 @@ Page {
|
||||
function geoFail() {
|
||||
geoMsg.text = qsTr("City not found (offline and not in local dataset).")
|
||||
geoMsg.visible = true
|
||||
geoMsg.color = Theme.errorColor
|
||||
}
|
||||
|
||||
function geoFound(name, lat, lon, src) {
|
||||
@@ -144,8 +153,8 @@ Page {
|
||||
geoMsg.text = qsTr("Found %1 (via %2)").arg(name).arg(src)
|
||||
geoMsg.visible = true
|
||||
geoMsg.color = Theme.highlightColor
|
||||
pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
||||
{ port: port, portIndex: -1, custom: true })
|
||||
page.pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
||||
{ port: port, portIndex: -1, custom: true })
|
||||
}
|
||||
|
||||
function geoXhr(query, cb) {
|
||||
@@ -199,8 +208,8 @@ Page {
|
||||
if (pref !== "") {
|
||||
for (var i = 0; i < Tides.PORTS.length; i++) {
|
||||
if (Tides.PORTS[i][0] === pref) {
|
||||
pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
||||
{ port: Tides.PORTS[i], portIndex: i, custom: false })
|
||||
page.pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
||||
{ port: Tides.PORTS[i], portIndex: i, custom: false })
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user