From 4fefa1f266fcbc9d55e425929ddcd52a7bc1e5c4 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 21 May 2015 17:16:27 +0200 Subject: [PATCH 1/3] bug fix --- mix/ClientModel.cpp | 10 +++++----- mix/CodeModel.cpp | 4 +++- mix/CodeModel.h | 2 +- mix/qml/QBoolTypeView.qml | 29 ++++++++++++++++++++++------- mix/qml/StateDialog.qml | 15 +++++++++++++-- mix/qml/StateListModel.qml | 1 + mix/qml/StructView.qml | 3 +++ mix/qml/TransactionDialog.qml | 3 +-- mix/qml/TransactionLog.qml | 22 ++++++++++++++++++++++ mix/qml/html/cm/inkpot.css | 7 ++++++- mix/qml/html/cm/solarized.css | 1 - 11 files changed, 77 insertions(+), 20 deletions(-) diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index 54d5db2b5..4b4eb70d1 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -389,7 +389,7 @@ std::pair ClientModel::resolvePair(QString const& _contractId) { std::pair ret; ret.first = _contractId; - ret.second = -1; + ret.second = 0; if (_contractId.startsWith("<") && _contractId.endsWith(">")) { QStringList values = ret.first.remove("<").remove(">").split(" - "); @@ -401,10 +401,10 @@ std::pair ClientModel::resolvePair(QString const& _contractId) QString ClientModel::resolveToken(std::pair const& _value, vector
const& _contracts) { - if (_value.second != -1) - return QString::fromStdString("0x" + dev::toHex(_contracts.at(_value.second).ref())); - else - return _value.first; + if (_contracts.size() > 0) + return QString::fromStdString("0x" + dev::toHex(_contracts.at(_value.second).ref())); + else + return _value.first; } std::pair ClientModel::retrieveToken(QString const& _value, vector
const& _contracts) diff --git a/mix/CodeModel.cpp b/mix/CodeModel.cpp index a73dc920e..81f01a556 100644 --- a/mix/CodeModel.cpp +++ b/mix/CodeModel.cpp @@ -197,6 +197,8 @@ CodeModel::~CodeModel() stop(); disconnect(this); releaseContracts(); + if (m_gasCostsMaps) + m_gasCostsMaps->deleteLater(); } void CodeModel::stop() @@ -358,7 +360,7 @@ void CodeModel::gasEstimation(solidity::CompilerStack const& _cs) { if (m_gasCostsMaps) m_gasCostsMaps->deleteLater(); - m_gasCostsMaps = new GasMapWrapper(this); + m_gasCostsMaps = new GasMapWrapper(); for (std::string n: _cs.getContractNames()) { ContractDefinition const& contractDefinition = _cs.getContractDefinition(n); diff --git a/mix/CodeModel.h b/mix/CodeModel.h index 5291bdc72..75e350c58 100644 --- a/mix/CodeModel.h +++ b/mix/CodeModel.h @@ -137,7 +137,7 @@ class GasMapWrapper: public QObject Q_PROPERTY(GasCostsMaps gasMaps MEMBER m_gasMaps CONSTANT) public: - GasMapWrapper(QObject* _parent): QObject(_parent){} + GasMapWrapper(QObject* _parent = 0): QObject(_parent){} void push(QString _source, int _start, int _end, QString _value, bool _isInfinite); bool contains(QString _key); void insert(QString _source, QVariantList _variantList); diff --git a/mix/qml/QBoolTypeView.qml b/mix/qml/QBoolTypeView.qml index c68b4e133..a95c12040 100644 --- a/mix/qml/QBoolTypeView.qml +++ b/mix/qml/QBoolTypeView.qml @@ -6,22 +6,37 @@ Item id: editRoot property string value property string defaultValue - property alias readOnly: !boolCombo.enabled + property bool readOnly: !boolCombo.enabled height: 20 width: 150 + onReadOnlyChanged: { + boolCombo.enabled = !readOnly; + } + + function init() + { + value = value === true ? "1" : value + value = value === false ? "0" : value; + value = value === "true" ? "1" : value + value = value === "false" ? "0" : value; + + if (value === "") + boolCombo.currentIndex = parseInt(defaultValue); + else + boolCombo.currentIndex = parseInt(value); + boolCombo.enabled = !readOnly; + } + Rectangle { anchors.fill: parent ComboBox { - property bool inited: false + property bool inited; Component.onCompleted: { - if (value === "") - currentIndex = parseInt(defaultValue); - else - currentIndex = parseInt(value); - inited = true + init(); + inited = true; } id: boolCombo diff --git a/mix/qml/StateDialog.qml b/mix/qml/StateDialog.qml index f8da6dabd..404a524f4 100644 --- a/mix/qml/StateDialog.qml +++ b/mix/qml/StateDialog.qml @@ -507,8 +507,13 @@ Dialog { Button { text: qsTr("OK") onClicked: { - close() - accepted() + if (titleField.text === "") + alertDialog.open() + else + { + close() + accepted() + } } } Button { @@ -517,6 +522,12 @@ Dialog { } } + MessageDialog + { + id: alertDialog + text: qsTr("Please provide a name.") + } + ListModel { id: accountsModel diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index a94188a23..d3062af9e 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -266,6 +266,7 @@ Item { var ctorTr = defaultTransactionItem(); ctorTr.functionId = c; ctorTr.contractId = c; + ctorTr.label = qsTr("Deploy") + " " + ctorTr.contractId; ctorTr.sender = state.accounts[0].secret; state.transactions.push(ctorTr); changed = true; diff --git a/mix/qml/StructView.qml b/mix/qml/StructView.qml index 4feab2166..cb38ba5ed 100644 --- a/mix/qml/StructView.qml +++ b/mix/qml/StructView.qml @@ -93,6 +93,9 @@ Column else item.value = getValue(); + if (ptype.category === QSolidityType.Bool) + item.init(); + item.onValueChanged.connect(function() { vals[pname] = item.value; valueChanged(); diff --git a/mix/qml/TransactionDialog.qml b/mix/qml/TransactionDialog.qml index 1437c2562..e7fe22e51 100644 --- a/mix/qml/TransactionDialog.qml +++ b/mix/qml/TransactionDialog.qml @@ -94,7 +94,6 @@ Dialog { function loadCtorParameters(contractId) { paramsModel = []; - console.log(contractId); var contract = codeModel.contracts[contractId]; if (contract) { var params = contract.contract.constructor.parameters; @@ -154,7 +153,7 @@ Dialog { if (functionComboBox.currentIndex >= 0 && functionComboBox.currentIndex < functionsModel.count) { var contract = codeModel.contracts[contractFromToken(recipients.currentValue())]; if (contract) { - var func = contract.contract.functions[functionComboBox.currentIndex]; + var func = contract.contract.functions[functionComboBox.currentIndex - 1]; if (func) { var parameters = func.parameters; for (var p = 0; p < parameters.length; p++) diff --git a/mix/qml/TransactionLog.qml b/mix/qml/TransactionLog.qml index 16ed3e9bf..d31fe0786 100644 --- a/mix/qml/TransactionLog.qml +++ b/mix/qml/TransactionLog.qml @@ -73,8 +73,30 @@ Item { } } + CheckBox + { + text: qsTr("Mine") + onCheckedChanged: { + mineAction.enabled = !checked; + mineTimer.running = checked; + } + } + + Timer + { + id: mineTimer + repeat: true; + interval: 12000 + running: false + onTriggered: + { + clientModel.mine(); + } + } + Button { + id: mineBtn anchors.rightMargin: 9 anchors.verticalCenter: parent.verticalCenter action: mineAction diff --git a/mix/qml/html/cm/inkpot.css b/mix/qml/html/cm/inkpot.css index c6863e624..6a2d8d63a 100644 --- a/mix/qml/html/cm/inkpot.css +++ b/mix/qml/html/cm/inkpot.css @@ -52,7 +52,7 @@ span.CodeMirror-selectedtext { color: #ffffff !important; } .CodeMirror-errorannotation { border-bottom: 1px solid #DD3330; margin-bottom: 4px; -} + } .CodeMirror-errorannotation-context { font-family: monospace; @@ -63,3 +63,8 @@ span.CodeMirror-selectedtext { color: #ffffff !important; } border-top: solid 2px #063742; } +.CodeMirror-search-field +{ + font-size: 12px; +} + diff --git a/mix/qml/html/cm/solarized.css b/mix/qml/html/cm/solarized.css index 1d298b990..df0859d25 100644 --- a/mix/qml/html/cm/solarized.css +++ b/mix/qml/html/cm/solarized.css @@ -194,4 +194,3 @@ span.CodeMirror-selectedtext { color: #586e75 !important; } .CodeMirror-gasCosts { border-bottom: double 1px #2aa198; } - From bcc7ba2aadf7108d788d5211e12f7f1abb7b6fde Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 22 May 2015 15:05:13 +0200 Subject: [PATCH 2/3] small changes --- mix/ClientModel.cpp | 7 ++----- mix/CodeModel.cpp | 2 +- mix/CodeModel.h | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index 4b4eb70d1..6b5242084 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -387,14 +387,11 @@ void ClientModel::executeSequence(vector const& _sequence, std::pair ClientModel::resolvePair(QString const& _contractId) { - std::pair ret; - ret.first = _contractId; - ret.second = 0; + std::pair ret = std::make_pair(_contractId, 0); if (_contractId.startsWith("<") && _contractId.endsWith(">")) { QStringList values = ret.first.remove("<").remove(">").split(" - "); - ret.first = values[0]; - ret.second = values[1].toUInt(); + ret = std::make_pair(values[0], values[1].toUInt()); } return ret; } diff --git a/mix/CodeModel.cpp b/mix/CodeModel.cpp index 81f01a556..424732c2b 100644 --- a/mix/CodeModel.cpp +++ b/mix/CodeModel.cpp @@ -360,7 +360,7 @@ void CodeModel::gasEstimation(solidity::CompilerStack const& _cs) { if (m_gasCostsMaps) m_gasCostsMaps->deleteLater(); - m_gasCostsMaps = new GasMapWrapper(); + m_gasCostsMaps = new GasMapWrapper; for (std::string n: _cs.getContractNames()) { ContractDefinition const& contractDefinition = _cs.getContractDefinition(n); diff --git a/mix/CodeModel.h b/mix/CodeModel.h index 75e350c58..dcf3d0c1e 100644 --- a/mix/CodeModel.h +++ b/mix/CodeModel.h @@ -137,7 +137,7 @@ class GasMapWrapper: public QObject Q_PROPERTY(GasCostsMaps gasMaps MEMBER m_gasMaps CONSTANT) public: - GasMapWrapper(QObject* _parent = 0): QObject(_parent){} + GasMapWrapper(QObject* _parent = nullptr): QObject(_parent){} void push(QString _source, int _start, int _end, QString _value, bool _isInfinite); bool contains(QString _key); void insert(QString _source, QVariantList _variantList); From 32e16bfa70b21371c46b1ad0a1dfdca38f63fa33 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 22 May 2015 16:33:12 +0200 Subject: [PATCH 3/3] small changes --- mix/CodeModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix/CodeModel.cpp b/mix/CodeModel.cpp index 424732c2b..d0f70683d 100644 --- a/mix/CodeModel.cpp +++ b/mix/CodeModel.cpp @@ -198,7 +198,7 @@ CodeModel::~CodeModel() disconnect(this); releaseContracts(); if (m_gasCostsMaps) - m_gasCostsMaps->deleteLater(); + delete m_gasCostsMaps; } void CodeModel::stop()