lista: ListItemLayout (titolo+paese+range senza sovrapposizioni); card porto vicino: binding con guardia, click centralizzato openPort, log

This commit is contained in:
2026-09-01 22:54:53 +02:00
parent bfd7369ec7
commit d6cc714ef9
2 changed files with 24 additions and 36 deletions
+16 -10
View File
@@ -39,9 +39,16 @@ Page {
nearKm = np.km
}
}
console.log("[tide] init nearPort:", nearPort ? nearPort[0] + " (" + nearKm.toFixed(1) + " km)" : "null")
refresh()
}
function openPort(port) {
console.log("[tide] openPort:", port ? port[0] : "undefined")
pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
{ port: port, portIndex: Tides.PORTS.indexOf(port), custom: false })
}
function refresh() {
if (!port) {
console.log("[tide] refresh: port UNDEFINED")
@@ -120,12 +127,14 @@ Page {
Label {
anchors.fill: parent
anchors.margins: Theme.paddingSmall
text: qsTr("📍 Nearest port: %1 — %2 · ±%3 m")
.arg(page.nearPort[0])
.arg(page.nearKm < 222
? (page.nearKm / 111).toFixed(1) + "°"
: Math.round(page.nearKm) + " km")
.arg(((page.nearPort[4][1][0] + page.nearPort[4][2][0]) * 2).toFixed(2))
text: page.nearPort
? qsTr("📍 Nearest port: %1 — %2 · ±%3 m")
.arg(page.nearPort[0])
.arg(page.nearKm < 222
? (page.nearKm / 111).toFixed(1) + "°"
: Math.round(page.nearKm) + " km")
.arg(((page.nearPort[4][1][0] + page.nearPort[4][2][0]) * 2).toFixed(2))
: ""
color: Theme.errorColor
font.pixelSize: Theme.fontSizeSmall
wrapMode: Text.Wrap
@@ -133,10 +142,7 @@ Page {
}
MouseArea {
anchors.fill: parent
onClicked: pageStack.push(Qt.resolvedUrl("DetailPage.qml"),
{ port: page.nearPort,
portIndex: Tides.PORTS.indexOf(page.nearPort),
custom: false })
onClicked: page.openPort(page.nearPort)
}
}