filter field
This commit is contained in:
parent
bbea0cff24
commit
7490a782ab
@ -41,6 +41,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtQuick 1.1
|
import QtQuick 1.1
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
|
||||||
import "." 0.1
|
import "." 0.1
|
||||||
|
|
||||||
@ -58,7 +59,8 @@ CommonDialog {
|
|||||||
id: defaultDelegate
|
id: defaultDelegate
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
//platformInverted: root.platformInverted
|
visible: modelData.search(RegExp(filterField.filterText, "i")) != -1
|
||||||
|
height: visible? paintedHeight*2 : 0
|
||||||
text: modelData
|
text: modelData
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -78,35 +80,53 @@ CommonDialog {
|
|||||||
content: Item {
|
content: Item {
|
||||||
id: contentItem
|
id: contentItem
|
||||||
|
|
||||||
width: theme.defaultFont.mSize.width * 40
|
implicitWidth: theme.defaultFont.mSize.width * 40
|
||||||
height: theme.defaultFont.mSize.height * 12
|
height: theme.defaultFont.mSize.height * 12
|
||||||
|
|
||||||
Item {
|
TextField {
|
||||||
// Clipping item with bottom margin added to align content with rounded background graphics
|
id: filterField
|
||||||
id: clipItem
|
property string filterText
|
||||||
anchors.fill: parent
|
onTextChanged: searchTimer.restart()
|
||||||
anchors.bottomMargin: 4
|
clearButtonShown: true
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
Timer {
|
||||||
|
id: searchTimer
|
||||||
|
running: false
|
||||||
|
repeat: false
|
||||||
|
interval: 500
|
||||||
|
onTriggered: filterField.filterText = filterField.text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ListView {
|
||||||
|
id: listView
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
top: filterField.bottom
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
currentIndex : -1
|
||||||
|
width: contentItem.width
|
||||||
|
height: contentItem.height
|
||||||
|
delegate: root.delegate
|
||||||
clip: true
|
clip: true
|
||||||
ListView {
|
|
||||||
id: listView
|
|
||||||
|
|
||||||
currentIndex : -1
|
Keys.onPressed: {
|
||||||
width: contentItem.width
|
if (event.key == Qt.Key_Up || event.key == Qt.Key_Down
|
||||||
height: contentItem.height
|
|| event.key == Qt.Key_Left || event.key == Qt.Key_Right
|
||||||
delegate: root.delegate
|
|| event.key == Qt.Key_Select || event.key == Qt.Key_Enter
|
||||||
clip: true
|
|| event.key == Qt.Key_Return) {
|
||||||
|
listView.currentIndex = 0
|
||||||
Keys.onPressed: {
|
event.accepted = true
|
||||||
if (event.key == Qt.Key_Up || event.key == Qt.Key_Down
|
|
||||||
|| event.key == Qt.Key_Left || event.key == Qt.Key_Right
|
|
||||||
|| event.key == Qt.Key_Select || event.key == Qt.Key_Enter
|
|
||||||
|| event.key == Qt.Key_Return) {
|
|
||||||
listView.currentIndex = 0
|
|
||||||
event.accepted = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar {
|
ScrollBar {
|
||||||
id: scrollBar
|
id: scrollBar
|
||||||
flickableItem: listView
|
flickableItem: listView
|
||||||
|
Loading…
Reference in New Issue
Block a user