status-desktop/ui/app/AppLayouts/Chat/panels/ContactListPanel.qml

76 lines
2.2 KiB
QML
Raw Normal View History

2020-12-11 20:38:10 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.3
import StatusQ.Core 0.1
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Core.Theme 0.1
2020-12-11 20:38:10 +00:00
import utils 1.0
StatusListView {
id: contactListPanel
2020-12-11 20:38:10 +00:00
property string searchString
property bool selectMode: true
property var onItemChecked
property var selectedPubKeys: []
spacing: 0
2020-12-11 20:38:10 +00:00
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
delegate: StatusListItem {
id: contactDelegate
property bool isChecked: selectedPubKeys.indexOf(model.pubKey) !== -1
visible: {
if (selectMode) {
return !searchString || model.displayName.toLowerCase().includes(searchString)
2020-12-11 20:38:10 +00:00
}
return checkbox.checked
}
title: !model.displayName.endsWith(".eth") && !!model.localNickname ?
model.localNickname : Utils.removeStatusEns(model.displayName)
asset.height: asset.isImage ? 40 : 20
asset.width: asset.isImage ? 40 : 20
asset.name: model.icon
asset.isImage: model.icon !== ""
asset.color: Utils.colorForColorId(model.colorId)
asset.charactersLen: 2
ringSettings.ringSpecModel: Utils.getColorHashAsJson(model.pubKey)
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
}
}
components: [
StatusCheckBox {
id: checkbox
visible: contactListPanel.selectMode
checked: selectedPubKeys.indexOf(model.pubKey) !== -1
onClicked: {
contactDelegate.contactToggled(model.pubKey)
}
2020-12-11 20:38:10 +00:00
}
]
onClicked: {
contactDelegate.contactToggled(model.pubKey)
2020-12-11 20:38:10 +00:00
}
}
}