summaryrefslogtreecommitdiff
path: root/kodereviewer/qml/PullRequestFilesDrawer.qml
blob: e54fc7b478127f3a87a9030d9be3821ad20e0460 (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
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts

import org.kde.kirigami as Kirigami

import org.kde.kirigamiaddons.delegates as Delegates
import org.deprecated.kodereviewer 1.0

Kirigami.OverlayDrawer {
    id: root

    required property FileModel fileModel

    width: actualWidth

    readonly property int minWidth: Kirigami.Units.gridUnit * 15
    readonly property int maxWidth: Kirigami.Units.gridUnit * 25
    readonly property int defaultWidth: Kirigami.Units.gridUnit * 20
    property int actualWidth: {
        return Kirigami.Units.gridUnit * 20;
    }

    onOpened: forceActiveFocus()

    edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge

    topPadding: 0
    bottomPadding: 0
    leftPadding: 0
    rightPadding: 0

    Kirigami.Theme.colorSet: Kirigami.Theme.View

    contentItem: Loader {
        id: loader
        active: root.drawerOpen

        sourceComponent: QQC2.ScrollView {
            ListView {
                id: listView
                model: root.fileModel
                delegate: Delegates.RoundedItemDelegate {
                    required property string filename
                    required property string patch
                    highlighted: ListView.isCurrentItem
                    text: filename

                    onClicked: {
                        textArea.text = patch
                        textArea.file = filename
                    }
                }
            }
        }
    }
}