File indexing completed on 2024-05-12 15:58:37

0001 /*
0002  *  SPDX-FileCopyrightText: 2011 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "kis_post_execution_undo_adapter.h"
0008 
0009 #include "kis_undo_store.h"
0010 #include "kis_image_interfaces.h"
0011 #include "commands_new/kis_saved_commands.h"
0012 
0013 
0014 KisPostExecutionUndoAdapter::KisPostExecutionUndoAdapter(KisUndoStore *undoStore,
0015                                                          KisStrokesFacade *strokesFacade)
0016     : m_undoStore(undoStore),
0017       m_strokesFacade(strokesFacade)
0018 {
0019 }
0020 
0021 void KisPostExecutionUndoAdapter::addCommand(KUndo2CommandSP command)
0022 {
0023     if(!command) return;
0024     KisSavedCommand *m = new KisSavedCommand(command, m_strokesFacade);
0025 
0026     m_undoStore->addCommand(m);
0027 }
0028 
0029 KisSavedMacroCommand* KisPostExecutionUndoAdapter::createMacro(const KUndo2MagicString& macroName)
0030 {
0031     return new KisSavedMacroCommand(macroName, m_strokesFacade);
0032 }
0033 
0034 void KisPostExecutionUndoAdapter::addMacro(KisSavedMacroCommand *macro)
0035 {
0036     m_undoStore->addCommand(macro);
0037 }
0038 
0039 void KisPostExecutionUndoAdapter::setUndoStore(KisUndoStore *undoStore)
0040 {
0041     m_undoStore = undoStore;
0042 }
0043 
0044 KisStrokesFacade* KisPostExecutionUndoAdapter::strokesFacade() const
0045 {
0046     return m_strokesFacade;
0047 }