Browse Source

Merge pull request #2004 from yann300/bugFix

Mix - Bug fixes
cl-refactor
Arkadiy Paronyan 10 years ago
parent
commit
d9df2c7046
  1. 15
      mix/ClientModel.cpp
  2. 4
      mix/CodeModel.cpp
  3. 2
      mix/CodeModel.h
  4. 29
      mix/qml/QBoolTypeView.qml
  5. 15
      mix/qml/StateDialog.qml
  6. 1
      mix/qml/StateListModel.qml
  7. 3
      mix/qml/StructView.qml
  8. 3
      mix/qml/TransactionDialog.qml
  9. 22
      mix/qml/TransactionLog.qml
  10. 7
      mix/qml/html/cm/inkpot.css
  11. 1
      mix/qml/html/cm/solarized.css

15
mix/ClientModel.cpp

@ -387,24 +387,21 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence,
std::pair<QString, int> ClientModel::resolvePair(QString const& _contractId) std::pair<QString, int> ClientModel::resolvePair(QString const& _contractId)
{ {
std::pair<QString, int> ret; std::pair<QString, int> ret = std::make_pair(_contractId, 0);
ret.first = _contractId;
ret.second = -1;
if (_contractId.startsWith("<") && _contractId.endsWith(">")) if (_contractId.startsWith("<") && _contractId.endsWith(">"))
{ {
QStringList values = ret.first.remove("<").remove(">").split(" - "); QStringList values = ret.first.remove("<").remove(">").split(" - ");
ret.first = values[0]; ret = std::make_pair(values[0], values[1].toUInt());
ret.second = values[1].toUInt();
} }
return ret; return ret;
} }
QString ClientModel::resolveToken(std::pair<QString, int> const& _value, vector<Address> const& _contracts) QString ClientModel::resolveToken(std::pair<QString, int> const& _value, vector<Address> const& _contracts)
{ {
if (_value.second != -1) if (_contracts.size() > 0)
return QString::fromStdString("0x" + dev::toHex(_contracts.at(_value.second).ref())); return QString::fromStdString("0x" + dev::toHex(_contracts.at(_value.second).ref()));
else else
return _value.first; return _value.first;
} }
std::pair<QString, int> ClientModel::retrieveToken(QString const& _value, vector<Address> const& _contracts) std::pair<QString, int> ClientModel::retrieveToken(QString const& _value, vector<Address> const& _contracts)

4
mix/CodeModel.cpp

@ -197,6 +197,8 @@ CodeModel::~CodeModel()
stop(); stop();
disconnect(this); disconnect(this);
releaseContracts(); releaseContracts();
if (m_gasCostsMaps)
delete m_gasCostsMaps;
} }
void CodeModel::stop() void CodeModel::stop()
@ -358,7 +360,7 @@ void CodeModel::gasEstimation(solidity::CompilerStack const& _cs)
{ {
if (m_gasCostsMaps) if (m_gasCostsMaps)
m_gasCostsMaps->deleteLater(); m_gasCostsMaps->deleteLater();
m_gasCostsMaps = new GasMapWrapper(this); m_gasCostsMaps = new GasMapWrapper;
for (std::string n: _cs.getContractNames()) for (std::string n: _cs.getContractNames())
{ {
ContractDefinition const& contractDefinition = _cs.getContractDefinition(n); ContractDefinition const& contractDefinition = _cs.getContractDefinition(n);

2
mix/CodeModel.h

@ -137,7 +137,7 @@ class GasMapWrapper: public QObject
Q_PROPERTY(GasCostsMaps gasMaps MEMBER m_gasMaps CONSTANT) Q_PROPERTY(GasCostsMaps gasMaps MEMBER m_gasMaps CONSTANT)
public: public:
GasMapWrapper(QObject* _parent): QObject(_parent){} GasMapWrapper(QObject* _parent = nullptr): QObject(_parent){}
void push(QString _source, int _start, int _end, QString _value, bool _isInfinite); void push(QString _source, int _start, int _end, QString _value, bool _isInfinite);
bool contains(QString _key); bool contains(QString _key);
void insert(QString _source, QVariantList _variantList); void insert(QString _source, QVariantList _variantList);

29
mix/qml/QBoolTypeView.qml

@ -6,22 +6,37 @@ Item
id: editRoot id: editRoot
property string value property string value
property string defaultValue property string defaultValue
property alias readOnly: !boolCombo.enabled property bool readOnly: !boolCombo.enabled
height: 20 height: 20
width: 150 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 { Rectangle {
anchors.fill: parent anchors.fill: parent
ComboBox ComboBox
{ {
property bool inited: false property bool inited;
Component.onCompleted: Component.onCompleted:
{ {
if (value === "") init();
currentIndex = parseInt(defaultValue); inited = true;
else
currentIndex = parseInt(value);
inited = true
} }
id: boolCombo id: boolCombo

15
mix/qml/StateDialog.qml

@ -507,8 +507,13 @@ Dialog {
Button { Button {
text: qsTr("OK") text: qsTr("OK")
onClicked: { onClicked: {
close() if (titleField.text === "")
accepted() alertDialog.open()
else
{
close()
accepted()
}
} }
} }
Button { Button {
@ -517,6 +522,12 @@ Dialog {
} }
} }
MessageDialog
{
id: alertDialog
text: qsTr("Please provide a name.")
}
ListModel { ListModel {
id: accountsModel id: accountsModel

1
mix/qml/StateListModel.qml

@ -266,6 +266,7 @@ Item {
var ctorTr = defaultTransactionItem(); var ctorTr = defaultTransactionItem();
ctorTr.functionId = c; ctorTr.functionId = c;
ctorTr.contractId = c; ctorTr.contractId = c;
ctorTr.label = qsTr("Deploy") + " " + ctorTr.contractId;
ctorTr.sender = state.accounts[0].secret; ctorTr.sender = state.accounts[0].secret;
state.transactions.push(ctorTr); state.transactions.push(ctorTr);
changed = true; changed = true;

3
mix/qml/StructView.qml

@ -93,6 +93,9 @@ Column
else else
item.value = getValue(); item.value = getValue();
if (ptype.category === QSolidityType.Bool)
item.init();
item.onValueChanged.connect(function() { item.onValueChanged.connect(function() {
vals[pname] = item.value; vals[pname] = item.value;
valueChanged(); valueChanged();

3
mix/qml/TransactionDialog.qml

@ -94,7 +94,6 @@ Dialog {
function loadCtorParameters(contractId) function loadCtorParameters(contractId)
{ {
paramsModel = []; paramsModel = [];
console.log(contractId);
var contract = codeModel.contracts[contractId]; var contract = codeModel.contracts[contractId];
if (contract) { if (contract) {
var params = contract.contract.constructor.parameters; var params = contract.contract.constructor.parameters;
@ -154,7 +153,7 @@ Dialog {
if (functionComboBox.currentIndex >= 0 && functionComboBox.currentIndex < functionsModel.count) { if (functionComboBox.currentIndex >= 0 && functionComboBox.currentIndex < functionsModel.count) {
var contract = codeModel.contracts[contractFromToken(recipients.currentValue())]; var contract = codeModel.contracts[contractFromToken(recipients.currentValue())];
if (contract) { if (contract) {
var func = contract.contract.functions[functionComboBox.currentIndex]; var func = contract.contract.functions[functionComboBox.currentIndex - 1];
if (func) { if (func) {
var parameters = func.parameters; var parameters = func.parameters;
for (var p = 0; p < parameters.length; p++) for (var p = 0; p < parameters.length; p++)

22
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 Button
{ {
id: mineBtn
anchors.rightMargin: 9 anchors.rightMargin: 9
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
action: mineAction action: mineAction

7
mix/qml/html/cm/inkpot.css

@ -52,7 +52,7 @@ span.CodeMirror-selectedtext { color: #ffffff !important; }
.CodeMirror-errorannotation { .CodeMirror-errorannotation {
border-bottom: 1px solid #DD3330; border-bottom: 1px solid #DD3330;
margin-bottom: 4px; margin-bottom: 4px;
} }
.CodeMirror-errorannotation-context { .CodeMirror-errorannotation-context {
font-family: monospace; font-family: monospace;
@ -63,3 +63,8 @@ span.CodeMirror-selectedtext { color: #ffffff !important; }
border-top: solid 2px #063742; border-top: solid 2px #063742;
} }
.CodeMirror-search-field
{
font-size: 12px;
}

1
mix/qml/html/cm/solarized.css

@ -194,4 +194,3 @@ span.CodeMirror-selectedtext { color: #586e75 !important; }
.CodeMirror-gasCosts { .CodeMirror-gasCosts {
border-bottom: double 1px #2aa198; border-bottom: double 1px #2aa198;
} }

Loading…
Cancel
Save