Browse Source

Display Catched Events

cl-refactor
yann300 10 years ago
parent
commit
885494fe2f
  1. 6
      mix/ClientModel.cpp
  2. 102
      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;
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;

102
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,8 +156,15 @@ ColumnLayout
Layout.preferredWidth: blockWidth
Layout.preferredHeight: parent.height
color: "#DEDCDC"
id: rowContentTr
anchors.top: parent.top
ColumnLayout
{
anchors.top: parent.top
spacing: 10
RowLayout
{
anchors.top: parent.top
anchors.verticalCenter: parent.verticalCenter
spacing: cellSpacing
Text
@ -176,9 +235,9 @@ ColumnLayout
{
for (var k = 0; k < transactions.get(index).logs.count; k++)
{
/*console.log("_________________________")
console.log("_________________________")
console.log(JSON.stringify(transactions.get(index).logs[k]))
console.log("_________________________")*/
console.log("_________________________")
}
return transactions.get(index).logs.count
}
@ -186,6 +245,12 @@ ColumnLayout
return ""
}
}
MouseArea {
anchors.fill: parent
onClicked: {
rowTransaction.displayContent();
}
}
}
Button
@ -199,6 +264,39 @@ ColumnLayout
}
}
}
RowLayout
{
id: rowDetailedContent
visible: false
Layout.preferredHeight:{
if (index >= 0 && transactions.get(index).logs)
return 100 * transactions.get(index).logs.count
else
return 100
}
onVisibleChanged:
{
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.preferredHeight:
{
if (index >= 0)
return 30 + 30 * blockModel.get(index).transactions.count
else
return 50
return calculateHeight()
}
transactions:

2
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)

Loading…
Cancel
Save