Browse Source

Display Catched Events

cl-refactor
yann300 10 years ago
parent
commit
885494fe2f
  1. 6
      mix/ClientModel.cpp
  2. 240
      mix/qml/Block.qml
  3. 5
      mix/qml/BlockChain.qml
  4. 2
      mix/qml/StateListModel.qml

6
mix/ClientModel.cpp

@ -759,6 +759,12 @@ void ClientModel::onNewTransaction()
{ {
QVariantMap l; QVariantMap l;
l.insert("address", QString::fromStdString(log.address.hex())); l.insert("address", QString::fromStdString(log.address.hex()));
std::ostringstream s;
s << log.data;
l.insert("data", QString::fromStdString(s.str()));
std::ostringstream streamTopic;
streamTopic << log.topics;
l.insert("topic", QString::fromStdString(streamTopic.str()));
auto const& sign = log.topics.front(); // first hash supposed to be the event signature. To check auto const& sign = log.topics.front(); // first hash supposed to be the event signature. To check
auto dataIterator = log.data.begin(); auto dataIterator = log.data.begin();
int topicDataIndex = 1; int topicDataIndex = 1;

240
mix/qml/Block.qml

@ -18,6 +18,28 @@ ColumnLayout
property int horizontalMargin: 10 property int horizontalMargin: 10
property int trHeight: 30 property int trHeight: 30
spacing: 0 spacing: 0
property int openedTr: 0
function calculateHeight()
{
if (transactions)
{
if (index >= 0)
return 30 + 30 * transactions.count + openedTr
else
return 30
}
else
return 30
}
onOpenedTrChanged:
{
Layout.preferredHeight = calculateHeight()
height = calculateHeight()
}
RowLayout RowLayout
{ {
@ -54,13 +76,43 @@ ColumnLayout
RowLayout RowLayout
{ {
id: rowTransaction
Layout.preferredHeight: trHeight Layout.preferredHeight: trHeight
function displayContent()
{
logsText.text = ""
if (index >= 0 && transactions.get(index).logs && transactions.get(index).logs.count)
{
for (var k = 0; k < transactions.get(index).logs.count; k++)
{
var log = transactions.get(index).logs.get(k)
if (log.name)
logsText.text += log.name + ":\n"
else
logsText.text += "log:\n"
if (log.param)
for (var i = 0; i < log.param.count; i++)
{
var p = log.param.get(i)
logsText.text += p.name + " = " + p.value + " - indexed:" + p.indexed + "\n"
}
else{
logsText.text += "From : " + log.address + "\n"
}
}
logsText.text += "\n\n"
}
rowDetailedContent.visible = !rowDetailedContent.visible
}
Rectangle Rectangle
{ {
id: trSaveStatus id: trSaveStatus
Layout.preferredWidth: statusWidth Layout.preferredWidth: statusWidth
Layout.preferredHeight: trHeight Layout.preferredHeight: trHeight
color: "transparent" color: "transparent"
anchors.top: parent.top
property bool saveStatus property bool saveStatus
Image { Image {
@ -104,98 +156,144 @@ ColumnLayout
Layout.preferredWidth: blockWidth Layout.preferredWidth: blockWidth
Layout.preferredHeight: parent.height Layout.preferredHeight: parent.height
color: "#DEDCDC" color: "#DEDCDC"
RowLayout id: rowContentTr
anchors.top: parent.top
ColumnLayout
{ {
anchors.verticalCenter: parent.verticalCenter anchors.top: parent.top
spacing: cellSpacing spacing: 10
Text RowLayout
{ {
id: hash anchors.top: parent.top
anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: horizontalMargin spacing: cellSpacing
Layout.preferredWidth: fromWidth Text
elide: Text.ElideRight {
maximumLineCount: 1 id: hash
text: { anchors.left: parent.left
if (index >= 0) anchors.leftMargin: horizontalMargin
return transactions.get(index).sender Layout.preferredWidth: fromWidth
else elide: Text.ElideRight
return "" maximumLineCount: 1
text: {
if (index >= 0)
return transactions.get(index).sender
else
return ""
}
} }
}
Text Text
{ {
id: func id: func
text: { text: {
if (index >= 0) if (index >= 0)
parent.userFrienldyToken(transactions.get(index).label) parent.userFrienldyToken(transactions.get(index).label)
else else
return "" return ""
}
elide: Text.ElideRight
maximumLineCount: 1
Layout.preferredWidth: toWidth
} }
elide: Text.ElideRight
maximumLineCount: 1
Layout.preferredWidth: toWidth
}
function userFrienldyToken(value) function userFrienldyToken(value)
{ {
if (value && value.indexOf("<") === 0) if (value && value.indexOf("<") === 0)
return value.split(" - ")[0].replace("<", "") + "." + value.split("> ")[1] + "()"; return value.split(" - ")[0].replace("<", "") + "." + value.split("> ")[1] + "()";
else
return value
}
Text
{
id: returnValue
elide: Text.ElideRight
maximumLineCount: 1
Layout.preferredWidth: valueWidth
text: {
if (index >= 0 && transactions.get(index).returned)
return transactions.get(index).returned
else else
return "" return value
} }
}
Rectangle
{
Layout.preferredWidth: logsWidth
Layout.preferredHeight: trHeight - 10
width: logsWidth
color: "transparent"
Text Text
{ {
id: logs id: returnValue
anchors.left: parent.left elide: Text.ElideRight
anchors.leftMargin: 10 maximumLineCount: 1
Layout.preferredWidth: valueWidth
text: { text: {
if (index >= 0 && transactions.get(index).logs && transactions.get(index).logs.count) if (index >= 0 && transactions.get(index).returned)
{ return transactions.get(index).returned
for (var k = 0; k < transactions.get(index).logs.count; k++) else
return ""
}
}
Rectangle
{
Layout.preferredWidth: logsWidth
Layout.preferredHeight: trHeight - 10
width: logsWidth
color: "transparent"
Text
{
id: logs
anchors.left: parent.left
anchors.leftMargin: 10
text: {
if (index >= 0 && transactions.get(index).logs && transactions.get(index).logs.count)
{ {
/*console.log("_________________________") for (var k = 0; k < transactions.get(index).logs.count; k++)
console.log(JSON.stringify(transactions.get(index).logs[k])) {
console.log("_________________________")*/ console.log("_________________________")
console.log(JSON.stringify(transactions.get(index).logs[k]))
console.log("_________________________")
}
return transactions.get(index).logs.count
} }
return transactions.get(index).logs.count else
return ""
} }
else }
return "" MouseArea {
anchors.fill: parent
onClicked: {
rowTransaction.displayContent();
}
}
}
Button
{
id: debug
Layout.preferredWidth: debugActionWidth
text: "debug"
onClicked:
{
clientModel.debugRecord(transactions.get(index).recordIndex);
} }
} }
} }
Button RowLayout
{ {
id: debug id: rowDetailedContent
Layout.preferredWidth: debugActionWidth visible: false
text: "debug" Layout.preferredHeight:{
onClicked: if (index >= 0 && transactions.get(index).logs)
return 100 * transactions.get(index).logs.count
else
return 100
}
onVisibleChanged:
{ {
clientModel.debugRecord(transactions.get(index).recordIndex); var lognb = transactions.get(index).logs.count
if (visible)
{
rowContentTr.Layout.preferredHeight = trHeight + 100 * lognb
openedTr += 100 * lognb
}
else
{
rowContentTr.Layout.preferredHeight = trHeight
openedTr -= 100 * lognb
}
}
Text {
anchors.left: parent.left
anchors.leftMargin: horizontalMargin
id: logsText
} }
} }
} }

5
mix/qml/BlockChain.qml

@ -127,10 +127,7 @@ ColumnLayout {
Layout.preferredWidth: blockChainScrollView.width Layout.preferredWidth: blockChainScrollView.width
Layout.preferredHeight: Layout.preferredHeight:
{ {
if (index >= 0) return calculateHeight()
return 30 + 30 * blockModel.get(index).transactions.count
else
return 50
} }
transactions: transactions:

2
mix/qml/StateListModel.qml

@ -16,8 +16,6 @@ Item {
property string defaultAccount: "cb73d9408c4720e230387d956eb0f829d8a4dd2c1055f96257167e14e7169074" //support for old project property string defaultAccount: "cb73d9408c4720e230387d956eb0f829d8a4dd2c1055f96257167e14e7169074" //support for old project
function fromPlainStateItem(s) { function fromPlainStateItem(s) {
console.log("èèèèèèèèèèèè");
console.log(s);
if (!s.accounts) if (!s.accounts)
s.accounts = [stateListModel.newAccount("1000000", QEther.Ether, defaultAccount)]; //support for old project s.accounts = [stateListModel.newAccount("1000000", QEther.Ether, defaultAccount)]; //support for old project
if (!s.contracts) if (!s.contracts)

Loading…
Cancel
Save