2020-06-17 15:18:31 -04:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-06-13 09:49:20 -04:00
|
|
|
import "./samples/"
|
|
|
|
import "../../../../../imports"
|
|
|
|
import "../../../../../shared"
|
2020-06-17 17:54:03 -04:00
|
|
|
import "../../../Chat/components"
|
2020-06-18 09:54:08 -04:00
|
|
|
import "."
|
2020-06-13 09:49:20 -04:00
|
|
|
|
|
|
|
ListView {
|
2020-06-16 14:04:56 -04:00
|
|
|
id: contactList
|
2020-06-13 09:49:20 -04:00
|
|
|
property var contacts: ContactsData {}
|
2020-06-16 14:04:56 -04:00
|
|
|
property var selectable: true
|
2020-07-24 13:27:26 +02:00
|
|
|
property string searchStr: ""
|
2020-06-16 14:04:56 -04:00
|
|
|
property alias selectedContact: contactGroup.checkedButton
|
2020-07-21 17:03:22 -04:00
|
|
|
property string searchString: ""
|
|
|
|
property string lowerCaseSearchString: searchString.toLowerCase()
|
2020-08-10 15:06:46 +02:00
|
|
|
property string contactToRemove: ""
|
2020-06-13 09:49:20 -04:00
|
|
|
|
2020-07-21 17:03:22 -04:00
|
|
|
width: parent.width
|
2020-06-13 09:49:20 -04:00
|
|
|
|
|
|
|
model: contacts
|
|
|
|
delegate: Contact {
|
2020-08-07 15:26:51 -04:00
|
|
|
name: Utils.removeStatusEns(model.name)
|
2020-06-13 09:49:20 -04:00
|
|
|
address: model.address
|
|
|
|
identicon: model.identicon
|
2020-06-22 08:16:44 -04:00
|
|
|
isContact: model.isContact
|
2020-07-24 13:27:26 +02:00
|
|
|
isBlocked: model.isBlocked
|
2020-06-16 14:04:56 -04:00
|
|
|
selectable: contactList.selectable
|
2020-06-17 17:54:03 -04:00
|
|
|
profileClick: profilePopup.openPopup.bind(profilePopup)
|
2020-07-21 17:03:22 -04:00
|
|
|
visible: searchString === "" ||
|
|
|
|
model.name.toLowerCase().includes(lowerCaseSearchString) ||
|
|
|
|
model.address.toLowerCase().includes(lowerCaseSearchString)
|
2020-08-10 13:56:16 +02:00
|
|
|
onBlockContactActionTriggered: {
|
|
|
|
blockContactConfirmationDialog.contactName = name
|
|
|
|
blockContactConfirmationDialog.contactAddress = address
|
|
|
|
blockContactConfirmationDialog.open()
|
|
|
|
}
|
2020-08-10 14:15:57 +02:00
|
|
|
onRemoveContactActionTriggered: {
|
2020-08-10 15:06:46 +02:00
|
|
|
contactList.contactToRemove = address
|
2020-08-10 14:15:57 +02:00
|
|
|
removeContactConfirmationDialog.open()
|
|
|
|
}
|
2020-06-17 17:54:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ProfilePopup {
|
|
|
|
id: profilePopup
|
2020-08-10 13:56:16 +02:00
|
|
|
onBlockButtonClicked: {
|
|
|
|
blockContactConfirmationDialog.contactName = name
|
|
|
|
blockContactConfirmationDialog.contactAddress = address
|
|
|
|
blockContactConfirmationDialog.open()
|
|
|
|
}
|
2020-08-10 14:15:57 +02:00
|
|
|
onRemoveButtonClicked: {
|
2020-08-10 15:06:46 +02:00
|
|
|
contactList.contactToRemove = address
|
2020-08-10 14:15:57 +02:00
|
|
|
removeContactConfirmationDialog.open()
|
|
|
|
}
|
2020-06-16 14:04:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ButtonGroup {
|
|
|
|
id: contactGroup
|
2020-06-13 09:49:20 -04:00
|
|
|
}
|
2020-07-24 13:27:26 +02:00
|
|
|
|
2020-08-10 13:56:16 +02:00
|
|
|
BlockContactConfirmationDialog {
|
|
|
|
id: blockContactConfirmationDialog
|
|
|
|
onBlockButtonClicked: {
|
|
|
|
profileModel.blockContact(blockContactConfirmationDialog.contactAddress)
|
|
|
|
blockContactConfirmationDialog.close()
|
|
|
|
}
|
|
|
|
}
|
2020-08-10 14:15:57 +02:00
|
|
|
|
2020-08-10 15:06:46 +02:00
|
|
|
ConfirmationDialog {
|
2020-08-10 14:15:57 +02:00
|
|
|
id: removeContactConfirmationDialog
|
2020-08-10 15:06:46 +02:00
|
|
|
title: qsTrId("remove-contact")
|
2020-08-26 11:52:26 -04:00
|
|
|
//% "Are you sure you want to remove this contact?"
|
|
|
|
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
2020-08-10 15:06:46 +02:00
|
|
|
onConfirmButtonClicked: {
|
|
|
|
if (profileModel.isAdded(contactList.contactToRemove)) {
|
|
|
|
profileModel.removeContact(contactList.contactToRemove)
|
2020-08-10 14:15:57 +02:00
|
|
|
}
|
|
|
|
removeContactConfirmationDialog.close()
|
|
|
|
}
|
|
|
|
}
|
2020-06-13 09:49:20 -04:00
|
|
|
}
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|