2020-12-11 20:38:10 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.3
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2021-11-30 10:50:53 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2020-12-11 20:38:10 +00:00
|
|
|
|
2021-11-30 10:50:53 +00:00
|
|
|
import utils 1.0
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
ScrollView {
|
2021-11-30 10:50:53 +00:00
|
|
|
id: contactListPanel
|
|
|
|
|
|
|
|
property alias model: groupMembers.model
|
2020-12-11 20:38:10 +00:00
|
|
|
property string searchString
|
|
|
|
property bool selectMode: true
|
|
|
|
property var onItemChecked
|
|
|
|
|
2022-02-14 12:18:25 +00:00
|
|
|
property var selectedPubKeys: []
|
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.vertical.policy: groupMembers.contentHeight > groupMembers.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
|
|
|
|
2022-02-14 12:18:25 +00:00
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
ListView {
|
2021-11-30 10:50:53 +00:00
|
|
|
id: groupMembers
|
2020-12-11 20:38:10 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
clip: true
|
2021-11-30 10:50:53 +00:00
|
|
|
delegate: StatusListItem {
|
|
|
|
id: contactDelegate
|
2022-02-14 12:18:25 +00:00
|
|
|
property bool isChecked: selectedPubKeys.indexOf(model.pubKey) !== -1
|
2021-11-30 10:50:53 +00:00
|
|
|
title: !model.name.endsWith(".eth") && !!model.localNickname ?
|
|
|
|
model.localNickname : Utils.removeStatusEns(model.name)
|
2021-12-08 21:20:43 +00:00
|
|
|
image.source: Global.getProfileImage(model.pubKey) || model.identicon
|
2021-11-30 10:50:53 +00:00
|
|
|
image.isIdenticon: !!model.identicon
|
|
|
|
visible: {
|
2020-12-11 20:38:10 +00:00
|
|
|
if (selectMode) {
|
|
|
|
return !searchString || model.name.toLowerCase().includes(searchString)
|
|
|
|
}
|
2022-01-25 21:06:25 +00:00
|
|
|
return checkbox.checked
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
2022-02-14 12:18:25 +00:00
|
|
|
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
|
|
|
|
function contactToggled(pubKey) {
|
|
|
|
if (contactListPanel.selectMode) {
|
|
|
|
let pubkeys = contactListPanel.selectedPubKeys
|
|
|
|
let idx = pubkeys.indexOf(pubKey)
|
|
|
|
if (idx === -1) {
|
|
|
|
pubkeys.push(pubKey)
|
|
|
|
} else if (idx > -1) {
|
|
|
|
pubkeys.splice(idx, 1);
|
|
|
|
}
|
|
|
|
contactListPanel.selectedPubKeys = pubkeys
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-30 10:50:53 +00:00
|
|
|
components: [
|
|
|
|
StatusCheckBox {
|
|
|
|
id: checkbox
|
2022-02-14 12:18:25 +00:00
|
|
|
visible: contactListPanel.selectMode
|
|
|
|
checked: selectedPubKeys.indexOf(model.pubKey) !== -1
|
2021-11-30 10:50:53 +00:00
|
|
|
onClicked: {
|
2022-02-14 12:18:25 +00:00
|
|
|
contactDelegate.contactToggled(model.pubKey)
|
2021-11-30 10:50:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
onClicked: {
|
2022-02-14 12:18:25 +00:00
|
|
|
contactDelegate.contactToggled(model.pubKey)
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|