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

0001 // SPDX-FileCopyrightText: 2022 Tobias Fella <tobias.fella@kde.org>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Controls
0006 import QtQuick.Layouts
0007 import Qt.labs.platform
0008 
0009 import org.kde.neochat
0010 
0011 /**
0012  * @brief A timeline delegate for a poll message.
0013  *
0014  * @inherit MessageDelegate
0015  */
0016 MessageDelegate {
0017     id: root
0018 
0019     /**
0020      * @brief The poll handler for this poll.
0021      *
0022      * This contains the required information like what the question, answers and
0023      * current number of votes for each is.
0024      */
0025     required property var pollHandler
0026 
0027     bubbleContent: ColumnLayout {
0028         Label {
0029             id: questionLabel
0030             text: root.pollHandler.question
0031             wrapMode: Text.Wrap
0032             Layout.fillWidth: true
0033         }
0034         Repeater {
0035             model: root.pollHandler.options
0036             delegate: RowLayout {
0037                 Layout.fillWidth: true
0038                 CheckBox {
0039                     checked: root.pollHandler.answers[root.room.localUser.id] ? root.pollHandler.answers[root.room.localUser.id].includes(modelData["id"]) : false
0040                     onClicked: root.pollHandler.sendPollAnswer(root.eventId, modelData["id"])
0041                     enabled: !root.pollHandler.hasEnded
0042                 }
0043                 Label {
0044                     text: modelData["org.matrix.msc1767.text"]
0045                     Layout.fillWidth: true
0046                     wrapMode: Text.Wrap
0047                 }
0048                 Label {
0049                     visible: root.pollHandler.kind == "org.matrix.msc3381.poll.disclosed" || pollHandler.hasEnded
0050                     Layout.preferredWidth: contentWidth
0051                     text: root.pollHandler.counts[modelData["id"]] ?? "0"
0052                 }
0053             }
0054         }
0055         Label {
0056             visible: root.pollHandler.kind == "org.matrix.msc3381.poll.disclosed" || root.pollHandler.hasEnded
0057             text: i18np("Based on votes by %1 user", "Based on votes by %1 users", root.pollHandler.answerCount) + (root.pollHandler.hasEnded ? (" " + i18nc("as in 'this vote has ended'", "(Ended)")) : "")
0058             font.pointSize: questionLabel.font.pointSize * 0.8
0059         }
0060     }
0061 }