2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-06-13 13:49:20 +00:00
|
|
|
import "./samples/"
|
|
|
|
import "../../../../../imports"
|
|
|
|
import "../../../../../shared"
|
2020-06-17 21:54:03 +00:00
|
|
|
import "../../../Chat/components"
|
2020-06-18 13:54:08 +00:00
|
|
|
import "."
|
2020-06-13 13:49:20 +00:00
|
|
|
|
|
|
|
ListView {
|
2020-06-16 18:04:56 +00:00
|
|
|
id: contactList
|
2020-06-13 13:49:20 +00:00
|
|
|
property var contacts: ContactsData {}
|
2020-06-16 18:04:56 +00:00
|
|
|
property var selectable: true
|
2020-07-24 11:27:26 +00:00
|
|
|
property string searchStr: ""
|
2020-06-16 18:04:56 +00:00
|
|
|
property alias selectedContact: contactGroup.checkedButton
|
2020-07-21 21:03:22 +00:00
|
|
|
property string searchString: ""
|
|
|
|
property string lowerCaseSearchString: searchString.toLowerCase()
|
2020-08-10 13:06:46 +00:00
|
|
|
property string contactToRemove: ""
|
2020-06-13 13:49:20 +00:00
|
|
|
|
2020-07-21 21:03:22 +00:00
|
|
|
width: parent.width
|
2020-06-13 13:49:20 +00:00
|
|
|
|
|
|
|
model: contacts
|
2020-10-02 14:37:51 +00:00
|
|
|
|
2020-06-13 13:49:20 +00:00
|
|
|
delegate: Contact {
|
2020-08-07 19:26:51 +00:00
|
|
|
name: Utils.removeStatusEns(model.name)
|
2020-06-13 13:49:20 +00:00
|
|
|
address: model.address
|
2020-09-16 19:52:48 +00:00
|
|
|
localNickname: model.localNickname
|
2020-06-13 13:49:20 +00:00
|
|
|
identicon: model.identicon
|
2020-06-22 12:16:44 +00:00
|
|
|
isContact: model.isContact
|
2020-07-24 11:27:26 +00:00
|
|
|
isBlocked: model.isBlocked
|
2020-06-16 18:04:56 +00:00
|
|
|
selectable: contactList.selectable
|
2020-06-17 21:54:03 +00:00
|
|
|
profileClick: profilePopup.openPopup.bind(profilePopup)
|
2020-07-21 21:03:22 +00:00
|
|
|
visible: searchString === "" ||
|
|
|
|
model.name.toLowerCase().includes(lowerCaseSearchString) ||
|
|
|
|
model.address.toLowerCase().includes(lowerCaseSearchString)
|
2020-08-10 11:56:16 +00:00
|
|
|
onBlockContactActionTriggered: {
|
|
|
|
blockContactConfirmationDialog.contactName = name
|
|
|
|
blockContactConfirmationDialog.contactAddress = address
|
|
|
|
blockContactConfirmationDialog.open()
|
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
onRemoveContactActionTriggered: {
|
2020-10-02 14:37:51 +00:00
|
|
|
removeContactConfirmationDialog.value = address
|
2020-08-10 12:15:57 +00:00
|
|
|
removeContactConfirmationDialog.open()
|
|
|
|
}
|
2020-06-17 21:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ProfilePopup {
|
|
|
|
id: profilePopup
|
2020-06-13 13:49:20 +00:00
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
2020-10-02 14:37:51 +00:00
|
|
|
// TODO: Make BlockContactConfirmationDialog a dynamic component on a future refactor
|
2020-08-10 11:56:16 +00:00
|
|
|
BlockContactConfirmationDialog {
|
|
|
|
id: blockContactConfirmationDialog
|
|
|
|
onBlockButtonClicked: {
|
2020-12-06 22:15:51 +00:00
|
|
|
profileModel.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
|
2020-08-10 11:56:16 +00:00
|
|
|
blockContactConfirmationDialog.close()
|
|
|
|
}
|
|
|
|
}
|
2020-08-10 12:15:57 +00:00
|
|
|
|
2020-10-02 14:37:51 +00:00
|
|
|
// TODO: Make ConfirmationDialog a dynamic component on a future refactor
|
2020-08-10 13:06:46 +00:00
|
|
|
ConfirmationDialog {
|
2020-08-10 12:15:57 +00:00
|
|
|
id: removeContactConfirmationDialog
|
2020-08-10 13:06:46 +00:00
|
|
|
title: qsTrId("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-")
|
2020-08-10 13:06:46 +00:00
|
|
|
onConfirmButtonClicked: {
|
2020-12-06 22:15:51 +00:00
|
|
|
if (profileModel.contacts.isAdded(removeContactConfirmationDialog.value)) {
|
|
|
|
profileModel.contacts.removeContact(removeContactConfirmationDialog.value);
|
2020-08-10 12:15:57 +00:00
|
|
|
}
|
|
|
|
removeContactConfirmationDialog.close()
|
|
|
|
}
|
|
|
|
}
|
2020-10-02 14:37:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ButtonGroup {
|
|
|
|
id: contactGroup
|
|
|
|
}
|
2020-06-13 13:49:20 +00:00
|
|
|
}
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|