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
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property UsersStore usersStore
|
2022-09-06 13:19:50 +00:00
|
|
|
|
|
|
|
onConfirmed: {
|
2022-11-08 08:36:08 +00:00
|
|
|
usersStore.updateGroupMembers()
|
|
|
|
usersStore.resetTemporaryModel()
|
2022-09-06 13:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onRejected: {
|
2022-11-08 08:36:08 +00:00
|
|
|
usersStore.resetTemporaryModel()
|
2022-09-06 13:19:50 +00:00
|
|
|
}
|
2022-11-08 08:36:08 +00:00
|
|
|
|
|
|
|
onEntryAccepted: if (suggestionsDelegate) {
|
2022-09-06 13:19:50 +00:00
|
|
|
if (!root.limitReached) {
|
2022-11-08 08:36:08 +00:00
|
|
|
usersStore.appendTemporaryModel(suggestionsDelegate._pubKey, suggestionsDelegate.userName)
|
2022-09-06 13:19:50 +00:00
|
|
|
root.edit.clear()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-08 08:36:08 +00:00
|
|
|
onEntryRemoved: if (delegate) {
|
2022-09-06 13:19:50 +00:00
|
|
|
if (!delegate.isReadonly) {
|
2022-11-08 08:36:08 +00:00
|
|
|
usersStore.removeFromTemporaryModel(delegate._pubKey)
|
2022-09-06 13:19:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
model: SortFilterProxyModel {
|
2022-11-08 08:36:08 +00:00
|
|
|
sourceModel: root.usersStore.temporaryModel
|
2022-09-06 13:19:50 +00:00
|
|
|
sorters: RoleSorter {
|
2023-06-14 16:00:41 +00:00
|
|
|
roleName: "memberRole"
|
2022-09-06 13:19:50 +00:00
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: StatusTagItem {
|
|
|
|
readonly property string _pubKey: model.pubKey
|
|
|
|
|
|
|
|
height: ListView.view.height
|
2022-11-08 08:36:08 +00:00
|
|
|
text: root.tagText(model.localNickname, model.displayName, model.alias)
|
|
|
|
|
2022-09-06 13:19:50 +00:00
|
|
|
isReadonly: {
|
2023-06-14 16:00:41 +00:00
|
|
|
if (model.memberRole === Constants.memberRole.owner) return true
|
2022-11-08 08:36:08 +00:00
|
|
|
if (root.rootStore.amIChatAdmin()) return false
|
|
|
|
return index < root.usersStore.usersModel.count
|
2022-09-06 13:19:50 +00:00
|
|
|
}
|
2023-06-14 16:00:41 +00:00
|
|
|
icon: model.memberRole === Constants.memberRole.owner ? "crown" : ""
|
2022-09-06 13:19:50 +00:00
|
|
|
|
2023-04-03 15:12:21 +00:00
|
|
|
onClosed: root.entryRemoved(this)
|
2022-09-06 13:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2022-11-08 08:36:08 +00:00
|
|
|
usersStore.resetTemporaryModel()
|
2022-09-06 13:19:50 +00:00
|
|
|
}
|
|
|
|
}
|