Browse Source

add watchers.qml & KeyValuePanel.qml

cl-refactor
yann300 10 years ago
parent
commit
8afa6e1c46
  1. 12
      mix/ClientModel.cpp
  2. 2
      mix/ClientModel.h
  3. 4
      mix/qml/Block.qml
  4. 22
      mix/qml/BlockChain.qml
  5. 66
      mix/qml/KeyValuePanel.qml
  6. 24
      mix/qml/ScenarioExecution.qml
  7. 59
      mix/qml/Watchers.qml

12
mix/ClientModel.cpp

@ -840,6 +840,18 @@ void ClientModel::onNewTransaction()
gasUsed, sender, label, inputParameters, logs);
QQmlEngine::setObjectOwnership(log, QQmlEngine::JavaScriptOwnership);
emit newRecord(log);
QVariantMap accountBalances;
for (auto const& ctr : m_contractAddresses)
{
u256 wei = m_client.balanceAt(ctr);
accountBalances.insert(ctr, wei);
}
for (auto const& account : m_account)
{
u256 wei = m_client.balanceAt(account);
accountBalances.insert(ctr, wei);
}
emit newState(recordIndex, accountBalances);
}
}

2
mix/ClientModel.h

@ -236,6 +236,8 @@ signals:
void newRecord(RecordLogEntry* _r);
/// State (transaction log) cleared
void stateCleared();
/// new state has been processed
void newState(unsigned _record, QVariantMap _accounts);
private:
RecordLogEntry* lastBlock() const;

4
mix/qml/Block.qml

@ -22,6 +22,7 @@ ColumnLayout
property int blockIndex
property variant scenario
property string labelColor: "#414141"
signal txSelected(var txIndex)
function calculateHeight()
{
@ -204,9 +205,12 @@ ColumnLayout
anchors.fill: parent
onDoubleClicked:
{
/*
transactionDialog.stateAccounts = scenario.accounts
transactionDialog.execute = false
transactionDialog.open(index, blockIndex, transactions.get(index))
*/
txSelected(index)
}
}

22
mix/qml/BlockChain.qml

@ -14,11 +14,13 @@ import "."
ColumnLayout {
id: blockChainPanel
property variant model
property var states: {}
spacing: 0
property int previousWidth
property variant debugTrRequested: []
signal chainChanged
signal chainReloaded
signal txSelected(var blockIndex, var txIndex)
Connections
{
@ -54,6 +56,11 @@ ColumnLayout {
previousWidth = width
}
function state(record)
{
return states[record]
}
function load(scenario)
{
if (!scenario)
@ -61,6 +68,7 @@ ColumnLayout {
if (model)
rebuild.startBlinking()
model = scenario
states = []
blockModel.clear()
for (var b in model.blocks)
blockModel.append(model.blocks[b])
@ -164,6 +172,14 @@ ColumnLayout {
model: blockModel
Block
{
Connections
{
target: block
onTxSelected: {
txSelected(index, txIndex)
}
}
id: block
scenario: blockChainPanel.model
Layout.preferredWidth: blockChainScrollView.width
Layout.preferredHeight:
@ -271,6 +287,7 @@ ColumnLayout {
if (ensureNotFuturetime.running)
return;
stopBlinking()
states = []
var retBlocks = [];
var bAdded = 0;
for (var j = 0; j < model.blocks.length; j++)
@ -475,6 +492,11 @@ ColumnLayout {
model.blocks[model.blocks.length - 1].transactions.push(itemTr)
blockModel.appendTransaction(itemTr)
}
onNewState: {
states[_record] = _accounts
}
onMiningComplete:
{
}

66
mix/qml/KeyValuePanel.qml

@ -0,0 +1,66 @@
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.1
import Qt.labs.settings 1.0
import org.ethereum.qml.QEther 1.0
import "js/Debugger.js" as Debugger
import "js/ErrorLocationFormater.js" as ErrorLocationFormater
import "js/TransactionHelper.js" as TransactionHelper
import "js/QEtherHelper.js" as QEtherHelper
import "."
ColumnLayout {
id: root
property alias title: titleLabel.text
property variant data
function key(index)
{
}
function value(index)
{
}
RowLayout
{
Label
{
id: titleLabel
}
}
RowLayout
{
Repeater
{
id: repeaterKeyValue
RowLayout
{
Rectangle
{
id: key
Label
{
text: {
return root.key(index)
}
}
}
Rectangle
{
id: value
Label
{
text: {
return root.value(index)
}
}
}
}
}
}
}

24
mix/qml/ScenarioExecution.qml

@ -18,11 +18,11 @@ Rectangle {
onProjectLoaded: {
loader.init()
}
}
Column
{
id: scenarioColumn
anchors.margins: 10
anchors.fill: parent
spacing: 10
@ -63,5 +63,27 @@ Rectangle {
id: blockChain
width: parent.width
}
Connections
{
target: blockChain
onTxSelected:{
var tx = model.block[blockIndex].transactions[txIndex]
var state = blockChain.getState(tx.recordIndex)
watchers.updateWidthTx(tx, state)
}
}
}
ScrollView
{
anchors.top: scenarioColumn.bottom
width: parent.width
height: 500
Watchers
{
id: watchers
anchors.topMargin: 10
}
}
}

59
mix/qml/Watchers.qml

@ -0,0 +1,59 @@
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.1
import Qt.labs.settings 1.0
import org.ethereum.qml.QEther 1.0
import "js/Debugger.js" as Debugger
import "js/ErrorLocationFormater.js" as ErrorLocationFormater
import "js/TransactionHelper.js" as TransactionHelper
import "js/QEtherHelper.js" as QEtherHelper
import "."
ColumnLayout {
property variant tx
property variant state
function updateWidthTx(_tx, _state)
{
console.log("update tx")
console.log(JSON.stringify(tx))
console.log(JSON.stringify(state))
txLabel.text = tx.label
tx = _tx
state = _state
}
RowLayout
{
Label {
id: txLabel
}
}
KeyValuePanel
{
id: inputParams
title: qsTr("INPUT PARAMETERS")
}
KeyValuePanel
{
id: returnParams
title: qsTr("RETURN PARAMETERS")
}
KeyValuePanel
{
id: balance
title: qsTr("BALANCES")
}
KeyValuePanel
{
id: events
title: qsTr("EVENTS")
}
}
Loading…
Cancel
Save