2022-09-06 13:19:50 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
import "../panels"
|
|
|
|
import "../stores"
|
|
|
|
import "private"
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
MembersSelectorBase {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
// TODO: use stores instead of modules
|
|
|
|
property var sectionModule
|
|
|
|
property var chatContentModule
|
|
|
|
|
2022-09-29 15:18:29 +00:00
|
|
|
confirmBtnEnabled: true
|
2022-09-06 13:19:50 +00:00
|
|
|
onConfirmed: {
|
|
|
|
d.updateGroupMembers()
|
|
|
|
d.resetTemporaryModel()
|
|
|
|
}
|
|
|
|
|
|
|
|
onRejected: {
|
|
|
|
d.resetTemporaryModel()
|
|
|
|
}
|
2022-09-29 15:18:29 +00:00
|
|
|
limitReached: (model.count === membersLimit)
|
2022-09-06 13:19:50 +00:00
|
|
|
onEntryAccepted: {
|
|
|
|
if (!root.limitReached) {
|
|
|
|
d.appendTemporaryModel(suggestionsDelegate._pubKey, suggestionsDelegate.userName)
|
|
|
|
root.edit.clear()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onEntryRemoved: {
|
|
|
|
if (!delegate.isReadonly) {
|
|
|
|
d.removeFromTemporaryModel(delegate._pubKey)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.chatContentModule.usersModule.temporaryModel
|
|
|
|
sorters: RoleSorter {
|
|
|
|
roleName: "isAdmin"
|
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: StatusTagItem {
|
|
|
|
readonly property string _pubKey: model.pubKey
|
|
|
|
|
|
|
|
height: ListView.view.height
|
2022-09-09 07:40:21 +00:00
|
|
|
text: model.displayName !== "" ? model.displayName : model.alias
|
2022-09-06 13:19:50 +00:00
|
|
|
isReadonly: {
|
|
|
|
if (model.isAdmin) return true
|
|
|
|
if (root.chatContentModule.amIChatAdmin()) return false
|
|
|
|
return index < root.chatContentModule.usersModule.model.count
|
|
|
|
}
|
|
|
|
icon: model.isAdmin ? "crown" : ""
|
|
|
|
|
|
|
|
onClicked: root.entryRemoved(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
function appendTemporaryModel(pubKey, displayName) {
|
|
|
|
root.chatContentModule.usersModule.appendTemporaryModel(pubKey, displayName)
|
|
|
|
}
|
|
|
|
function removeFromTemporaryModel(pubKey) {
|
|
|
|
root.chatContentModule.usersModule.removeFromTemporaryModel(pubKey)
|
|
|
|
}
|
|
|
|
function resetTemporaryModel() {
|
|
|
|
root.chatContentModule.usersModule.resetTemporaryModel()
|
|
|
|
}
|
|
|
|
function updateGroupMembers() {
|
|
|
|
root.chatContentModule.usersModule.updateGroupMembers()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
d.resetTemporaryModel()
|
|
|
|
}
|
|
|
|
}
|