Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeUnclipCommand Class Reference

The undo / redo command for removing the shape clip path. More...

#include <KoShapeUnclipCommand.h>

+ Inheritance diagram for KoShapeUnclipCommand:

Classes

class  Private
 

Public Member Functions

 KoShapeUnclipCommand (KoShapeControllerBase *controller, const QList< KoShape * > &shapes, KUndo2Command *parent=0)
 
 KoShapeUnclipCommand (KoShapeControllerBase *controller, KoShape *shape, KUndo2Command *parent=0)
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoShapeUnclipCommand () override
 Destroys the command.
 
- Public Member Functions inherited from KUndo2Command
QString actionText () const
 
virtual bool canAnnihilateWith (const KUndo2Command *other) const
 
const KUndo2Commandchild (int index) const
 
int childCount () const
 
virtual QTime endTime () const
 
KUndo2CommandExtraDataextraData () 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 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 undoMergedCommands ()
 
virtual ~KUndo2Command ()
 

Private Attributes

Private *const d
 

Detailed Description

The undo / redo command for removing the shape clip path.

Definition at line 18 of file KoShapeUnclipCommand.h.

Constructor & Destructor Documentation

◆ KoShapeUnclipCommand() [1/2]

KoShapeUnclipCommand::KoShapeUnclipCommand ( KoShapeControllerBase * controller,
const QList< KoShape * > & shapes,
KUndo2Command * parent = 0 )

Command to remove clip path from multiple shapes.

Parameters
controllerthe controller to used for adding the clip shapes.
shapesa set of all the shapes to remove the clip path from.
parentthe parent command used for macro commands

Definition at line 75 of file KoShapeUnclipCommand.cpp.

76 : KUndo2Command(parent), d(new Private(controller))
77{
78 d->shapesToUnclip = shapes;
79 Q_FOREACH (KoShape *shape, d->shapesToUnclip) {
80 d->oldClipPaths.append(shape->clipPath());
81 }
82
83 setText(kundo2_i18n("Unclip Shape"));
84}
void setText(const KUndo2MagicString &text)
KUndo2Command(KUndo2Command *parent=0)
KoClipPath * clipPath() const
Returns the currently set clip path or 0 if there is no clip path set.
Definition KoShape.cpp:1128
KUndo2MagicString kundo2_i18n(const char *text)

References KoShape::clipPath(), d, kundo2_i18n(), KoShapeUnclipCommand::Private::oldClipPaths, KUndo2Command::setText(), and KoShapeUnclipCommand::Private::shapesToUnclip.

◆ KoShapeUnclipCommand() [2/2]

KoShapeUnclipCommand::KoShapeUnclipCommand ( KoShapeControllerBase * controller,
KoShape * shape,
KUndo2Command * parent = 0 )

Command to remove clip path from a single shape.

Parameters
controllerthe controller to used for adding the clip shapes.
shapea single shape to remove the clip path from.
parentthe parent command used for macro commands

Definition at line 86 of file KoShapeUnclipCommand.cpp.

87 : KUndo2Command(parent), d(new Private(controller))
88{
89 d->shapesToUnclip.append(shape);
90 d->oldClipPaths.append(shape->clipPath());
91
92 setText(kundo2_i18n("Unclip Shapes"));
93}

References KoShape::clipPath(), d, kundo2_i18n(), KoShapeUnclipCommand::Private::oldClipPaths, KUndo2Command::setText(), and KoShapeUnclipCommand::Private::shapesToUnclip.

◆ ~KoShapeUnclipCommand()

KoShapeUnclipCommand::~KoShapeUnclipCommand ( )
override

Destroys the command.

Definition at line 95 of file KoShapeUnclipCommand.cpp.

96{
97 delete d;
98}

References d.

Member Function Documentation

◆ redo()

void KoShapeUnclipCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Definition at line 100 of file KoShapeUnclipCommand.cpp.

101{
103
104 const uint shapeCount = d->shapesToUnclip.count();
105 for (uint i = 0; i < shapeCount; ++i) {
106 d->shapesToUnclip[i]->setClipPath(0);
107 d->shapesToUnclip[i]->update();
108 }
109
110 const uint clipPathCount = d->clipPathShapes.count();
111 for (uint i = 0; i < clipPathCount; ++i) {
112 if (d->clipPathParents.at(i)) {
113 d->clipPathParents.at(i)->addShape(d->clipPathShapes[i]);
114 }
115 }
116
117 d->executed = true;
118
120}
unsigned int uint
virtual void redo()
QList< KoPathShape * > clipPathShapes
QList< KoShapeContainer * > clipPathParents

References KoShapeUnclipCommand::Private::clipPathParents, KoShapeUnclipCommand::Private::clipPathShapes, KoShapeUnclipCommand::Private::createClipPathShapes(), d, KoShapeUnclipCommand::Private::executed, KUndo2Command::redo(), and KoShapeUnclipCommand::Private::shapesToUnclip.

◆ undo()

void KoShapeUnclipCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Definition at line 122 of file KoShapeUnclipCommand.cpp.

123{
125
126 const uint shapeCount = d->shapesToUnclip.count();
127 for (uint i = 0; i < shapeCount; ++i) {
128 d->shapesToUnclip[i]->setClipPath(d->oldClipPaths[i]);
129 d->shapesToUnclip[i]->update();
130 }
131
132 const uint clipPathCount = d->clipPathShapes.count();
133 for (uint i = 0; i < clipPathCount; ++i) {
134 if (d->clipPathParents.at(i)) {
135 d->clipPathParents.at(i)->removeShape(d->clipPathShapes[i]);
136 }
137 }
138
139 d->executed = false;
140}
virtual void undo()

References KoShapeUnclipCommand::Private::clipPathParents, KoShapeUnclipCommand::Private::clipPathShapes, d, KoShapeUnclipCommand::Private::executed, KoShapeUnclipCommand::Private::oldClipPaths, KoShapeUnclipCommand::Private::shapesToUnclip, and KUndo2Command::undo().

Member Data Documentation

◆ d

Private* const KoShapeUnclipCommand::d
private

Definition at line 47 of file KoShapeUnclipCommand.h.


The documentation for this class was generated from the following files: