swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 1 | import QtQuick 2.5 |
| 2 | import QtQuick.Controls 2.15 |
| 3 | import QtQuick.Controls.Material 2.0 |
| 4 | import QtQuick.Layouts 1.3 |
| 5 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 6 | import sh.swisschili.REFAL 1.0 |
| 7 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 8 | ApplicationWindow { |
| 9 | id: root |
| 10 | width: 1080 |
| 11 | height: 720 |
| 12 | title: "Notebook" |
| 13 | visible: true |
| 14 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 15 | Material.theme: Material.Light |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 16 | Material.accent: Material.Orange |
| 17 | |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 18 | Notebook { |
| 19 | id: notebook |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | Component.onCompleted: { |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 23 | notebook.cellModel.addCell("Refal { = Hi!; }", ""); |
| 24 | notebook.cellModel.addCell("<Refal>", "Hi!"); |
| 25 | notebook.cellModel.addCell("Hello there", "Hello there"); |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 26 | } |
| 27 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 28 | 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" |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 39 | width: implicitWidth |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | TabButton { |
| 43 | text: "Another Workspace" |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 44 | width: implicitWidth |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | TabButton { |
| 48 | text: "Testing" |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 49 | width: implicitWidth |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 50 | } |
| 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 |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 63 | model: notebook.cellModel |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 64 | clip: true |
| 65 | |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame^] | 66 | 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 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 83 | delegate: NotebookCell { |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 84 | id: notebookCell |
| 85 | |
| 86 | required property var model |
| 87 | required property var index |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame^] | 88 | required property var uuid |
| 89 | required property int status |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 90 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 91 | width: codeEditor.width - 5 |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 92 | |
| 93 | code: model.code |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame^] | 94 | result: model.result.trim() |
| 95 | status: model.status |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 96 | |
| 97 | onCodeEditingFinished: model.code = code |
| 98 | |
| 99 | onInsertBelowClicked: { |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame^] | 100 | 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) |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 107 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 108 | } |
| 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 | } |