| 135 | } |
| 136 | |
| 137 | void MacroEditorDialog::copyCurrentMacro() |
| 138 | { |
| 139 | QModelIndex currentIndex = ui->listMacros->selectionModel()->currentIndex(); |
| 140 | |
| 141 | if (currentIndex.isValid()) { |
| 142 | Macro *originalMacro = model->macro(currentIndex); |
| 143 | |
| 144 | model->insertRows(currentIndex.row() + 1, 1); |
| 145 | |
| 146 | Macro *newMacro = model->macro(model->index(currentIndex.row() + 1)); |
| 147 | |
| 148 | // TODO: move this into a copy constructor in the Macro class? |
| 149 | |
| 150 | newMacro->setName(originalMacro->getName() + " " + tr("(Copy)")); |
| 151 | |
| 152 | for (const MacroStep &step : qAsConst(originalMacro->getSteps())) { |
| 153 | newMacro->addMacroStep(step); |
| 154 | } |
| 155 | |
| 156 | // Select the newly created macro |
| 157 | ui->listMacros->setCurrentIndex(model->index(currentIndex.row() + 1)); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | void MacroEditorDialog::insertMacroStep() |
| 162 | { |
nothing calls this directly
no test coverage detected