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

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

#include <KoShapeCreateCommand.h>

+ Inheritance diagram for KoShapeCreateCommand:

Public Member Functions

 KoShapeCreateCommand (KoShapeControllerBase *controller, const QList< KoShape * > shape, KoShapeContainer *parentShape=0, KUndo2Command *parent=0)
 
 KoShapeCreateCommand (KoShapeControllerBase *controller, KoShape *shape, KoShapeContainer *parentShape=0, KUndo2Command *parent=0)
 
 Private (KoShapeControllerBase *_document, const QList< KoShape * > &_shapes, KoShapeContainer *_parentShape)
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoShapeCreateCommand () override
 
- 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

KoShapeContainerexplicitParentShape
 
bool firstRedo = true
 
QList< KoShape * > shapes
 
KoShapeControllerBaseshapesDocument
 
KisSurrogateUndoStore undoStore
 

Protected Member Functions

 KoShapeCreateCommand (KoShapeControllerBase *controller, const QList< KoShape * > shapes, KoShapeContainer *parentShape, KUndo2Command *parent, const KUndo2MagicString &undoString)
 

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 creating shapes.

Definition at line 25 of file KoShapeCreateCommand.cpp.

Constructor & Destructor Documentation

◆ KoShapeCreateCommand() [1/3]

KoShapeCreateCommand::KoShapeCreateCommand ( KoShapeControllerBase * controller,
KoShape * shape,
KoShapeContainer * parentShape = 0,
KUndo2Command * parent = 0 )

Command used on creation of new shapes

Parameters
controllerthe controller used to add/remove the shape from
shapethe shape that's just been created.
parentthe parent command used for macro commands

Definition at line 44 of file KoShapeCreateCommand.cpp.

45 : KoShapeCreateCommand(controller, QList<KoShape *>() << shape, parentShape, parent)
46{
47}
KoShapeCreateCommand(KoShapeControllerBase *controller, KoShape *shape, KoShapeContainer *parentShape=0, KUndo2Command *parent=0)

◆ KoShapeCreateCommand() [2/3]

KoShapeCreateCommand::KoShapeCreateCommand ( KoShapeControllerBase * controller,
const QList< KoShape * > shape,
KoShapeContainer * parentShape = 0,
KUndo2Command * parent = 0 )

Command used on creation of new shapes

Parameters
controllerthe controller used to add/remove the shape from
shapesthe shapes that have just been created.
parentthe parent command used for macro commands

Definition at line 49 of file KoShapeCreateCommand.cpp.

50 : KoShapeCreateCommand(controller, shapes, parentShape, parent, kundo2_i18np("Create shape", "Create %1 shapes", shapes.size()))
51{
52}
KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1)

◆ ~KoShapeCreateCommand()

KoShapeCreateCommand::~KoShapeCreateCommand ( )
override

Definition at line 60 of file KoShapeCreateCommand.cpp.

61{
62 delete d;
63}

References d.

◆ KoShapeCreateCommand() [3/3]

KoShapeCreateCommand::KoShapeCreateCommand ( KoShapeControllerBase * controller,
const QList< KoShape * > shapes,
KoShapeContainer * parentShape,
KUndo2Command * parent,
const KUndo2MagicString & undoString )
protected

Definition at line 54 of file KoShapeCreateCommand.cpp.

55 : KUndo2Command(undoString, parent)
56 , d(new Private(controller, shapes, parentShape))
57{
58}
KUndo2Command(KUndo2Command *parent=0)

Member Function Documentation

◆ Private()

KoShapeCreateCommand::Private ( KoShapeControllerBase * _document,
const QList< KoShape * > & _shapes,
KoShapeContainer * _parentShape )
inline

Definition at line 28 of file KoShapeCreateCommand.cpp.

29 : shapesDocument(_document),
30 shapes(_shapes),
31 explicitParentShape(_parentShape)
32 {
33 }
KoShapeContainer * explicitParentShape
KoShapeControllerBase * shapesDocument

◆ redo()

void KoShapeCreateCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Definition at line 65 of file KoShapeCreateCommand.cpp.

66{
68 KIS_SAFE_ASSERT_RECOVER_RETURN(d->explicitParentShape);
69
70 if (d->firstRedo) {
71 Q_FOREACH(KoShape *shape, d->shapes) {
72
73 d->undoStore.addCommand(new KoAddShapeCommand(shape, d->explicitParentShape));
74
75 KoShapeContainer *shapeParent = shape->parent();
77 dynamic_cast<KoShapeLayer*>(shape));
78
79 if (shapeParent) {
80 d->undoStore.addCommand(KoShapeReorderCommand::mergeInShape(shapeParent->shapes(), shape));
81 }
82 }
83 d->firstRedo = false;
84 } else {
85 d->undoStore.redoAll();
86 }
87}
virtual void redo()
QList< KoShape * > shapes() const
static KoShapeReorderCommand * mergeInShape(QList< KoShape * > shapes, KoShape *newShape, KUndo2Command *parent=0)
mergeInShape adjust zIndex of all the shapes and newShape to avoid collisions between shapes and newS...
KoShapeContainer * parent() const
Definition KoShape.cpp:1039
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References d, KIS_SAFE_ASSERT_RECOVER_NOOP, KIS_SAFE_ASSERT_RECOVER_RETURN, KoShapeReorderCommand::mergeInShape(), KoShape::parent(), KUndo2Command::redo(), and KoShapeContainer::shapes().

◆ undo()

void KoShapeCreateCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Definition at line 89 of file KoShapeCreateCommand.cpp.

90{
91 d->undoStore.undoAll();
93}
virtual void undo()

References d, and KUndo2Command::undo().

Member Data Documentation

◆ d

Private* const KoShapeCreateCommand::d
private

Definition at line 54 of file KoShapeCreateCommand.h.

◆ explicitParentShape

KoShapeContainer* KoShapeCreateCommand::explicitParentShape

Definition at line 37 of file KoShapeCreateCommand.cpp.

◆ firstRedo

bool KoShapeCreateCommand::firstRedo = true

Definition at line 40 of file KoShapeCreateCommand.cpp.

◆ shapes

QList<KoShape*> KoShapeCreateCommand::shapes

Definition at line 36 of file KoShapeCreateCommand.cpp.

◆ shapesDocument

KoShapeControllerBase* KoShapeCreateCommand::shapesDocument

Definition at line 35 of file KoShapeCreateCommand.cpp.

◆ undoStore

KisSurrogateUndoStore KoShapeCreateCommand::undoStore

Definition at line 39 of file KoShapeCreateCommand.cpp.


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