|
Krita Source Code Documentation
|
#include <kundo2stack.h>
Inheritance diagram for KUndo2Command:Public Member Functions | |
| QString | actionText () const |
| virtual bool | canAnnihilateWith (const KUndo2Command *other) const |
| const KUndo2Command * | child (int index) const |
| int | childCount () const |
| virtual QTime | endTime () const |
| KUndo2CommandExtraData * | extraData () const |
| bool | hasParent () const |
| virtual int | id () const |
| virtual bool | isMerged () const |
| KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0) | |
| KUndo2Command (KUndo2Command *parent=0) | |
| virtual QVector< KUndo2Command * > | mergeCommandsVector () const |
| virtual bool | mergeWith (const KUndo2Command *other) |
| virtual void | redo () |
| virtual void | redoMergedCommands () |
| void | setEndTime () |
| virtual void | setEndTime (const QTime &time) |
| void | setExtraData (KUndo2CommandExtraData *data) |
| void | setText (const KUndo2MagicString &text) |
| void | setTime () |
| virtual void | setTime (const QTime &time) |
| virtual void | setTimedID (int timedID) |
| KUndo2MagicString | text () const |
| virtual QTime | time () const |
| virtual int | timedId () const |
| virtual bool | timedMergeWith (KUndo2Command *other) |
| virtual void | undo () |
| virtual void | undoMergedCommands () |
| virtual | ~KUndo2Command () |
Private Attributes | |
| KUndo2CommandPrivate * | d {0} |
| QTime | m_endOfCommand |
| bool | m_hasParent {false} |
| QVector< KUndo2Command * > | m_mergeCommandsVector |
| int | m_timedID {-1} |
| QTime | m_timeOfCreation |
Friends | |
| class | KUndo2QStack |
WARNING: In general, don't derive undo commands from QObject. And if you really need it, don't use QObject lifetime tracking for the commands: KUndo2Command has its own, nonvirtual hierarchy, and don't make it a parent or a child of any QObject. Otherwise two different parents will try to track the lifetime of your command and, most probably, you'll get a crash.
As a general rule: an undo command should be derived from QObject only for the sake of signal/slots capabilities. Nothing else.
Definition at line 86 of file kundo2stack.h.
|
explicit |
Constructs a KUndo2Command object with parent parent.
If parent is not 0, this command is appended to parent's child list. The parent command then owns this command and will delete it in its destructor.
Definition at line 145 of file kundo2stack.cpp.
|
explicit |
\class KUndo2Command
\brief The KUndo2Command class is the base class of all commands stored on a KUndo2QStack.
\since 4.2
For an overview of Qt's Undo Framework, see the
\l{Overview of Qt's Undo Framework}{overview document}.
A KUndo2Command represents a single editing action on a document; for example,
inserting or deleting a block of text in a text editor. KUndo2Command can apply
a change to the document with redo() and undo the change with undo(). The
implementations for these functions must be provided in a derived class.
\snippet doc/src/snippets/code/src_gui_util_qundostack.cpp 0
A KUndo2Command has an associated text(). This is a short string
describing what the command does. It is used to update the text
properties of the stack's undo and redo actions; see
KUndo2QStack::createUndoAction() and KUndo2QStack::createRedoAction().
KUndo2Command objects are owned by the stack they were pushed on.
KUndo2QStack deletes a command if it has been undone and a new command is pushed. For example:
In effect, when a command is pushed, it becomes the top-most command on the stack. To support command compression, KUndo2Command has an id() and the virtual function mergeWith(). These functions are used by KUndo2QStack::push(). To support command macros, a KUndo2Command object can have any number of child commands. Undoing or redoing the parent command will cause the child commands to be undone or redone. A command can be assigned to a parent explicitly in the constructor. In this case, the command will be owned by the parent. The parent in this case is usually an empty command, in that it doesn't provide its own implementation of undo() and redo(). Instead, it uses the base implementations of these functions, which simply call undo() or redo() on all its children. The parent should, however, have a meaningful text(). \snippet doc/src/snippets/code/src_gui_util_qundostack.cpp 2 Another way to create macros is to use the convenience functions KUndo2QStack::beginMacro() and KUndo2QStack::endMacro(). \sa KUndo2QStack
Constructs a KUndo2Command object with the given parent and text.
If parent is not 0, this command is appended to parent's child list. The parent command then owns this command and will delete it in its destructor.
Definition at line 123 of file kundo2stack.cpp.
|
virtual |
Destroys the KUndo2Command object and all child commands.
Definition at line 160 of file kundo2stack.cpp.
References KUndo2CommandPrivate::child_list, and d.
| QString KUndo2Command::actionText | ( | ) | const |
Returns a short text string describing what this command does; for example, "insert text".
The text is used when the text properties of the stack's undo and redo actions are updated.
Definition at line 256 of file kundo2stack.cpp.
References KUndo2CommandPrivate::actionText, and d.
|
virtual |
Attempts to merge this command with command and checks if the two commands compensate each other. If the function returns true, both commands are removed from the stack.
If this function returns true, calling this command's redo() followed by other redo() must have no effect.
The function itself shouldn't do any changes to the command, because after returning true, the command will be deleted as a "noop"
KUndo2QStack will only try to merge two commands if they have the same id, and the id is not -1.
The default implementation returns false.
Reimplemented in KisNodeCompositeOpCommand, KisNodeOpacityCommand, KisSavedCommand, KisSavedMacroCommand, and KisNodePropertyListCommand.
Definition at line 364 of file kundo2stack.cpp.
| const KUndo2Command * KUndo2Command::child | ( | int | index | ) | const |
Returns the child command at index.
Definition at line 315 of file kundo2stack.cpp.
References KUndo2CommandPrivate::child_list, and d.
| int KUndo2Command::childCount | ( | ) | const |
Returns the number of child commands in this command.
Definition at line 302 of file kundo2stack.cpp.
References KUndo2CommandPrivate::child_list, and d.
|
virtual |
Reimplemented in KisSavedCommand.
Definition at line 393 of file kundo2stack.cpp.
References m_endOfCommand.
| KUndo2CommandExtraData * KUndo2Command::extraData | ( | ) | const |
Definition at line 434 of file kundo2stack.cpp.
References d, and KUndo2CommandPrivate::extraData.
| bool KUndo2Command::hasParent | ( | ) | const |
Definition at line 322 of file kundo2stack.cpp.
References m_hasParent.
|
virtual |
Returns the ID of this command.
A command ID is used in command compression. It must be an integer unique to this command's class, or -1 if the command doesn't support compression.
If the command supports compression this function must be overridden in the derived class to return the correct ID. The base implementation returns -1.
KUndo2QStack::push() will only try to merge two commands if they have the same ID, and the ID is not -1.
Reimplemented in KoParameterHandleMoveCommand, KoPathControlPointMoveCommand, KoPathPointMoveCommand, KoPathShapeMarkerCommand, KoShapeBackgroundCommand, KoShapeMergeTextPropertiesCommand, KoShapeMoveCommand, KoShapePaintOrderCommand, KoShapeResizeCommand, KoShapeStrokeCommand, KoShapeTransformCommand, KoShapeTransparencyCommand, KisNodeCompositeOpCommand, KisNodeOpacityCommand, KisNodePropertyListCommand, KisNodeRenameCommand, KisChangeProjectionColorCommand, KisSavedCommand, KisSavedMacroCommand, KisSwitchCurrentTimeCommand, KisSwitchCurrentTimeToKeyframeCommand, KisImageAnimSettingCommand, KisSimpleModifyTransformMaskCommand, DisableUIUpdatesCommand, UpdateCommand, EmitImageSignalsCommand, KisChangeGuidesCommand, KisStoryboardChildEditCommand, EllipseShapeConfigCommand, RectangleShapeConfigCommand, SvgInlineSizeChangeCommand, SvgMoveTextCommand, SvgTextInsertCommand, SvgTextMergePropertiesRangeCommand, and SvgTextRemoveCommand.
Definition at line 181 of file kundo2stack.cpp.
|
virtual |
Reimplemented in KisSavedCommand.
Definition at line 429 of file kundo2stack.cpp.
References m_mergeCommandsVector.
|
virtual |
Reimplemented in KisSavedCommand.
Definition at line 425 of file kundo2stack.cpp.
References m_mergeCommandsVector.
|
virtual |
Attempts to merge this command with command. Returns true on success; otherwise returns false.
If this function returns true, calling this command's redo() must have the same effect as redoing both this command and command. Similarly, calling this command's undo() must have the same effect as undoing command and this command.
KUndo2QStack will only try to merge two commands if they have the same id, and the id is not -1.
The default implementation returns false.
Reimplemented in KisChangeCloneLayersCommand, KoParameterHandleMoveCommand, KoPathControlPointMoveCommand, KoPathPointMoveCommand, KoPathShapeMarkerCommand, KoShapeBackgroundCommand, KoShapeMergeTextPropertiesCommand, KoShapeMoveCommand, KoShapePaintOrderCommand, KoShapeResizeCommand, KoShapeStrokeCommand, KoShapeTransformCommand, KoShapeTransparencyCommand, KisNodeCompositeOpCommand, KisNodeOpacityCommand, KisNodePropertyListCommand, KisNodeRenameCommand, KisChangeProjectionColorCommand, KisSavedCommand, KisSavedMacroCommand, KisSwitchCurrentTimeCommand, KisSwitchCurrentTimeToKeyframeCommand, DisableUIUpdatesCommand, UpdateCommand, EmitImageSignalsCommand, EllipseShapeConfigCommand, RectangleShapeConfigCommand, KisLayerCollapseCommand, KisSimpleModifyTransformMaskCommand, KisStoryboardChildEditCommand, SvgInlineSizeChangeCommand, SvgMoveTextCommand, SvgTextInsertCommand, SvgTextMergePropertiesRangeCommand, SvgTextRemoveCommand, and KisImageAnimSettingCommand.
Definition at line 205 of file kundo2stack.cpp.
|
virtual |
Applies a change to the document. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.
The default implementation calls redo() on all child commands.
Reimplemented in KisChangeValueCommand< mem_ptr, ValueType >, KisChangeIndirectValueCommand< mem_ptr, ValueType >, KisChangeDeselectedMaskCommand, KisCommandUtils::AggregateCommand, KisCommandUtils::SkipFirstRedoWrapper, KisCommandUtils::FlipFlopCommand, KisCommandUtils::CompositeCommand, KoMultiPathPointMergeCommand, KoParameterHandleMoveCommand, KoParameterToPathCommand, KoPathBreakAtPointCommand, KoPathCombineCommand, KoPathControlPointMoveCommand, KoPathFillRuleCommand, KoPathPointInsertCommand, KoPathPointMergeCommand, KoPathPointMoveCommand, KoPathPointRemoveCommand, KoPathPointTypeCommand, KoPathReverseCommand, KoPathSegmentBreakCommand, KoPathSegmentTypeCommand, KoPathShapeMarkerCommand, KoShapeAlignCommand, KoShapeBackgroundCommand, KoShapeClipCommand, KoShapeConnectionChangeCommand, KoShapeCreateCommand, KoShapeDeleteCommand, KoShapeDistributeCommand, KoShapeGroupCommand, KoShapeKeepAspectRatioCommand, KoShapeLockCommand, KoShapeMergeTextPropertiesCommand, KoShapeMoveCommand, KoShapePaintOrderCommand, KoShapeRenameCommand, KoShapeReorderCommand, KoShapeRunAroundCommand, KoShapeShadowCommand, KoShapeShearCommand, KoShapeSizeCommand, KoShapeStrokeCommand, KoShapeTransformCommand, KoShapeTransparencyCommand, KoShapeUnclipCommand, KoShapeUngroupCommand, KoSubpathJoinCommand, KoSubpathRemoveCommand, KoSvgConvertTextTypeCommand, KisChangeFilterCmd, KisImageChangeLayersCommand, KisImageChangeVisibilityCommand, KisImageLayerAddCommand, KisImageLayerMoveCommand, KisImageLayerRemoveCommand, KisImageLayerRemoveCommandImpl, KisNodeCompositeOpCommand, KisNodeOpacityCommand, KisNodePropertyListCommand, KisBatchUpdateLayerModificationCommand, KisDeselectActiveSelectionCommand, KisNodeRenameCommand, KisReselectActiveSelectionCommand, KisActivateSelectionMaskCommand, KisChangeProjectionColorCommand, KisImageResizeCommand, KisImageSetResolutionCommand, KisResetShapesCommand, KisMoveCommandCommon< ObjectSP >, KisMoveCommandCommon< KisNodeSP >, KisMoveCommandCommon< KisSelectionSP >, KisNodeMoveCommand2, KisProcessingCommand, KisSavedCommandBase, KisSelectionMoveCommand2, KisSetLayerStyleCommand, KisSwitchCurrentTimeCommand, KisSwitchCurrentTimeToKeyframeCommand, KisTransactionBasedCommand, KisUpdateCommand, KisChangeChannelFlagsCommand, KisChangeChannelLockFlagsCommand, KisChangeCloneLayersCommand, KisImageAnimSettingCommand, KisLayerCollapseCommand, KisMergeLabeledLayersCommand, KisSimpleModifyTransformMaskCommand, KisDoSomethingCommand< DoSomethingOp, LayerType >, KisInsertKeyframeCommand, KisRemoveKeyframeCommand, KisScalarKeyframeUpdateCommand, KisLayerUtils::FillSelectionMasks, KisLayerUtils::RefreshDelayedUpdateLayers, KisLayerUtils::MergeMetaData, KisLayerUtils::SplitAlphaCommand, KisLayerUtils::SelectGlobalSelectionMask, KisPaintDevice::Private::FrameInsertionCommand, KisPaintDevice::Private::DeviceChangeProfileCommand, KisPaintDeviceData::ChangeProfileCommand, KisPaintDeviceData::ChangeColorSpaceCommand, KisSelection::ChangeShapeSelectionCommand, KisSuspendProjectionUpdatesStrokeStrategy::Private::SuspendUpdatesCommand, KisSuspendProjectionUpdatesStrokeStrategy::Private::ResumeAndIssueGraphUpdatesCommand, KisSuspendProjectionUpdatesStrokeStrategy::Private::StartBatchUIUpdatesCommand, KisSuspendProjectionUpdatesStrokeStrategy::Private::EndBatchUIUpdatesCommand, KisTransactionData, KisChangeOverlayWrapperCommand, SetKeyStrokesColorSpaceCommand, SetKeyStrokeColorsCommand, AddSwatchCommand, RemoveSwatchCommand, ChangeGroupNameCommand, MoveGroupCommand, AddGroupCommand, RemoveGroupCommand, ClearCommand, SetColumnCountCommand, SetCommentCommand, SetPaletteTypeCommand, KisTransformToolActivationCommand, KisChangeGuidesCommand, TransformShapeLayerDeferred, KisTakeAllShapesCommand, AddReferenceImagesCommand, RemoveReferenceImagesCommand, KisChangeFileLayerCmd, KisGuiContextCommand, MultinodePropertyUndoCommand< PropertyAdapter >, KisReferenceImage::SetSaturationCommand, EditAssistantsCommand, KisAddStoryboardCommand, KisRemoveStoryboardCommand, KisDuplicateStoryboardCommand, KisMoveStoryboardCommand, KisVisualizeStoryboardCommand, KisStoryboardChildEditCommand, KisQmicSynchronizeLayersCommand, EllipseShapeConfigCommand, RectangleShapeConfigCommand, SpiralShapeConfigCommand, StarShapeConfigCommand, SvgInlineSizeChangeCommand, SvgMoveTextCommand, SvgTextChangeCommand, SvgTextInsertCommand, SvgTextInsertRichCommand, SvgTextMergePropertiesRangeCommand, SvgTextRemoveCommand, and KisCommandUtils::SkipFirstRedoBase.
Definition at line 222 of file kundo2stack.cpp.
References KUndo2CommandPrivate::child_list, and d.
|
virtual |
Definition at line 412 of file kundo2stack.cpp.
References mergeCommandsVector(), redo(), and redoMergedCommands().
| void KUndo2Command::setEndTime | ( | ) |
Definition at line 385 of file kundo2stack.cpp.
References setEndTime().
|
virtual |
Reimplemented in KisSavedCommand.
Definition at line 389 of file kundo2stack.cpp.
References m_endOfCommand, and time().
| void KUndo2Command::setExtraData | ( | KUndo2CommandExtraData * | data | ) |
The user can assign an arbitrary object associated with the command. The data object is owned by the command. If you assign the object twice, the first one will be destroyed.
Definition at line 439 of file kundo2stack.cpp.
References d, and KUndo2CommandPrivate::extraData.
| void KUndo2Command::setText | ( | const KUndo2MagicString & | undoText | ) |
Sets the command's text to be the text specified.
The specified text should be a short user-readable string describing what this command does.
Definition at line 288 of file kundo2stack.cpp.
References KUndo2CommandPrivate::actionText, d, KUndo2CommandPrivate::text, and KUndo2MagicString::toSecondaryString().
| void KUndo2Command::setTime | ( | ) |
Definition at line 370 of file kundo2stack.cpp.
References setTime().
|
virtual |
Reimplemented in KisSavedCommand.
Definition at line 375 of file kundo2stack.cpp.
References m_timeOfCreation, and time().
|
virtual |
| KUndo2MagicString KUndo2Command::text | ( | ) | const |
Returns a short text string describing what this command does; for example, "insert text".
The text is used when the text properties of the stack's undo and redo actions are updated.
Definition at line 274 of file kundo2stack.cpp.
References d, and KUndo2CommandPrivate::text.
|
virtual |
Reimplemented in KisSavedCommand.
Definition at line 380 of file kundo2stack.cpp.
References m_timeOfCreation.
|
virtual |
Reimplemented in KisSavedCommand.
Definition at line 327 of file kundo2stack.cpp.
References m_timedID.
|
virtual |
Reimplemented in KisSavedCommand.
Definition at line 336 of file kundo2stack.cpp.
References m_mergeCommandsVector, m_timeOfCreation, time(), and timedId().
|
virtual |
Reverts a change to the document. After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.
The default implementation calls undo() on all child commands in reverse order.
Reimplemented in KisChangeValueCommand< mem_ptr, ValueType >, KisChangeIndirectValueCommand< mem_ptr, ValueType >, KisChangeDeselectedMaskCommand, KisCommandUtils::AggregateCommand, KisCommandUtils::SkipFirstRedoWrapper, KisCommandUtils::FlipFlopCommand, KisCommandUtils::CompositeCommand, KoMultiPathPointMergeCommand, KoParameterHandleMoveCommand, KoParameterToPathCommand, KoPathBreakAtPointCommand, KoPathCombineCommand, KoPathControlPointMoveCommand, KoPathFillRuleCommand, KoPathPointInsertCommand, KoPathPointMergeCommand, KoPathPointMoveCommand, KoPathPointRemoveCommand, KoPathPointTypeCommand, KoPathReverseCommand, KoPathSegmentBreakCommand, KoPathSegmentTypeCommand, KoPathShapeMarkerCommand, KoShapeAlignCommand, KoShapeBackgroundCommand, KoShapeClipCommand, KoShapeConnectionChangeCommand, KoShapeCreateCommand, KoShapeDeleteCommand, KoShapeDistributeCommand, KoShapeGroupCommand, KoShapeKeepAspectRatioCommand, KoShapeLockCommand, KoShapeMergeTextPropertiesCommand, KoShapeMoveCommand, KoShapePaintOrderCommand, KoShapeRenameCommand, KoShapeReorderCommand, KoShapeRunAroundCommand, KoShapeShadowCommand, KoShapeShearCommand, KoShapeSizeCommand, KoShapeStrokeCommand, KoShapeTransformCommand, KoShapeTransparencyCommand, KoShapeUnclipCommand, KoShapeUngroupCommand, KoSubpathJoinCommand, KoSubpathRemoveCommand, KoSvgConvertTextTypeCommand, KisChangeFilterCmd, KisImageChangeLayersCommand, KisImageChangeVisibilityCommand, KisImageLayerAddCommand, KisImageLayerMoveCommand, KisImageLayerRemoveCommand, KisImageLayerRemoveCommandImpl, KisNodeCompositeOpCommand, KisNodeOpacityCommand, KisNodePropertyListCommand, KisBatchUpdateLayerModificationCommand, KisDeselectActiveSelectionCommand, KisNodeRenameCommand, KisReselectActiveSelectionCommand, KisActivateSelectionMaskCommand, KisChangeProjectionColorCommand, KisImageResizeCommand, KisImageSetResolutionCommand, KisResetShapesCommand, KisMoveCommandCommon< ObjectSP >, KisMoveCommandCommon< KisNodeSP >, KisMoveCommandCommon< KisSelectionSP >, KisNodeMoveCommand2, KisProcessingCommand, KisSavedCommandBase, KisSelectionMoveCommand2, KisSetLayerStyleCommand, KisSwitchCurrentTimeCommand, KisSwitchCurrentTimeToKeyframeCommand, KisTransactionBasedCommand, KisUpdateCommand, KisChangeChannelFlagsCommand, KisChangeChannelLockFlagsCommand, KisChangeCloneLayersCommand, KisImageAnimSettingCommand, KisLayerCollapseCommand, KisMergeLabeledLayersCommand, KisSimpleModifyTransformMaskCommand, KisDoSomethingCommand< DoSomethingOp, LayerType >, KisInsertKeyframeCommand, KisRemoveKeyframeCommand, KisScalarKeyframeUpdateCommand, KisLayerUtils::SplitAlphaCommand, KisPaintDevice::Private::FrameInsertionCommand, KisPaintDevice::Private::DeviceChangeProfileCommand, KisPaintDeviceData::ChangeProfileCommand, KisPaintDeviceData::ChangeColorSpaceCommand, KisSelection::ChangeShapeSelectionCommand, KisSuspendProjectionUpdatesStrokeStrategy::Private::SuspendUpdatesCommand, KisSuspendProjectionUpdatesStrokeStrategy::Private::ResumeAndIssueGraphUpdatesCommand, KisSuspendProjectionUpdatesStrokeStrategy::Private::StartBatchUIUpdatesCommand, KisSuspendProjectionUpdatesStrokeStrategy::Private::EndBatchUIUpdatesCommand, KisTransactionData, KisChangeOverlayWrapperCommand, SetKeyStrokesColorSpaceCommand, SetKeyStrokeColorsCommand, AddSwatchCommand, RemoveSwatchCommand, ChangeGroupNameCommand, MoveGroupCommand, AddGroupCommand, RemoveGroupCommand, ClearCommand, SetColumnCountCommand, SetCommentCommand, SetPaletteTypeCommand, KisTransformToolActivationCommand, KisChangeGuidesCommand, TransformShapeLayerDeferred, KisTakeAllShapesCommand, AddReferenceImagesCommand, RemoveReferenceImagesCommand, KisChangeFileLayerCmd, KisGuiContextCommand, MultinodePropertyUndoCommand< PropertyAdapter >, KisReferenceImage::SetSaturationCommand, EditAssistantsCommand, KisAddStoryboardCommand, KisRemoveStoryboardCommand, KisDuplicateStoryboardCommand, KisMoveStoryboardCommand, KisVisualizeStoryboardCommand, KisStoryboardChildEditCommand, KisQmicSynchronizeLayersCommand, EllipseShapeConfigCommand, RectangleShapeConfigCommand, SpiralShapeConfigCommand, StarShapeConfigCommand, SvgInlineSizeChangeCommand, SvgMoveTextCommand, SvgTextChangeCommand, SvgTextInsertCommand, SvgTextInsertRichCommand, SvgTextMergePropertiesRangeCommand, SvgTextRemoveCommand, and KisCommandUtils::SkipFirstRedoBase.
Definition at line 240 of file kundo2stack.cpp.
References KUndo2CommandPrivate::child_list, and d.
|
virtual |
Definition at line 398 of file kundo2stack.cpp.
References mergeCommandsVector(), undo(), and undoMergedCommands().
|
friend |
Definition at line 142 of file kundo2stack.h.
|
private |
Definition at line 88 of file kundo2stack.h.
|
private |
Definition at line 149 of file kundo2stack.h.
|
private |
Definition at line 145 of file kundo2stack.h.
|
private |
Definition at line 150 of file kundo2stack.h.
|
private |
Definition at line 146 of file kundo2stack.h.
|
private |
Definition at line 148 of file kundo2stack.h.