Warning, /network/neochat/src/qml/RoomData.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com>
0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003 
0004 import QtQuick
0005 import QtQuick.Layouts
0006 
0007 import org.kde.kirigami as Kirigami
0008 import org.kde.kirigamiaddons.formcard as FormCard
0009 import org.kde.kitemmodels
0010 
0011 import org.kde.neochat
0012 
0013 ColumnLayout {
0014     id: root
0015 
0016     required property NeoChatRoom room
0017     required property NeoChatConnection connection
0018 
0019     FormCard.FormHeader {
0020         title: i18nc("@title", "Choose Room")
0021     }
0022     FormCard.FormCard {
0023         FormCard.FormComboBoxDelegate {
0024             id: roomComboBox
0025             text: i18n("Room")
0026             textRole: "displayName"
0027             valueRole: "roomId"
0028             model: RoomListModel {
0029                 id: roomListModel
0030                 connection: root.connection
0031             }
0032             currentIndex: -1
0033             Component.onCompleted: currentIndex = roomListModel.rowForRoom(root.room)
0034             onCurrentValueChanged: root.room = roomListModel.roomByAliasOrId(roomComboBox.currentValue)
0035         }
0036         FormCard.FormTextDelegate {
0037             text: i18n("Room Id: %1", root.room.id)
0038         }
0039         FormCard.FormCheckDelegate {
0040             text: i18n("Show m.room.member events")
0041             checked: true
0042             onToggled: {
0043                 if (checked) {
0044                     stateEventFilterModel.removeStateEventTypeFiltered("m.room.member");
0045                 } else {
0046                     stateEventFilterModel.addStateEventTypeFiltered("m.room.member");
0047                 }
0048             }
0049         }
0050         FormCard.FormCheckDelegate {
0051             id: roomAccountDataVisibleCheck
0052             text: i18n("Show room account data")
0053             checked: false
0054         }
0055     }
0056     FormCard.FormHeader {
0057         visible: roomAccountDataVisibleCheck.checked
0058         title: i18n("Room Account Data")
0059     }
0060     FormCard.FormCard {
0061         visible: roomAccountDataVisibleCheck.checked
0062         Repeater {
0063             model: root.room.accountDataEventTypes
0064             delegate: FormCard.FormButtonDelegate {
0065                 text: modelData
0066                 onClicked: applicationWindow().pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/MessageSourceSheet.qml", {
0067                     "sourceText": root.room.roomAcountDataJson(text)
0068                 }, {
0069                     "title": i18n("Event Source"),
0070                     "width": Kirigami.Units.gridUnit * 25
0071                 })
0072             }
0073         }
0074     }
0075     FormCard.FormHeader {
0076         id: stateEventListHeader
0077         title: i18n("Room State")
0078     }
0079     FormCard.FormCard {
0080         Repeater {
0081             model: StateFilterModel {
0082                 id: stateEventFilterModel
0083                 sourceModel: StateModel {
0084                     id: stateModel
0085                     room: root.room
0086                 }
0087             }
0088 
0089             delegate: FormCard.FormButtonDelegate {
0090                 text: model.type
0091                 description: model.stateKey
0092                 onClicked: applicationWindow().pageStack.pushDialogLayer('qrc:/org/kde/neochat/qml/MessageSourceSheet.qml', {
0093                     sourceText: stateModel.stateEventJson(stateEventFilterModel.mapToSource(stateEventFilterModel.index(model.index, 0)))
0094                 }, {
0095                     title: i18n("Event Source"),
0096                     width: Kirigami.Units.gridUnit * 25
0097                 })
0098             }
0099         }
0100     }
0101 }