@ -9,7 +9,7 @@ Window {
id: modalTransactionDialog
id: modalTransactionDialog
modality: Qt . WindowModal
modality: Qt . WindowModal
width: 640
width: 640
height: 48 0
height: 6 40
visible: false
visible: false
property int transactionIndex
property int transactionIndex
@ -21,10 +21,12 @@ Window {
property var itemParams ;
property var itemParams ;
property bool isConstructorTransaction ;
property bool isConstructorTransaction ;
property bool useTransactionDefaultValue: false
property bool useTransactionDefaultValue: false
property var qType ;
signal accepted ;
signal accepted ;
function open ( index , item ) {
function open ( index , item ) {
qType = [ ] ;
rowFunction . visible = ! useTransactionDefaultValue ;
rowFunction . visible = ! useTransactionDefaultValue ;
rowValue . visible = ! useTransactionDefaultValue ;
rowValue . visible = ! useTransactionDefaultValue ;
rowGas . visible = ! useTransactionDefaultValue ;
rowGas . visible = ! useTransactionDefaultValue ;
@ -68,6 +70,7 @@ Window {
}
}
function loadParameters ( ) {
function loadParameters ( ) {
paramsModel . clear ( ) ;
if ( ! paramsModel )
if ( ! paramsModel )
return ;
return ;
if ( functionComboBox . currentIndex >= 0 && functionComboBox . currentIndex < functionsModel . count ) {
if ( functionComboBox . currentIndex >= 0 && functionComboBox . currentIndex < functionsModel . count ) {
@ -75,7 +78,27 @@ Window {
var parameters = func . parameters ;
var parameters = func . parameters ;
for ( var p = 0 ; p < parameters . length ; p ++ ) {
for ( var p = 0 ; p < parameters . length ; p ++ ) {
var pname = parameters [ p ] . name ;
var pname = parameters [ p ] . name ;
paramsModel . append ( { name: pname , type: parameters [ p ] . type , value: itemParams [ pname ] !== undefined ? itemParams [ pname ] . value ( ) : "" } ) ;
var varComponent ;
var type = parameters [ p ] . type ;
if ( type . indexOf ( "int" ) !== - 1 )
varComponent = Qt . createComponent ( "qrc:/qml/QIntType.qml" ) ;
else if ( type . indexOf ( "real" ) !== - 1 )
varComponent = Qt . createComponent ( "qrc:/qml/QRealType.qml" ) ;
else if ( type . indexOf ( "string" ) !== - 1 || type . indexOf ( "text" ) !== - 1 )
varComponent = Qt . createComponent ( "qrc:/qml/QStringType.qml" ) ;
else if ( type . indexOf ( "hash" ) !== - 1 || type . indexOf ( "address" ) !== - 1 )
varComponent = Qt . createComponent ( "qrc:/qml/QHashType.qml" ) ;
else if ( type . indexOf ( "bool" ) !== - 1 )
varComponent = Qt . createComponent ( "qrc:/qml/QBoolType.qml" ) ;
var param = varComponent . createObject ( modalTransactionDialog ) ;
var value = itemParams [ pname ] !== undefined ? itemParams [ pname ] : "" ;
param . setValue ( value ) ;
param . setDeclaration ( parameters [ p ] ) ;
qType . push ( { name: pname , value: param } ) ;
paramsModel . append ( { name: pname , type: parameters [ p ] . type , value: value } ) ;
}
}
}
}
}
}
@ -85,6 +108,15 @@ Window {
visible = false ;
visible = false ;
}
}
function qTypeParam ( name )
{
for ( var k in qType )
{
if ( qType [ k ] . name === name )
return qType [ k ] . value ;
}
}
function getItem ( )
function getItem ( )
{
{
var item ;
var item ;
@ -109,14 +141,15 @@ Window {
if ( isConstructorTransaction )
if ( isConstructorTransaction )
item . functionId = qsTr ( "Constructor" ) ;
item . functionId = qsTr ( "Constructor" ) ;
var orderedQType = [ ] ;
for ( var p = 0 ; p < transactionDialog . transactionParams . count ; p ++ ) {
for ( var p = 0 ; p < transactionDialog . transactionParams . count ; p ++ ) {
var parameter = transactionDialog . transactionParams . get ( p ) ;
var parameter = transactionDialog . transactionParams . get ( p ) ;
var intComponent = Qt . createComponent ( "qrc:/qml/BigIntValue.qml" ) ;
var qtypeParam = qTypeParam ( parameter . name ) ;
var param = intComponent . createObject ( modalTransactionDialog ) ;
qtypeParam . setValue ( parameter . value ) ;
orderedQType . push ( qtypeParam ) ;
param . setValue ( parameter . value ) ;
item . parameters [ parameter . name ] = parameter . value ;
item . parameters [ parameter . name ] = param ;
}
}
item . qType = orderedQType ;
return item ;
return item ;
}
}
@ -219,8 +252,10 @@ Window {
}
}
TableView {
TableView {
model: paramsModel
model: paramsModel
Layout.fillWidth: true
Layout.preferredWidth: 120 * 2 + 240
Layout.minimumHeight: 150
Layout.preferredHeight: 400
Layout.maximumHeight: 600
TableViewColumn {
TableViewColumn {
role: "name"
role: "name"
title: qsTr ( "Name" )
title: qsTr ( "Name" )
@ -234,12 +269,11 @@ Window {
TableViewColumn {
TableViewColumn {
role: "value"
role: "value"
title: qsTr ( "Value" )
title: qsTr ( "Value" )
width: 1 20
width: 24 0
}
}
itemDelegate: {
rowDelegate: rowDelegate
return editableDelegate ;
itemDelegate: editableDelegate
}
}
}
}
}
}
}
@ -268,19 +302,15 @@ Window {
}
}
Component {
Component {
id: editable Delegate
id: row Delegate
Item {
Item {
height: 100
Text {
}
width: parent . width
anchors.margins: 4
anchors.left: parent . left
anchors.verticalCenter: parent . verticalCenter
elide: styleData . elideMode
text: styleData . value !== undefined ? styleData.value : ""
color: styleData . textColor
visible: ! styleData . selected
}
}
Component {
id: editableDelegate
Item {
Loader {
Loader {
id: loaderEditor
id: loaderEditor
anchors.fill: parent
anchors.fill: parent
@ -289,14 +319,87 @@ Window {
target: loaderEditor . item
target: loaderEditor . item
onTextChanged: {
onTextChanged: {
if ( styleData . role === "value" && styleData . row < paramsModel . count )
if ( styleData . role === "value" && styleData . row < paramsModel . count )
paramsModel . setProperty ( styleData . row , styleData . role , loaderEditor . item . text ) ;
loaderEditor . updateValue ( styleData . row , styleData . role , loaderEditor . item . text ) ;
}
}
function updateValue ( row , role , value )
{
paramsModel . setProperty ( styleData . row , styleData . role , value ) ;
}
sourceComponent:
{
if ( styleData . role === "value" )
{
if ( paramsModel . get ( styleData . row ) === undefined )
return null ;
if ( paramsModel . get ( styleData . row ) . type . indexOf ( "int" ) !== - 1 )
return intViewComp ;
else if ( paramsModel . get ( styleData . row ) . type . indexOf ( "bool" ) !== - 1 )
return boolViewComp ;
else if ( paramsModel . get ( styleData . row ) . type . indexOf ( "string" ) !== - 1 )
return stringViewComp ;
else if ( paramsModel . get ( styleData . row ) . type . indexOf ( "hash" ) !== - 1 )
return hashViewComp ;
}
else
return editor ;
}
Component
{
id: intViewComp
QIntTypeView
{
id: intView
text: styleData . value
}
}
Component
{
id: boolViewComp
QBoolTypeView
{
id: boolView
defaultValue: "1"
Component.onCompleted:
{
loaderEditor . updateValue ( styleData . row , styleData . role ,
( paramsModel . get ( styleData . row ) . value === "" ? defaultValue :
paramsModel . get ( styleData . row ) . value ) ) ;
text = ( paramsModel . get ( styleData . row ) . value === "" ? defaultValue : paramsModel . get ( styleData . row ) . value ) ;
}
}
}
}
sourceComponent: ( styleData . selected ) ? editor : null
}
Component
{
id: stringViewComp
QStringTypeView
{
id: stringView
text: styleData . value
}
}
Component
{
id: hashViewComp
QHashTypeView
{
id: hashView
text: styleData . value
}
}
Component {
Component {
id: editor
id: editor
TextInput {
TextInput {
id: textinput
id: textinput
readOnly: true
color: styleData . textColor
color: styleData . textColor
text: styleData . value
text: styleData . value
MouseArea {
MouseArea {