From 691a82106e813393bb594bf8e75ffcc9b9bfa4df Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 27 Oct 2016 15:08:31 +0200 Subject: [PATCH] feat(SearchBox): create `_filter` function --- tests/ui/modules/Common/SearchBox.qml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/ui/modules/Common/SearchBox.qml b/tests/ui/modules/Common/SearchBox.qml index 566c9c105..ef798bafe 100644 --- a/tests/ui/modules/Common/SearchBox.qml +++ b/tests/ui/modules/Common/SearchBox.qml @@ -44,6 +44,18 @@ Item { _isOpen = true } + function _filter (text) { + console.assert( + model.setFilterFixedString != null, + '`model.setFilterFixedString` must be defined.' + ) + + model.setFilterFixedString(text) + if (model.invalidate) { + model.invalidate() + } + } + // ----------------------------------------------------------------- implicitHeight: searchField.height @@ -63,18 +75,7 @@ Item { Keys.onEscapePressed: searchBox.hideMenu() onActiveFocusChanged: activeFocus && searchBox.showMenu() - onTextChanged: { - console.assert( - model.setFilterFixedString != null, - '`model.setFilterFixedString` must be defined.' - ) - - model.setFilterFixedString(text) - - if (model.invalidate) { - model.invalidate() - } - } + onTextChanged: _filter() } // Wrap the search box menu in a window.