Browse Source

- Bug fix: When a state was selected, the state is not being showed in the combobox.

- Removing animation
cl-refactor
Ali Mashatan 10 years ago
parent
commit
99a5df6b26
  1. 21
      mix/qml/StatesComboBox.qml
  2. 334
      mix/qml/TransactionLog.qml

21
mix/qml/StatesComboBox.qml

@ -49,8 +49,14 @@ Rectangle {
signal editItem(real item);
property variant items;
property alias selectedItem: chosenItemText.text;
property alias selectedIndex: listView.currentRow;
readonly property alias selectedItem: chosenItemText.text;
readonly property alias selectedIndex: listView.currentRow;
function setSelectedIndex(index)
{
listView.currentRow = index;
chosenItemText.text = statesComboBox.items.get(0).title;
}
signal comboClicked;
property variant colorItem;
@ -64,12 +70,12 @@ Rectangle {
color: statesComboBox.color;
smooth:true;
Text {
id:chosenItemText
anchors.top: parent.top;
anchors.left: parent.left;
anchors.margins: 2;
color: statesComboBox.colorItem;
id:chosenItemText
text:statesComboBox.items.get(0).title;
text:""
smooth:true
}
@ -96,7 +102,7 @@ Rectangle {
height:500;
width:statesComboBox.width;
model: statesComboBox.items
currentRow: 0
currentRow: -1
headerVisible: false;
backgroundVisible: false
alternatingRowColors : false;
@ -162,7 +168,7 @@ Rectangle {
else {
statesComboBox.state = ""
var prevSelection = chosenItemText.text
chosenItemText.text = modelData
chosenItemText.text = styleData.value
if(chosenItemText.text != prevSelection)
statesComboBox.comboClicked();
listView.currentRow = styleData.row;
@ -179,7 +185,4 @@ Rectangle {
PropertyChanges { target: dropDownList; height:20*statesComboBox.items.count }
}
transitions: Transition {
NumberAnimation { target: dropDownList; properties: "height"; easing.type: Easing.OutExpo; duration: 1000 }
}
}

334
mix/qml/TransactionLog.qml

@ -7,202 +7,184 @@ import org.ethereum.qml.RecordLogEntry 1.0
Item {
property ListModel fullModel: ListModel{}
property ListModel transactionModel: ListModel{}
property ListModel callModel: ListModel{}
property ListModel fullModel: ListModel{}
property ListModel transactionModel: ListModel{}
property ListModel callModel: ListModel{}
Action {
id: addStateAction
text: "Add State"
shortcut: "Ctrl+Alt+T"
enabled: codeModel.hasContract && !clientModel.running;
onTriggered: projectModel.stateListModel.addState();
}
Action {
id: editStateAction
text: "Edit State"
shortcut: "Ctrl+Alt+T"
enabled: codeModel.hasContract && !clientModel.running && statesCombo.currentIndex >= 0 && projectModel.stateListModel.count > 0;
onTriggered: projectModel.stateListModel.editState(statesCombo.currentIndex);
}
Action {
id: addStateAction
text: "Add State"
shortcut: "Ctrl+Alt+T"
enabled: codeModel.hasContract && !clientModel.running;
onTriggered: projectModel.stateListModel.addState();
}
Action {
id: editStateAction
text: "Edit State"
shortcut: "Ctrl+Alt+T"
enabled: codeModel.hasContract && !clientModel.running && statesCombo.selectedIndex >= 0 && projectModel.stateListModel.count > 0;
onTriggered: projectModel.stateListModel.editState(statesCombo.selectedIndex);
}
ColumnLayout {
anchors.fill: parent
RowLayout {
ColumnLayout {
anchors.fill: parent
RowLayout {
Connections
{
id: compilationStatus
target: codeModel
property bool compilationComplete: false
onCompilationComplete: compilationComplete = true
onCompilationError: compilationComplete = false
}
Connections
{
target: projectModel
onProjectSaved:
{
if (projectModel.appIsClosing)
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();
}
}
Connections
{
id: compilationStatus
target: codeModel
property bool compilationComplete: false
onCompilationComplete: compilationComplete = true
onCompilationError: compilationComplete = false
}
/*ComboBox {
id: statesCombo
model: projectModel.stateListModel
width: 150
editable: false
textRole: "title"
onActivated: {
model.runState(index);
}
Connections {
target: projectModel.stateListModel
onStateRun: {
if (statesCombo.currentIndex !== index)
statesCombo.currentIndex = index;
}
}
}*/
StatesComboBox
Connections
{
target: projectModel
onProjectSaved:
{
if (projectModel.appIsClosing)
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();
}
}
StatesComboBox
{
id: statesCombo
items:projectModel.stateListModel
onSelectItem: console.log("Combobox Select Item: " + item )
onEditItem: console.log("Combobox Edit Item: " + item )
onEditItem: projectModel.stateListModel.editState(item)
colorItem: "black"
colorSelect: "yellow"
color: "gray"
colorSelect: "blue"
color: "white"
Connections {
target: projectModel.stateListModel
onStateRun: {
if (statesCombo.selectedIndex !== index)
statesCombo.selectedIndex = index;
statesCombo.setSelectedIndex( index );
}
}
}
Button
{
anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter
action: editStateAction
}
Button
{
anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter
action: addStateAction
}
Button
{
anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter
action: mineAction
}
Button
{
anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter
action: editStateAction
}
Button
{
anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter
action: addStateAction
}
Button
{
anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter
action: mineAction
}
ComboBox {
id: itemFilter
ComboBox {
id: itemFilter
function getCurrentModel()
{
return currentIndex === 0 ? fullModel : currentIndex === 1 ? transactionModel : currentIndex === 2 ? callModel : fullModel;
}
function getCurrentModel()
{
return currentIndex === 0 ? fullModel : currentIndex === 1 ? transactionModel : currentIndex === 2 ? callModel : fullModel;
}
model: ListModel {
ListElement { text: qsTr("Calls and Transactions"); value: 0; }
ListElement { text: qsTr("Only Transactions"); value: 1; }
ListElement { text: qsTr("Only Calls"); value: 2; }
}
model: ListModel {
ListElement { text: qsTr("Calls and Transactions"); value: 0; }
ListElement { text: qsTr("Only Transactions"); value: 1; }
ListElement { text: qsTr("Only Calls"); value: 2; }
}
onCurrentIndexChanged:
{
logTable.model = itemFilter.getCurrentModel();
}
}
}
TableView {
id: logTable
Layout.fillWidth: true
Layout.fillHeight: true
model: fullModel
onCurrentIndexChanged:
{
logTable.model = itemFilter.getCurrentModel();
}
}
}
TableView {
id: logTable
Layout.fillWidth: true
Layout.fillHeight: true
model: fullModel
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
}
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);
appContext.toClipboard(item.returned);
}
}
}
}
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
}
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);
appContext.toClipboard(item.returned);
}
}
}
}
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);
}
}
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);
}
}
}

Loading…
Cancel
Save