##// END OF EJS Templates
Calls rename dialog when clicking action in the menu
Alexandre Leroux -
r685:a2408b382cf6
parent child
Show More
@@ -1,3 +1,5
1 #include <Variable/RenameVariableDialog.h>
2 #include <Variable/Variable.h>
1 #include <Variable/VariableController.h>
3 #include <Variable/VariableController.h>
2 #include <Variable/VariableInspectorWidget.h>
4 #include <Variable/VariableInspectorWidget.h>
3 #include <Variable/VariableMenuHeaderWidget.h>
5 #include <Variable/VariableMenuHeaderWidget.h>
@@ -179,6 +181,16 void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept
179 auto selectedVariable = selectedVariables.front();
181 auto selectedVariable = selectedVariables.front();
180
182
181 auto renameFun = [&selectedVariable, &model, this]() {
183 auto renameFun = [&selectedVariable, &model, this]() {
184 // Generates forbidden names (names associated to existing variables)
185 auto allVariables = model->variables();
186 auto forbiddenNames = QVector<QString>(allVariables.size());
187 std::transform(allVariables.cbegin(), allVariables.cend(), forbiddenNames.begin(),
188 [](const auto &variable) { return variable->name(); });
189
190 RenameVariableDialog dialog{selectedVariable->name(), forbiddenNames, this};
191 if (dialog.exec() == QDialog::Accepted) {
192 selectedVariable->setName(dialog.name());
193 }
182 };
194 };
183
195
184 tableMenu.addAction(tr("Rename..."), renameFun);
196 tableMenu.addAction(tr("Rename..."), renameFun);
General Comments 0
You need to be logged in to leave comments. Login now