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

The undo / redo command for setting the shape stroke. More...

#include <KoShapeStrokeCommand.h>

+ Inheritance diagram for KoShapeStrokeCommand:

Public Member Functions

void addNewStroke (KoShapeStrokeModelSP newStroke)
 
void addOldStroke (KoShapeStrokeModelSP oldStroke)
 
int id () const override
 
 KoShapeStrokeCommand (const QList< KoShape * > &shapes, const QList< KoShapeStrokeModelSP > &strokes, KUndo2Command *parent=0)
 
 KoShapeStrokeCommand (const QList< KoShape * > &shapes, KoShapeStrokeModelSP stroke, KUndo2Command *parent=0)
 
 KoShapeStrokeCommand (KoShape *shape, KoShapeStrokeModelSP stroke, KUndo2Command *parent=0)
 
bool mergeWith (const KUndo2Command *command) override
 
 Private ()
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoShapeStrokeCommand () 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 bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
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

QList< KoShapeStrokeModelSPnewStrokes
 the new strokes to set
 
QList< KoShapeStrokeModelSPoldStrokes
 the old strokes, one for each shape
 
QList< KoShape * > shapes
 the shapes to set stroke for
 

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 setting the shape stroke.

Definition at line 19 of file KoShapeStrokeCommand.cpp.

Constructor & Destructor Documentation

◆ ~Private()

KoShapeStrokeCommand::~Private ( )
inline

Definition at line 23 of file KoShapeStrokeCommand.cpp.

24 {
25 }

◆ KoShapeStrokeCommand() [1/3]

KoShapeStrokeCommand::KoShapeStrokeCommand ( const QList< KoShape * > & shapes,
KoShapeStrokeModelSP stroke,
KUndo2Command * parent = 0 )

Command to set a new shape stroke.

Parameters
shapesa set of all the shapes that should get the new stroke.
strokethe new stroke, the same for all given shapes
parentthe parent command used for macro commands

Definition at line 42 of file KoShapeStrokeCommand.cpp.

43 : KUndo2Command(parent)
44 , d(new Private())
45{
46 d->shapes = shapes;
47
48 // save old strokes
49 Q_FOREACH (KoShape *shape, d->shapes) {
50 d->addOldStroke(shape->stroke());
51 d->addNewStroke(stroke);
52 }
53
54 setText(kundo2_i18n("Set stroke"));
55}
void setText(const KUndo2MagicString &text)
KUndo2Command(KUndo2Command *parent=0)
QList< KoShape * > shapes
the shapes to set stroke for
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:1067
KUndo2MagicString kundo2_i18n(const char *text)

References d, kundo2_i18n(), KUndo2Command::setText(), shapes, and KoShape::stroke().

◆ KoShapeStrokeCommand() [2/3]

KoShapeStrokeCommand::KoShapeStrokeCommand ( const QList< KoShape * > & shapes,
const QList< KoShapeStrokeModelSP > & strokes,
KUndo2Command * parent = 0 )

Command to set new shape strokes.

Parameters
shapesa set of all the shapes that should get a new stroke.
strokesthe new strokes, one for each shape
parentthe parent command used for macro commands

Definition at line 57 of file KoShapeStrokeCommand.cpp.

60 : KUndo2Command(parent)
61 , d(new Private())
62{
63 Q_ASSERT(shapes.count() == strokes.count());
64
65 d->shapes = shapes;
66
67 // save old strokes
68 Q_FOREACH (KoShape *shape, shapes)
69 d->addOldStroke(shape->stroke());
70 foreach (KoShapeStrokeModelSP stroke, strokes)
71 d->addNewStroke(stroke);
72
73 setText(kundo2_i18n("Set stroke"));
74}

References d, kundo2_i18n(), KUndo2Command::setText(), shapes, and KoShape::stroke().

◆ KoShapeStrokeCommand() [3/3]

KoShapeStrokeCommand::KoShapeStrokeCommand ( KoShape * shape,
KoShapeStrokeModelSP stroke,
KUndo2Command * parent = 0 )

Command to set a new shape stroke.

Parameters
shapea single shape that should get the new stroke.
strokethe new stroke
parentthe parent command used for macro commands

Definition at line 76 of file KoShapeStrokeCommand.cpp.

77 : KUndo2Command(parent)
78 , d(new Private())
79{
80 d->shapes.append(shape);
81 d->addNewStroke(stroke);
82 d->addOldStroke(shape->stroke());
83
84 setText(kundo2_i18n("Set stroke"));
85}

References d, kundo2_i18n(), KUndo2Command::setText(), and KoShape::stroke().

◆ ~KoShapeStrokeCommand()

KoShapeStrokeCommand::~KoShapeStrokeCommand ( )
override

Definition at line 87 of file KoShapeStrokeCommand.cpp.

88{
89 delete d;
90}

References d.

Member Function Documentation

◆ addNewStroke()

void KoShapeStrokeCommand::addNewStroke ( KoShapeStrokeModelSP newStroke)
inline

Definition at line 32 of file KoShapeStrokeCommand.cpp.

33 {
34 newStrokes.append(newStroke);
35 }
QList< KoShapeStrokeModelSP > newStrokes
the new strokes to set

◆ addOldStroke()

void KoShapeStrokeCommand::addOldStroke ( KoShapeStrokeModelSP oldStroke)
inline

Definition at line 27 of file KoShapeStrokeCommand.cpp.

28 {
29 oldStrokes.append(oldStroke);
30 }
QList< KoShapeStrokeModelSP > oldStrokes
the old strokes, one for each shape

◆ id()

int KoShapeStrokeCommand::id ( ) const
overridevirtual

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.

See also
mergeWith(), KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 116 of file KoShapeStrokeCommand.cpp.

References KisCommandUtils::ChangeShapeStrokeId.

◆ mergeWith()

bool KoShapeStrokeCommand::mergeWith ( const KUndo2Command * command)
overridevirtual

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.

See also
id() KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 121 of file KoShapeStrokeCommand.cpp.

122{
123 const KoShapeStrokeCommand *other = dynamic_cast<const KoShapeStrokeCommand*>(command);
124
125 if (!other ||
126 other->d->shapes != d->shapes) {
127
128 return false;
129 }
130
131 d->newStrokes = other->d->newStrokes;
132 return true;
133}
The undo / redo command for setting the shape stroke.

References d.

◆ Private()

KoShapeStrokeCommand::Private ( )
inline

Definition at line 22 of file KoShapeStrokeCommand.cpp.

22{}

◆ redo()

void KoShapeStrokeCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Definition at line 92 of file KoShapeStrokeCommand.cpp.

93{
95 QList<KoShapeStrokeModelSP>::iterator strokeIt = d->newStrokes.begin();
96 Q_FOREACH (KoShape *shape, d->shapes) {
97 const QRectF oldDirtyRect = shape->boundingRect();
98 shape->setStroke(*strokeIt);
99 shape->updateAbsolute(oldDirtyRect | shape->boundingRect());
100 ++strokeIt;
101 }
102}
virtual void redo()
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:335
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:1081
virtual void updateAbsolute(const QRectF &rect) const
Definition KoShape.cpp:616

References KoShape::boundingRect(), d, KUndo2Command::redo(), KoShape::setStroke(), and KoShape::updateAbsolute().

◆ undo()

void KoShapeStrokeCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Definition at line 104 of file KoShapeStrokeCommand.cpp.

105{
107 QList<KoShapeStrokeModelSP>::iterator strokeIt = d->oldStrokes.begin();
108 Q_FOREACH (KoShape *shape, d->shapes) {
109 const QRectF oldDirtyRect = shape->boundingRect();
110 shape->setStroke(*strokeIt);
111 shape->updateAbsolute(oldDirtyRect | shape->boundingRect());
112 ++strokeIt;
113 }
114}
virtual void undo()

References KoShape::boundingRect(), d, KoShape::setStroke(), KUndo2Command::undo(), and KoShape::updateAbsolute().

Member Data Documentation

◆ d

Private* const KoShapeStrokeCommand::d
private

Definition at line 61 of file KoShapeStrokeCommand.h.

◆ newStrokes

QList<KoShapeStrokeModelSP> KoShapeStrokeCommand::newStrokes

the new strokes to set

Definition at line 39 of file KoShapeStrokeCommand.cpp.

◆ oldStrokes

QList<KoShapeStrokeModelSP> KoShapeStrokeCommand::oldStrokes

the old strokes, one for each shape

Definition at line 38 of file KoShapeStrokeCommand.cpp.

◆ shapes

QList<KoShape*> KoShapeStrokeCommand::shapes

the shapes to set stroke for

Definition at line 37 of file KoShapeStrokeCommand.cpp.


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