From 9701380e3c23a45c914a90ca4efa321168d1bf2e Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 12 Nov 2020 16:42:03 -0800 Subject: [PATCH] search contact list --- qml/widgets/ContactList.qml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/qml/widgets/ContactList.qml b/qml/widgets/ContactList.qml index e0165564..e391df71 100644 --- a/qml/widgets/ContactList.qml +++ b/qml/widgets/ContactList.qml @@ -28,6 +28,10 @@ ColumnLayout { id: myprof } + function filterContact(displayName, handle) { + return searchAddText.text == "" || displayName.toLowerCase().includes(searchAddText.text.toLowerCase()) || handle.toLowerCase().startsWith(searchAddText.text.toLowerCase()) + } + function removeContact(model, handle) { for(var i = 0; i < model.count; i++){ if(model.get(i)["_handle"] == handle) { @@ -50,16 +54,17 @@ ColumnLayout { //: ex: "... paste an address here to add a contact ..." - placeholderText: qsTr("paste-address-to-add-contact") + //placeholderText: qsTr("paste-address-to-add-contact") horizontalAlignment: TextInput.AlignHCenter icon: gcd.assetPath + "core/search-24px.svg" onTextChanged: { - if (text != "") { + // TODO: detect peer or group address and insert a contactRow that asks to add the corresponding group or peer + /*if (text != "") { gcd.importString(text) text = "" - } + }*/ } } @@ -88,6 +93,7 @@ ColumnLayout { model = blockedContactsModel } + // If contact already in model, skip for (var i = 0; i < model.count; i++) { if (model.get(i)["_handle"] == handle) { return @@ -166,6 +172,7 @@ ColumnLayout { loading: _loading rowColor: (_authorization == Const.auth_unknown) ? Theme.backgroundHilightElementColor : Theme.backgroundMainColor Layout.fillWidth: true + visible: filterContact(displayName, handle) } } @@ -275,6 +282,7 @@ ColumnLayout { authorization: _authorization loading: _loading Layout.fillWidth: true + visible: filterContact(displayName, handle) } } }