status-desktop/ui/app/AppLayouts/Profile/Sections/Contacts/ContactList.qml

80 lines
2.8 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "./samples/"
import "../../../../../imports"
import "../../../../../shared"
import "../../../Chat/components"
2020-06-18 13:54:08 +00:00
import "."
ListView {
id: contactList
property var contacts: ContactsData {}
property string searchStr: ""
property string searchString: ""
property string lowerCaseSearchString: searchString.toLowerCase()
property string contactToRemove: ""
property Component profilePopupComponent: ProfilePopup {
id: profilePopup
onClosed: destroy()
}
width: parent.width
model: contacts
2020-10-02 14:37:51 +00:00
delegate: Contact {
name: Utils.removeStatusEns(model.name)
address: model.address
localNickname: model.localNickname
2020-11-30 17:03:52 +00:00
identicon: model.thumbnailImage || model.identicon
2020-06-22 12:16:44 +00:00
isContact: model.isContact
isBlocked: model.isBlocked
profileClick: function (showFooter, userName, fromAuthor, identicon, textParam, nickName) {
var popup = profilePopupComponent.createObject(contactList);
popup.openPopup(showFooter, userName, fromAuthor, identicon, textParam, nickName);
}
visible: searchString === "" ||
model.name.toLowerCase().includes(lowerCaseSearchString) ||
model.address.toLowerCase().includes(lowerCaseSearchString)
onBlockContactActionTriggered: {
blockContactConfirmationDialog.contactName = name
blockContactConfirmationDialog.contactAddress = address
blockContactConfirmationDialog.open()
}
onRemoveContactActionTriggered: {
2020-10-02 14:37:51 +00:00
removeContactConfirmationDialog.value = address
removeContactConfirmationDialog.open()
}
}
2020-10-02 14:37:51 +00:00
// TODO: Make BlockContactConfirmationDialog a dynamic component on a future refactor
BlockContactConfirmationDialog {
id: blockContactConfirmationDialog
onBlockButtonClicked: {
2020-12-06 22:15:51 +00:00
profileModel.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
blockContactConfirmationDialog.close()
}
}
2020-10-02 14:37:51 +00:00
// TODO: Make ConfirmationDialog a dynamic component on a future refactor
ConfirmationDialog {
id: removeContactConfirmationDialog
title: qsTr("Remove contact")
2020-08-26 15:52:26 +00:00
//% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: {
2020-12-06 22:15:51 +00:00
if (profileModel.contacts.isAdded(removeContactConfirmationDialog.value)) {
profileModel.contacts.removeContact(removeContactConfirmationDialog.value);
}
removeContactConfirmationDialog.close()
}
}
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/