7#ifndef KISRESOURCEMODEL_H
8#define KISRESOURCEMODEL_H
10#include <QAbstractTableModel>
11#include <QSortFilterProxyModel>
13#include <kritaresources_export.h>
95 return setResourceActive(index,
false);
120 virtual KoResourceSP importResource(
const QString &filename, QIODevice *device,
const bool allowOverwrite,
const QString &storageId = QString(
"")) = 0;
219 ShowInactiveResources = 0,
225 ShowInactiveStorages = 0,
264 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
265 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
266 QVariant data(
const QModelIndex &index,
int role)
const override;
267 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override;
268 bool setData(
const QModelIndex &index,
const QVariant &
value,
int role)
override;
269 Qt::ItemFlags flags(
const QModelIndex &index)
const override;
270 QHash<int, QByteArray> roleNames()
const override;
274 KoResourceSP resourceForIndex(QModelIndex index = QModelIndex())
const override;
275 QModelIndex indexForResource(
KoResourceSP resource)
const override;
276 QModelIndex indexForResourceId(
int resourceId)
const override;
277 bool setResourceActive(
const QModelIndex &index,
bool value)
override;
278 KoResourceSP importResourceFile(
const QString &filename,
const bool allowOverwrite,
const QString &storageId = QString(
""))
override;
279 KoResourceSP importResource(
const QString &filename, QIODevice *device,
const bool allowOverwrite,
const QString &storageId = QString(
""))
override;
280 bool importWillOverwriteResource(
const QString &fileName,
const QString &storageLocation = QString())
const override;
281 bool exportResource(
KoResourceSP resource, QIODevice *device)
override;
282 bool addResource(
KoResourceSP resource,
const QString &storageId = QString(
""))
override;
283 bool addResourceDeduplicateFileName(
KoResourceSP resource,
const QString &storageId = QString(
""))
override;
286 bool renameResource(
KoResourceSP resource,
const QString &name)
override;
287 bool setResourceMetaData(
KoResourceSP resource, QMap<QString, QVariant> metadata)
override;
291 void storageActiveStateChanged(
const QString &location);
292 void storageResynchronized(
const QString &storage,
bool isBulkResynchronization);
293 void storagesBulkSynchronizationFinished();
305 void beginExternalResourceImport(
const QString &resourceType,
int numResources);
310 void endExternalResourceImport(
const QString &resourceType);
317 void beginExternalResourceRemove(
const QString &resourceType,
const QVector<int> &resourceId);
322 void endExternalResourceRemove(
const QString &resourceType);
328 void slotResourceActiveStateChanged(
const QString &resourceType,
int resourceId);
338 bool resourceExists(
const QString &md5,
const QString &filename,
const QString &name);
394 void showOnlyUntaggedResources(
bool showOnlyUntagged);
398 KoResourceSP resourceForIndex(QModelIndex index = QModelIndex())
const override;
399 QModelIndex indexForResource(
KoResourceSP resource)
const override;
400 QModelIndex indexForResourceId(
int resourceId)
const override;
401 bool setResourceActive(
const QModelIndex &index,
bool value)
override;
402 KoResourceSP importResourceFile(
const QString &filename,
const bool allowOverwrite,
const QString &storageId = QString(
""))
override;
403 KoResourceSP importResource(
const QString &filename, QIODevice *device,
const bool allowOverwrite,
const QString &storageId = QString(
""))
override;
404 bool importWillOverwriteResource(
const QString &fileName,
const QString &storageLocation = QString())
const override;
405 bool exportResource(
KoResourceSP resource, QIODevice *device)
override;
406 bool addResource(
KoResourceSP resource,
const QString &storageId = QString(
""))
override;
407 bool addResourceDeduplicateFileName(
KoResourceSP resource,
const QString &storageId = QString(
""))
override;
410 bool renameResource(
KoResourceSP resource,
const QString &name)
override;
411 bool setResourceMetaData(
KoResourceSP resource, QMap<QString, QVariant> metadata)
override;
438 bool filterAcceptsColumn(
int source_column,
const QModelIndex &source_parent)
const override;
439 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent)
const override;
440 bool lessThan(
const QModelIndex &source_left,
const QModelIndex &source_right)
const override;
444 bool filterResource(
const QModelIndex &idx)
const;
float value(const T *src, size_t ch)
virtual void setStorageFilter(StorageFilter filter)=0
virtual void setResourceFilter(ResourceFilter filter)=0
virtual ~KisAbstractResourceFilterInterface()
virtual KoResourceSP importResource(const QString &filename, QIODevice *device, const bool allowOverwrite, const QString &storageId=QString(""))=0
importResource imports a resource from a QIODevice
virtual QModelIndex indexForResource(KoResourceSP resource) const =0
indexFromResource
virtual bool exportResource(KoResourceSP resource, QIODevice *device)=0
exportResource exports a resource into a QIODevice
virtual bool updateResource(KoResourceSP resource)=0
updateResource creates a new version of the resource in the storage and in the database....
virtual KoResourceSP resourceForIndex(QModelIndex index=QModelIndex()) const =0
resourceForIndex returns a properly versioned and id'ed resource object
virtual bool setResourceActive(const QModelIndex &index, bool value)=0
setResourceActive changes 'active' state of the resource
bool setResourceInactive(const QModelIndex &index)
virtual QModelIndex indexForResourceId(int resourceId) const =0
indexFromResource
Columns
The Columns enum indexes the columns in the model. To get the thumbnail for a particular resource,...
@ Status
Whether the resource is active. Duplicate of ResourceActive.
@ ResourceActive
Whether the current resource is active.
@ Dirty
A dirty resource is one that has been modified locally but not saved.
@ LargeThumbnail
A larger thumbnail for displaying in a tooltip. 200x200 or so.
@ MetaData
MetaData is a map of key, value pairs that is associated with this resource.
@ BrokenStatus
Whether the resource is broken (bool)
@ StorageActive
Whether the current resource's storage is active.
virtual KoResourceSP importResourceFile(const QString &filename, const bool allowOverwrite, const QString &storageId=QString(""))=0
importResourceFile
virtual bool addResource(KoResourceSP resource, const QString &storageId=QString(""))=0
addResource adds the given resource to the database and storage. If the resource already exists in th...
virtual bool renameResource(KoResourceSP resource, const QString &name)=0
renameResource name the given resource. The resource will have its name field reset,...
virtual bool importWillOverwriteResource(const QString &fileName, const QString &storageLocation=QString()) const =0
importWillOverwriteResource checks is importing a resource with this filename will overwrite anything
virtual bool addResourceDeduplicateFileName(KoResourceSP resource, const QString &storageId)=0
addResource adds the given resource to the database and storage. If the resource already exists in th...
virtual bool reloadResource(KoResourceSP resource)=0
reloadResource
virtual bool setResourceMetaData(KoResourceSP resource, QMap< QString, QVariant > metadata)=0
setResourceMetaData
virtual ~KisAbstractResourceModel()
The KisAllresourcesModel class provides access to the cache database for a particular resource type....
The KisResourceModel class provides the main access to resources. It is possible to filter the resour...