UI: Optimize undo/redo functions with constant references
This commit is contained in:
parent
a59f6c4e50
commit
3ce12bc5e9
2 changed files with 9 additions and 8 deletions
|
|
@ -30,9 +30,10 @@ void undo_stack::clear()
|
|||
ui->actionMainRedo->setDisabled(true);
|
||||
}
|
||||
|
||||
void undo_stack::add_action(const QString &name, undo_redo_cb undo,
|
||||
undo_redo_cb redo, std::string undo_data,
|
||||
std::string redo_data, bool repeatable)
|
||||
void undo_stack::add_action(const QString &name, const undo_redo_cb &undo,
|
||||
const undo_redo_cb &redo,
|
||||
const std::string &undo_data,
|
||||
const std::string &redo_data, bool repeatable)
|
||||
{
|
||||
if (!is_enabled())
|
||||
return;
|
||||
|
|
@ -42,8 +43,6 @@ void undo_stack::add_action(const QString &name, undo_redo_cb undo,
|
|||
undo_items.pop_back();
|
||||
}
|
||||
|
||||
undo_redo_t n = {name, undo_data, redo_data, undo, redo};
|
||||
|
||||
if (repeatable) {
|
||||
repeat_reset_timer.start();
|
||||
}
|
||||
|
|
@ -54,6 +53,8 @@ void undo_stack::add_action(const QString &name, undo_redo_cb undo,
|
|||
return;
|
||||
}
|
||||
|
||||
undo_redo_t n = {name, undo_data, redo_data, undo, redo};
|
||||
|
||||
last_is_repeatable = repeatable;
|
||||
undo_items.push_front(n);
|
||||
clear_redo();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue