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
|
2022-08-19 10:01:54 +00:00
|
|
|
import StatusQ.Core.Theme 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-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2021-11-30 10:50:53 +00:00
|
|
|
id: contactListPanel
|
|
|
|
|
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: []
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
spacing: 0
|
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
delegate: StatusListItem {
|
|
|
|
id: contactDelegate
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
property bool isChecked: selectedPubKeys.indexOf(model.pubKey) !== -1
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
visible: {
|
|
|
|
if (selectMode) {
|
|
|
|
return !searchString || model.displayName.toLowerCase().includes(searchString)
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
2022-07-14 11:03:36 +00:00
|
|
|
return checkbox.checked
|
|
|
|
}
|
2022-02-14 12:18:25 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
title: !model.displayName.endsWith(".eth") && !!model.localNickname ?
|
|
|
|
model.localNickname : Utils.removeStatusEns(model.displayName)
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.height: asset.isImage ? 40 : 20
|
|
|
|
asset.width: asset.isImage ? 40 : 20
|
|
|
|
asset.name: model.icon
|
|
|
|
asset.isImage: model.icon !== ""
|
2022-09-06 15:06:33 +00:00
|
|
|
asset.color: Utils.colorForColorId(model.colorId)
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.charactersLen: 2
|
2022-07-14 11:03:36 +00:00
|
|
|
ringSettings.ringSpecModel: Utils.getColorHashAsJson(model.pubKey)
|
2022-03-09 10:27:32 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
height: visible ? implicitHeight : 0
|
2022-02-14 12:18:25 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
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);
|
2022-02-14 12:18:25 +00:00
|
|
|
}
|
2022-07-14 11:03:36 +00:00
|
|
|
contactListPanel.selectedPubKeys = pubkeys
|
2022-02-14 12:18:25 +00:00
|
|
|
}
|
2022-07-14 11:03:36 +00:00
|
|
|
}
|
2022-02-14 12:18:25 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
components: [
|
|
|
|
StatusCheckBox {
|
|
|
|
id: checkbox
|
|
|
|
visible: contactListPanel.selectMode
|
|
|
|
checked: selectedPubKeys.indexOf(model.pubKey) !== -1
|
|
|
|
onClicked: {
|
|
|
|
contactDelegate.contactToggled(model.pubKey)
|
2021-11-30 10:50:53 +00:00
|
|
|
}
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
2022-07-14 11:03:36 +00:00
|
|
|
]
|
|
|
|
onClicked: {
|
|
|
|
contactDelegate.contactToggled(model.pubKey)
|
2020-12-11 20:38:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|