Browse Source

- Clear debugger view if empty record.

cl-refactor
yann300 10 years ago
parent
commit
92762f9d0d
  1. 9
      mix/ClientModel.cpp
  2. 19
      mix/ClientModel.h
  3. 9
      mix/qml/Debugger.qml
  4. 13
      mix/qml/TransactionLog.qml
  5. 4
      mix/qml/js/ProjectModel.js

9
mix/ClientModel.cpp

@ -325,6 +325,11 @@ void ClientModel::showDebuggerForTransaction(ExecutionResult const& _t)
debugDataReady(debugData);
}
void ClientModel::emptyRecord()
{
debugDataReady(new QDebugData());
}
void ClientModel::debugRecord(unsigned _index)
{
@ -356,7 +361,7 @@ RecordLogEntry* ClientModel::lastBlock() const
strGas << blockInfo.gasUsed;
std::stringstream strNumber;
strNumber << blockInfo.number;
RecordLogEntry* record = new RecordLogEntry(0, QString::fromStdString(strNumber.str()), QString(" - Block - "), tr("Hash: ") + QString(QString::fromStdString(blockInfo.hash.abridged())), tr("Gas Used: ") + QString::fromStdString(strGas.str()), QString(), QString(), false);
RecordLogEntry* record = new RecordLogEntry(0, QString::fromStdString(strNumber.str()), tr(" - Block - "), tr("Hash: ") + QString(QString::fromStdString(toHex(blockInfo.hash.ref()))), tr("Gas Used: ") + QString::fromStdString(strGas.str()), QString(), QString(), false, RecordLogEntry::RecordType::Block);
QQmlEngine::setObjectOwnership(record, QQmlEngine::JavaScriptOwnership);
return record;
}
@ -436,7 +441,7 @@ void ClientModel::onNewTransaction()
}
}
RecordLogEntry* log = new RecordLogEntry(recordIndex, transactionIndex, contract, function, value, address, returned, tr.isCall());
RecordLogEntry* log = new RecordLogEntry(recordIndex, transactionIndex, contract, function, value, address, returned, tr.isCall(), RecordLogEntry::RecordType::Transaction);
QQmlEngine::setObjectOwnership(log, QQmlEngine::JavaScriptOwnership);
emit newRecord(log);
}

19
mix/ClientModel.h

@ -72,6 +72,7 @@ struct TransactionSettings
class RecordLogEntry: public QObject
{
Q_OBJECT
Q_ENUMS(RecordType)
/// Recording index
Q_PROPERTY(unsigned recordIndex MEMBER m_recordIndex CONSTANT)
/// Human readable transaction bloack and transaction index
@ -88,13 +89,20 @@ class RecordLogEntry: public QObject
Q_PROPERTY(QString returned MEMBER m_returned CONSTANT)
/// true if call, false if transaction
Q_PROPERTY(bool call MEMBER m_call CONSTANT)
/// @returns record type
Q_PROPERTY(RecordType type MEMBER m_type CONSTANT)
public:
enum RecordType
{
Transaction,
Block
};
RecordLogEntry():
m_recordIndex(0), m_call(false) {}
RecordLogEntry(unsigned _recordIndex, QString _transactionIndex, QString _contract, QString _function, QString _value, QString _address, QString _returned, bool _call):
m_recordIndex(_recordIndex), m_transactionIndex(_transactionIndex), m_contract(_contract), m_function(_function), m_value(_value), m_address(_address), m_returned(_returned), m_call(_call) {}
m_recordIndex(0), m_call(false), m_type(RecordType::Transaction) {}
RecordLogEntry(unsigned _recordIndex, QString _transactionIndex, QString _contract, QString _function, QString _value, QString _address, QString _returned, bool _call, RecordType _type):
m_recordIndex(_recordIndex), m_transactionIndex(_transactionIndex), m_contract(_contract), m_function(_function), m_value(_value), m_address(_address), m_returned(_returned), m_call(_call), m_type(_type) {}
private:
unsigned m_recordIndex;
@ -105,6 +113,7 @@ private:
QString m_address;
QString m_returned;
bool m_call;
RecordType m_type;
};
/**
@ -140,6 +149,8 @@ public slots:
void setupState(QVariantMap _state);
/// Show the debugger for a specified record
Q_INVOKABLE void debugRecord(unsigned _index);
/// Show the debugger for an empty record
Q_INVOKABLE void emptyRecord();
private slots:
/// Update UI with machine states result. Display a modal dialog.

9
mix/qml/Debugger.qml

@ -36,10 +36,13 @@ Rectangle {
function update(data, giveFocus)
{
if (codeModel.hasContract)
if (data === null)
Debugger.init(null);
else if (data.states.length === 0)
Debugger.init(null);
else if (codeModel.hasContract)
{
if (data !== null)
Debugger.init(data);
Debugger.init(data);
debugScrollArea.visible = true;
compilationErrorArea.visible = false;
machineStates.visible = true;

13
mix/qml/TransactionLog.qml

@ -3,6 +3,7 @@ import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.1
import org.ethereum.qml.RecordLogEntry 1.0
Item {
@ -133,7 +134,10 @@ Item {
}
onActivated: {
var item = logTable.model.get(row);
clientModel.debugRecord(item.recordIndex);
if (item.type === RecordLogEntry.Transaction)
clientModel.debugRecord(item.recordIndex);
else
clientModel.emptyRecord();
}
Keys.onPressed: {
if ((event.modifiers & Qt.ControlModifier) && event.key === Qt.Key_C && currentRow >=0 && currentRow < logTable.model.count) {
@ -159,11 +163,8 @@ Item {
callModel.append(_r);
}
onMiningComplete: {
var block = clientModel.lastBlock;
console.log(block);
fullModel.append(block);
console.log(JSON.stringify(block));
fullModel.append(clientModel.lastBlock);
transactionModel.append(clientModel.lastBlock);
}
}
}

4
mix/qml/js/ProjectModel.js

@ -282,7 +282,7 @@ function deployProject(force) {
var date = new Date();
var deploymentId = date.toLocaleString(Qt.locale(), "ddMMyyHHmmsszzz");
var jsonRpcUrl = "http://127.0.0.1:8080";
var jsonRpcUrl = "http://127.0.0.1:8080";
console.log("Deploying " + deploymentId + " to " + jsonRpcUrl);
deploymentStarted();
@ -369,7 +369,7 @@ function finalizeDeployment(deploymentId, addresses) {
//copy scripts
fileIo.copyFile("qrc:///js/bignumber.min.js", deploymentDir + "bignumber.min.js");
fileIo.copyFile("qrc:///js/webthree.js", deploymentDir + "ethereum.js");
deploymentAddress = address;
deploymentAddress = addresses;
saveProject();
deploymentComplete();
}

Loading…
Cancel
Save