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;
207 ShowInactiveResources = 0,
213 ShowInactiveStorages = 0,
252 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
253 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
254 QVariant data(
const QModelIndex &index,
int role)
const override;
255 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override;
256 bool setData(
const QModelIndex &index,
const QVariant &
value,
int role)
override;
257 Qt::ItemFlags flags(
const QModelIndex &index)
const override;
258 QHash<int, QByteArray> roleNames()
const override;
262 KoResourceSP resourceForIndex(QModelIndex index = QModelIndex())
const override;
263 QModelIndex indexForResource(
KoResourceSP resource)
const override;
264 QModelIndex indexForResourceId(
int resourceId)
const override;
265 bool setResourceActive(
const QModelIndex &index,
bool value)
override;
266 KoResourceSP importResourceFile(
const QString &filename,
const bool allowOverwrite,
const QString &storageId = QString(
""))
override;
267 KoResourceSP importResource(
const QString &filename, QIODevice *device,
const bool allowOverwrite,
const QString &storageId = QString(
""))
override;
268 bool importWillOverwriteResource(
const QString &fileName,
const QString &storageLocation = QString())
const override;
269 bool exportResource(
KoResourceSP resource, QIODevice *device)
override;
270 bool addResource(
KoResourceSP resource,
const QString &storageId = QString(
""))
override;
273 bool renameResource(
KoResourceSP resource,
const QString &name)
override;
274 bool setResourceMetaData(
KoResourceSP resource, QMap<QString, QVariant> metadata)
override;
278 void storageActiveStateChanged(
const QString &location);
279 void storageResynchronized(
const QString &storage,
bool isBulkResynchronization);
280 void storagesBulkSynchronizationFinished();
292 void beginExternalResourceImport(
const QString &resourceType,
int numResources);
297 void endExternalResourceImport(
const QString &resourceType);
304 void beginExternalResourceRemove(
const QString &resourceType,
const QVector<int> &resourceId);
309 void endExternalResourceRemove(
const QString &resourceType);
315 void slotResourceActiveStateChanged(
const QString &resourceType,
int resourceId);
325 bool resourceExists(
const QString &md5,
const QString &filename,
const QString &name);
381 void showOnlyUntaggedResources(
bool showOnlyUntagged);
385 KoResourceSP resourceForIndex(QModelIndex index = QModelIndex())
const override;
386 QModelIndex indexForResource(
KoResourceSP resource)
const override;
387 QModelIndex indexForResourceId(
int resourceId)
const override;
388 bool setResourceActive(
const QModelIndex &index,
bool value)
override;
389 KoResourceSP importResourceFile(
const QString &filename,
const bool allowOverwrite,
const QString &storageId = QString(
""))
override;
390 KoResourceSP importResource(
const QString &filename, QIODevice *device,
const bool allowOverwrite,
const QString &storageId = QString(
""))
override;
391 bool importWillOverwriteResource(
const QString &fileName,
const QString &storageLocation = QString())
const override;
392 bool exportResource(
KoResourceSP resource, QIODevice *device)
override;
393 bool addResource(
KoResourceSP resource,
const QString &storageId = QString(
""))
override;
396 bool renameResource(
KoResourceSP resource,
const QString &name)
override;
397 bool setResourceMetaData(
KoResourceSP resource, QMap<QString, QVariant> metadata)
override;
424 bool filterAcceptsColumn(
int source_column,
const QModelIndex &source_parent)
const override;
425 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent)
const override;
426 bool lessThan(
const QModelIndex &source_left,
const QModelIndex &source_right)
const override;
430 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 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...