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

#include <KoShapeBulkActionLock.h>

+ Inheritance diagram for KoShapeBulkActionLockAdapter:

Public Types

using Update = std::pair<KoShape*, QRectF>
 
using UpdatesList = std::vector<Update>
 

Public Member Functions

 KoShapeBulkActionLockAdapter (const QList< KoShape * > &shapes)
 
void lock ()
 
UpdatesList takeFinalUpdatesList ()
 
void unlock ()
 

Private Member Functions

void addBulkInterfaceDependees (const QList< KoShape * > dependees)
 
void tryAddBulkInterfaceShape (KoShape *shape)
 

Private Attributes

QList< KoShapeBulkActionInterface * > m_bulkInterfaceShapes
 
std::unordered_map< KoShape *, QRectF > m_finalUpdates
 
QList< KoShape * > m_normalUpdateShapes
 

Detailed Description

Definition at line 19 of file KoShapeBulkActionLock.h.

Member Typedef Documentation

◆ Update

using KoShapeBulkActionLockAdapter::Update = std::pair<KoShape*, QRectF>

Definition at line 21 of file KoShapeBulkActionLock.h.

◆ UpdatesList

Definition at line 22 of file KoShapeBulkActionLock.h.

Constructor & Destructor Documentation

◆ KoShapeBulkActionLockAdapter()

KoShapeBulkActionLockAdapter::KoShapeBulkActionLockAdapter ( const QList< KoShape * > & shapes)

Definition at line 14 of file KoShapeBulkActionLock.cpp.

15{
16 Q_FOREACH(KoShape *shape, shapes) {
17 // explicitly called shaped will be "updated" in both
18 // ways, using normal updates and dependent bulk updates
19 m_normalUpdateShapes.append(shape);
22 }
23}
void addBulkInterfaceDependees(const QList< KoShape * > dependees)
void tryAddBulkInterfaceShape(KoShape *shape)
QList< KoShape * > dependees() const
Returns list of shapes depending on this shape.
Definition KoShape.cpp:1054

References addBulkInterfaceDependees(), KoShape::dependees(), m_normalUpdateShapes, and tryAddBulkInterfaceShape().

Member Function Documentation

◆ addBulkInterfaceDependees()

void KoShapeBulkActionLockAdapter::addBulkInterfaceDependees ( const QList< KoShape * > dependees)
private

Definition at line 38 of file KoShapeBulkActionLock.cpp.

39{
40 Q_FOREACH(KoShape *shape, dependees) {
43 }
44}

References addBulkInterfaceDependees(), KoShape::dependees(), and tryAddBulkInterfaceShape().

◆ lock()

void KoShapeBulkActionLockAdapter::lock ( )

Definition at line 46 of file KoShapeBulkActionLock.cpp.

47{
48 m_finalUpdates.clear();
49
50 Q_FOREACH(KoShape *shape, m_normalUpdateShapes) {
51 m_finalUpdates[shape] |= shape->boundingRect();
52 }
53
55 iface->startBulkAction();
56 }
57
58}
QList< KoShapeBulkActionInterface * > m_bulkInterfaceShapes
std::unordered_map< KoShape *, QRectF > m_finalUpdates
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:299
Interface for bulk actions on shapes.
virtual void startBulkAction()=0

References KoShape::boundingRect(), m_bulkInterfaceShapes, m_finalUpdates, m_normalUpdateShapes, and KoShapeBulkActionInterface::startBulkAction().

◆ takeFinalUpdatesList()

KoShapeBulkActionLockAdapter::UpdatesList KoShapeBulkActionLockAdapter::takeFinalUpdatesList ( )

Definition at line 76 of file KoShapeBulkActionLock.cpp.

77{
78 UpdatesList result;
79 result.reserve(m_finalUpdates.size());
80
81 for (auto it = m_finalUpdates.begin(); it != m_finalUpdates.end(); ++it) {
82 result.emplace_back(it->first, it->second);
83 }
84
85 return result;
86}

References m_finalUpdates.

◆ tryAddBulkInterfaceShape()

void KoShapeBulkActionLockAdapter::tryAddBulkInterfaceShape ( KoShape * shape)
private

Definition at line 25 of file KoShapeBulkActionLock.cpp.

26{
27 KoShapeBulkActionInterface *iface = dynamic_cast<KoShapeBulkActionInterface *>(shape);
28 if (iface) {
29 // postpone update till the end, if the shape is present
30 // multiple times
31 if (m_bulkInterfaceShapes.contains(iface)) {
32 m_bulkInterfaceShapes.removeOne(iface);
33 }
34 m_bulkInterfaceShapes.append(iface);
35 }
36};

References m_bulkInterfaceShapes.

◆ unlock()

void KoShapeBulkActionLockAdapter::unlock ( )

Definition at line 60 of file KoShapeBulkActionLock.cpp.

61{
63 const QRectF update = iface->endBulkAction();
64
65 KoShape *shape = dynamic_cast<KoShape*>(iface);
66 KIS_SAFE_ASSERT_RECOVER(shape) { continue; }
67 m_finalUpdates[shape] |= update;
68 }
69
70 Q_FOREACH(KoShape *shape, m_normalUpdateShapes) {
71 m_finalUpdates[shape] |= shape->boundingRect();
72 }
73}
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
bool update(QSpinBox *spinBox)
virtual QRectF endBulkAction()=0

References KoShape::boundingRect(), KoShapeBulkActionInterface::endBulkAction(), KIS_SAFE_ASSERT_RECOVER, m_bulkInterfaceShapes, m_finalUpdates, and m_normalUpdateShapes.

Member Data Documentation

◆ m_bulkInterfaceShapes

QList<KoShapeBulkActionInterface*> KoShapeBulkActionLockAdapter::m_bulkInterfaceShapes
private

Definition at line 35 of file KoShapeBulkActionLock.h.

◆ m_finalUpdates

std::unordered_map<KoShape*, QRectF> KoShapeBulkActionLockAdapter::m_finalUpdates
private

Definition at line 37 of file KoShapeBulkActionLock.h.

◆ m_normalUpdateShapes

QList<KoShape*> KoShapeBulkActionLockAdapter::m_normalUpdateShapes
private

Definition at line 36 of file KoShapeBulkActionLock.h.


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