Browse Source

fix #1472

cl-refactor
Ali Mashatan 10 years ago
parent
commit
11670e68d3
  1. 50
      mix/qml/Debugger.qml
  2. 454
      mix/qml/StatesComboBox.qml
  3. 292
      mix/qml/TransactionLog.qml

50
mix/qml/Debugger.qml

@ -220,31 +220,31 @@ Rectangle {
id: jumpButtons id: jumpButtons
spacing: 3 spacing: 3
StepActionImage StepActionImage
{ {
id: playAction id: playAction
enabledStateImg: "qrc:/qml/img/play_button.png" enabledStateImg: "qrc:/qml/img/play_button.png"
disableStateImg: "qrc:/qml/img/play_button.png" disableStateImg: "qrc:/qml/img/play_button.png"
onClicked: console.log("play"); onClicked: console.log("play");
width: 30 width: 30
height: 30 height: 30
buttonShortcut: "Ctrl+Shift+F8" buttonShortcut: "Ctrl+Shift+F8"
buttonTooltip: qsTr("Play") buttonTooltip: qsTr("Play")
visible: true visible: true
} }
StepActionImage StepActionImage
{ {
id: pauseAction id: pauseAction
enabledStateImg: "qrc:/qml/img/pause_button.png" enabledStateImg: "qrc:/qml/img/pause_button.png"
disableStateImg: "qrc:/qml/img/pause_button.png" disableStateImg: "qrc:/qml/img/pause_button.png"
onClicked: console.log("pause"); onClicked: console.log("pause");
width: 30 width: 30
height: 30 height: 30
buttonShortcut: "Ctrl+Shift+F9" buttonShortcut: "Ctrl+Shift+F9"
buttonTooltip: qsTr("Pause") buttonTooltip: qsTr("Pause")
visible: true visible: true
} }
StepActionImage StepActionImage
{ {

454
mix/qml/StatesComboBox.qml

@ -1,18 +1,18 @@
/* /*
This file is part of cpp-ethereum. This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful, cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file StatesComboBox.qml /** @file StatesComboBox.qml
* @author Ali Mashatan ali@ethdev.com * @author Ali Mashatan ali@ethdev.com
@ -26,220 +26,220 @@ import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
Rectangle { Rectangle {
id: statesComboBox id: statesComboBox
width: 200 width: 200
height: 20 height: 20
Component.onCompleted: { Component.onCompleted: {
var top = dropDownList var top = dropDownList
while (top.parent) { while (top.parent) {
top = top.parent top = top.parent
if (top.objectName == "debugPanel") if (top.objectName == "debugPanel")
break break
} }
var coordinates = dropDownList.mapToItem(top, 0, 0) var coordinates = dropDownList.mapToItem(top, 0, 0)
//the order is important //the order is important
dropDownShowdowList.parent = top dropDownShowdowList.parent = top
dropDownList.parent = top dropDownList.parent = top
dropDownShowdowList.x = coordinates.x dropDownShowdowList.x = coordinates.x
dropDownShowdowList.y = coordinates.y dropDownShowdowList.y = coordinates.y
dropDownList.x = coordinates.x dropDownList.x = coordinates.x
dropDownList.y = coordinates.y dropDownList.y = coordinates.y
} }
signal selectItem(real item) signal selectItem(real item)
signal editItem(real item) signal editItem(real item)
signal selectCreate signal selectCreate
property variant rowHeight: 25 property variant rowHeight: 25
property variant items property variant items
property alias selectedItem: chosenItemText.text property alias selectedItem: chosenItemText.text
property alias selectedIndex: listView.currentRow property alias selectedIndex: listView.currentRow
function setSelectedIndex(index) { function setSelectedIndex(index) {
listView.currentRow = index listView.currentRow = index
chosenItemText.text = statesComboBox.items.get(index).title chosenItemText.text = statesComboBox.items.get(index).title
} }
signal comboClicked signal comboClicked
property variant colorItem property variant colorItem
property variant colorSelect property variant colorSelect
smooth: true smooth: true
Rectangle { Rectangle {
id: chosenItem id: chosenItem
width: parent.width width: parent.width
height: statesComboBox.height height: statesComboBox.height
color: statesComboBox.color color: statesComboBox.color
smooth: true smooth: true
Text { Text {
id: chosenItemText id: chosenItemText
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.margins: 2 anchors.margins: 2
color: statesComboBox.colorItem color: statesComboBox.colorItem
text: "" text: ""
smooth: true smooth: true
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
statesComboBox.state = statesComboBox.state === "dropDown" ? "" : "dropDown" statesComboBox.state = statesComboBox.state === "dropDown" ? "" : "dropDown"
} }
} }
} }
Rectangle { Rectangle {
id: dropDownShowdowList id: dropDownShowdowList
width: statesComboBox.width width: statesComboBox.width
opacity: 0.3 opacity: 0.3
height: 0 height: 0
clip: true clip: true
radius: 4 radius: 4
anchors.top: chosenItem.top anchors.top: chosenItem.top
anchors.margins: 2 anchors.margins: 2
color: "gray" color: "gray"
} }
//ToDo: We need scrollbar for items //ToDo: We need scrollbar for items
Rectangle { Rectangle {
id: dropDownList id: dropDownList
width: statesComboBox.width width: statesComboBox.width
height: 0 height: 0
clip: true clip: true
radius: 4 radius: 4
anchors.top: chosenItem.top anchors.top: chosenItem.top
anchors.margins: 2 anchors.margins: 2
color: statesComboBox.color color: statesComboBox.color
ColumnLayout { ColumnLayout {
spacing: 2 spacing: 2
TableView { TableView {
id: listView id: listView
height: 20 height: 20
implicitHeight: 0 implicitHeight: 0
width: statesComboBox.width width: statesComboBox.width
model: statesComboBox.items model: statesComboBox.items
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
currentRow: -1 currentRow: -1
headerVisible: false headerVisible: false
backgroundVisible: false backgroundVisible: false
alternatingRowColors: false alternatingRowColors: false
frameVisible: false frameVisible: false
TableViewColumn { TableViewColumn {
role: "title" role: "title"
title: "" title: ""
width: statesComboBox.width width: statesComboBox.width
delegate: mainItemDelegate delegate: mainItemDelegate
} }
rowDelegate: Rectangle { rowDelegate: Rectangle {
width: statesComboBox.width width: statesComboBox.width
height: statesComboBox.rowHeight height: statesComboBox.rowHeight
} }
Component { Component {
id: mainItemDelegate id: mainItemDelegate
Rectangle { Rectangle {
id: itemDelegate id: itemDelegate
width: statesComboBox.width width: statesComboBox.width
height: statesComboBox.height height: statesComboBox.height
Text { Text {
id: textItemid id: textItemid
text: styleData.value text: styleData.value
color: statesComboBox.colorItem color: statesComboBox.colorItem
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.margins: 5 anchors.margins: 5
} }
Image { Image {
id: imageItemid id: imageItemid
height: 20 height: 20
width: 20 width: 20
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
anchors.margins: 5 anchors.margins: 5
visible: false visible: false
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
source: "img/edit_combox.png" source: "img/edit_combox.png"
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onEntered: { onEntered: {
imageItemid.visible = true imageItemid.visible = true
textItemid.color = statesComboBox.colorSelect textItemid.color = statesComboBox.colorSelect
} }
onExited: { onExited: {
imageItemid.visible = false imageItemid.visible = false
textItemid.color = statesComboBox.colorItem textItemid.color = statesComboBox.colorItem
} }
onClicked: { onClicked: {
if (mouseX > imageItemid.x if (mouseX > imageItemid.x
&& mouseX < imageItemid.x + imageItemid.width && mouseX < imageItemid.x + imageItemid.width
&& mouseY > imageItemid.y && mouseY > imageItemid.y
&& mouseY < imageItemid.y + imageItemid.height) && mouseY < imageItemid.y + imageItemid.height)
statesComboBox.editItem(styleData.row) statesComboBox.editItem(styleData.row)
else { else {
statesComboBox.state = "" statesComboBox.state = ""
var prevSelection = chosenItemText.text var prevSelection = chosenItemText.text
chosenItemText.text = styleData.value chosenItemText.text = styleData.value
listView.currentRow = styleData.row listView.currentRow = styleData.row
statesComboBox.selectItem(styleData.row) statesComboBox.selectItem(styleData.row)
} }
} }
} }
} //Item } //Item
} //Component } //Component
} //Table View } //Table View
RowLayout { RowLayout {
Rectangle { Rectangle {
width: 1 width: 1
} }
Text { Text {
id: createStateText id: createStateText
width: statesComboBox.width width: statesComboBox.width
height: statesComboBox.height height: statesComboBox.height
font.bold: true font.bold: true
text: qsTr("Create State ...") text: qsTr("Create State ...")
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onEntered: { onEntered: {
createStateText.color = statesComboBox.colorSelect createStateText.color = statesComboBox.colorSelect
} }
onExited: { onExited: {
createStateText.color = statesComboBox.colorItem createStateText.color = statesComboBox.colorItem
} }
onClicked: { onClicked: {
statesComboBox.state = "" statesComboBox.state = ""
statesComboBox.selectCreate() statesComboBox.selectCreate()
} }
} }
} }
} }
} }
} }
states: State { states: State {
name: "dropDown" name: "dropDown"
PropertyChanges { PropertyChanges {
target: dropDownList target: dropDownList
height: (statesComboBox.rowHeight * (statesComboBox.items.count + 1)) height: (statesComboBox.rowHeight * (statesComboBox.items.count + 1))
} }
PropertyChanges { PropertyChanges {
target: dropDownShowdowList target: dropDownShowdowList
width: statesComboBox.width + 3 width: statesComboBox.width + 3
height: (statesComboBox.rowHeight * (statesComboBox.items.count + 1)) + 3 height: (statesComboBox.rowHeight * (statesComboBox.items.count + 1)) + 3
} }
PropertyChanges { PropertyChanges {
target: listView target: listView
height: 20 height: 20
implicitHeight: (statesComboBox.rowHeight * (statesComboBox.items.count)) implicitHeight: (statesComboBox.rowHeight * (statesComboBox.items.count))
} }
} }
} }

292
mix/qml/TransactionLog.qml

@ -6,157 +6,157 @@ import QtQuick.Layouts 1.1
import org.ethereum.qml.RecordLogEntry 1.0 import org.ethereum.qml.RecordLogEntry 1.0
Item { Item {
property ListModel fullModel: ListModel{} property ListModel fullModel: ListModel{}
property ListModel transactionModel: ListModel{} property ListModel transactionModel: ListModel{}
property ListModel callModel: ListModel{} property ListModel callModel: ListModel{}
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
RowLayout { RowLayout {
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
Connections Connections
{ {
id: compilationStatus id: compilationStatus
target: codeModel target: codeModel
property bool compilationComplete: false property bool compilationComplete: false
onCompilationComplete: compilationComplete = true onCompilationComplete: compilationComplete = true
onCompilationError: compilationComplete = false onCompilationError: compilationComplete = false
} }
Connections Connections
{ {
target: projectModel target: projectModel
onProjectSaved: onProjectSaved:
{ {
if (projectModel.appIsClosing || projectModel.projectIsClosing) if (projectModel.appIsClosing || projectModel.projectIsClosing)
return; return;
if (compilationStatus.compilationComplete && codeModel.hasContract && !clientModel.running) if (compilationStatus.compilationComplete && codeModel.hasContract && !clientModel.running)
projectModel.stateListModel.debugDefaultState(); projectModel.stateListModel.debugDefaultState();
} }
onProjectClosed: onProjectClosed:
{ {
fullModel.clear(); fullModel.clear();
transactionModel.clear(); transactionModel.clear();
callModel.clear(); callModel.clear();
} }
onContractSaved: { onContractSaved: {
if (compilationStatus.compilationComplete && codeModel.hasContract && !clientModel.running) if (compilationStatus.compilationComplete && codeModel.hasContract && !clientModel.running)
projectModel.stateListModel.debugDefaultState(); projectModel.stateListModel.debugDefaultState();
} }
} }
StatesComboBox StatesComboBox
{ {
id: statesCombo id: statesCombo
items: projectModel.stateListModel items: projectModel.stateListModel
onSelectCreate: projectModel.stateListModel.addState(); onSelectCreate: projectModel.stateListModel.addState();
onEditItem: projectModel.stateListModel.editState(item) onEditItem: projectModel.stateListModel.editState(item)
colorItem: "black" colorItem: "black"
colorSelect: "blue" colorSelect: "blue"
color: "white" color: "white"
Connections { Connections {
target: projectModel.stateListModel target: projectModel.stateListModel
onStateRun: { onStateRun: {
if (statesCombo.selectedIndex !== index) if (statesCombo.selectedIndex !== index)
statesCombo.setSelectedIndex( index ); statesCombo.setSelectedIndex( index );
} }
} }
} }
Button Button
{ {
anchors.rightMargin: 9 anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
action: mineAction action: mineAction
} }
ComboBox { ComboBox {
id: itemFilter id: itemFilter
function getCurrentModel() function getCurrentModel()
{ {
return currentIndex === 0 ? fullModel : currentIndex === 1 ? transactionModel : currentIndex === 2 ? callModel : fullModel; return currentIndex === 0 ? fullModel : currentIndex === 1 ? transactionModel : currentIndex === 2 ? callModel : fullModel;
} }
model: ListModel { model: ListModel {
ListElement { text: qsTr("Calls and Transactions"); value: 0; } ListElement { text: qsTr("Calls and Transactions"); value: 0; }
ListElement { text: qsTr("Only Transactions"); value: 1; } ListElement { text: qsTr("Only Transactions"); value: 1; }
ListElement { text: qsTr("Only Calls"); value: 2; } ListElement { text: qsTr("Only Calls"); value: 2; }
} }
onCurrentIndexChanged: onCurrentIndexChanged:
{ {
logTable.model = itemFilter.getCurrentModel(); logTable.model = itemFilter.getCurrentModel();
} }
} }
} }
TableView { TableView {
id: logTable id: logTable
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
model: fullModel model: fullModel
TableViewColumn { TableViewColumn {
role: "transactionIndex" role: "transactionIndex"
title: qsTr("#") title: qsTr("#")
width: 40 width: 40
} }
TableViewColumn { TableViewColumn {
role: "contract" role: "contract"
title: qsTr("Contract") title: qsTr("Contract")
width: 100 width: 100
} }
TableViewColumn { TableViewColumn {
role: "function" role: "function"
title: qsTr("Function") title: qsTr("Function")
width: 120 width: 120
} }
TableViewColumn { TableViewColumn {
role: "value" role: "value"
title: qsTr("Value") title: qsTr("Value")
width: 60 width: 60
} }
TableViewColumn { TableViewColumn {
role: "address" role: "address"
title: qsTr("Destination") title: qsTr("Destination")
width: 130 width: 130
} }
TableViewColumn { TableViewColumn {
role: "returned" role: "returned"
title: qsTr("Returned") title: qsTr("Returned")
width: 120 width: 120
} }
onActivated: { onActivated: {
var item = logTable.model.get(row); var item = logTable.model.get(row);
if (item.type === RecordLogEntry.Transaction) if (item.type === RecordLogEntry.Transaction)
clientModel.debugRecord(item.recordIndex); clientModel.debugRecord(item.recordIndex);
else else
clientModel.emptyRecord(); clientModel.emptyRecord();
} }
Keys.onPressed: { Keys.onPressed: {
if ((event.modifiers & Qt.ControlModifier) && event.key === Qt.Key_C && currentRow >=0 && currentRow < logTable.model.count) { if ((event.modifiers & Qt.ControlModifier) && event.key === Qt.Key_C && currentRow >=0 && currentRow < logTable.model.count) {
var item = logTable.model.get(currentRow); var item = logTable.model.get(currentRow);
appContext.toClipboard(item.returned); appContext.toClipboard(item.returned);
} }
} }
} }
} }
Connections { Connections {
target: clientModel target: clientModel
onStateCleared: { onStateCleared: {
fullModel.clear(); fullModel.clear();
transactionModel.clear(); transactionModel.clear();
callModel.clear(); callModel.clear();
} }
onNewRecord: { onNewRecord: {
fullModel.append(_r); fullModel.append(_r);
if (!_r.call) if (!_r.call)
transactionModel.append(_r); transactionModel.append(_r);
else else
callModel.append(_r); callModel.append(_r);
} }
onMiningComplete: { onMiningComplete: {
fullModel.append(clientModel.lastBlock); fullModel.append(clientModel.lastBlock);
transactionModel.append(clientModel.lastBlock); transactionModel.append(clientModel.lastBlock);
} }
} }
} }

Loading…
Cancel
Save