Browse Source

Merge pull request #984 from yann300/ui_improvement

Bug fix: Using constructor with parameters not working.
cl-refactor
Arkadiy Paronyan 10 years ago
parent
commit
029be5f7f9
  1. 4
      mix/ClientModel.cpp
  2. 4
      mix/qml/ProjectList.qml
  3. 34
      mix/qml/TransactionDialog.qml

4
mix/ClientModel.cpp

@ -236,7 +236,7 @@ void ClientModel::executeSequence(std::vector<TransactionSettings> const& _seque
}
if (!f)
BOOST_THROW_EXCEPTION(FunctionNotFoundException() << FunctionName(transaction.functionId.toStdString()));
if (!transaction.functionId.isEmpty())
encoder.encode(f);
for (int p = 0; p < transaction.parameterValues.size(); p++)
{
@ -247,6 +247,8 @@ void ClientModel::executeSequence(std::vector<TransactionSettings> const& _seque
if (transaction.functionId.isEmpty())
{
bytes param = encoder.encodedData();
contractCode.insert(contractCode.end(), param.begin(), param.end());
Address newAddress = deployContract(contractCode, transaction);
if (newAddress != m_contractAddress)
{

4
mix/qml/ProjectList.qml

@ -127,6 +127,10 @@ Item {
}
}
onNewProject: {
sectionModel.clear();
}
onProjectLoaded: {
addDocToSubModel();
if (modelData === "Contracts")

34
mix/qml/TransactionDialog.qml

@ -60,26 +60,18 @@ Window {
else
{
var parameters = codeModel.code.contract.constructor.parameters;
for (var p = 0; p < parameters.length; p++) {
var pname = parameters[p].name;
paramsModel.append({ name: pname, type: parameters[p].type, value: itemParams[pname] !== undefined ? itemParams[pname].value() : "" });
}
for (var p = 0; p < parameters.length; p++)
loadParameter(parameters[p]);
}
visible = true;
valueField.focus = true;
}
function loadParameters() {
paramsModel.clear();
if (!paramsModel)
return;
if (functionComboBox.currentIndex >= 0 && functionComboBox.currentIndex < functionsModel.count) {
var func = codeModel.code.contract.functions[functionComboBox.currentIndex];
var parameters = func.parameters;
for (var p = 0; p < parameters.length; p++) {
var pname = parameters[p].name;
function loadParameter(parameter)
{
var type = parameter.type;
var pname = parameter.name;
var varComponent;
var type = parameters[p].type;
if (type.indexOf("int") !== -1)
varComponent = Qt.createComponent("qrc:/qml/QIntType.qml");
@ -96,10 +88,20 @@ Window {
var value = itemParams[pname] !== undefined ? itemParams[pname] : "";
param.setValue(value);
param.setDeclaration(parameters[p]);
param.setDeclaration(parameter);
qType.push({ name: pname, value: param });
paramsModel.append({ name: pname, type: parameters[p].type, value: value });
paramsModel.append({ name: pname, type: type, value: value });
}
function loadParameters() {
paramsModel.clear();
if (!paramsModel)
return;
if (functionComboBox.currentIndex >= 0 && functionComboBox.currentIndex < functionsModel.count) {
var func = codeModel.code.contract.functions[functionComboBox.currentIndex];
var parameters = func.parameters;
for (var p = 0; p < parameters.length; p++)
loadParameter(parameters[p]);
}
}

Loading…
Cancel
Save