summaryrefslogtreecommitdiff
path: root/kodereviewer/qml/FilesDrawer.qml
blob: 3f98290373447ab253c388b9db4ce6a98e48cdad (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
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.kde.kitemmodels

import org.deprecated.kodereviewer 1.0


Kirigami.ContextDrawer {
    id: contextDrawer
    modal: false
    handleVisible: false
    property alias model: descendantsModel.model
    width: Kirigami.Units.gridUnit * 20

    signal fileSelected(string filename, string text)

    contentItem: ColumnLayout {
        id: mainLayout
        implicitWidth: Kirigami.Units.gridUnit * 20
        QQC2.ToolBar {
            id: toolbar
            Layout.fillWidth: true

            Layout.preferredHeight: pageStack.globalToolBar.preferredHeight

            contentItem: RowLayout {
                Kirigami.Heading {
                    Layout.fillWidth: true
                    text: "Files"
                }
            }
        }

        QQC2.ScrollView {
            Layout.fillWidth: true
            Layout.fillHeight: true

            ListView {
                anchors.fill: parent
                clip: true
                id: menu
                model: KDescendantsProxyModel {
                    id: descendantsModel
                }

                delegate: Delegates.RoundedTreeDelegate {
                    padding: 4
                    required property string filename
                    required property string iconName
                    required property string path
                    required property string patch
                    required property bool isFile
                    text: filename
                    icon.name: iconName

                    highlighted: menu.currentItem ? menu.currentItem.path == path : false
                    onClicked: {
                        menu.currentIndex = index
                        if (isFile) {
                            contextDrawer.fileSelected(filename, patch)
                        }
                    }
                }
            }
        }
    }
}