|
Krita Source Code Documentation
|
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) |
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) |
| KoResourceManager & | operator= (const KoResourceManager &) |
Private Attributes | |
| QHash< int, KoAbstractCanvasResourceInterfaceSP > | m_abstractResources |
| QMultiHash< int, KoActiveCanvasResourceDependencySP > | m_dependencyFromSource |
| QMultiHash< int, KoActiveCanvasResourceDependencySP > | m_dependencyFromTarget |
| QMultiHash< int, KoDerivedResourceConverterSP > | m_derivedFromSource |
| QHash< int, KoDerivedResourceConverterSP > | m_derivedResources |
| QHash< int, QVariant > | m_resources |
| QHash< int, KoResourceUpdateMediatorSP > | m_updateMediators |
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.
|
inline |
Definition at line 37 of file KoResourceManager_p.h.
|
private |
| 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.
References hasActiveCanvasResourceDependency(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_dependencyFromSource, and m_dependencyFromTarget.
| 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.
References hasAbstractResource(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_derivedFromSource, and m_derivedResources.
| 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.
References connect(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_updateMediators, and slotResourceInternalsChanged().
| bool KoResourceManager::boolResource | ( | int | key | ) | const |
Return the resource determined by param key as a boolean.
| key | the identifying key for the resource |
Definition at line 207 of file KoResourceManager_p.cpp.
References m_resources.
| void KoResourceManager::clearResource | ( | int | key | ) |
Remove the resource with key from the provider.
| key | the key that will be used to remove the resource |
Definition at line 250 of file KoResourceManager_p.cpp.
References m_abstractResources, m_derivedResources, m_resources, and notifyResourceChanged().
| bool KoResourceManager::hasAbstractResource | ( | int | key | ) |
key existsDefinition at line 358 of file KoResourceManager_p.cpp.
References m_abstractResources.
| bool KoResourceManager::hasActiveCanvasResourceDependency | ( | int | sourceKey, |
| int | targetKey ) const |
Definition at line 315 of file KoResourceManager_p.cpp.
References m_dependencyFromSource.
| bool KoResourceManager::hasDerivedResourceConverter | ( | int | key | ) |
key is a derived resource (has a converter installed)Definition at line 275 of file KoResourceManager_p.cpp.
References m_derivedResources.
| bool KoResourceManager::hasResource | ( | int | key | ) | const |
Returns true if there is a resource set with the requested key.
| key | the identifying key for the resource |
Definition at line 239 of file KoResourceManager_p.cpp.
References m_abstractResources, m_derivedResources, and m_resources.
| bool KoResourceManager::hasResourceUpdateMediator | ( | int | key | ) |
Definition at line 296 of file KoResourceManager_p.cpp.
References m_updateMediators.
| int KoResourceManager::intResource | ( | int | key | ) | const |
Return the resource determined by param key as an integer.
| key | the identifying key for the resource |
Definition at line 214 of file KoResourceManager_p.cpp.
References m_resources.
| KoColor KoResourceManager::koColorResource | ( | int | key | ) | const |
Return the resource determined by param key as a KoColor.
| key | the identifying key for the resource |
Definition at line 184 of file KoResourceManager_p.cpp.
References m_resources, and resource().
| KoShape * KoResourceManager::koShapeResource | ( | int | key | ) | const |
Return the resource determined by param key as a pointer to a KoShape.
| key | the identifying key for the resource |
Definition at line 193 of file KoResourceManager_p.cpp.
References m_resources, and resource().
|
private |
Definition at line 127 of file KoResourceManager_p.cpp.
References hasResource(), m_dependencyFromTarget, notifyResourceChangeAttempted(), notifyResourceChanged(), and resource().
|
private |
Definition at line 115 of file KoResourceManager_p.cpp.
References m_derivedFromSource, notifyResourceChangeAttempted(), and value().
|
private |
Definition at line 93 of file KoResourceManager_p.cpp.
References m_derivedFromSource, notifyResourceChanged(), and value().
|
private |
Definition at line 109 of file KoResourceManager_p.cpp.
References notifyDerivedResourcesChangeAttempted(), resourceChangeAttempted(), and value().
|
private |
Definition at line 86 of file KoResourceManager_p.cpp.
References notifyDependenciesAboutTargetChange(), notifyDerivedResourcesChanged(), resourceChanged(), and value().
|
private |
| void KoResourceManager::removeAbstractResource | ( | int | key | ) |
Remove abstract resource with key
Definition at line 363 of file KoResourceManager_p.cpp.
References hasAbstractResource(), m_abstractResources, and slotAbstractResourceChangedExternal().
| void KoResourceManager::removeActiveCanvasResourceDependency | ( | int | sourceKey, |
| int | targetKey ) |
Remove specified dependency
Definition at line 329 of file KoResourceManager_p.cpp.
References hasActiveCanvasResourceDependency(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_dependencyFromSource, and m_dependencyFromTarget.
| 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.
Definition at line 280 of file KoResourceManager_p.cpp.
References m_derivedFromSource, and m_derivedResources.
| void KoResourceManager::removeResourceUpdateMediator | ( | int | key | ) |
Definition at line 301 of file KoResourceManager_p.cpp.
References KIS_SAFE_ASSERT_RECOVER_RETURN, and m_updateMediators.
| QVariant KoResourceManager::resource | ( | int | key | ) | const |
Returns a qvariant containing the specified resource or a standard one if the specified resource does not exist.
| key | the key |
Definition at line 146 of file KoResourceManager_p.cpp.
References m_abstractResources, m_derivedResources, m_resources, and value().
|
signal |
|
signal |
| 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.
References connect(), hasDerivedResourceConverter(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_abstractResources, notifyResourceChanged(), resource(), and slotAbstractResourceChangedExternal().
Set a resource of type KoColor.
| key | the integer key |
| color | the new value for the key. |
Definition at line 163 of file KoResourceManager_p.cpp.
References setResource(), and v.
Set a resource of type KoUnit
| key | the integer key |
| unit | the unit for the key. |
Definition at line 177 of file KoResourceManager_p.cpp.
References setResource(), and v.
| void KoResourceManager::setResource | ( | int | key, |
| const QVariant & | value ) |
Set a resource of any type.
| key | the integer key |
| value | the new value for the key. |
Definition at line 30 of file KoResourceManager_p.cpp.
References m_abstractResources, m_derivedResources, m_resources, m_updateMediators, notifyResourceChangeAttempted(), notifyResourceChanged(), and value().
Set a resource of type KoShape*.
| key | the integer key |
| shape | the new shape for the key. |
Definition at line 170 of file KoResourceManager_p.cpp.
References setResource(), and v.
| QSizeF KoResourceManager::sizeResource | ( | int | key | ) | const |
Return the resource determined by param key as a QSizeF.
| key | the identifying key for the resource |
Definition at line 230 of file KoResourceManager_p.cpp.
References m_resources, and resource().
|
privateslot |
Definition at line 25 of file KoResourceManager_p.cpp.
References notifyResourceChanged(), and value().
|
privateslot |
Definition at line 18 of file KoResourceManager_p.cpp.
References KIS_SAFE_ASSERT_RECOVER_RETURN, m_abstractResources, m_resources, notifyDependenciesAboutTargetChange(), and notifyDerivedResourcesChanged().
| QString KoResourceManager::stringResource | ( | int | key | ) | const |
Return the resource determined by param key as a QString .
| key | the identifying key for the resource |
Definition at line 221 of file KoResourceManager_p.cpp.
References m_resources, and resource().
| KoUnit KoResourceManager::unitResource | ( | int | key | ) | const |
Return the resource determined by param key as a KoUnit.
| key | the identifying key for the resource |
Definition at line 202 of file KoResourceManager_p.cpp.
References resource().
|
private |
Definition at line 263 of file KoResourceManager_p.h.
|
private |
Definition at line 259 of file KoResourceManager_p.h.
|
private |
Definition at line 260 of file KoResourceManager_p.h.
|
private |
Definition at line 257 of file KoResourceManager_p.h.
|
private |
Definition at line 256 of file KoResourceManager_p.h.
|
private |
Definition at line 254 of file KoResourceManager_p.h.
|
private |
Definition at line 262 of file KoResourceManager_p.h.