From 1e9e83c4ae209f498e9182479797705094f354bf 2017-06-15 09:56:44 From: Alexandre Leroux Date: 2017-06-15 09:56:44 Subject: [PATCH] Notifies view when a variable is added to the model --- diff --git a/core/src/Variable/VariableModel.cpp b/core/src/Variable/VariableModel.cpp index 38fcdc8..c7b7684 100644 --- a/core/src/Variable/VariableModel.cpp +++ b/core/src/Variable/VariableModel.cpp @@ -26,12 +26,17 @@ VariableModel::VariableModel(QObject *parent) Variable *VariableModel::createVariable(const QString &name) noexcept { + auto insertIndex = rowCount(); + beginInsertRows({}, insertIndex, insertIndex); + /// @todo For the moment, the other data of the variable is initialized with default values auto variable = std::make_unique(name, QStringLiteral("unit"), QStringLiteral("mission")); impl->m_Variables.push_back(std::move(variable)); - return impl->m_Variables.back().get(); + endInsertRows(); + + return impl->m_Variables.at(insertIndex).get(); } int VariableModel::columnCount(const QModelIndex &parent) const