From a2408b382cf60cbac75a29158583faaa53218345 2017-09-01 07:10:56 From: Alexandre Leroux Date: 2017-09-01 07:10:56 Subject: [PATCH] Calls rename dialog when clicking action in the menu --- diff --git a/gui/src/Variable/VariableInspectorWidget.cpp b/gui/src/Variable/VariableInspectorWidget.cpp index 57be966..53889b0 100644 --- a/gui/src/Variable/VariableInspectorWidget.cpp +++ b/gui/src/Variable/VariableInspectorWidget.cpp @@ -1,3 +1,5 @@ +#include +#include #include #include #include @@ -179,6 +181,16 @@ void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept auto selectedVariable = selectedVariables.front(); auto renameFun = [&selectedVariable, &model, this]() { + // Generates forbidden names (names associated to existing variables) + auto allVariables = model->variables(); + auto forbiddenNames = QVector(allVariables.size()); + std::transform(allVariables.cbegin(), allVariables.cend(), forbiddenNames.begin(), + [](const auto &variable) { return variable->name(); }); + + RenameVariableDialog dialog{selectedVariable->name(), forbiddenNames, this}; + if (dialog.exec() == QDialog::Accepted) { + selectedVariable->setName(dialog.name()); + } }; tableMenu.addAction(tr("Rename..."), renameFun);