1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-02-24 12:14:57 +00:00

Some clean up

This commit is contained in:
Quentin Rouland 2025-02-11 10:52:03 +01:00
parent c6f2424017
commit 7e8ac60cc9
3 changed files with 18 additions and 15 deletions

View File

@ -19,14 +19,15 @@ Page {
for (var i = 0; i < __passwords.length; i++) { for (var i = 0; i < __passwords.length; i++) {
if (__passwords[i].toUpperCase().indexOf(filter.toUpperCase()) > -1) if (__passwords[i].toUpperCase().indexOf(filter.toUpperCase()) > -1)
ret.push(__passwords[i]); ret.push(__passwords[i]);
} }
} }
return ret; return ret;
} }
function __searchUpdateModel(text) { function __searchUpdateModel() {
var ret = __searchPasswords(text); const filter = passwordListHeader.searchBar.text;
console.info("filter : %1".arg(filter));
var ret = __searchPasswords(filter);
passwordListSearch.model.clear(); passwordListSearch.model.clear();
for (var i = 0; i < ret.length; i++) { for (var i = 0; i < ret.length; i++) {
if (ret[i]) if (ret[i])
@ -51,6 +52,7 @@ Page {
}); });
Pass.onLsSucceed.connect(function(passwords) { Pass.onLsSucceed.connect(function(passwords) {
passwordListPage.__passwords = passwords; passwordListPage.__passwords = passwords;
__searchUpdateModel();
}); });
Pass.ls(); Pass.ls();
} }
@ -109,7 +111,7 @@ Page {
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
spacing: 1 spacing: 1
visible: passwordListNav.model.count !== 0 && passwordListHeader.searchBarIsActive visible: passwordListNav.model.count !== 0 && !passwordListHeader.searchBar.visible
model: FolderListModel { model: FolderListModel {
nameFilters: ["*.gpg"] nameFilters: ["*.gpg"]
@ -146,7 +148,7 @@ Page {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
visible: passwordListNav.model.count !== 0 && !passwordListHeader.searchBarIsActive visible: passwordListNav.model.count !== 0 && passwordListHeader.searchBar.visible
model: ListModel { model: ListModel {
} }
@ -175,11 +177,16 @@ Page {
} }
Timer {
id: searchTimer
interval: 500
onTriggered: __searchUpdateModel()
}
header: MainHeader { header: MainHeader {
id: passwordListHeader id: passwordListHeader
onSearchBarActived: __searchUpdateModel("") searchBar.onTextChanged: searchTimer.restart()
onSearchBarTextChanged: __searchUpdateModel(text)
leadingActionBar.height: units.gu(4) leadingActionBar.height: units.gu(4)
leadingActionBar.actions: [ leadingActionBar.actions: [
Action { Action {

View File

@ -4,10 +4,9 @@ import QtQuick 2.4
PageHeader { PageHeader {
id: mainHeader id: mainHeader
readonly property bool searchBarIsActive: !searchBar.visible property alias searchBar: searchBar
//property alias searchBarText: searchBar.text
signal searchBarActived() //signal searchBarTextChanged(string text)
signal searchBarTextChanged(string text)
width: parent.width width: parent.width
height: units.gu(6) height: units.gu(6)
@ -16,14 +15,13 @@ PageHeader {
trailingActionBar.numberOfSlots: 2 trailingActionBar.numberOfSlots: 2
trailingActionBar.actions: [ trailingActionBar.actions: [
Action { Action {
iconName: searchBarIsActive ? "search" : "close" iconName: !searchBar.visible ? "search" : "close"
text: i18n.tr("Search") text: i18n.tr("Search")
onTriggered: { onTriggered: {
searchBar.visible = !searchBar.visible; searchBar.visible = !searchBar.visible;
labelTitle.visible = !searchBar.visible; labelTitle.visible = !searchBar.visible;
if (searchBar.visible === true) { if (searchBar.visible === true) {
searchBar.focus = true; searchBar.focus = true;
searchBarActived();
} }
} }
}, },
@ -64,7 +62,6 @@ PageHeader {
height: units.gu(4) height: units.gu(4)
visible: false visible: false
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
onTextChanged: searchBarTextChanged(searchBar.text)
} }
} }

View File

@ -15,7 +15,6 @@ Page {
property string __repoUrl property string __repoUrl
function __loadForm() { function __loadForm() {
console.debug("yo");
switch (combo.selectedIndex) { switch (combo.selectedIndex) {
case 0: case 0:
importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneHttp.qml"); importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneHttp.qml");