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

The KoSvgTextReorderShapeInsideCommand class Within a text shape, the order of the shapes inside determines the order in which the shapes are evaluated for filling. This command allows changing that order. More...

#include <KoSvgTextReorderShapeInsideCommand.h>

+ Inheritance diagram for KoSvgTextReorderShapeInsideCommand:

Classes

struct  Private
 

Public Types

enum  MoveShapeType { MoveEarlier , MoveLater , BringToFront , SendToBack }
 

Public Member Functions

 KoSvgTextReorderShapeInsideCommand (KoSvgTextShape *textShape, QList< KoShape * > shape, MoveShapeType type, KUndo2Command *parent=nullptr)
 
void redo () override
 
void undo () override
 
 ~KoSvgTextReorderShapeInsideCommand ()
 
- 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

QScopedPointer< Privated
 

Detailed Description

The KoSvgTextReorderShapeInsideCommand class Within a text shape, the order of the shapes inside determines the order in which the shapes are evaluated for filling. This command allows changing that order.

Definition at line 21 of file KoSvgTextReorderShapeInsideCommand.h.

Member Enumeration Documentation

◆ MoveShapeType

Constructor & Destructor Documentation

◆ KoSvgTextReorderShapeInsideCommand()

KoSvgTextReorderShapeInsideCommand::KoSvgTextReorderShapeInsideCommand ( KoSvgTextShape * textShape,
QList< KoShape * > shape,
MoveShapeType type,
KUndo2Command * parent = nullptr )

Definition at line 34 of file KoSvgTextReorderShapeInsideCommand.cpp.

35 : KUndo2Command(parent)
36 , d(new Private(textShape, shapes, type))
37{
38
39}
KUndo2Command(KUndo2Command *parent=0)

◆ ~KoSvgTextReorderShapeInsideCommand()

KoSvgTextReorderShapeInsideCommand::~KoSvgTextReorderShapeInsideCommand ( )

Definition at line 41 of file KoSvgTextReorderShapeInsideCommand.cpp.

42{
43
44}

Member Function Documentation

◆ redo()

void KoSvgTextReorderShapeInsideCommand::redo ( )
overridevirtual

Applies a change to the document. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls redo() on all child commands.

See also
undo()

Reimplemented from KUndo2Command.

Definition at line 46 of file KoSvgTextReorderShapeInsideCommand.cpp.

47{
48 KoShapeBulkActionLock lock(d->textShape);
49
50 int newIndex = d->textShape->shapesInside().indexOf(d->shapes.first());
51 const int max = (d->textShape->shapesInside().size() -1);
52 if (d->type == MoveEarlier || d->type == BringToFront) {
53 if (d->type == MoveEarlier) {
54 newIndex = qMax(0, newIndex - 1);
55 } else {
56 newIndex = 0;
57 }
58 Q_FOREACH(KoShape *shape, d->shapes) {
59 const int index = d->textShape->shapesInside().indexOf(shape);
60 if (index == newIndex) continue;
61
62 d->textShape->moveShapeInsideToIndex(shape, newIndex);
63 newIndex += 1;
64 }
65 } else {
66 if (d->type == MoveLater) {
67 newIndex = qMin(max, newIndex + d->shapes.size());
68 } else {
69 newIndex = max;
70 }
71 auto end = std::make_reverse_iterator(d->shapes.begin());
72 auto begin = std::make_reverse_iterator(d->shapes.end());
73 for (auto it = begin; it != end; it++) {
74 KoShape *shape = *it;
75
76 const int index = d->textShape->shapesInside().indexOf(shape);
77 if (index == newIndex) continue;
78 if (newIndex < 0) continue;
79
80 d->textShape->moveShapeInsideToIndex(shape, newIndex);
81 newIndex -= 1;
82 }
83 }
84
86}
static void bulkShapesUpdate(const UpdatesList &updates)
constexpr std::enable_if< sizeof...(values)==0, size_t >::type max()

References BringToFront, KoShapeBulkActionLock::bulkShapesUpdate(), d, MoveEarlier, MoveLater, and KoShapeBulkActionLock::unlock().

◆ undo()

void KoSvgTextReorderShapeInsideCommand::undo ( )
overridevirtual

Reverts a change to the document. After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls undo() on all child commands in reverse order.

See also
redo()

Reimplemented from KUndo2Command.

Definition at line 88 of file KoSvgTextReorderShapeInsideCommand.cpp.

89{
90 KoShapeBulkActionLock lock(d->textShape);
91
92 if (d->type == MoveEarlier || d->type == BringToFront) {
93 for (int i = d->oldIndices.size() -1 ; i>= 0; i--) {
94 d->textShape->moveShapeInsideToIndex(d->shapes.at(i), d->oldIndices.at(i));
95 }
96 } else {
97 for (int i = 0; i< d->oldIndices.size(); i++) {
98 d->textShape->moveShapeInsideToIndex(d->shapes.at(i), d->oldIndices.at(i));
99 }
100 }
101 d->textShape->setMemento(d->memento);
102
104}

References BringToFront, KoShapeBulkActionLock::bulkShapesUpdate(), d, MoveEarlier, and KoShapeBulkActionLock::unlock().

Member Data Documentation

◆ d

QScopedPointer<Private> KoSvgTextReorderShapeInsideCommand::d
private

Definition at line 38 of file KoSvgTextReorderShapeInsideCommand.h.


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