blob: bf99a8d417510a849e6cc5c71d82ff40f9798519 [file] [log] [blame]
swissChili23958ca2022-02-21 19:23:34 -08001import QtQuick 2.5
2import QtQuick.Controls 2.15
3import QtQuick.Controls.Material 2.0
4import QtQuick.Layouts 1.3
5
swissChili4b3105a2022-02-22 16:34:39 -08006import sh.swisschili.REFAL 1.0
7
swissChili23958ca2022-02-21 19:23:34 -08008ApplicationWindow {
9 id: root
10 width: 1080
11 height: 720
12 title: "Notebook"
13 visible: true
14
swissChili4b3105a2022-02-22 16:34:39 -080015 Material.theme: Material.Light
swissChili23958ca2022-02-21 19:23:34 -080016 Material.accent: Material.Orange
17
swissChili25620b02022-02-23 17:15:16 -080018 Notebook {
19 id: notebook
swissChili4b3105a2022-02-22 16:34:39 -080020 }
21
22 Component.onCompleted: {
swissChili25620b02022-02-23 17:15:16 -080023 notebook.cellModel.addCell("Refal { = Hi!; }", "");
24 notebook.cellModel.addCell("<Refal>", "Hi!");
25 notebook.cellModel.addCell("Hello there", "Hello there");
swissChili4b3105a2022-02-22 16:34:39 -080026 }
27
swissChili23958ca2022-02-21 19:23:34 -080028 ColumnLayout {
29 id: column
30 anchors.fill: parent
31
32 TabBar {
33 id: bar
34
35 Layout.fillWidth: true
36
37 TabButton {
38 text: "Example Workspace"
swissChili25620b02022-02-23 17:15:16 -080039 width: implicitWidth
swissChili23958ca2022-02-21 19:23:34 -080040 }
41
42 TabButton {
43 text: "Another Workspace"
swissChili25620b02022-02-23 17:15:16 -080044 width: implicitWidth
swissChili23958ca2022-02-21 19:23:34 -080045 }
46
47 TabButton {
48 text: "Testing"
swissChili25620b02022-02-23 17:15:16 -080049 width: implicitWidth
swissChili23958ca2022-02-21 19:23:34 -080050 }
51 }
52
53 SplitView {
54 id: split
55 Layout.fillHeight: true
56 Layout.fillWidth: true
57 orientation: Qt.Horizontal
58
59 ListView {
60 id: codeEditor
61 SplitView.fillWidth: true
62 SplitView.minimumWidth: 400
swissChili25620b02022-02-23 17:15:16 -080063 model: notebook.cellModel
swissChili23958ca2022-02-21 19:23:34 -080064 clip: true
65
swissChilid85daa92022-02-24 15:29:02 -080066 header: ColumnLayout {
67 width: codeEditor.width
68
69 DocumentPadding {
70 Layout.bottomMargin: 0
71
72 Label {
73 font.pointSize: 18
74 text: "Notebook"
75 }
76 }
77
78 InsertRow {
79 onInsertClicked: notebook.cellModel.insertRows(notebook.cellModel.index(0, 0), 1);
80 }
81 }
82
swissChili4b3105a2022-02-22 16:34:39 -080083 delegate: NotebookCell {
swissChili25620b02022-02-23 17:15:16 -080084 id: notebookCell
85
86 required property var model
87 required property var index
swissChilid85daa92022-02-24 15:29:02 -080088 required property var uuid
89 required property int status
swissChili25620b02022-02-23 17:15:16 -080090
swissChili23958ca2022-02-21 19:23:34 -080091 width: codeEditor.width - 5
swissChili25620b02022-02-23 17:15:16 -080092
93 code: model.code
swissChilid85daa92022-02-24 15:29:02 -080094 result: model.result.trim()
95 status: model.status
swissChili25620b02022-02-23 17:15:16 -080096
97 onCodeEditingFinished: model.code = code
98
99 onInsertBelowClicked: {
swissChilid85daa92022-02-24 15:29:02 -0800100 console.info(index);
101 notebook.cellModel.insertRows(notebook.cellModel.index(index + 1, 0), 1);
102 }
103
104 onRunClicked: {
105 console.info("Cell run clicked")
106 notebook.runCell(uuid)
swissChili25620b02022-02-23 17:15:16 -0800107 }
swissChili23958ca2022-02-21 19:23:34 -0800108 }
109 }
110
111 Item {
112 id: variables
113 SplitView.minimumWidth: 240
114
115 Label {
116 anchors.centerIn: parent
117 text: "Vars"
118 }
119 }
120 }
121 }
122}