From e9574e46dec20b2973a8f45f5a00de47ce69d61c Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 6 Feb 2015 11:38:16 +0100 Subject: [PATCH] Change the contract name (in left pane) when contract name changed in editor. --- mix/CodeModel.cpp | 7 +++++++ mix/CodeModel.h | 2 ++ mix/qml/ProjectList.qml | 13 +++++++++++++ 3 files changed, 22 insertions(+) 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