Browse Source

Change the contract name (in left pane) when contract name changed in

editor.
cl-refactor
yann300 10 years ago
committed by yann300
parent
commit
e9574e46de
  1. 7
      mix/CodeModel.cpp
  2. 2
      mix/CodeModel.h
  3. 13
      mix/qml/ProjectList.qml

7
mix/CodeModel.cpp

@ -171,12 +171,19 @@ void CodeModel::onCompilationComplete(CompilationResult* _newResult)
{ {
m_compiling = false; m_compiling = false;
bool contractChanged = m_result->contractInterface() != _newResult->contractInterface(); bool contractChanged = m_result->contractInterface() != _newResult->contractInterface();
bool nameChanged = false;
if (m_result->successful())
nameChanged = !(m_result->sharedContract()->name() == _newResult->sharedContract()->name()); //@todo should manage multiple contracts.
m_result.reset(_newResult); m_result.reset(_newResult);
emit compilationComplete(); emit compilationComplete();
emit stateChanged(); emit stateChanged();
if (m_result->successful()) if (m_result->successful())
{ {
emit codeChanged(); emit codeChanged();
if (nameChanged)
emit contractNameChanged(_newResult->sharedContract()->name());
if (contractChanged) if (contractChanged)
emit contractInterfaceChanged(); emit contractInterfaceChanged();
} }

2
mix/CodeModel.h

@ -148,6 +148,8 @@ signals:
void contractInterfaceChanged(); void contractInterfaceChanged();
/// Emitted on compilation complete. Internal /// Emitted on compilation complete. Internal
void compilationCompleteInternal(CompilationResult* _newResult); void compilationCompleteInternal(CompilationResult* _newResult);
/// Emitted when the contract name has changed
void contractNameChanged(QString _newName);
private slots: private slots:
void onCompilationComplete(CompilationResult* _newResult); void onCompilationComplete(CompilationResult* _newResult);

13
mix/qml/ProjectList.qml

@ -68,6 +68,19 @@ Item {
id: sectionModel id: sectionModel
} }
Connections {
target: codeModel
onContractNameChanged: {
if (modelData === "Contracts")
{
var ctr = projectModel.listModel.get(0);
ctr.name = _newName;
projectModel.listModel.set(0, ctr);
sectionModel.set(0, ctr);
}
}
}
Connections { Connections {
id: projectModelConnection id: projectModelConnection
target: projectModel target: projectModel

Loading…
Cancel
Save