From c950a1c0afe997ecd180732c997cbffd1e4d0f93 Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Thu, 14 Jan 2021 21:50:19 +0200 Subject: [PATCH] Apply the search term when returning to the main view for example after editing an entry --- qml/pages/MainView.qml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/qml/pages/MainView.qml b/qml/pages/MainView.qml index 577a39a..36502f0 100644 --- a/qml/pages/MainView.qml +++ b/qml/pages/MainView.qml @@ -41,6 +41,7 @@ Page { // This holds the time of the last update of the page as Unix Timestamp (in Milliseconds) property double lastUpdated: 0 property double seconds_global: 0 + property string searchTerm: "" // Reload the List of OTPs from storage function refreshOTPList() { @@ -79,11 +80,17 @@ Page { lastUpdated = curDate.getTime(); } - // Reload OTP List on Return to the Page (to e.g. accomodate changed scd ettings) + // Reload OTP List on Return to the Page (to e.g. accomodate changed settings) onStatusChanged: { - if (status === PageStatus.Activating) { - refreshOTPList(); + if (status === PageStatus.Activating) { + refreshOTPList(); + + if (searchTerm != "") { + for (var i = 0; i < appWin.listModel.count; i++) { + appWin.listModel.get(i).itemVisible = appWin.listModel.get(i).title.toString().toLowerCase().indexOf(searchTerm.toLowerCase()) > -1 + } } + } } Timer { @@ -167,6 +174,7 @@ Page { inputMethodHints: Qt.ImhNoPredictiveText // Qt.ImhPreferUppercase | Qt.ImhNoAutoUppercase placeholderText: qsTr("Search") onTextChanged: { + searchTerm = searchField.text for (var i = 0; i < appWin.listModel.count; i++) { appWin.listModel.get(i).itemVisible = appWin.listModel.get(i).title.toString().toLowerCase().indexOf(searchField.text.toLowerCase()) > -1 }