@@ -14,6 +14,7 @@ ContractResult::ContractResult(QWidget *parent) :
14
14
ui->groupBoxCreateOrSendTo ->setStyleSheet (STYLE_GROUPBOX);
15
15
16
16
ui->scrollAreaParams ->setStyleSheet (" .QScrollArea { border: none;}" );
17
+ ui->scrollAreaResult ->setStyleSheet (" .QScrollArea { border: none;}" );
17
18
}
18
19
19
20
ContractResult::~ContractResult ()
@@ -46,19 +47,13 @@ void ContractResult::setResultData(QVariant result, FunctionABI function, QStrin
46
47
47
48
void ContractResult::setParamsData (FunctionABI function, QStringList paramValues)
48
49
{
49
- QStringList paramNames;
50
- for (std::vector<ParameterABI>::const_iterator param = function.inputs .begin (); param != function.inputs .end (); ++param)
51
- {
52
- paramNames.append (QString::fromStdString (param->name ));
53
- }
54
-
55
50
// Remove previous widget from scroll area
56
51
QWidget *scrollWidget = ui->scrollAreaParams ->widget ();
57
- if (scrollWidget)
58
- scrollWidget->deleteLater ();
52
+ if (scrollWidget)
53
+ scrollWidget->deleteLater ();
59
54
60
55
// Don't show empty list
61
- if (paramNames. isEmpty () )
56
+ if (function. inputs . size () == 0 )
62
57
{
63
58
ui->scrollAreaParams ->setVisible (false );
64
59
return ;
@@ -71,25 +66,38 @@ void ContractResult::setParamsData(FunctionABI function, QStringList paramValues
71
66
widgetParams->setLayout (vLayout);
72
67
73
68
// Add rows with params and values sent
74
- for (int i = 0 ; i < paramNames.count (); i++)
69
+ int i = 0 ;
70
+ for (std::vector<ParameterABI>::const_iterator param = function.inputs .begin (); param != function.inputs .end (); ++param)
75
71
{
72
+
76
73
QHBoxLayout *hLayout = new QHBoxLayout ();
77
- hLayout->setSpacing (30 );
74
+ hLayout->setSpacing (10 );
78
75
hLayout->setContentsMargins (0 ,0 ,0 ,0 );
79
76
80
77
QLabel *paramName = new QLabel (this );
81
78
QLineEdit *paramValue = new QLineEdit (this );
82
79
paramValue->setReadOnly (true );
83
- paramName->setMinimumWidth (110 );
84
- paramName->setText (paramNames[i]);
80
+ paramName->setFixedWidth (160 );
81
+
82
+ QFontMetrics metrix (paramName->font ());
83
+ int width = paramName->width () + 10 ;
84
+ QString text (QString (" %2 <b>%1" ).arg (QString::fromStdString (param->name )).arg (QString::fromStdString (param->type )));
85
+ QString clippedText = metrix.elidedText (text, Qt::ElideRight, width);
86
+
87
+ paramName->setToolTip (QString (" %2 %1" ).arg (QString::fromStdString (param->name )).arg (QString::fromStdString (param->type )));
88
+ paramName->setText (clippedText);
85
89
paramValue->setText (paramValues[i]);
86
90
87
91
hLayout->addWidget (paramName);
88
92
hLayout->addWidget (paramValue);
89
93
90
94
vLayout->addLayout (hLayout);
95
+ i++;
91
96
}
97
+ widgetParams->adjustSize ();
98
+ ui->scrollAreaParams ->setMaximumHeight (widgetParams->sizeHint ().height () + 2 );
92
99
ui->scrollAreaParams ->setWidget (widgetParams);
100
+ ui->scrollAreaParams ->setVisible (true );
93
101
}
94
102
95
103
void ContractResult::updateCreateResult (QVariant result)
@@ -133,9 +141,52 @@ void ContractResult::updateCallResult(QVariant result, FunctionABI function, QSt
133
141
std::vector<ParameterABI::ErrorType> errors;
134
142
if (function.abiOut (rawData, values, errors))
135
143
{
144
+ // Remove previous widget from scroll area
145
+ QWidget *scrollWidget = ui->scrollAreaResult ->widget ();
146
+ if (scrollWidget)
147
+ scrollWidget->deleteLater ();
148
+
136
149
if (values.size () > 0 )
137
150
{
138
- ui->lineEditResult ->setText (QString::fromStdString (values[0 ]));
151
+ QWidget *widgetResults = new QWidget (this );
152
+ QVBoxLayout *vLayout = new QVBoxLayout (widgetResults);
153
+ vLayout->setSpacing (6 );
154
+ vLayout->setContentsMargins (0 ,6 ,0 ,6 );
155
+ widgetResults->setLayout (vLayout);
156
+
157
+ for (size_t i = 0 ; i < values.size (); i++)
158
+ {
159
+ QHBoxLayout *hLayout = new QHBoxLayout ();
160
+ hLayout->setSpacing (10 );
161
+ hLayout->setContentsMargins (0 ,0 ,0 ,0 );
162
+
163
+ QLabel *resultName = new QLabel (this );
164
+ QLineEdit *resultValue = new QLineEdit (this );
165
+ resultValue->setReadOnly (true );
166
+ resultName->setFixedWidth (160 );
167
+
168
+ QFontMetrics metrix (resultName->font ());
169
+ int width = resultName->width () + 10 ;
170
+ QString text (QString (" %2 <b>%1" ).arg (QString::fromStdString (function.outputs [i].name )).arg (QString::fromStdString (function.outputs [i].type )));
171
+ QString clippedText = metrix.elidedText (text, Qt::ElideRight, width);
172
+
173
+ resultName->setText (clippedText);
174
+ resultName->setToolTip (QString (" %2 %1" ).arg (QString::fromStdString (function.outputs [i].name )).arg (QString::fromStdString (function.outputs [i].type )));
175
+ resultValue->setText (QString::fromStdString (values[i]));
176
+
177
+ hLayout->addWidget (resultName);
178
+ hLayout->addWidget (resultValue);
179
+
180
+ vLayout->addLayout (hLayout);
181
+ }
182
+ widgetResults->adjustSize ();
183
+ ui->scrollAreaResult ->setMaximumHeight (widgetResults->sizeHint ().height () + 2 );
184
+ ui->scrollAreaResult ->setWidget (widgetResults);
185
+ ui->groupBoxResult ->setVisible (true );
186
+ }
187
+ else
188
+ {
189
+ ui->groupBoxResult ->setVisible (false );
139
190
}
140
191
}
141
192
else
0 commit comments