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 nearKm = np.km
} }
} }
console.log("[tide] init nearPort:", nearPort ? nearPort[0] + " (" + nearKm.toFixed(1) + " km)" : "null")
refresh() 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() { function refresh() {
if (!port) { if (!port) {
console.log("[tide] refresh: port UNDEFINED") console.log("[tide] refresh: port UNDEFINED")
@@ -120,12 +127,14 @@ Page {
Label { Label {
anchors.fill: parent anchors.fill: parent
anchors.margins: Theme.paddingSmall anchors.margins: Theme.paddingSmall
text: qsTr("📍 Nearest port: %1 — %2 · ±%3 m") text: page.nearPort
.arg(page.nearPort[0]) ? qsTr("📍 Nearest port: %1 — %2 · ±%3 m")
.arg(page.nearKm < 222 .arg(page.nearPort[0])
? (page.nearKm / 111).toFixed(1) + "°" .arg(page.nearKm < 222
: Math.round(page.nearKm) + " km") ? (page.nearKm / 111).toFixed(1) + "°"
.arg(((page.nearPort[4][1][0] + page.nearPort[4][2][0]) * 2).toFixed(2)) : Math.round(page.nearKm) + " km")
.arg(((page.nearPort[4][1][0] + page.nearPort[4][2][0]) * 2).toFixed(2))
: ""
color: Theme.errorColor color: Theme.errorColor
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
wrapMode: Text.Wrap wrapMode: Text.Wrap
@@ -133,10 +142,7 @@ Page {
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: pageStack.push(Qt.resolvedUrl("DetailPage.qml"), onClicked: page.openPort(page.nearPort)
{ port: page.nearPort,
portIndex: Tides.PORTS.indexOf(page.nearPort),
custom: false })
} }
} }
+8 -26
View File
@@ -83,32 +83,14 @@ Page {
contentHeight: Theme.itemSizeMedium contentHeight: Theme.itemSizeMedium
highlighted: model.isPreferred highlighted: model.isPreferred
Label { ListItemLayout {
text: model.name title.text: model.name
color: model.isPreferred ? Theme.highlightColor : Theme.primaryColor title.color: model.isPreferred ? Theme.highlightColor : Theme.primaryColor
font.pixelSize: Theme.fontSizeMedium title.truncationMode: TruncationMode.Fade
anchors.left: parent.left subtitle.text: model.country
anchors.leftMargin: Theme.horizontalPageMargin subtitle.color: Theme.secondaryColor
anchors.verticalCenter: parent.verticalCenter summary.text: model.range
truncationMode: TruncationMode.Fade summary.color: Theme.secondaryColor
width: parent.width - 3 * Theme.horizontalPageMargin
}
Label {
text: model.country
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
anchors.left: parent.left
anchors.leftMargin: Theme.horizontalPageMargin
anchors.top: parent.top
anchors.topMargin: Theme.paddingSmall
}
Label {
text: model.range
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
anchors.right: parent.right
anchors.rightMargin: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
} }
onClicked: { onClicked: {
console.log("[tide] open port:", model.name, "custom:", model.custom) console.log("[tide] open port:", model.name, "custom:", model.custom)