resources/stations/generateunclassifiedlist.xq \
resources/harmattan/qml/main.qml \
resources/harmattan/qml/StationListPage.qml \
- resources/harmattan/qml/StationPage.qml
+ resources/harmattan/qml/StationPage.qml \
+ resources/harmattan/qml/SearchBar.qml
unix {
isEmpty(PREFIX) {
--- /dev/null
+import QtQuick 1.0
+import com.nokia.meego 1.0
+
+Item {
+ property alias text: searchField.text
+ width: parent.width
+ height: 48
+
+ TextField {
+ id: searchField
+ width: parent.width
+ anchors.margins: 16
+ anchors.centerIn: parent
+ placeholderText: qsTr("Search")
+ inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
+ platformStyle: TextFieldStyle { paddingRight: clearButton.width }
+ onTextChanged: {
+ if (searchField.text.length == 0) {
+ searchButton.visible = true
+ clearButton.visible = false
+ } else {
+ searchButton.visible = false
+ clearButton.visible = true
+ }
+ }
+ Image {
+ id: searchButton
+ visible: true
+ smooth: true
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ source: "image://theme/icon-m-common-search"
+ }
+ Image {
+ id: clearButton
+ visible: false
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ source: "image://theme/icon-m-input-clear"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ inputContext.reset()
+ searchField.text = ""
+ }
+ }
+ }
+ }
+}
function highlightSearch(s)
{
- return s.replace(searchField.text,
- '<span style="text-decoration:underline">' +
- searchField.text + '</span>')
+ // TODO compile RegExp on change, or find a way to cleanly use
+ // stationListProxyModel.filterRegExp
+ if (searchField.text.length) {
+ var r = new RegExp(searchField.text, 'i')
+ var match = r.exec(s)
+ return s.replace(r, '<span style="text-decoration:underline">' +
+ match + '</span>')
+ } else {
+ return s
+ }
}
Column {
- width: parent.width
+ x: 16
+ y: 16
+ width: parent.width - 32
height: parent.height
- TextField {
+ spacing: 16
+ SearchBar {
id: searchField
- width: parent.width
- placeholderText: "Search..."
- platformStyle: TextFieldStyle { paddingRight: clearButton.width }
- onTextChanged: {
- }
- Image {
- id: clearButton
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- source: "image://theme/icon-m-input-clear"
- MouseArea {
- anchors.fill: parent
- onClicked: {
- inputContext.reset()
- searchField.text = ""
- }
- }
- }
}
- Rectangle {
- height: 16
+ Binding {
+ target: stationListProxyModel
+ property: "searchPattern"
+ value: searchField.text
}
ListView {
id: stationListView
import QtQuick 1.1
import com.nokia.meego 1.0
import QtWebKit 1.0
+import QtQuick 1.0
Page {
property alias html: view.html
settings.defaultFixedFontSize: labelStyle.fontPixelSize
settings.standardFontFamily: labelStyle.fontFamily
}
-}
+ }
{
m_searchPattern = pattern;
setFilterFixedString(m_searchPattern);
+ qDebug() << "set Search pattern to" << pattern;
}
StationListProxyModel::SortingMode StationListProxyModel::sortingMode()