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
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Core 0.1
|
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
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
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
|
|
|
|
|
|
|
|
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-03-09 10:27:32 +00:00
|
|
|
|
2022-02-14 12:18:25 +00:00
|
|
|
property bool isChecked: selectedPubKeys.indexOf(model.pubKey) !== -1
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2021-11-30 10:50:53 +00:00
|
|
|
visible: {
|
2020-12-11 20:38:10 +00:00
|
|
|
if (selectMode) {
|
2022-06-12 16:17:18 +00:00
|
|
|
return !searchString || model.displayName.toLowerCase().includes(searchString)
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
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
|
|
|
|
2022-06-12 16:17:18 +00:00
|
|
|
title: !model.displayName.endsWith(".eth") && !!model.localNickname ?
|
|
|
|
model.localNickname : Utils.removeStatusEns(model.displayName)
|
2022-03-30 15:30:28 +00:00
|
|
|
image.source: Global.getProfileImage(model.pubKey)
|
2022-03-09 10:27:32 +00:00
|
|
|
ringSettings.ringSpecModel: Utils.getColorHashAsJson(model.pubKey)
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|