File indexing completed on 2024-12-22 04:10:03
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 0008 #ifndef KISASYNCHRONOUSLYMERGEABLECOMMANDINTERFACE_H 0009 #define KISASYNCHRONOUSLYMERGEABLECOMMANDINTERFACE_H 0010 0011 class KUndo2Command; 0012 0013 /** 0014 * A special base class for commands that should be able to merge 0015 * (compress) when used inside KisProcessingApplicator (or anything 0016 * else that uses KisSavedMacroCommand). 0017 * 0018 * KisProcessingApplicator generates many commands, but undo stack 0019 * wants only one command to represent user's action. That is why 0020 * the action is wrapped into KisSavedMacroCommand. This macro command 0021 * class has a special algorithm for merging an action consisting of 0022 * multiple commands. This algorithm must know if **all** the commands 0023 * of the macro can be merged before doing the actual merge. Using 0024 * KUndo2Command::mergeWith() is not possible for this purpose, because 0025 * it merges commands right away and one cannot undo that. 0026 * 0027 * \see KisSavedMacroCommand::mergeWith() 0028 * \see example in KisNodeCompositeOpCommand 0029 */ 0030 class KisAsynchronouslyMergeableCommandInterface 0031 { 0032 public: 0033 virtual ~KisAsynchronouslyMergeableCommandInterface(); 0034 0035 /** 0036 * @return true if \p command can be merged with (*this) command 0037 * using KUndo2Command::mergeWith() call. 0038 * 0039 * WARNING: if canMergeWith() returned true, then mergeWith() must 0040 * also return true. Otherwise KisSavedMacroCommand will 0041 * be able to enter inconsistent state and assert. 0042 */ 0043 virtual bool canMergeWith(const KUndo2Command *command) const = 0; 0044 }; 0045 0046 #endif // KISASYNCHRONOUSLYMERGEABLECOMMANDINTERFACE_H