import QtQuick 2.0 import QtQuick.Controls 1.0; import QtQuick.Layouts 1.0; import QtQuick.Dialogs 1.0; import QtQuick.Window 2.1; import QtQuick.Controls.Styles 1.1 import Ethereum 1.0 Rectangle { id: root property var title: "Block Chain" property var menuItem objectName: "chainView" visible: false anchors.fill: parent TableView { id: blockTable width: parent.width anchors.top: parent.top anchors.bottom: parent.bottom TableViewColumn{ role: "number" ; title: "#" ; width: 100 } TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 } TableViewColumn{ role: "txAmount" ; title: "Tx amount" ; width: 100 } model: blockModel itemDelegate: Item { Text { anchors { left: parent.left right: parent.right leftMargin: 10 verticalCenter: parent.verticalCenter } color: styleData.textColor elide: styleData.elideMode text: styleData.value font.pixelSize: 11 MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton propagateComposedEvents: true anchors.fill: parent onClicked: { blockTable.selection.clear() blockTable.selection.select(styleData.row) if(mouse.button == Qt.RightButton) { contextMenu.row = styleData.row; contextMenu.popup() } } onDoubleClicked: { popup.visible = true popup.setDetails(blockModel.get(styleData.row)) } } } } Menu { id: contextMenu property var row MenuItem { text: "Details" onTriggered: { popup.visible = true popup.setDetails(blockModel.get(contextMenu.row)) } } MenuSeparator{} MenuItem { text: "Copy" onTriggered: { copyToClipboard(blockModel.get(contextMenu.row).hash) } } MenuItem { text: "Dump State" onTriggered: { generalFileDialog.show(false, function(path) { var hash = blockModel.get(contextMenu.row).hash; gui.dumpState(hash, path); }); } } } } function addBlock(block, initial) { if(initial == undefined){ initial = false } var amount = block.transactions.length; var txs = []; for(var i = 0; i < block.transactions.length; i++) { var tx = JSON.parse(block.transactions.getAsJson(i)); txs.push(tx); } if(initial){ blockModel.append({raw: block.raw, bloom: block.bloom, size: block.size, number: block.number, name: block.name, gasLimit: block.gasLimit, gasUsed: block.gasUsed, coinbase: block.coinbase, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) } else { blockModel.insert(0, {raw: block.raw, bloom: block.bloom, size: block.size, number: block.number, name: block.name, gasLimit: block.gasLimit, gasUsed: block.gasUsed, coinbase: block.coinbase, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) } } Window { id: popup visible: false //flags: Qt.CustomizeWindowHint | Qt.Tool | Qt.WindowCloseButtonHint property var block width: root.width height: 300 Component{ id: blockDetailsDelegate Rectangle { color: "#252525" width: popup.width height: 150 Column { anchors.leftMargin: 10 anchors.topMargin: 5 anchors.top: parent.top anchors.left: parent.left Text { text: '