14#ifndef KORESOURCESERVER_H
15#define KORESOURCESERVER_H
20#include <QApplication>
23#include <QTemporaryFile>
27#include "ksharedconfig.h"
86 Q_ASSERT(!type.isEmpty());
88 if (QThread::currentThread() != qApp->thread()) {
107 if (QThread::currentThread() != qApp->thread()) {
119 if (QThread::currentThread() != qApp->thread()) {
136 if (QThread::currentThread() != qApp->thread()) {
157 if (QThread::currentThread() != qApp->thread()) {
183 if (QThread::currentThread() != qApp->thread()) {
193 QFileInfo fi(filename);
233 if (QThread::currentThread() != qApp->thread()) {
238 if (filename.isEmpty() || filename.isNull()) {
243 if (resources.size() > 0) {
244 return resources.first().dynamicCast<T>();
254 if (QThread::currentThread() != qApp->thread()) {
258 if (name.isEmpty() || name.isNull()) {
264 if (resources.size() > 0) {
265 return resources.first().dynamicCast<T>();
275 if (QThread::currentThread() != qApp->thread()) {
278 if (md5.isEmpty() || md5.isNull()) {
283 if (resources.size() > 0) {
284 return resources.first().dynamicCast<T>();
313 if (QThread::currentThread() != qApp->thread()) {
327 if (QThread::currentThread() != qApp->thread()) {
bool setResourceInactive(const QModelIndex &index)
static KisResourcesInterfaceSP instance()
QString resourceLocationBase() const
resourceLocationBase is the place where all resource storages (folder, bundles etc....
static KisResourceLocator * instance()
The KisResourceModel class provides the main access to resources. It is possible to filter the resour...
KoResourceSP importResourceFile(const QString &filename, const bool allowOverwrite, const QString &storageId=QString("")) override
importResourceFile
bool reloadResource(KoResourceSP resource) override
reloadResource
QVector< KisTagSP > tagsForResource(int resourceId) const
QVector< KoResourceSP > resourcesForMD5(const QString md5sum) const
bool updateResource(KoResourceSP resource) override
updateResource creates a new version of the resource in the storage and in the database....
QVector< KoResourceSP > resourcesForFilename(QString fileName) const
QVector< KoResourceSP > resourcesForName(QString name) const
bool addResource(KoResourceSP resource, const QString &storageId=QString("")) override
addResource adds the given resource to the database and storage. If the resource already exists in th...
QModelIndex indexForResource(KoResourceSP resource) const override
indexFromResource
KoResourceSP resourceForIndex(QModelIndex index=QModelIndex()) const override
resourceForIndex returns a properly versioned and id'ed resource object
virtual void removingResource(QSharedPointer< T > resource)=0
virtual ~KoResourceServerObserver()
virtual void resourceAdded(QSharedPointer< T > resource)=0
virtual void unsetResourceServer()=0
virtual void resourceChanged(QSharedPointer< T > resource)=0
void addObserver(ObserverType *observer)
void notifyResourceAdded(QSharedPointer< T > resource)
int resourceCount() const
virtual ~KoResourceServer()
QSharedPointer< T > resourceByMD5(const QString &md5) const
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 r...
KisResourceModel * m_resourceModel
bool reloadResource(QSharedPointer< T > resource)
void removeObserver(ObserverType *observer)
KisResourceModel * resourceModel() const
bool addResource(QSharedPointer< T > resource, bool save=true)
Adds an already loaded resource to the server.
bool updateResource(QSharedPointer< T > resource)
KoResourceServerObserver< T > ObserverType
bool removeResourceFromServer(QSharedPointer< T > resource)
Remove a resource from Resource Server but not from a file.
KoResourceSP importResourceFile(const QString &filename, const bool allowOverwrite)
QList< ObserverType * > m_observers
KoResourceServer(const QString &type)
QSharedPointer< T > firstResource() const
Return the first resource available.
QString saveLocation()
Returns path where to save user defined and imported resources to.
QSharedPointer< T > resourceByFilename(const QString &filename) const
void removeResourceFile(const QString &filename)
Removes the resource file from the resource server.
QSharedPointer< T > resourceByName(const QString &name) const
QVector< KisTagSP > assignedTagsList(KoResourceSP resource) const
void notifyResourceChanged(QSharedPointer< T > resource)
void notifyRemovingResource(QSharedPointer< T > resource)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)