|
@ -10,8 +10,9 @@ import "js/Debugger.js" as Debugger |
|
|
import "js/ErrorLocationFormater.js" as ErrorLocationFormater |
|
|
import "js/ErrorLocationFormater.js" as ErrorLocationFormater |
|
|
import "." |
|
|
import "." |
|
|
|
|
|
|
|
|
RowLayout |
|
|
ColumnLayout |
|
|
{ |
|
|
{ |
|
|
|
|
|
id: blockChainSelector |
|
|
signal restored(variant scenario) |
|
|
signal restored(variant scenario) |
|
|
signal saved(variant scenario) |
|
|
signal saved(variant scenario) |
|
|
signal duplicated(variant scenario) |
|
|
signal duplicated(variant scenario) |
|
@ -22,154 +23,209 @@ RowLayout |
|
|
scenarioList.load() |
|
|
scenarioList.load() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
id: blockChainSelector |
|
|
function needSaveOrReload() |
|
|
|
|
|
{ |
|
|
Dialog { |
|
|
editStatus.visible = true |
|
|
id: newStateWin |
|
|
} |
|
|
modality: Qt.ApplicationModal |
|
|
|
|
|
title: qsTr("New Project"); |
|
|
|
|
|
|
|
|
|
|
|
width: 320 |
|
|
|
|
|
height: 120 |
|
|
|
|
|
|
|
|
|
|
|
visible: false |
|
|
//anchors.margins: 10 |
|
|
|
|
|
//width: parent.width |
|
|
|
|
|
Rectangle |
|
|
|
|
|
{ |
|
|
|
|
|
Layout.fillWidth: true |
|
|
|
|
|
Layout.preferredHeight: 30 |
|
|
|
|
|
color: "transparent" |
|
|
|
|
|
Rectangle |
|
|
|
|
|
{ |
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter |
|
|
|
|
|
color: "transparent" |
|
|
|
|
|
Text |
|
|
|
|
|
{ |
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter |
|
|
|
|
|
id: scenarioName |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
contentItem: Rectangle { |
|
|
TextInput |
|
|
anchors.fill: parent |
|
|
{ |
|
|
anchors.margins: 10 |
|
|
id: scenarioNameEdit |
|
|
RowLayout { |
|
|
visible: false |
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
Text { |
|
|
anchors.horizontalCenter: parent.horizontalCenter |
|
|
text: qsTr("Name:") |
|
|
Keys.onEnterPressed: |
|
|
|
|
|
{ |
|
|
|
|
|
save() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Rectangle |
|
|
function edit() |
|
|
{ |
|
|
{ |
|
|
Layout.preferredWidth: 250 |
|
|
editIconRect.anchors.left = scenarioNameEdit.right |
|
|
Layout.preferredHeight: parent.height |
|
|
editStatus.parent.anchors.left = scenarioNameEdit.right |
|
|
border.width: 1 |
|
|
scenarioNameEdit.forceActiveFocus() |
|
|
border.color: "#cccccc" |
|
|
} |
|
|
TextInput |
|
|
|
|
|
{ |
|
|
function save() |
|
|
anchors.fill: parent |
|
|
{ |
|
|
id: stateName |
|
|
editIconRect.anchors.left = scenarioName.right |
|
|
} |
|
|
editStatus.parent.anchors.left = scenarioName.right |
|
|
|
|
|
scenarioName.text = scenarioNameEdit.text |
|
|
|
|
|
scenarioName.visible = true |
|
|
|
|
|
scenarioNameEdit.visible = false |
|
|
|
|
|
projectModel.stateListModel.getState(scenarioList.currentIndex).title = scenarioName.text |
|
|
|
|
|
projectModel.saveProjectFile() |
|
|
|
|
|
saved(state) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
RowLayout |
|
|
|
|
|
|
|
|
Connections |
|
|
{ |
|
|
{ |
|
|
anchors.bottom: parent.bottom |
|
|
target: blockChainSelector |
|
|
anchors.right: parent.right; |
|
|
onLoaded: |
|
|
function acceptAndClose() |
|
|
|
|
|
{ |
|
|
{ |
|
|
var item = projectModel.stateListModel.createDefaultState(); |
|
|
scenarioName.text = scenario.title |
|
|
item.title = stateName.text |
|
|
scenarioNameEdit.text = scenario.title |
|
|
projectModel.stateListModel.appendState(item) |
|
|
|
|
|
projectModel.stateListModel.save() |
|
|
|
|
|
close() |
|
|
|
|
|
scenarioList.currentIndex = projectModel.stateListModel.count - 1 |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function close() |
|
|
Rectangle |
|
|
{ |
|
|
{ |
|
|
newStateWin.close() |
|
|
anchors.left: scenarioName.right |
|
|
stateName.text = "" |
|
|
anchors.top: scenarioName.top |
|
|
|
|
|
anchors.leftMargin: 2 |
|
|
|
|
|
Layout.preferredWidth: 20 |
|
|
|
|
|
Text { |
|
|
|
|
|
id: editStatus |
|
|
|
|
|
text: "*" |
|
|
|
|
|
visible: false |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Button { |
|
|
Rectangle |
|
|
id: okButton; |
|
|
{ |
|
|
enabled: stateName.text !== "" |
|
|
id: editIconRect |
|
|
text: qsTr("OK"); |
|
|
anchors.left: scenarioName.right |
|
|
onClicked: { |
|
|
anchors.leftMargin: 15 |
|
|
parent.acceptAndClose(); |
|
|
Image { |
|
|
|
|
|
source: "qrc:/qml/img/edit.png" |
|
|
|
|
|
width: 10 |
|
|
|
|
|
fillMode: Image.PreserveAspectFit |
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter |
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter |
|
|
|
|
|
MouseArea |
|
|
|
|
|
{ |
|
|
|
|
|
anchors.fill: parent |
|
|
|
|
|
onClicked: |
|
|
|
|
|
{ |
|
|
|
|
|
scenarioName.visible = !scenarioName.visible |
|
|
|
|
|
scenarioNameEdit.visible = !scenarioNameEdit.visible |
|
|
|
|
|
if (!scenarioNameEdit.visible) |
|
|
|
|
|
scenarioNameEdit.save() |
|
|
|
|
|
else |
|
|
|
|
|
scenarioNameEdit.edit() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Button { |
|
|
|
|
|
text: qsTr("Cancel"); |
|
|
|
|
|
onClicked: parent.close(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ComboBox |
|
|
RowLayout |
|
|
{ |
|
|
{ |
|
|
id: scenarioList |
|
|
Layout.fillWidth: true |
|
|
model: projectModel.stateListModel |
|
|
Layout.preferredHeight: 50 |
|
|
textRole: "title" |
|
|
spacing: 0 |
|
|
onCurrentIndexChanged: |
|
|
|
|
|
{ |
|
|
|
|
|
restoreScenario.restore() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function load() |
|
|
Row |
|
|
{ |
|
|
{ |
|
|
var state = projectModel.stateListModel.getState(currentIndex) |
|
|
Layout.preferredWidth: 100 * 5 |
|
|
loaded(state) |
|
|
Layout.preferredHeight: 50 |
|
|
} |
|
|
spacing: 0 |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Row |
|
|
ComboBox |
|
|
{ |
|
|
|
|
|
Layout.preferredWidth: 100 * 4 |
|
|
|
|
|
Layout.preferredHeight: 30 |
|
|
|
|
|
spacing: 0 |
|
|
|
|
|
ScenarioButton { |
|
|
|
|
|
id: restoreScenario |
|
|
|
|
|
width: 100 |
|
|
|
|
|
height: 30 |
|
|
|
|
|
buttonShortcut: "" |
|
|
|
|
|
sourceImg: "qrc:/qml/img/restoreicon@2x.png" |
|
|
|
|
|
onClicked: { |
|
|
|
|
|
restore() |
|
|
|
|
|
} |
|
|
|
|
|
text: qsTr("Restore") |
|
|
|
|
|
function restore() |
|
|
|
|
|
{ |
|
|
{ |
|
|
var state = projectModel.stateListModel.reloadStateFromFromProject(scenarioList.currentIndex) |
|
|
id: scenarioList |
|
|
restored(state) |
|
|
model: projectModel.stateListModel |
|
|
loaded(state) |
|
|
textRole: "title" |
|
|
|
|
|
height: 30 |
|
|
|
|
|
onCurrentIndexChanged: |
|
|
|
|
|
{ |
|
|
|
|
|
restoreScenario.restore() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function load() |
|
|
|
|
|
{ |
|
|
|
|
|
var state = projectModel.stateListModel.getState(currentIndex) |
|
|
|
|
|
loaded(state) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ScenarioButton { |
|
|
|
|
|
id: restoreScenario |
|
|
|
|
|
width: 100 |
|
|
|
|
|
height: 30 |
|
|
|
|
|
buttonShortcut: "" |
|
|
|
|
|
sourceImg: "qrc:/qml/img/restoreicon@2x.png" |
|
|
|
|
|
onClicked: { |
|
|
|
|
|
restore() |
|
|
|
|
|
} |
|
|
|
|
|
text: qsTr("Restore") |
|
|
|
|
|
function restore() |
|
|
|
|
|
{ |
|
|
|
|
|
var state = projectModel.stateListModel.reloadStateFromFromProject(scenarioList.currentIndex) |
|
|
|
|
|
if (state) |
|
|
|
|
|
{ |
|
|
|
|
|
editStatus.visible = false |
|
|
|
|
|
restored(state) |
|
|
|
|
|
loaded(state) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ScenarioButton { |
|
|
ScenarioButton { |
|
|
id: saveScenario |
|
|
id: saveScenario |
|
|
text: qsTr("Save") |
|
|
text: qsTr("Save") |
|
|
onClicked: { |
|
|
onClicked: { |
|
|
projectModel.saveProjectFile() |
|
|
projectModel.saveProjectFile() |
|
|
saved(state) |
|
|
saved(state) |
|
|
|
|
|
} |
|
|
|
|
|
width: 100 |
|
|
|
|
|
height: 30 |
|
|
|
|
|
buttonShortcut: "" |
|
|
|
|
|
sourceImg: "qrc:/qml/img/saveicon@2x.png" |
|
|
} |
|
|
} |
|
|
width: 100 |
|
|
|
|
|
height: 30 |
|
|
|
|
|
buttonShortcut: "" |
|
|
|
|
|
sourceImg: "qrc:/qml/img/saveicon@2x.png" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ScenarioButton |
|
|
ScenarioButton |
|
|
{ |
|
|
{ |
|
|
id: duplicateScenario |
|
|
id: duplicateScenario |
|
|
text: qsTr("Duplicate") |
|
|
text: qsTr("Duplicate") |
|
|
onClicked: { |
|
|
onClicked: { |
|
|
projectModel.stateListModel.duplicateState(scenarioList.currentIndex) |
|
|
projectModel.stateListModel.duplicateState(scenarioList.currentIndex) |
|
|
duplicated(state) |
|
|
duplicated(state) |
|
|
|
|
|
} |
|
|
|
|
|
width: 100 |
|
|
|
|
|
height: 30 |
|
|
|
|
|
buttonShortcut: "" |
|
|
|
|
|
sourceImg: "qrc:/qml/img/duplicateicon@2x.png" |
|
|
} |
|
|
} |
|
|
width: 100 |
|
|
|
|
|
height: 30 |
|
|
|
|
|
buttonShortcut: "" |
|
|
|
|
|
sourceImg: "qrc:/qml/img/duplicateicon@2x.png" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ScenarioButton { |
|
|
ScenarioButton { |
|
|
id: addScenario |
|
|
id: addScenario |
|
|
width: 100 |
|
|
width: 100 |
|
|
height: 30 |
|
|
height: 30 |
|
|
buttonShortcut: "" |
|
|
buttonShortcut: "" |
|
|
sourceImg: "qrc:/qml/img/plus.png" |
|
|
sourceImg: "qrc:/qml/img/plus.png" |
|
|
onClicked: { |
|
|
onClicked: { |
|
|
newStateWin.open() |
|
|
var item = projectModel.stateListModel.createDefaultState(); |
|
|
|
|
|
item.title = qsTr("New Scenario") |
|
|
|
|
|
projectModel.stateListModel.appendState(item) |
|
|
|
|
|
projectModel.stateListModel.save() |
|
|
|
|
|
scenarioList.currentIndex = projectModel.stateListModel.count - 1 |
|
|
|
|
|
scenarioNameEdit.edit() |
|
|
|
|
|
} |
|
|
|
|
|
text: qsTr("New") |
|
|
} |
|
|
} |
|
|
text: qsTr("New") |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|