From: Luciano Montanaro Date: Fri, 27 Dec 2013 02:27:51 +0000 (+0100) Subject: Fix search and scroll issue with the station list X-Git-Tag: 0.8.0~1^2~14 X-Git-Url: https://vcs.maemo.org/git/?p=quandoparte;a=commitdiff_plain;h=69a990cf99ed03385b3d6cea2387701766308e32 Fix search and scroll issue with the station list --- diff --git a/application/resources/sailfish/qml/pages/StationListPage.qml b/application/resources/sailfish/qml/pages/StationListPage.qml index ccb051c..8ede923 100644 --- a/application/resources/sailfish/qml/pages/StationListPage.qml +++ b/application/resources/sailfish/qml/pages/StationListPage.qml @@ -12,14 +12,10 @@ Page { property: "searchPattern" value: stationListPage.searchPattern } - SilicaListView { - id: stationListView - clip: true - width: parent.width - cacheBuffer: 10 - anchors.top: parent.top - anchors.bottom: parent.bottom - model: stationListProxyModel + SilicaFlickable { + interactive: !stationListView.flicking + anchors.fill: parent + pressDelay: 0 PullDownMenu { MenuItem { text: qsTr("About Quando Parte") @@ -38,46 +34,81 @@ Page { onClicked: stationListProxyModel.sortingMode = StationListProxyModel.RecentUsageSorting } } - header: SearchField { - id: searchField - placeholderText: qsTr("Search station...") - inputMethodHints: Qt.ImhNoAutoUppercase - onTextChanged: stationListPage.searchPattern = searchField.text - width: stationListPage.width + PageHeader { + id: header + SearchField { + id: searchField + placeholderText: qsTr("Search station...") + inputMethodHints: Qt.ImhNoAutoUppercase + onTextChanged: stationListPage.searchPattern = searchField.text + width: stationListPage.width + EnterKey.onClicked: searchField.focus = false + } } - delegate: BackgroundItem { - id: listItem - height: Theme.itemSizeExtraSmall + SilicaListView { + id: stationListView + clip: true width: parent.width - Label { - id: mainText - anchors { - fill: parent - margins: Theme.paddingMedium + cacheBuffer: 4 * Theme.itemSizeExtraSmall + anchors.top: header.bottom + anchors.bottom: parent.bottom + model: stationListProxyModel + objectName: + searchField.focus = false + delegate: ListItem { + id: listItem + contentHeight: Theme.itemSizeExtraSmall + width: parent.width + Label { + id: mainText + anchors { + fill: parent + margins: Theme.paddingMedium + } + x: Theme.paddingLarge + textFormat: Text.StyledText + text: model.name ? Private.highlightSearch(model.name, Theme.highlightColor) : "" + verticalAlignment: Text.AlignVCenter } - x: Theme.paddingLarge - textFormat: Text.StyledText - text: model.name ? Private.highlightSearch(model.name, Theme.highlightColor) : "" - verticalAlignment: Text.AlignVCenter - } - Image { - id: favoriteIndicator - visible: model.favorite - source: "image://theme/icon-m-favorite-selected" - anchors { - verticalCenter: parent.verticalCenter - right: parent.right + Image { + id: favoriteIndicator + visible: model.favorite + source: "image://theme/icon-m-favorite-selected" + anchors { + verticalCenter: parent.verticalCenter + right: parent.right + } } - } - onClicked: Private.loadStation(model.name, model.code) - onPressAndHold: contextMenu.show(listItem) - ContextMenu { - id: contextMenu - MenuItem { - text: qsTr("Show on the map") - onClicked: Qt.openUrlExternally("geo:" + model.longitude + "," + model.latitude) + onClicked: { + Private.loadStation(model.name, model.code) + } + //onPressAndHold: contextMenu.show(listItem) + menu: contextMenu + Component { + id: contextMenu + ContextMenu { + MenuItem { + text: model.favorite ? qsTr("Remove from Favorites") : qsTr("Add to Favorites") + onClicked: { + console.log("Favorite Stations (before):" + settings.favoriteStations) + model.favorite ^= true + /* + var index = settings.favoriteStations.indexOf(model.name) + if (index === -1) + settings.favoriteStations.push(model.name) + else settings.favoriteStations.splice(index, 1) + */ + console.log("Favorite Stations (after):" + settings.favoriteStations) + } + } + MenuItem { + text: qsTr("Show on the map") + onClicked: Qt.openUrlExternally("geo:" + model.latitude + "," + model.longitude) + } + } } } + VerticalScrollDecorator {} } } }