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

#include <KoShapeLoadingContext.h>

+ Inheritance diagram for KoShapeLoadingContext:

Classes

struct  AdditionalAttributeData
 

Public Member Functions

void addLayer (KoShapeLayer *layer, const QString &layerName)
 Adds a new layer to be referenced by the given name later.
 
void addShapeId (KoShape *shape, const QString &id)
 register the id for a specific shape
 
void addShapeSubItemId (KoShape *shape, const QVariant &subItem, const QString &id)
 register the id for a specific shape sub item
 
void addSharedData (const QString &id, KoSharedLoadingData *data)
 
void clearLayers ()
 
KoDocumentResourceManagerdocumentResourceManager () const
 
 KoShapeLoadingContext (KoStore *store, KoDocumentResourceManager *documentResources)
 
KoShapeLayerlayer (const QString &layerName)
 Returns layer referenced by given name.
 
QString mimeTypeForPath (const QString &href, bool b=true)
 
 Private (KoStore *store, KoDocumentResourceManager *resourceManager)
 
KoSectionModel * sectionModel ()
 returns the current section model
 
void setSectionModel (KoSectionModel *sectionModel)
 sets the section model for the loading context
 
void setZIndex (int index)
 Set z-index.
 
KoShapeshapeById (const QString &id)
 return the shape formerly registered using addShapeId()
 
void shapeLoaded (KoShape *shape)
 
QPair< KoShape *, QVariant > shapeSubItemById (const QString &id)
 return the shape and subitem formerly registered using addShapeSubItemId()
 
KoSharedLoadingDatasharedData (const QString &id) const
 
KoStorestore () const
 
void updateShape (const QString &id, KoLoadingShapeUpdater *shapeUpdater)
 
int zIndex ()
 Get current z-index.
 
 ~KoShapeLoadingContext ()
 destructor
 
 ~Private ()
 

Static Public Member Functions

static void addAdditionalAttributeData (const AdditionalAttributeData &attributeData)
 Add an additional attribute that should be loaded during shape loading.
 
static QSet< AdditionalAttributeDataadditionalAttributeData ()
 Get the additional attribute data for loading of a shape.
 

Public Attributes

KoDocumentResourceManagerdocumentResources
 
QMap< QString, KoShape * > drawIds
 
QMap< QString, KoShapeLayer * > layers
 
KoSectionModel * sectionModel
 
QMap< QString, KoSharedLoadingData * > sharedData
 
KoStorestore
 
QMap< QString, QPair< KoShape *, QVariant > > subIds
 
QMultiMap< QString, KoLoadingShapeUpdater * > updaterById
 
QMultiMap< KoShape *, KoLoadingShapeUpdater * > updaterByShape
 
int zIndex
 

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

Context passed to shapes during loading. This class holds various variables as well as a context full of variables which all together form the context of a loading operation.

Definition at line 29 of file KoShapeLoadingContext.cpp.

Constructor & Destructor Documentation

◆ ~Private()

KoShapeLoadingContext::~Private ( )
inline

Definition at line 40 of file KoShapeLoadingContext.cpp.

40 {
41 Q_FOREACH (KoSharedLoadingData * data, sharedData) {
42 delete data;
43 }
44 }
QMap< QString, KoSharedLoadingData * > sharedData

◆ KoShapeLoadingContext()

KoShapeLoadingContext::KoShapeLoadingContext ( KoStore * store,
KoDocumentResourceManager * documentResources )

constructor

Parameters
contextthe context created for generic ODF loading.
documentResourcesthe data of the shape controller.

Definition at line 58 of file KoShapeLoadingContext.cpp.

◆ ~KoShapeLoadingContext()

KoShapeLoadingContext::~KoShapeLoadingContext ( )

destructor

Definition at line 63 of file KoShapeLoadingContext.cpp.

64{
65 delete d;
66}

References d.

Member Function Documentation

◆ addAdditionalAttributeData()

void KoShapeLoadingContext::addAdditionalAttributeData ( const AdditionalAttributeData & attributeData)
static

Add an additional attribute that should be loaded during shape loading.

An application can use that to set the data for additional attributes that should be loaded during shape loading. If attribute is set it will not change if set again. The tag is used to differentiate the attributes

Parameters
attributeDataThe data describing the additional attribute data

Definition at line 170 of file KoShapeLoadingContext.cpp.

171{
172 s_additionalAttributes.insert(attributeData);
173}
static QSet< KoShapeLoadingContext::AdditionalAttributeData > s_additionalAttributes

References s_additionalAttributes.

◆ additionalAttributeData()

QSet< KoShapeLoadingContext::AdditionalAttributeData > KoShapeLoadingContext::additionalAttributeData ( )
static

Get the additional attribute data for loading of a shape.

This is used by KoShape::loadOdfAttributes to load all additional attributes defined in the returned set.

Definition at line 175 of file KoShapeLoadingContext.cpp.

176{
178}

References s_additionalAttributes.

◆ addLayer()

void KoShapeLoadingContext::addLayer ( KoShapeLayer * layer,
const QString & layerName )

Adds a new layer to be referenced by the given name later.

Definition at line 85 of file KoShapeLoadingContext.cpp.

86{
87 d->layers[ layerName ] = layer;
88}
KoShapeLayer * layer(const QString &layerName)
Returns layer referenced by given name.

References d, and layer().

◆ addShapeId()

void KoShapeLoadingContext::addShapeId ( KoShape * shape,
const QString & id )

register the id for a specific shape

Definition at line 95 of file KoShapeLoadingContext.cpp.

96{
97 d->drawIds.insert(id, shape);
98 auto it(d->updaterById.find(id));
99 while (it != d->updaterById.end() && it.key() == id) {
100 d->updaterByShape.insert(shape, it.value());
101 it = d->updaterById.erase(it);
102 }
103}

References d.

◆ addShapeSubItemId()

void KoShapeLoadingContext::addShapeSubItemId ( KoShape * shape,
const QVariant & subItem,
const QString & id )

register the id for a specific shape sub item

Definition at line 110 of file KoShapeLoadingContext.cpp.

111{
112 d->subIds.insert(id, QPair<KoShape *, QVariant>(shape, subItem));
113}

References d.

◆ addSharedData()

void KoShapeLoadingContext::addSharedData ( const QString & id,
KoSharedLoadingData * data )

Add shared data

This can be use to pass data between shapes on loading. E.g. The decoded text styles of the TextShape. With that the styles only have to be read once and can be used in all shapes that also need them.

The ownership of the added data is passed to the context. The KoShapeLoadingContext will delete the added data when it is destroyed.

Data inserted for a specific id will not be overwritten by calling addSharedData with the same id again.

You get an assertion when the id is already existing.

See also
KoSharedLoadingData

Definition at line 148 of file KoShapeLoadingContext.cpp.

149{
150 auto it(d->sharedData.find(id));
151 // data will not be overwritten
152 if (it == d->sharedData.end()) {
153 d->sharedData.insert(id, data);
154 } else {
155 warnFlake << "The id" << id << "is already registered. Data not inserted";
156 Q_ASSERT(it == d->sharedData.end());
157 }
158}
#define warnFlake
Definition FlakeDebug.h:16

References d, and warnFlake.

◆ clearLayers()

void KoShapeLoadingContext::clearLayers ( )

remove all layers

This can be used for loading different layer sets per page.

Definition at line 90 of file KoShapeLoadingContext.cpp.

91{
92 d->layers.clear();
93}

References d.

◆ documentResourceManager()

KoDocumentResourceManager * KoShapeLoadingContext::documentResourceManager ( ) const

Definition at line 180 of file KoShapeLoadingContext.cpp.

181{
182 return d->documentResources;
183}

References d.

◆ layer()

KoShapeLayer * KoShapeLoadingContext::layer ( const QString & layerName)

Returns layer referenced by given name.

Definition at line 80 of file KoShapeLoadingContext.cpp.

81{
82 return d->layers.value(layerName, 0);
83}

References d.

◆ mimeTypeForPath()

QString KoShapeLoadingContext::mimeTypeForPath ( const QString & href,
bool b = true )

Definition at line 73 of file KoShapeLoadingContext.cpp.

74{
75 Q_UNUSED(href);
76 Q_UNUSED(b);
77 return "image/svg+xml";
78}

◆ Private()

KoShapeLoadingContext::Private ( KoStore * store,
KoDocumentResourceManager * resourceManager )
inline

Definition at line 32 of file KoShapeLoadingContext.cpp.

33 : store(store)
34 , zIndex(0)
35 , documentResources(resourceManager)
36 , sectionModel(0)
37 {
38 }

◆ sectionModel()

KoSectionModel * KoShapeLoadingContext::sectionModel ( )

returns the current section model

Returns
the pointer to KoSectionModel

◆ setSectionModel()

void KoShapeLoadingContext::setSectionModel ( KoSectionModel * sectionModel)

sets the section model for the loading context

Parameters
sectionModelthe section model to set

Definition at line 190 of file KoShapeLoadingContext.cpp.

191{
192 d->sectionModel = sectionModel;
193}

References d, and sectionModel.

◆ setZIndex()

void KoShapeLoadingContext::setZIndex ( int index)

Set z-index.

Definition at line 143 of file KoShapeLoadingContext.cpp.

144{
145 d->zIndex = index;
146}

References d.

◆ shapeById()

KoShape * KoShapeLoadingContext::shapeById ( const QString & id)

return the shape formerly registered using addShapeId()

Definition at line 105 of file KoShapeLoadingContext.cpp.

106{
107 return d->drawIds.value(id, 0);
108}

References d.

◆ shapeLoaded()

void KoShapeLoadingContext::shapeLoaded ( KoShape * shape)

this checks if there is an updater for this shape if yes it calls it this needs to be done via the shape id and

Definition at line 127 of file KoShapeLoadingContext.cpp.

128{
129 auto it(d->updaterByShape.find(shape));
130 while (it != d->updaterByShape.end() && it.key() == shape) {
131 it.value()->update(shape);
132 delete it.value();
133 it = d->updaterByShape.erase(it);
134 }
135}

References d.

◆ shapeSubItemById()

QPair< KoShape *, QVariant > KoShapeLoadingContext::shapeSubItemById ( const QString & id)

return the shape and subitem formerly registered using addShapeSubItemId()

Definition at line 115 of file KoShapeLoadingContext.cpp.

116{
117 return d->subIds.value(id);
118}

References d.

◆ sharedData()

KoSharedLoadingData * KoShapeLoadingContext::sharedData ( const QString & id) const

Get the shared data.

See also
KoSharedLoadingData
Parameters
idThe id used to identify the shared data.
Returns
The shared data for the id or 0 if there is no shared data for the id.

◆ store()

KoStore * KoShapeLoadingContext::store ( ) const

◆ updateShape()

void KoShapeLoadingContext::updateShape ( const QString & id,
KoLoadingShapeUpdater * shapeUpdater )

call function on the shapeUpdater when the shape with the id shapeid is inserted After that destroy the updater.

Definition at line 122 of file KoShapeLoadingContext.cpp.

123{
124 d->updaterById.insert(id, shapeUpdater);
125}

References d.

◆ zIndex()

int KoShapeLoadingContext::zIndex ( )

Get current z-index.

Member Data Documentation

◆ d

Private* const KoShapeLoadingContext::d
private

Definition at line 180 of file KoShapeLoadingContext.h.

◆ documentResources

KoDocumentResourceManager* KoShapeLoadingContext::documentResources

Definition at line 55 of file KoShapeLoadingContext.cpp.

◆ drawIds

QMap<QString, KoShape*> KoShapeLoadingContext::drawIds

Definition at line 49 of file KoShapeLoadingContext.cpp.

◆ layers

QMap<QString, KoShapeLayer*> KoShapeLoadingContext::layers

Definition at line 48 of file KoShapeLoadingContext.cpp.

◆ sectionModel

KoSectionModel * KoShapeLoadingContext::sectionModel

Definition at line 56 of file KoShapeLoadingContext.cpp.

◆ sharedData

KoSharedLoadingData * KoShapeLoadingContext::sharedData

Definition at line 51 of file KoShapeLoadingContext.cpp.

◆ store

KoStore * KoShapeLoadingContext::store

Definition at line 46 of file KoShapeLoadingContext.cpp.

◆ subIds

QMap<QString, QPair<KoShape *, QVariant> > KoShapeLoadingContext::subIds

Definition at line 50 of file KoShapeLoadingContext.cpp.

◆ updaterById

QMultiMap<QString, KoLoadingShapeUpdater*> KoShapeLoadingContext::updaterById

Definition at line 53 of file KoShapeLoadingContext.cpp.

◆ updaterByShape

QMultiMap<KoShape *, KoLoadingShapeUpdater*> KoShapeLoadingContext::updaterByShape

Definition at line 54 of file KoShapeLoadingContext.cpp.

◆ zIndex

int KoShapeLoadingContext::zIndex

Definition at line 52 of file KoShapeLoadingContext.cpp.


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