feat(Storybook): pages search

Closes: #8173
This commit is contained in:
Michał Cieślak 2022-11-08 11:19:14 +01:00 committed by Lukáš Tinkl
parent bdded864f2
commit a2e6bc00dd
3 changed files with 51 additions and 2 deletions

View File

@ -104,9 +104,8 @@ ApplicationWindow {
Layout.fillWidth: true
Layout.fillHeight: true
PagesList {
FilteredPagesList {
anchors.fill: parent
currentPage: root.currentPage
model: pagesModel

View File

@ -0,0 +1,49 @@
import QtQuick 2.14
import QtQuick.Layouts 1.14
import QtQuick.Controls 2.14
import SortFilterProxyModel 0.2
ColumnLayout {
id: root
property alias model: filteredModel.sourceModel
property alias currentPage: pagesList.currentPage
signal pageSelected(string page)
SortFilterProxyModel {
id: filteredModel
filters: ExpressionFilter {
enabled: textField.length > 0
expression: {
const searchText = textField.text.toLowerCase()
return model.title.toLowerCase().indexOf(searchText) !== -1
}
}
}
TextField {
id: textField
Layout.fillWidth: true
placeholderText: "search"
Keys.onEscapePressed: {
text = ""
focus = false
}
}
PagesList {
id: pagesList
Layout.fillWidth: true
Layout.fillHeight: true
model: filteredModel
onPageSelected: root.pageSelected(page)
}
}

View File

@ -1,4 +1,5 @@
CompilationErrorsBox 1.0 CompilationErrorsBox.qml
FilteredPagesList 1.0 FilteredPagesList.qml
HotComponentFromSource 1.0 HotComponentFromSource.qml
HotLoader 1.0 HotLoader.qml
HotReloader 1.0 HotReloader.qml