From 885494fe2feaaed50c55352d249492344146dfc1 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 8 Jun 2015 15:17:34 +0200 Subject: [PATCH] Display Catched Events --- mix/ClientModel.cpp | 6 + mix/qml/Block.qml | 240 ++++++++++++++++++++++++++----------- mix/qml/BlockChain.qml | 5 +- mix/qml/StateListModel.qml | 2 - 4 files changed, 176 insertions(+), 77 deletions(-) diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index 156a5285f..195f49f67 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -759,6 +759,12 @@ void ClientModel::onNewTransaction() { QVariantMap l; 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 dataIterator = log.data.begin(); int topicDataIndex = 1; diff --git a/mix/qml/Block.qml b/mix/qml/Block.qml index d3775ea5c..b3865ac4a 100644 --- a/mix/qml/Block.qml +++ b/mix/qml/Block.qml @@ -18,6 +18,28 @@ ColumnLayout property int horizontalMargin: 10 property int trHeight: 30 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 { @@ -54,13 +76,43 @@ ColumnLayout RowLayout { + id: rowTransaction 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 { id: trSaveStatus Layout.preferredWidth: statusWidth Layout.preferredHeight: trHeight color: "transparent" + anchors.top: parent.top property bool saveStatus Image { @@ -104,98 +156,144 @@ ColumnLayout Layout.preferredWidth: blockWidth Layout.preferredHeight: parent.height color: "#DEDCDC" - RowLayout + id: rowContentTr + anchors.top: parent.top + ColumnLayout { - anchors.verticalCenter: parent.verticalCenter - spacing: cellSpacing - Text + anchors.top: parent.top + spacing: 10 + RowLayout { - id: hash - anchors.left: parent.left - anchors.leftMargin: horizontalMargin - Layout.preferredWidth: fromWidth - elide: Text.ElideRight - maximumLineCount: 1 - text: { - if (index >= 0) - return transactions.get(index).sender - else - return "" + anchors.top: parent.top + anchors.verticalCenter: parent.verticalCenter + spacing: cellSpacing + Text + { + id: hash + anchors.left: parent.left + anchors.leftMargin: horizontalMargin + Layout.preferredWidth: fromWidth + elide: Text.ElideRight + maximumLineCount: 1 + text: { + if (index >= 0) + return transactions.get(index).sender + else + return "" + } } - } - Text - { - id: func - text: { - if (index >= 0) - parent.userFrienldyToken(transactions.get(index).label) - else - return "" + Text + { + id: func + text: { + if (index >= 0) + parent.userFrienldyToken(transactions.get(index).label) + else + return "" + } + elide: Text.ElideRight + maximumLineCount: 1 + Layout.preferredWidth: toWidth } - elide: Text.ElideRight - maximumLineCount: 1 - Layout.preferredWidth: toWidth - } - function userFrienldyToken(value) - { - if (value && value.indexOf("<") === 0) - 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 + function userFrienldyToken(value) + { + if (value && value.indexOf("<") === 0) + return value.split(" - ")[0].replace("<", "") + "." + value.split("> ")[1] + "()"; else - return "" + return value } - } - Rectangle - { - Layout.preferredWidth: logsWidth - Layout.preferredHeight: trHeight - 10 - width: logsWidth - color: "transparent" Text { - id: logs - anchors.left: parent.left - anchors.leftMargin: 10 + id: returnValue + elide: Text.ElideRight + maximumLineCount: 1 + Layout.preferredWidth: valueWidth text: { - if (index >= 0 && transactions.get(index).logs && transactions.get(index).logs.count) - { - for (var k = 0; k < transactions.get(index).logs.count; k++) + if (index >= 0 && transactions.get(index).returned) + return transactions.get(index).returned + 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("_________________________") - console.log(JSON.stringify(transactions.get(index).logs[k])) - console.log("_________________________")*/ + for (var k = 0; k < transactions.get(index).logs.count; k++) + { + 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 - Layout.preferredWidth: debugActionWidth - text: "debug" - onClicked: + id: rowDetailedContent + visible: false + Layout.preferredHeight:{ + 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 } } } diff --git a/mix/qml/BlockChain.qml b/mix/qml/BlockChain.qml index 2fc78b0b1..e9b1fc1db 100644 --- a/mix/qml/BlockChain.qml +++ b/mix/qml/BlockChain.qml @@ -127,10 +127,7 @@ ColumnLayout { Layout.preferredWidth: blockChainScrollView.width Layout.preferredHeight: { - if (index >= 0) - return 30 + 30 * blockModel.get(index).transactions.count - else - return 50 + return calculateHeight() } transactions: diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index 44873e8db..dac3e0831 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -16,8 +16,6 @@ Item { property string defaultAccount: "cb73d9408c4720e230387d956eb0f829d8a4dd2c1055f96257167e14e7169074" //support for old project function fromPlainStateItem(s) { - console.log("èèèèèèèèèèèè"); - console.log(s); if (!s.accounts) s.accounts = [stateListModel.newAccount("1000000", QEther.Ether, defaultAccount)]; //support for old project if (!s.contracts)