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

The KoResourceManager class provides access to the currently active resources for a given canvas. It has nearly zilch to do with the system that provides resources like brushes or palettes to the application. More...

#include <KoResourceManager_p.h>

+ Inheritance diagram for KoResourceManager:

Signals

void resourceChangeAttempted (int key, const QVariant &value)
 
void resourceChanged (int key, const QVariant &value)
 

Public Member Functions

void addActiveCanvasResourceDependency (KoActiveCanvasResourceDependencySP dep)
 
void addDerivedResourceConverter (KoDerivedResourceConverterSP converter)
 
void addResourceUpdateMediator (KoResourceUpdateMediatorSP mediator)
 
bool boolResource (int key) const
 
void clearResource (int key)
 
bool hasAbstractResource (int key)
 
bool hasActiveCanvasResourceDependency (int sourceKey, int targetKey) const
 
bool hasDerivedResourceConverter (int key)
 
bool hasResource (int key) const
 
bool hasResourceUpdateMediator (int key)
 
int intResource (int key) const
 
KoColor koColorResource (int key) const
 
 KoResourceManager ()
 
KoShapekoShapeResource (int key) const
 
void removeAbstractResource (int key)
 
void removeActiveCanvasResourceDependency (int sourceKey, int targetKey)
 
void removeDerivedResourceConverter (int key)
 
void removeResourceUpdateMediator (int key)
 
QVariant resource (int key) const
 
void setAbstractResource (KoAbstractCanvasResourceInterfaceSP resource)
 
void setResource (int key, const KoColor &color)
 
void setResource (int key, const KoUnit &unit)
 
void setResource (int key, const QVariant &value)
 
void setResource (int key, KoShape *shape)
 
QSizeF sizeResource (int key) const
 
QString stringResource (int key) const
 
KoUnit unitResource (int key) const
 

Private Slots

void slotAbstractResourceChangedExternal (int key, const QVariant &value)
 
void slotResourceInternalsChanged (int key)
 

Private Member Functions

 KoResourceManager (const KoResourceManager &)
 
void notifyDependenciesAboutTargetChange (int targetKey, const QVariant &value)
 
void notifyDerivedResourcesChangeAttempted (int key, const QVariant &value)
 
void notifyDerivedResourcesChanged (int key, const QVariant &value)
 
void notifyResourceChangeAttempted (int key, const QVariant &value)
 
void notifyResourceChanged (int key, const QVariant &value)
 
KoResourceManageroperator= (const KoResourceManager &)
 

Private Attributes

QHash< int, KoAbstractCanvasResourceInterfaceSPm_abstractResources
 
QMultiHash< int, KoActiveCanvasResourceDependencySPm_dependencyFromSource
 
QMultiHash< int, KoActiveCanvasResourceDependencySPm_dependencyFromTarget
 
QMultiHash< int, KoDerivedResourceConverterSPm_derivedFromSource
 
QHash< int, KoDerivedResourceConverterSPm_derivedResources
 
QHash< int, QVariant > m_resources
 
QHash< int, KoResourceUpdateMediatorSPm_updateMediators
 

Detailed Description

The KoResourceManager class provides access to the currently active resources for a given canvas. It has nearly zilch to do with the system that provides resources like brushes or palettes to the application.

Definition at line 32 of file KoResourceManager_p.h.

Constructor & Destructor Documentation

◆ KoResourceManager() [1/2]

KoResourceManager::KoResourceManager ( )
inline

Definition at line 37 of file KoResourceManager_p.h.

37{}

◆ KoResourceManager() [2/2]

KoResourceManager::KoResourceManager ( const KoResourceManager & )
private

Member Function Documentation

◆ addActiveCanvasResourceDependency()

void KoResourceManager::addActiveCanvasResourceDependency ( KoActiveCanvasResourceDependencySP dep)

Add a dependency object that will link two active resources. When the target of the dependency changes, the source will get a notification about the change.

Definition at line 307 of file KoResourceManager_p.cpp.

308{
309 KIS_SAFE_ASSERT_RECOVER_RETURN(!hasActiveCanvasResourceDependency(dep->sourceKey(), dep->targetKey()));
310
311 m_dependencyFromSource.insert(dep->sourceKey(), dep);
312 m_dependencyFromTarget.insert(dep->targetKey(), dep);
313}
QMultiHash< int, KoActiveCanvasResourceDependencySP > m_dependencyFromSource
bool hasActiveCanvasResourceDependency(int sourceKey, int targetKey) const
QMultiHash< int, KoActiveCanvasResourceDependencySP > m_dependencyFromTarget
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References hasActiveCanvasResourceDependency(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_dependencyFromSource, and m_dependencyFromTarget.

◆ addDerivedResourceConverter()

void KoResourceManager::addDerivedResourceConverter ( KoDerivedResourceConverterSP converter)

Some of the resources may be "derived" from the others. For example opacity, composite op and erase mode properties are contained inside a paintop preset, so we need not create a separate resource for them. Instead we created a derived resource, that loads/saves values from/to another resource, but has its own "resource changed" signal (via a different key).

When a parent resource changes, the resource manager emits update signals for all its derived resources.

Definition at line 264 of file KoResourceManager_p.cpp.

265{
266 KIS_SAFE_ASSERT_RECOVER_NOOP(!m_derivedResources.contains(converter->key()));
267
268 if (hasAbstractResource(converter->key()))
269 qWarning() << "An abstract resource with the same resource ID exists!";
270
271 m_derivedResources.insert(converter->key(), converter);
272 m_derivedFromSource.insert(converter->sourceKey(), converter);
273}
QHash< int, KoDerivedResourceConverterSP > m_derivedResources
bool hasAbstractResource(int key)
QMultiHash< int, KoDerivedResourceConverterSP > m_derivedFromSource
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References hasAbstractResource(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_derivedFromSource, and m_derivedResources.

◆ addResourceUpdateMediator()

void KoResourceManager::addResourceUpdateMediator ( KoResourceUpdateMediatorSP mediator)

Some resources can "mutate", that is their value doesn't change (a pointer), whereas the contents changes. But we should still notify all the derived resources subscribers that the resource has changed. For that purpose we use a special mediator class that connects the resource (which is not a QObject at all) and the resource manager controls that connection.

Definition at line 289 of file KoResourceManager_p.cpp.

290{
291 KIS_SAFE_ASSERT_RECOVER_NOOP(!m_updateMediators.contains(mediator->key()));
292 m_updateMediators.insert(mediator->key(), mediator);
293 connect(mediator.data(), SIGNAL(sigResourceChanged(int)), SLOT(slotResourceInternalsChanged(int)));
294}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void slotResourceInternalsChanged(int key)
QHash< int, KoResourceUpdateMediatorSP > m_updateMediators

References connect(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_updateMediators, and slotResourceInternalsChanged().

◆ boolResource()

bool KoResourceManager::boolResource ( int key) const

Return the resource determined by param key as a boolean.

Parameters
keythe identifying key for the resource
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 207 of file KoResourceManager_p.cpp.

208{
209 if (! m_resources.contains(key))
210 return false;
211 return m_resources[key].toBool();
212}
QHash< int, QVariant > m_resources

References m_resources.

◆ clearResource()

void KoResourceManager::clearResource ( int key)

Remove the resource with key from the provider.

Parameters
keythe key that will be used to remove the resource
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 250 of file KoResourceManager_p.cpp.

251{
252 // we cannot remove a derived resource
253 if (m_derivedResources.contains(key)) return;
254
255 // we cannot remove an abstract resource either
256 if (m_abstractResources.contains(key)) return;
257
258 if (m_resources.contains(key)) {
259 m_resources.remove(key);
260 notifyResourceChanged(key, QVariant());
261 }
262}
QHash< int, KoAbstractCanvasResourceInterfaceSP > m_abstractResources
void notifyResourceChanged(int key, const QVariant &value)

References m_abstractResources, m_derivedResources, m_resources, and notifyResourceChanged().

◆ hasAbstractResource()

bool KoResourceManager::hasAbstractResource ( int key)
Returns
true if abstract resource with key exists
See also
setAbstractResource

Definition at line 358 of file KoResourceManager_p.cpp.

359{
360 return m_abstractResources.contains(key);
361}

References m_abstractResources.

◆ hasActiveCanvasResourceDependency()

bool KoResourceManager::hasActiveCanvasResourceDependency ( int sourceKey,
int targetKey ) const
Returns
true if specified dependency exists
See also
addActiveCanvasResourceDependency

Definition at line 315 of file KoResourceManager_p.cpp.

316{
317 auto it = m_dependencyFromSource.find(sourceKey);
318
319 while (it != m_dependencyFromSource.end() && it.key() == sourceKey) {
320 if (it.value()->targetKey() == targetKey) {
321 return true;
322 }
323 ++it;
324 }
325
326 return false;
327}

References m_dependencyFromSource.

◆ hasDerivedResourceConverter()

bool KoResourceManager::hasDerivedResourceConverter ( int key)
Returns
true if the resource with key is a derived resource (has a converter installed)
See also
addDerivedResourceConverter()

Definition at line 275 of file KoResourceManager_p.cpp.

276{
277 return m_derivedResources.contains(key);
278}

References m_derivedResources.

◆ hasResource()

bool KoResourceManager::hasResource ( int key) const

Returns true if there is a resource set with the requested key.

Parameters
keythe identifying key for the resource
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 239 of file KoResourceManager_p.cpp.

240{
241 if (m_abstractResources.contains(key)) return true;
242
245
246 const int realKey = converter ? converter->sourceKey() : key;
247 return m_resources.contains(realKey);
248}
QSharedPointer< KoDerivedResourceConverter > KoDerivedResourceConverterSP

References m_abstractResources, m_derivedResources, and m_resources.

◆ hasResourceUpdateMediator()

bool KoResourceManager::hasResourceUpdateMediator ( int key)
See also
addResourceUpdateMediator()

Definition at line 296 of file KoResourceManager_p.cpp.

297{
298 return m_updateMediators.contains(key);
299}

References m_updateMediators.

◆ intResource()

int KoResourceManager::intResource ( int key) const

Return the resource determined by param key as an integer.

Parameters
keythe identifying key for the resource
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 214 of file KoResourceManager_p.cpp.

215{
216 if (! m_resources.contains(key))
217 return 0;
218 return m_resources[key].toInt();
219}

References m_resources.

◆ koColorResource()

KoColor KoResourceManager::koColorResource ( int key) const

Return the resource determined by param key as a KoColor.

Parameters
keythe identifying key for the resource
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 184 of file KoResourceManager_p.cpp.

185{
186 if (! m_resources.contains(key)) {
187 KoColor empty;
188 return empty;
189 }
190 return resource(key).value<KoColor>();
191}
QVariant resource(int key) const

References m_resources, and resource().

◆ koShapeResource()

KoShape * KoResourceManager::koShapeResource ( int key) const

Return the resource determined by param key as a pointer to a KoShape.

Parameters
keythe identifying key for the resource
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 193 of file KoResourceManager_p.cpp.

194{
195 if (! m_resources.contains(key))
196 return 0;
197
198 return resource(key).value<KoShape *>();
199}

References m_resources, and resource().

◆ notifyDependenciesAboutTargetChange()

void KoResourceManager::notifyDependenciesAboutTargetChange ( int targetKey,
const QVariant & value )
private

Definition at line 127 of file KoResourceManager_p.cpp.

128{
129 auto it = m_dependencyFromTarget.find(targetKey);
130 while (it != m_dependencyFromTarget.end() && it.key() == targetKey) {
131 const int sourceKey = it.value()->sourceKey();
132
133 if (hasResource(sourceKey)) {
134 QVariant sourceValue = resource(sourceKey);
135
136 notifyResourceChangeAttempted(sourceKey, sourceValue);
137 if (it.value()->shouldUpdateSource(sourceValue, targetValue)) {
138 notifyResourceChanged(sourceKey, sourceValue);
139 }
140 }
141
142 ++it;
143 }
144}
bool hasResource(int key) const
void notifyResourceChangeAttempted(int key, const QVariant &value)

References hasResource(), m_dependencyFromTarget, notifyResourceChangeAttempted(), notifyResourceChanged(), and resource().

◆ notifyDerivedResourcesChangeAttempted()

void KoResourceManager::notifyDerivedResourcesChangeAttempted ( int key,
const QVariant & value )
private

Definition at line 115 of file KoResourceManager_p.cpp.

116{
117 QMultiHash<int, KoDerivedResourceConverterSP>::const_iterator it = m_derivedFromSource.constFind(key);
118 QMultiHash<int, KoDerivedResourceConverterSP>::const_iterator end = m_derivedFromSource.constEnd();
119
120 while (it != end && it.key() == key) {
121 KoDerivedResourceConverterSP converter = it.value();
122 notifyResourceChangeAttempted(converter->key(), converter->readFromSource(value));
123 it++;
124 }
125}
float value(const T *src, size_t ch)

References m_derivedFromSource, notifyResourceChangeAttempted(), and value().

◆ notifyDerivedResourcesChanged()

void KoResourceManager::notifyDerivedResourcesChanged ( int key,
const QVariant & value )
private

Definition at line 93 of file KoResourceManager_p.cpp.

94{
95 QMultiHash<int, KoDerivedResourceConverterSP>::const_iterator it = m_derivedFromSource.constFind(key);
96 QMultiHash<int, KoDerivedResourceConverterSP>::const_iterator end = m_derivedFromSource.constEnd();
97
98 while (it != end && it.key() == key) {
99 KoDerivedResourceConverterSP converter = it.value();
100
101 if (converter->notifySourceChanged(value)) {
102 notifyResourceChanged(converter->key(), converter->readFromSource(value));
103 }
104
105 it++;
106 }
107}

References m_derivedFromSource, notifyResourceChanged(), and value().

◆ notifyResourceChangeAttempted()

void KoResourceManager::notifyResourceChangeAttempted ( int key,
const QVariant & value )
private

Definition at line 109 of file KoResourceManager_p.cpp.

110{
111 Q_EMIT resourceChangeAttempted(key, value);
113}
void resourceChangeAttempted(int key, const QVariant &value)
void notifyDerivedResourcesChangeAttempted(int key, const QVariant &value)

References notifyDerivedResourcesChangeAttempted(), resourceChangeAttempted(), and value().

◆ notifyResourceChanged()

void KoResourceManager::notifyResourceChanged ( int key,
const QVariant & value )
private

Definition at line 86 of file KoResourceManager_p.cpp.

87{
88 Q_EMIT resourceChanged(key, value);
91}
void notifyDependenciesAboutTargetChange(int targetKey, const QVariant &value)
void resourceChanged(int key, const QVariant &value)
void notifyDerivedResourcesChanged(int key, const QVariant &value)

References notifyDependenciesAboutTargetChange(), notifyDerivedResourcesChanged(), resourceChanged(), and value().

◆ operator=()

KoResourceManager & KoResourceManager::operator= ( const KoResourceManager & )
private

◆ removeAbstractResource()

void KoResourceManager::removeAbstractResource ( int key)

Remove abstract resource with key

See also
setAbstractResource

Definition at line 363 of file KoResourceManager_p.cpp.

364{
365 Q_ASSERT(hasAbstractResource(key));
366
367 KoAbstractCanvasResourceInterfaceSP resourceInterface = m_abstractResources.value(key);
368 disconnect(resourceInterface.data(), SIGNAL(sigResourceChangedExternal(int, QVariant)),
369 this, SLOT(slotAbstractResourceChangedExternal(int, QVariant)));
370 m_abstractResources.remove(key);
371}
void slotAbstractResourceChangedExternal(int key, const QVariant &value)

References hasAbstractResource(), m_abstractResources, and slotAbstractResourceChangedExternal().

◆ removeActiveCanvasResourceDependency()

void KoResourceManager::removeActiveCanvasResourceDependency ( int sourceKey,
int targetKey )

Remove specified dependency

See also
addActiveCanvasResourceDependency

Definition at line 329 of file KoResourceManager_p.cpp.

330{
332
333 {
334 auto it = m_dependencyFromSource.find(sourceKey);
335 while (it != m_dependencyFromSource.end() && it.key() == sourceKey) {
336 if (it.value()->targetKey() == targetKey) {
337 it = m_dependencyFromSource.erase(it);
338 break;
339 } else {
340 ++it;
341 }
342 }
343 }
344
345 {
346 auto it = m_dependencyFromTarget.find(targetKey);
347 while (it != m_dependencyFromTarget.end() && it.key() == targetKey) {
348 if (it.value()->sourceKey() == sourceKey) {
349 it = m_dependencyFromTarget.erase(it);
350 break;
351 } else {
352 ++it;
353 }
354 }
355 }
356}

References hasActiveCanvasResourceDependency(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_dependencyFromSource, and m_dependencyFromTarget.

◆ removeDerivedResourceConverter()

void KoResourceManager::removeDerivedResourceConverter ( int key)

Removes a derived resource converter. If you rty to add a resource with key it will be treated as a usual resource.

See also
addDerivedResourceConverter()

Definition at line 280 of file KoResourceManager_p.cpp.

281{
282 Q_ASSERT(m_derivedResources.contains(key));
283
285 m_derivedResources.remove(key);
286 m_derivedFromSource.remove(converter->sourceKey(), converter);
287}

References m_derivedFromSource, and m_derivedResources.

◆ removeResourceUpdateMediator()

void KoResourceManager::removeResourceUpdateMediator ( int key)

◆ resource()

QVariant KoResourceManager::resource ( int key) const

Returns a qvariant containing the specified resource or a standard one if the specified resource does not exist.

Parameters
keythe key
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 146 of file KoResourceManager_p.cpp.

147{
148 KoAbstractCanvasResourceInterfaceSP abstractResource =
150 if (abstractResource) {
151 return abstractResource->value();
152 }
153
156
157 const int realKey = converter ? converter->sourceKey() : key;
158 QVariant value = m_resources.value(realKey, QVariant());
159
160 return converter ? converter->readFromSource(value) : value;
161}
QSharedPointer< KoAbstractCanvasResourceInterface > KoAbstractCanvasResourceInterfaceSP

References m_abstractResources, m_derivedResources, m_resources, and value().

◆ resourceChangeAttempted

void KoResourceManager::resourceChangeAttempted ( int key,
const QVariant & value )
signal

◆ resourceChanged

void KoResourceManager::resourceChanged ( int key,
const QVariant & value )
signal

◆ setAbstractResource()

void KoResourceManager::setAbstractResource ( KoAbstractCanvasResourceInterfaceSP resource)

Some resources are abstract and stored outside the resource manager. For example, opacity is sometimes stored inside an individual tool, so we load the resource from that tool when it is active.

Definition at line 373 of file KoResourceManager_p.cpp.

374{
375 KIS_SAFE_ASSERT_RECOVER_RETURN(resourceInterface);
376
377 if (hasDerivedResourceConverter(resourceInterface->key()))
378 qWarning() << "A derived resource converter with the same resource ID exists!";
379
380 const QVariant oldValue = this->resource(resourceInterface->key());
381
382 KoAbstractCanvasResourceInterfaceSP oldResourceInterface =
383 m_abstractResources.value(resourceInterface->key());
384 if (oldResourceInterface) {
385 disconnect(oldResourceInterface.data(), SIGNAL(sigResourceChangedExternal(int, QVariant)),
386 this, SLOT(slotAbstractResourceChangedExternal(int, QVariant)));
387 }
388
389 m_abstractResources[resourceInterface->key()] = resourceInterface;
390
391 connect(resourceInterface.data(), SIGNAL(sigResourceChangedExternal(int, QVariant)),
392 this, SLOT(slotAbstractResourceChangedExternal(int, const QVariant&)));
393
394 if (oldValue != resourceInterface->value()) {
395 notifyResourceChanged(resourceInterface->key(), resourceInterface->value());
396 }
397}
bool hasDerivedResourceConverter(int key)

References connect(), hasDerivedResourceConverter(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_abstractResources, notifyResourceChanged(), resource(), and slotAbstractResourceChangedExternal().

◆ setResource() [1/4]

void KoResourceManager::setResource ( int key,
const KoColor & color )

Set a resource of type KoColor.

Parameters
keythe integer key
colorthe new value for the key.
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 163 of file KoResourceManager_p.cpp.

164{
165 QVariant v;
166 v.setValue(color);
167 setResource(key, v);
168}
qreal v
void setResource(int key, const QVariant &value)

References setResource(), and v.

◆ setResource() [2/4]

void KoResourceManager::setResource ( int key,
const KoUnit & unit )

Set a resource of type KoUnit

Parameters
keythe integer key
unitthe unit for the key.
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 177 of file KoResourceManager_p.cpp.

178{
179 QVariant v;
180 v.setValue(unit);
181 setResource(key, v);
182}

References setResource(), and v.

◆ setResource() [3/4]

void KoResourceManager::setResource ( int key,
const QVariant & value )

Set a resource of any type.

Parameters
keythe integer key
valuethe new value for the key.
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 30 of file KoResourceManager_p.cpp.

31{
33
36
39
40 if (abstractResource) {
41 const QVariant oldValue = abstractResource->value();
42 abstractResource->setValue(value);
43
44 if (m_updateMediators.contains(key)) {
45 m_updateMediators[key]->connectResource(value);
46 }
47
48 if (oldValue != value) {
50 }
51 } else if (converter) {
52 const int sourceKey = converter->sourceKey();
53 const QVariant oldSourceValue = m_resources.value(sourceKey, QVariant());
54
55 bool valueChanged = false;
56 const QVariant newSourceValue = converter->writeToSource(value, oldSourceValue, &valueChanged);
57
58 if (valueChanged) {
60 }
61
62 if (oldSourceValue != newSourceValue) {
63 m_resources[sourceKey] = newSourceValue;
64 notifyResourceChanged(sourceKey, newSourceValue);
65 }
66 } else if (m_resources.contains(key)) {
67 const QVariant oldValue = m_resources.value(key, QVariant());
68 m_resources[key] = value;
69
70 if (m_updateMediators.contains(key)) {
71 m_updateMediators[key]->connectResource(value);
72 }
73
74 if (oldValue != value) {
76 }
77 } else {
78 m_resources[key] = value;
79 if (m_updateMediators.contains(key)) {
80 m_updateMediators[key]->connectResource(value);
81 }
83 }
84}

References m_abstractResources, m_derivedResources, m_resources, m_updateMediators, notifyResourceChangeAttempted(), notifyResourceChanged(), and value().

◆ setResource() [4/4]

void KoResourceManager::setResource ( int key,
KoShape * shape )

Set a resource of type KoShape*.

Parameters
keythe integer key
shapethe new shape for the key.
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 170 of file KoResourceManager_p.cpp.

171{
172 QVariant v;
173 v.setValue(shape);
174 setResource(key, v);
175}

References setResource(), and v.

◆ sizeResource()

QSizeF KoResourceManager::sizeResource ( int key) const

Return the resource determined by param key as a QSizeF.

Parameters
keythe identifying key for the resource
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 230 of file KoResourceManager_p.cpp.

231{
232 if (! m_resources.contains(key)) {
233 QSizeF empty;
234 return empty;
235 }
236 return qvariant_cast<QSizeF>(resource(key));
237}

References m_resources, and resource().

◆ slotAbstractResourceChangedExternal

void KoResourceManager::slotAbstractResourceChangedExternal ( int key,
const QVariant & value )
privateslot

Definition at line 25 of file KoResourceManager_p.cpp.

26{
28}

References notifyResourceChanged(), and value().

◆ slotResourceInternalsChanged

void KoResourceManager::slotResourceInternalsChanged ( int key)
privateslot

◆ stringResource()

QString KoResourceManager::stringResource ( int key) const

Return the resource determined by param key as a QString .

Parameters
keythe identifying key for the resource
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 221 of file KoResourceManager_p.cpp.

222{
223 if (! m_resources.contains(key)) {
224 QString empty;
225 return empty;
226 }
227 return qvariant_cast<QString>(resource(key));
228}

References m_resources, and resource().

◆ unitResource()

KoUnit KoResourceManager::unitResource ( int key) const

Return the resource determined by param key as a KoUnit.

Parameters
keythe identifying key for the resource
See also
KoCanvasResource::CanvasResourceId KoDocumentResourceManager::DocumentResource

Definition at line 202 of file KoResourceManager_p.cpp.

203{
204 return resource(key).value<KoUnit>();
205}

References resource().

Member Data Documentation

◆ m_abstractResources

QHash<int, KoAbstractCanvasResourceInterfaceSP> KoResourceManager::m_abstractResources
private

Definition at line 263 of file KoResourceManager_p.h.

◆ m_dependencyFromSource

QMultiHash<int, KoActiveCanvasResourceDependencySP> KoResourceManager::m_dependencyFromSource
private

Definition at line 259 of file KoResourceManager_p.h.

◆ m_dependencyFromTarget

QMultiHash<int, KoActiveCanvasResourceDependencySP> KoResourceManager::m_dependencyFromTarget
private

Definition at line 260 of file KoResourceManager_p.h.

◆ m_derivedFromSource

QMultiHash<int, KoDerivedResourceConverterSP> KoResourceManager::m_derivedFromSource
private

Definition at line 257 of file KoResourceManager_p.h.

◆ m_derivedResources

QHash<int, KoDerivedResourceConverterSP> KoResourceManager::m_derivedResources
private

Definition at line 256 of file KoResourceManager_p.h.

◆ m_resources

QHash<int, QVariant> KoResourceManager::m_resources
private

Definition at line 254 of file KoResourceManager_p.h.

◆ m_updateMediators

QHash<int, KoResourceUpdateMediatorSP> KoResourceManager::m_updateMediators
private

Definition at line 262 of file KoResourceManager_p.h.


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