##// END OF EJS Templates
Adds 'Duplicate' action on variable menu
Alexandre Leroux -
r706:35ef72ac0d81
parent child
Show More
@@ -42,6 +42,13 public:
42 42 void setTimeController(TimeController *timeController) noexcept;
43 43
44 44 /**
45 * Clones the variable passed in parameter and adds the duplicate to the controller
46 * @param variable the variable to duplicate
47 * @return the duplicate created, nullptr if the variable couldn't be created
48 */
49 std::shared_ptr<Variable> cloneVariable(std::shared_ptr<Variable> variable) noexcept;
50
51 /**
45 52 * Deletes from the controller the variable passed in parameter.
46 53 *
47 54 * Delete a variable includes:
@@ -188,6 +188,11 void VariableController::setTimeController(TimeController *timeController) noexc
188 188 impl->m_TimeController = timeController;
189 189 }
190 190
191 std::shared_ptr<Variable>
192 VariableController::cloneVariable(std::shared_ptr<Variable> variable) noexcept
193 {
194 }
195
191 196 void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noexcept
192 197 {
193 198 if (!variable) {
@@ -176,10 +176,16 void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept
176 176 if (!selectedVariables.isEmpty()) {
177 177 tableMenu.addSeparator();
178 178
179 // 'Rename' action (only if one variable selected)
179 // 'Rename' and 'Duplicate' actions (only if one variable selected)
180 180 if (selectedVariables.size() == 1) {
181 181 auto selectedVariable = selectedVariables.front();
182 182
183 auto duplicateFun = [&selectedVariable]() {
184 sqpApp->variableController().cloneVariable(selectedVariable);
185 };
186
187 tableMenu.addAction(tr("Duplicate"), duplicateFun);
188
183 189 auto renameFun = [&selectedVariable, &model, this]() {
184 190 // Generates forbidden names (names associated to existing variables)
185 191 auto allVariables = model->variables();
General Comments 0
You need to be logged in to leave comments. Login now