MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / copyCurrentMacro

Method copyCurrentMacro

src/dialogs/MacroEditorDialog.cpp:137–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137void 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
161void MacroEditorDialog::insertMacroStep()
162{

Callers

nothing calls this directly

Calls 5

macroMethod · 0.80
addMacroStepMethod · 0.80
insertRowsMethod · 0.45
setNameMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected