add edit command for event pastes

This commit is contained in:
garak
2021-04-15 01:14:09 -04:00
parent 296d697df0
commit 47887aca4d
3 changed files with 39 additions and 13 deletions

View File

@@ -414,7 +414,11 @@ int EventDelete::id() const {
EventDuplicate::EventDuplicate(Editor *editor, Map *map,
QList<Event *> selectedEvents,
QUndoCommand *parent) : QUndoCommand(parent) {
setText("Duplicate Event");
if (selectedEvents.size() > 1) {
setText("Duplicate Events");
} else {
setText("Duplicate Event");
}
this->editor = editor;
@@ -462,6 +466,24 @@ int EventDuplicate::id() const {
return CommandId::ID_EventDuplicate | getEventTypeMask(this->selectedEvents);
}
/******************************************************************************
************************************************************************
******************************************************************************/
EventPaste::EventPaste(Editor *editor, Map *map,
QList<Event *> pastedEvents,
QUndoCommand *parent) : EventDuplicate(editor, map, pastedEvents) {
if (pastedEvents.size() > 1) {
setText("Paste Events");
} else {
setText("Paste Event");
}
}
int EventPaste::id() const {
return CommandId::ID_EventPaste | getEventTypeMask(this->selectedEvents);
}
/******************************************************************************
************************************************************************
******************************************************************************/

View File

@@ -156,9 +156,11 @@ void MainWindow::initExtraShortcuts() {
auto *shortcut_Copy = new Shortcut(QKeySequence("Ctrl+C"), this, SLOT(copy()));
shortcut_Copy->setObjectName("shortcut_Copy");
shortcut_Copy->setWhatsThis("Copy");
auto *shortcut_Paste = new Shortcut(QKeySequence("Ctrl+V"), this, SLOT(paste()));
shortcut_Paste->setObjectName("shortcut_Paste");
shortcut_Copy->setWhatsThis("Paste");
}
QObjectList MainWindow::shortcutableObjects() const {
@@ -1583,18 +1585,8 @@ void MainWindow::paste() {
newEvents.append(pasteEvent);
}
editor->project->loadEventPixmaps(editor->map->getAllEvents());
editor->map->editHistory.push(new EventPaste(this->editor, editor->map, newEvents));
for (Event *event : newEvents) {
editor->addMapEvent(event);
}
// select these events
editor->selected_events->clear();
for (Event *event : newEvents) {
editor->selected_events->append(event->pixmapItem);
}
editor->shouldReselectEvents();
break;
}
}