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

#include <KoShapePaintOrderCommand.h>

+ Inheritance diagram for KoShapePaintOrderCommand:

Public Member Functions

int id () const override
 
 KoShapePaintOrderCommand (const QList< KoShape * > &shapes, KoShape::PaintOrder first, KoShape::PaintOrder second, KUndo2Command *parent=nullptr)
 
bool mergeWith (const KUndo2Command *command) override
 
 Private ()
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoShapePaintOrderCommand () 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

KoShape::PaintOrder first
 
QList< KoShape::PaintOrderoldFirst
 
QList< KoShape::PaintOrderoldSecond
 
QList< bool > paintOrderInherited
 
KoShape::PaintOrder second
 
QList< KoShape * > shapes
 

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

Definition at line 12 of file KoShapePaintOrderCommand.cpp.

Constructor & Destructor Documentation

◆ ~Private()

KoShapePaintOrderCommand::~Private ( )
inline

Definition at line 17 of file KoShapePaintOrderCommand.cpp.

17 {
18 }

◆ KoShapePaintOrderCommand()

KoShapePaintOrderCommand::KoShapePaintOrderCommand ( const QList< KoShape * > & shapes,
KoShape::PaintOrder first,
KoShape::PaintOrder second,
KUndo2Command * parent = nullptr )

Definition at line 28 of file KoShapePaintOrderCommand.cpp.

32 : KUndo2Command(parent)
33 , d(new Private())
34{
35 d->shapes = shapes;
36 Q_FOREACH (KoShape *shape, d->shapes) {
37 d->oldFirst.append(shape->paintOrder().at(0));
38 d->oldSecond.append(shape->paintOrder().at(1));
39 d->paintOrderInherited.append(shape->inheritPaintOrder());
40 }
41 d->first = first;
42 d->second = second;
43
44 setText(kundo2_i18n("Set paint order"));
45}
void setText(const KUndo2MagicString &text)
KUndo2Command(KUndo2Command *parent=0)
virtual QVector< PaintOrder > paintOrder() const
paintOrder
Definition KoShape.cpp:773
bool inheritPaintOrder() const
inheritPaintOrder
Definition KoShape.cpp:795
KUndo2MagicString kundo2_i18n(const char *text)

References d, first, KoShape::inheritPaintOrder(), kundo2_i18n(), KoShape::paintOrder(), second, KUndo2Command::setText(), and shapes.

◆ ~KoShapePaintOrderCommand()

KoShapePaintOrderCommand::~KoShapePaintOrderCommand ( )
override

Definition at line 47 of file KoShapePaintOrderCommand.cpp.

48{
49 delete d;
50}

References d.

Member Function Documentation

◆ id()

int KoShapePaintOrderCommand::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 78 of file KoShapePaintOrderCommand.cpp.

References KisCommandUtils::ChangePaintOrderCommand.

◆ mergeWith()

bool KoShapePaintOrderCommand::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 83 of file KoShapePaintOrderCommand.cpp.

84{
85 const KoShapePaintOrderCommand *other = dynamic_cast<const KoShapePaintOrderCommand*>(command);
86
87 if (!other || other->d->shapes != d->shapes) {
88 return false;
89 }
90
91 d->first = other->d->first;
92 d->second = other->d->second;
93 return true;
94}

References d.

◆ Private()

KoShapePaintOrderCommand::Private ( )
inline

Definition at line 15 of file KoShapePaintOrderCommand.cpp.

15 {
16 }

◆ redo()

void KoShapePaintOrderCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Definition at line 53 of file KoShapePaintOrderCommand.cpp.

54{
56 Q_FOREACH (KoShape *shape, d->shapes) {
57 shape->setPaintOrder(d->first, d->second);
58 shape->update();
59 }
60}
virtual void redo()
virtual void setPaintOrder(PaintOrder first, PaintOrder second)
setPaintOrder set the paint order. As there's only three entries in any given paintorder,...
Definition KoShape.cpp:749
virtual void update() const
Definition KoShape.cpp:605

References d, KUndo2Command::redo(), KoShape::setPaintOrder(), and KoShape::update().

◆ undo()

void KoShapePaintOrderCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Definition at line 62 of file KoShapePaintOrderCommand.cpp.

63{
65 QList<KoShape::PaintOrder>::iterator firstIt = d->oldFirst.begin();
66 QList<KoShape::PaintOrder>::iterator secondIt = d->oldSecond.begin();
67 QList<bool>::iterator inheritIt = d->paintOrderInherited.begin();
68 Q_FOREACH (KoShape *shape, d->shapes) {
69 shape->setPaintOrder(*firstIt, *secondIt);
70 shape->setInheritPaintOrder(*inheritIt);
71 shape->update();
72 ++firstIt;
73 ++secondIt;
74 ++inheritIt;
75 }
76}
virtual void undo()
void setInheritPaintOrder(bool value)
setInheritPaintOrder set inherit paint order.
Definition KoShape.cpp:790

References d, KoShape::setInheritPaintOrder(), KoShape::setPaintOrder(), KUndo2Command::undo(), and KoShape::update().

Member Data Documentation

◆ d

Private* const KoShapePaintOrderCommand::d
private

Definition at line 32 of file KoShapePaintOrderCommand.h.

◆ first

KoShape::PaintOrder KoShapePaintOrderCommand::first

Definition at line 24 of file KoShapePaintOrderCommand.cpp.

◆ oldFirst

QList<KoShape::PaintOrder> KoShapePaintOrderCommand::oldFirst

Definition at line 21 of file KoShapePaintOrderCommand.cpp.

◆ oldSecond

QList<KoShape::PaintOrder> KoShapePaintOrderCommand::oldSecond

Definition at line 22 of file KoShapePaintOrderCommand.cpp.

◆ paintOrderInherited

QList<bool> KoShapePaintOrderCommand::paintOrderInherited

Definition at line 23 of file KoShapePaintOrderCommand.cpp.

◆ second

KoShape::PaintOrder KoShapePaintOrderCommand::second

Definition at line 25 of file KoShapePaintOrderCommand.cpp.

◆ shapes

QList<KoShape*> KoShapePaintOrderCommand::shapes

Definition at line 20 of file KoShapePaintOrderCommand.cpp.


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