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

The undo / redo command for deleting shapes. More...

#include <KoShapeDeleteCommand.h>

+ Inheritance diagram for KoShapeDeleteCommand:

Public Member Functions

 KoShapeDeleteCommand (KoShapeControllerBase *controller, const QList< KoShape * > &shapes, KUndo2Command *parent=0)
 
 KoShapeDeleteCommand (KoShapeControllerBase *controller, KoShape *shape, KUndo2Command *parent=0)
 
 Private (KoShapeControllerBase *c)
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoShapeDeleteCommand () override
 
 ~Private ()
 
- 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 ()
 

Public Attributes

KoShapeControllerBasecontroller
 the shape controller to use for removing/readding
 
bool deleteShapes
 shows if shapes should be deleted when deleting the command
 
QList< KoShapeContainer * > oldParents
 the old parents of the shapes
 
QList< KoShape * > shapes
 the list of shapes to delete
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Additional Inherited Members

- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Detailed Description

The undo / redo command for deleting shapes.

Definition at line 14 of file KoShapeDeleteCommand.cpp.

Constructor & Destructor Documentation

◆ ~Private()

KoShapeDeleteCommand::~Private ( )
inline

Definition at line 22 of file KoShapeDeleteCommand.cpp.

22 {
23 if (! deleteShapes)
24 return;
25
26 Q_FOREACH (KoShape *shape, shapes)
27 delete shape;
28 }
bool deleteShapes
shows if shapes should be deleted when deleting the command
QList< KoShape * > shapes
the list of shapes to delete

◆ KoShapeDeleteCommand() [1/2]

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

Command to delete a single shape by means of a shape controller.

Parameters
controllerthe controller to used for deleting.
shapea single shape that should be deleted.
parentthe parent command used for macro commands

Definition at line 36 of file KoShapeDeleteCommand.cpp.

37 : KUndo2Command(parent),
38 d(new Private(controller))
39{
40 d->shapes.append(shape);
41 d->oldParents.append(shape->parent());
42
43 setText(kundo2_i18nc("Delete one shape", "Delete shape"));
44}
void setText(const KUndo2MagicString &text)
KUndo2Command(KUndo2Command *parent=0)
KoShapeControllerBase * controller
the shape controller to use for removing/readding
KoShapeContainer * parent() const
Definition KoShape.cpp:1039
KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text)

References d, kundo2_i18nc(), KoShape::parent(), and KUndo2Command::setText().

◆ KoShapeDeleteCommand() [2/2]

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

Command to delete a set of shapes by means of a shape controller.

Parameters
controllerthe controller to used for deleting.
shapesa set of all the shapes that should be deleted.
parentthe parent command used for macro commands

Definition at line 46 of file KoShapeDeleteCommand.cpp.

48 : KUndo2Command(parent),
49 d(new Private(controller))
50{
51 d->shapes = shapes;
52 Q_FOREACH (KoShape *shape, d->shapes) {
53 d->oldParents.append(shape->parent());
54 }
55
56 setText(kundo2_i18np("Delete shape", "Delete shapes", shapes.count()));
57}
KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1)

References d, kundo2_i18np(), KoShape::parent(), KUndo2Command::setText(), and shapes.

◆ ~KoShapeDeleteCommand()

KoShapeDeleteCommand::~KoShapeDeleteCommand ( )
override

Definition at line 59 of file KoShapeDeleteCommand.cpp.

60{
61 delete d;
62}

References d.

Member Function Documentation

◆ Private()

KoShapeDeleteCommand::Private ( KoShapeControllerBase * c)
inline

Definition at line 17 of file KoShapeDeleteCommand.cpp.

18 : controller(c),
19 deleteShapes(false) {
20 }

◆ redo()

void KoShapeDeleteCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Reimplemented in RemoveReferenceImagesCommand.

Definition at line 64 of file KoShapeDeleteCommand.cpp.

65{
67 if (! d->controller)
68 return;
69
70 for (int i = 0; i < d->shapes.count(); i++) {
71 if (d->oldParents.at(i)) {
72 d->oldParents.at(i)->removeShape(d->shapes[i]);
73 }
74 }
75 d->deleteShapes = true;
76}
virtual void redo()

References d, and KUndo2Command::redo().

◆ undo()

void KoShapeDeleteCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Reimplemented in RemoveReferenceImagesCommand.

Definition at line 78 of file KoShapeDeleteCommand.cpp.

79{
81 if (! d->controller)
82 return;
83
84 for (int i = 0; i < d->shapes.count(); i++) {
85 if (d->oldParents.at(i)) {
86 d->oldParents.at(i)->addShape(d->shapes[i]);
87 }
88 }
89 d->deleteShapes = false;
90}
virtual void undo()

References d, and KUndo2Command::undo().

Member Data Documentation

◆ controller

KoShapeControllerBase* KoShapeDeleteCommand::controller

the shape controller to use for removing/readding

Definition at line 30 of file KoShapeDeleteCommand.cpp.

◆ d

Private* const KoShapeDeleteCommand::d
private

Definition at line 43 of file KoShapeDeleteCommand.h.

◆ deleteShapes

bool KoShapeDeleteCommand::deleteShapes

shows if shapes should be deleted when deleting the command

Definition at line 33 of file KoShapeDeleteCommand.cpp.

◆ oldParents

QList<KoShapeContainer*> KoShapeDeleteCommand::oldParents

the old parents of the shapes

Definition at line 32 of file KoShapeDeleteCommand.cpp.

◆ shapes

QList<KoShape*> KoShapeDeleteCommand::shapes

the list of shapes to delete

Definition at line 31 of file KoShapeDeleteCommand.cpp.


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