Add search/filter functionality

This commit is contained in:
Dag Heyman 2017-02-06 15:57:32 +01:00
parent 7d247ac5b5
commit 135d5c3b62
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338

View File

@ -141,8 +141,8 @@ ApplicationWindow {
anchors.top: appWindow.top
Repeater {
id: repeater1
model: credentials
id: repeater
model: filteredCredentials(credentials, search.text)
Rectangle {
id: credentialRectangle
@ -198,6 +198,7 @@ ApplicationWindow {
Layout.fillWidth: true
}
}
MessageDialog {
id: touchYourYubikey
icon: StandardIcon.Information
@ -273,6 +274,20 @@ ApplicationWindow {
standardButtons: StandardButton.Ok
}
function filteredCredentials(creds, search) {
var result = []
if (creds != null) {
for (var i = 0; i < creds.length; i++) {
var cred = creds[i]
if (cred.name.toLowerCase().indexOf(search.toLowerCase(
)) !== -1) {
result.push(creds[i])
}
}
}
return result
}
function hasIssuer(name) {
return name.indexOf(':') !== -1
}