From c6bc664eccf6f95f1b6c9664f5fd1c8de435b468 Mon Sep 17 00:00:00 2001 From: Carlo Baratto Date: Wed, 2 Sep 2026 18:36:38 +0200 Subject: [PATCH] =?UTF-8?q?home:=20layout=20standard=20Silica=20(header+ri?= =?UTF-8?q?cerca=20dentro=20la=20lista)=20=E2=80=94=20elimina=20la=20fasci?= =?UTF-8?q?a=20verde=20del=20pulley=20all'avvio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/pages/MainPage.qml | 68 +++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index 4628ae3..2cf4ca4 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -6,33 +6,12 @@ import "../js/comuni.js" as Comuni Page { id: page - // Campi di ricerca FUORI dall'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" - description: "v" + appVersion - } - - SearchField { - id: search - placeholderText: qsTr("Search a port or a town…") - onTextChanged: updateList() - EnterKey.enabled: text.trim().length > 0 - EnterKey.onClicked: findOnline() - } - } + // Messaggio mostrato nel footer quando la lista è vuota + property string hintMsg: "" SilicaListView { id: list - anchors.top: topCol.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom + anchors.fill: parent model: ListModel { id: resultModel } PullDownMenu { @@ -42,16 +21,33 @@ Page { } } + // Header della lista: titolo + ricerca (i campi qui scrollano con la + // lista; le funzioni della pagina ricevono il testo come parametro, + // perché gli id dell'header non sono visibili fuori dal componente) + header: Column { + width: parent.width + + PageHeader { + title: "Tide" + description: "v" + appVersion + } + + SearchField { + placeholderText: qsTr("Search a port or a town…") + onTextChanged: page.updateList(text) + EnterKey.enabled: text.trim().length > 0 + EnterKey.onClicked: page.findOnline(text) + } + } + footer: Item { width: parent.width - height: resultModel.count === 0 ? Theme.itemSizeSmall * 1.6 : 0 + height: resultModel.count === 0 ? Theme.itemSizeSmall * 1.8 : 0 Label { visible: resultModel.count === 0 anchors.fill: parent anchors.margins: Theme.horizontalPageMargin - text: search.text.trim() === "" - ? qsTr("Type to search among all Italian towns and known ports.") - : qsTr("No local results — press Enter to search online.") + text: page.hintMsg color: Theme.secondaryColor font.pixelSize: Theme.fontSizeSmall wrapMode: Text.Wrap @@ -119,10 +115,14 @@ Page { return "±" + (cost[1][0] + cost[2][0]).toFixed(2) + " m" } - function updateList() { - var q = norm(search.text.trim()) + function updateList(q) { + q = norm(q.trim()) resultModel.clear() - if (q === "") return + if (q === "") { + hintMsg = qsTr("Type to search among all Italian towns and known ports.") + return + } + hintMsg = qsTr("No local results — press Enter to search online.") var i, p, name // porti noti (match su nome o paese) for (i = 0; i < Tides.PORTS.length; i++) { @@ -233,8 +233,8 @@ Page { xhr.send() } - function findOnline() { - var q = search.text.trim() + function findOnline(q) { + q = q.trim() console.log("[tide] findOnline:", q) if (q === "") return // se è un porto noto, apri direttamente @@ -263,7 +263,7 @@ Page { } Component.onCompleted: { - updateList() + updateList("") var pref = appSettings.preferredPort if (pref !== "") { var found = false