|
Krita Source Code Documentation
|
#include <KoResourceServer.h>
Public Types | |
| typedef KoResourceServerObserver< T > | ObserverType |
Public Member Functions | |
| void | addObserver (ObserverType *observer) |
| bool | addResource (QSharedPointer< T > resource, bool save=true) |
| Adds an already loaded resource to the server. | |
| QVector< KisTagSP > | assignedTagsList (KoResourceSP resource) const |
| QSharedPointer< T > | firstResource () const |
| Return the first resource available. | |
| KoResourceSP | importResourceFile (const QString &filename, const bool allowOverwrite) |
| KoResourceServer (const QString &type) | |
| bool | reloadResource (QSharedPointer< T > resource) |
| void | removeObserver (ObserverType *observer) |
| void | removeResourceFile (const QString &filename) |
| Removes the resource file from the resource server. | |
| bool | removeResourceFromServer (QSharedPointer< T > resource) |
| Remove a resource from Resource Server but not from a file. | |
| QSharedPointer< T > | resource (const QString &md5, const QString &fileName, const QString &name) |
| resource retrieves a resource. If the md5sum is not empty, the resource will only be retrieved if a resource with that md5sum exists. If it is empty, a fallback to filename or name is possible. | |
| int | resourceCount () const |
| KisResourceModel * | resourceModel () const |
| QString | saveLocation () |
| Returns path where to save user defined and imported resources to. | |
| bool | updateResource (QSharedPointer< T > resource) |
| virtual | ~KoResourceServer () |
Protected Member Functions | |
| void | notifyRemovingResource (QSharedPointer< T > resource) |
| void | notifyResourceAdded (QSharedPointer< T > resource) |
| void | notifyResourceChanged (QSharedPointer< T > resource) |
Private Member Functions | |
| QSharedPointer< T > | resourceByFilename (const QString &filename) const |
| QSharedPointer< T > | resourceByMD5 (const QString &md5) const |
| QSharedPointer< T > | resourceByName (const QString &name) const |
Private Attributes | |
| QList< ObserverType * > | m_observers |
| KisResourceModel * | m_resourceModel {0} |
| KisTagModel * | m_tagModel {0} |
| QString | m_type |
KoResourceServer is a shim around KisResourceModel. It knows nothing by its own, and does nothing on its own. It can only be used in the gui thread.
Definition at line 75 of file KoResourceServer.h.
| typedef KoResourceServerObserver<T> KoResourceServer< T >::ObserverType |
Definition at line 79 of file KoResourceServer.h.
|
inline |
Definition at line 81 of file KoResourceServer.h.
References KIS_SAFE_ASSERT_RECOVER_NOOP, and kisBacktrace().
|
inlinevirtual |
Definition at line 94 of file KoResourceServer.h.
References KoResourceServer< T >::m_observers, KoResourceServer< T >::m_resourceModel, KoResourceServer< T >::m_tagModel, and KoResourceServerObserver< T >::unsetResourceServer().
|
inline |
Adds an observer to the server
| observer | the observer to be added |
| notifyLoadedResources | determines if the observer should be notified about the already loaded resources |
Definition at line 208 of file KoResourceServer.h.
References KoResourceServer< T >::m_observers.
|
inline |
Adds an already loaded resource to the server.
Definition at line 133 of file KoResourceServer.h.
References KisResourceModel::addResource(), KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), KoResourceServer< T >::m_resourceModel, KoResourceServer< T >::notifyResourceAdded(), KoResourceServer< T >::resource(), and warnResource.
|
inline |
Definition at line 336 of file KoResourceServer.h.
References KoResourceServer< T >::m_resourceModel, KoResourceServer< T >::resource(), and KisResourceModel::tagsForResource().
|
inline |
Return the first resource available.
Definition at line 115 of file KoResourceServer.h.
References KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), KoResourceServer< T >::m_resourceModel, and KisResourceModel::resourceForIndex().
|
inline |
Creates a new resource from a given file and adds them to the resource server The base implementation does only load one resource per file, override to implement collections
| filename | file name of the resource file to be imported |
| fileCreation | decides whether to create the file in the saveLocation() directory |
Definition at line 179 of file KoResourceServer.h.
References KisResourceModel::importResourceFile(), KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), and KoResourceServer< T >::m_resourceModel.
|
inlineprotected |
Definition at line 353 of file KoResourceServer.h.
References KoResourceServer< T >::m_observers, KoResourceServerObserver< T >::removingResource(), and KoResourceServer< T >::resource().
|
inlineprotected |
Definition at line 346 of file KoResourceServer.h.
References KoResourceServer< T >::m_observers, KoResourceServer< T >::resource(), and KoResourceServerObserver< T >::resourceAdded().
|
inlineprotected |
Definition at line 360 of file KoResourceServer.h.
References KoResourceServer< T >::m_observers, KoResourceServer< T >::resource(), and KoResourceServerObserver< T >::resourceChanged().
|
inline |
Reloads the resource from the persistent storage
Definition at line 324 of file KoResourceServer.h.
References KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), KoResourceServer< T >::m_resourceModel, KoResourceServer< T >::notifyResourceChanged(), KisResourceModel::reloadResource(), and KoResourceServer< T >::resource().
|
inline |
Removes an observer from the server
| observer | the observer to be removed |
Definition at line 219 of file KoResourceServer.h.
References KoResourceServer< T >::m_observers.
|
inline |
Removes the resource file from the resource server.
Definition at line 191 of file KoResourceServer.h.
References KoResourceServer< T >::removeResourceFromServer(), KoResourceServer< T >::resource(), KoResourceServer< T >::resourceByFilename(), and warnResource.
|
inline |
Remove a resource from Resource Server but not from a file.
Definition at line 154 of file KoResourceServer.h.
References KisResourceModel::indexForResource(), KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), KoResourceServer< T >::m_resourceModel, KoResourceServer< T >::notifyRemovingResource(), KoResourceServer< T >::resource(), and KisAbstractResourceModel::setResourceInactive().
|
inline |
resource retrieves a resource. If the md5sum is not empty, the resource will only be retrieved if a resource with that md5sum exists. If it is empty, a fallback to filename or name is possible.
| md5 | This is the hex-encoded md5sum as stored in e.g. configuration objects |
| fileName | A filename without the path |
| name | The name of the resource |
Definition at line 301 of file KoResourceServer.h.
References KisGlobalResourcesInterface::instance(), and KoResourceServer< T >::m_type.
|
inlineprivate |
Definition at line 230 of file KoResourceServer.h.
References KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), KoResourceServer< T >::m_resourceModel, and KisResourceModel::resourcesForFilename().
|
inlineprivate |
Definition at line 272 of file KoResourceServer.h.
References KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), KoResourceServer< T >::m_resourceModel, and KisResourceModel::resourcesForMD5().
|
inlineprivate |
Definition at line 251 of file KoResourceServer.h.
References KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), KoResourceServer< T >::m_resourceModel, and KisResourceModel::resourcesForName().
|
inline |
Definition at line 126 of file KoResourceServer.h.
References KIS_SAFE_ASSERT_RECOVER_NOOP, and KoResourceServer< T >::m_resourceModel.
|
inline |
Definition at line 104 of file KoResourceServer.h.
References KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), and KoResourceServer< T >::m_resourceModel.
|
inline |
Returns path where to save user defined and imported resources to.
Definition at line 169 of file KoResourceServer.h.
References KisResourceLocator::instance(), KoResourceServer< T >::m_type, and KisResourceLocator::resourceLocationBase().
|
inline |
Call after changing the content of a resource and saving it; Notifies the connected views.
Definition at line 310 of file KoResourceServer.h.
References KIS_SAFE_ASSERT_RECOVER_NOOP, kisBacktrace(), KoResourceServer< T >::m_resourceModel, KoResourceServer< T >::notifyResourceChanged(), KoResourceServer< T >::resource(), and KisResourceModel::updateResource().
|
private |
Definition at line 369 of file KoResourceServer.h.
|
private |
Definition at line 370 of file KoResourceServer.h.
|
private |
Definition at line 371 of file KoResourceServer.h.
|
private |
Definition at line 372 of file KoResourceServer.h.