File indexing completed on 2024-12-22 04:10:02

0001 /*
0002  *  SPDX-FileCopyrightText: 2009 Cyrille Berger <cberger@cberger.net>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KIS_IMAGE_NODE_PROPERTY_LIST_COMMAND_H_
0008 #define KIS_IMAGE_NODE_PROPERTY_LIST_COMMAND_H_
0009 
0010 #include "kis_node_command.h"
0011 #include "kis_base_node.h"
0012 #include "commands_new/KisAsynchronouslyMergeableCommandInterface.h"
0013 
0014 
0015 /// The command for changing the property list of a layer
0016 class KRITAIMAGE_EXPORT KisNodePropertyListCommand : public KisNodeCommand, public KisAsynchronouslyMergeableCommandInterface
0017 {
0018 
0019 public:
0020     /**
0021      * Constructor
0022      * @param node the layer to add
0023      * @param newPropertyList the property list to which the node to be added
0024      */
0025     KisNodePropertyListCommand(KisNodeSP node, KisBaseNode::PropertyList newPropertyList);
0026 
0027     void redo() override;
0028     void undo() override;
0029 
0030     int id() const override;
0031     bool mergeWith(const KUndo2Command *command) override;
0032     bool canMergeWith(const KUndo2Command *command) const override;
0033     bool canAnnihilateWith(const KUndo2Command *other) const override;
0034 
0035     typedef KisBaseNode::PropertyList PropertyList;
0036     static void setNodePropertiesAutoUndo(KisNodeSP node, KisImageSP image, PropertyList proplist);
0037 
0038 private:
0039     void doUpdate(const KisBaseNode::PropertyList &oldPropertyList,
0040                   const KisBaseNode::PropertyList &newPropertyList, const QRect &totalUpdateExtent);
0041     static const QSet<QString>& propsWithNoUpdates();
0042 private:
0043     KisBaseNode::PropertyList m_newPropertyList;
0044     KisBaseNode::PropertyList m_oldPropertyList;
0045 };
0046 #endif