@@ -184,22 +184,29 void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept | |||
|
184 | 184 | if (selectedVariables.size() == 1) { |
|
185 | 185 | auto selectedVariable = selectedVariables.front(); |
|
186 | 186 | |
|
187 |
auto duplicateFun = [ |
|
|
188 | sqpApp->variableController().cloneVariable(selectedVariable); | |
|
187 | auto duplicateFun = [varW = std::weak_ptr<Variable>(selectedVariable)]() | |
|
188 | { | |
|
189 | if (auto var = varW.lock()) { | |
|
190 | sqpApp->variableController().cloneVariable(var); | |
|
191 | } | |
|
189 | 192 | }; |
|
190 | 193 | |
|
191 | 194 | tableMenu.addAction(tr("Duplicate"), duplicateFun); |
|
192 | 195 | |
|
193 |
auto renameFun = [ |
|
|
196 | auto renameFun = [ varW = std::weak_ptr<Variable>(selectedVariable), &model, this ]() | |
|
197 | { | |
|
198 | if (auto var = varW.lock()) { | |
|
194 | 199 | // Generates forbidden names (names associated to existing variables) |
|
195 | 200 | auto allVariables = model->variables(); |
|
196 | 201 | auto forbiddenNames = QVector<QString>(allVariables.size()); |
|
197 |
std::transform(allVariables.cbegin(), allVariables.cend(), |
|
|
202 | std::transform(allVariables.cbegin(), allVariables.cend(), | |
|
203 | forbiddenNames.begin(), | |
|
198 | 204 | [](const auto &variable) { return variable->name(); }); |
|
199 | 205 | |
|
200 |
RenameVariableDialog dialog{ |
|
|
206 | RenameVariableDialog dialog{var->name(), forbiddenNames, this}; | |
|
201 | 207 | if (dialog.exec() == QDialog::Accepted) { |
|
202 |
|
|
|
208 | var->setName(dialog.name()); | |
|
209 | } | |
|
203 | 210 | } |
|
204 | 211 | }; |
|
205 | 212 |
General Comments 0
You need to be logged in to leave comments.
Login now