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)
|
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 {
|
SilicaListView {
|
||||||
id: list
|
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 }
|
model: ListModel { id: portModel }
|
||||||
|
|
||||||
header: Column {
|
header: SectionHeader { text: qsTr("Ports") }
|
||||||
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") }
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: ListItem {
|
delegate: ListItem {
|
||||||
contentHeight: Theme.itemSizeMedium
|
contentHeight: Theme.itemSizeMedium
|
||||||
@@ -84,8 +92,8 @@ Page {
|
|||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
page.pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
||||||
{ port: model.port, portIndex: model.realIndex, custom: model.custom })
|
{ port: model.port, portIndex: model.realIndex, custom: model.custom })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +133,7 @@ Page {
|
|||||||
function geoFail() {
|
function geoFail() {
|
||||||
geoMsg.text = qsTr("City not found (offline and not in local dataset).")
|
geoMsg.text = qsTr("City not found (offline and not in local dataset).")
|
||||||
geoMsg.visible = true
|
geoMsg.visible = true
|
||||||
|
geoMsg.color = Theme.errorColor
|
||||||
}
|
}
|
||||||
|
|
||||||
function geoFound(name, lat, lon, src) {
|
function geoFound(name, lat, lon, src) {
|
||||||
@@ -144,8 +153,8 @@ Page {
|
|||||||
geoMsg.text = qsTr("Found %1 (via %2)").arg(name).arg(src)
|
geoMsg.text = qsTr("Found %1 (via %2)").arg(name).arg(src)
|
||||||
geoMsg.visible = true
|
geoMsg.visible = true
|
||||||
geoMsg.color = Theme.highlightColor
|
geoMsg.color = Theme.highlightColor
|
||||||
pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
page.pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
||||||
{ port: port, portIndex: -1, custom: true })
|
{ port: port, portIndex: -1, custom: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
function geoXhr(query, cb) {
|
function geoXhr(query, cb) {
|
||||||
@@ -199,8 +208,8 @@ Page {
|
|||||||
if (pref !== "") {
|
if (pref !== "") {
|
||||||
for (var i = 0; i < Tides.PORTS.length; i++) {
|
for (var i = 0; i < Tides.PORTS.length; i++) {
|
||||||
if (Tides.PORTS[i][0] === pref) {
|
if (Tides.PORTS[i][0] === pref) {
|
||||||
pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
page.pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
|
||||||
{ port: Tides.PORTS[i], portIndex: i, custom: false })
|
{ port: Tides.PORTS[i], portIndex: i, custom: false })
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user