You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
4.2 KiB

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