summaryrefslogtreecommitdiff
path: root/kodereviewer/qml/ReviewList.qml
blob: 77a00e0320006cd0e5767bd7eded900eb2610c7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
pragma ComponentBehavior: Bound
import QtQuick
import QtCore
import QtQuick.Controls as QQC2
import QtQuick.Layouts

import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.kirigamiaddons.components as KirigamiComponents


Kirigami.CardsListView {
    id: root

    Kirigami.PlaceholderMessage {
        visible: root.count == 0
        anchors.centerIn: parent
        text: "No reviews!"
    }

    delegate: Kirigami.AbstractCard {
        id: delegate

        required property int id
        required property string diff
        required property var reviews

        // clip: true

        header: Editor {
            text: delegate.diff
            file: "bla.txt"
        }

        contentItem: Item {
            implicitHeight: commentsLayout.implicitHeight
            implicitWidth: commentsLayout.implicitWidth
            ColumnLayout {
                id: commentsLayout
                anchors.fill: parent

                Repeater {
                    model: delegate.reviews
                    ColumnLayout {
                        required property var modelData

                        Kirigami.Separator {
                            Layout.fillWidth: true
                        }
                        RowLayout {
                            Layout.fillWidth: true
                            Layout.fillHeight: true

                            KirigamiComponents.Avatar {
                                name: modelData.user.username
                                source: modelData.user.avatarUrl
                                Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
                                Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium
                                Layout.fillWidth: false
                                Layout.alignment: Qt.AlignTop
                            }
                            QQC2.Label {
                                text: `@${modelData.user.username}`
                                Layout.fillWidth: false
                                Layout.alignment: Qt.AlignTop
                            }
                        }
                        MarkdownLabel {
                            Layout.fillWidth: true
                            text: modelData.body
                        }

                    }
                }

                RowLayout {
                    MarkdownTextArea {
                        id: addComment
                        Layout.fillWidth: true
                    }
                    QQC2.Button {
                        icon.name: "document-send-symbolic"
                        enabled: addComment.text != ''

                        onClicked: {
                            if (addComment.text == '') {
                                return
                            }

                            root.connection.createComment(root.pullRequest.number, newCommentTextArea.text)
                            newCommentTextArea.text == ''
                            getCommentsTimer.restart()
                        }
                    }
                }
            }
        }
    }
}