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