You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

404 lines
8.9 KiB

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 "js/Debugger.js" as Debugger
import "js/ErrorLocationFormater.js" as ErrorLocationFormater
import "."
ColumnLayout
{
10 years ago
id: root
property variant transactions
property string status
property int number
property int blockWidth: Layout.preferredWidth - statusWidth - horizontalMargin
property int horizontalMargin: 10
10 years ago
property int trHeight: 35
10 years ago
spacing: 0
property int openedTr: 0
property int blockIndex
property variant scenario
property string labelColor: "#414141"
10 years ago
function calculateHeight()
{
if (transactions)
{
if (index >= 0)
10 years ago
return trHeight + trHeight * transactions.count + openedTr
10 years ago
else
10 years ago
return trHeight
10 years ago
}
else
10 years ago
return trHeight
10 years ago
}
10 years ago
onOpenedTrChanged:
{
Layout.preferredHeight = calculateHeight()
height = calculateHeight()
}
10 years ago
DebuggerPaneStyle {
id: dbgStyle
}
10 years ago
Rectangle
{
id: top
Layout.preferredWidth: blockWidth
height: 10
anchors.bottom: rowHeader.top
color: "#DEDCDC"
radius: 15
anchors.left: parent.left
anchors.leftMargin: statusWidth
anchors.bottomMargin: -5
}
10 years ago
RowLayout
{
Layout.preferredHeight: trHeight
Layout.preferredWidth: blockWidth
id: rowHeader
spacing: 0
10 years ago
Rectangle
{
Layout.preferredWidth: blockWidth
Layout.preferredHeight: trHeight
color: "#DEDCDC"
10 years ago
anchors.left: parent.left
anchors.leftMargin: statusWidth
10 years ago
Label {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: horizontalMargin
10 years ago
font.pointSize: dbgStyle.absoluteSize(1)
color: "#adadad"
10 years ago
text:
{
if (number === -2)
return qsTr("STARTING PARAMETERS")
else if (status === "mined")
10 years ago
return qsTr("BLOCK") + " " + number
else
return qsTr("PENDING TRANSACTIONS")
}
}
Label
{
text: qsTr("EDIT")
color: "#1397da"
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 14
MouseArea
{
anchors.fill: parent
onClicked:
{
// load edit block panel
}
10 years ago
}
}
}
}
10 years ago
Repeater // List of transactions
{
id: transactionRepeater
model: transactions
RowLayout
{
id: rowTransaction
Layout.preferredHeight: trHeight
spacing: 0
10 years ago
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"
10 years ago
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 {
10 years ago
logsText.text += "From : " + log.address + "\n"
}
}
logsText.text += "\n\n"
}
rowDetailedContent.visible = !rowDetailedContent.visible
}
10 years ago
Rectangle
{
id: trSaveStatus
Layout.preferredWidth: statusWidth
Layout.preferredHeight: parent.height
10 years ago
color: "transparent"
anchors.top: parent.top
property bool saveStatus
Image {
anchors.top: parent.top
10 years ago
anchors.left: parent.left
anchors.leftMargin: -9
anchors.topMargin: -9
10 years ago
id: saveStatusImage
source: "qrc:/qml/img/recyclediscard@2x.png"
10 years ago
width: statusWidth + 20
10 years ago
fillMode: Image.PreserveAspectFit
}
10 years ago
Component.onCompleted:
{
if (index >= 0)
saveStatus = transactions.get(index).saveStatus
}
10 years ago
onSaveStatusChanged:
{
if (saveStatus)
saveStatusImage.source = "qrc:/qml/img/recyclekeep@2x.png"
else
saveStatusImage.source = "qrc:/qml/img/recyclediscard@2x.png"
10 years ago
if (index >= 0)
transactions.get(index).saveStatus = saveStatus
}
10 years ago
MouseArea {
id: statusMouseArea
anchors.fill: parent
onClicked:
{
parent.saveStatus = !parent.saveStatus
}
}
}
10 years ago
Rectangle
{
Layout.preferredWidth: blockWidth
Layout.preferredHeight: parent.height
color: "#DEDCDC"
id: rowContentTr
anchors.top: parent.top
MouseArea
{
anchors.fill: parent
onDoubleClicked:
{
transactionDialog.stateAccounts = scenario.accounts
transactionDialog.execute = false
transactionDialog.open(index, blockIndex, transactions.get(index))
}
}
10 years ago
ColumnLayout
{
anchors.top: parent.top
width: parent.width
10 years ago
spacing: 20
10 years ago
RowLayout
{
anchors.top: parent.top
Layout.fillWidth: true
10 years ago
Rectangle
10 years ago
{
10 years ago
Layout.preferredWidth: fromWidth
10 years ago
anchors.left: parent.left
anchors.leftMargin: horizontalMargin
10 years ago
Text
{
id: hash
width: parent.width - 30
elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter
maximumLineCount: 1
color: labelColor
font.pointSize: dbgStyle.absoluteSize(1)
font.bold: true
text: {
if (index >= 0)
return transactions.get(index).sender
else
return ""
}
10 years ago
}
}
10 years ago
Rectangle
10 years ago
{
Layout.preferredWidth: toWidth
10 years ago
Text
{
id: func
text: {
if (index >= 0)
parent.parent.userFrienldyToken(transactions.get(index).label)
else
return ""
}
elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter
color: labelColor
font.pointSize: dbgStyle.absoluteSize(1)
font.bold: true
maximumLineCount: 1
width: parent.width
}
10 years ago
}
10 years ago
function userFrienldyToken(value)
{
if (value && value.indexOf("<") === 0)
{
if (value.split("> ")[1] === " - ")
return value.split(" - ")[0].replace("<", "")
else
return value.split(" - ")[0].replace("<", "") + "." + value.split("> ")[1] + "()";
}
else
return value
}
10 years ago
Rectangle
10 years ago
{
Layout.preferredWidth: valueWidth
10 years ago
Text
{
id: returnValue
elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter
maximumLineCount: 1
color: labelColor
font.bold: true
font.pointSize: dbgStyle.absoluteSize(1)
width: parent.width - 30
10 years ago
text: {
if (index >= 0 && transactions.get(index).returned)
return transactions.get(index).returned
else
return ""
}
10 years ago
}
}
10 years ago
Rectangle
{
Layout.preferredWidth: logsWidth
Layout.preferredHeight: trHeight - 10
width: logsWidth
color: "transparent"
Text
{
id: logs
anchors.left: parent.left
10 years ago
anchors.verticalCenter: parent.verticalCenter
10 years ago
anchors.leftMargin: 10
color: labelColor
10 years ago
font.bold: true
font.pointSize: dbgStyle.absoluteSize(1)
10 years ago
text: {
if (index >= 0 && transactions.get(index).logs && transactions.get(index).logs.count)
return transactions.get(index).logs.count
else
return ""
}
}
MouseArea {
anchors.fill: parent
onClicked: {
rowTransaction.displayContent();
}
}
}
}
10 years ago
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
}
}
10 years ago
Text {
anchors.left: parent.left
anchors.leftMargin: horizontalMargin
id: logsText
}
}
}
}
Rectangle
{
width: debugActionWidth
10 years ago
height: trHeight
anchors.left: rowContentTr.right
10 years ago
anchors.topMargin: -6
anchors.top: rowContentTr.top
anchors.leftMargin: -50
color: "transparent"
Image {
id: debugImg
source: "qrc:/qml/img/rightarrow@2x.png"
width: debugActionWidth
fillMode: Image.PreserveAspectFit
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
visible: transactions.get(index).recordIndex !== undefined
}
MouseArea
{
anchors.fill: parent
onClicked:
{
if (transactions.get(index).recordIndex !== undefined)
{
debugTrRequested = [ blockIndex, index ]
clientModel.debugRecord(transactions.get(index).recordIndex);
}
}
}
}
10 years ago
}
}
}