diff --git a/mix/CodeModel.cpp b/mix/CodeModel.cpp index a9cfcc336..c12b19a6f 100644 --- a/mix/CodeModel.cpp +++ b/mix/CodeModel.cpp @@ -171,12 +171,19 @@ void CodeModel::onCompilationComplete(CompilationResult* _newResult) { m_compiling = false; 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); emit compilationComplete(); emit stateChanged(); if (m_result->successful()) { emit codeChanged(); + if (nameChanged) + emit contractNameChanged(_newResult->sharedContract()->name()); if (contractChanged) emit contractInterfaceChanged(); } diff --git a/mix/CodeModel.h b/mix/CodeModel.h index 5f2add874..529d52d1d 100644 --- a/mix/CodeModel.h +++ b/mix/CodeModel.h @@ -148,6 +148,8 @@ signals: void contractInterfaceChanged(); /// Emitted on compilation complete. Internal void compilationCompleteInternal(CompilationResult* _newResult); + /// Emitted when the contract name has changed + void contractNameChanged(QString _newName); private slots: void onCompilationComplete(CompilationResult* _newResult); diff --git a/mix/qml/ProjectList.qml b/mix/qml/ProjectList.qml index 86784ec4b..64fefe5b3 100644 --- a/mix/qml/ProjectList.qml +++ b/mix/qml/ProjectList.qml @@ -68,6 +68,19 @@ Item { 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 { id: projectModelConnection target: projectModel