|
Krita Source Code Documentation
|
#include <KisResourceModel.h>
Inheritance diagram for KisAbstractResourceModel:Public Types | |
| enum | Columns { Id = 0 , StorageId , Name , Filename , Tooltip , Thumbnail , Status , Location , ResourceType , Tags , MD5 , LargeThumbnail , Dirty , MetaData , ResourceActive , StorageActive , BrokenStatus , BrokenStatusMessage } |
| The Columns enum indexes the columns in the model. To get the thumbnail for a particular resource, create the index with QModelIndex(row, Thumbnail). More... | |
Public Member Functions | |
| 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 the given storage with md5, filename or name, the existing resource will be updated instead. If the existing resource was inactive, it will be active (undeleted). | |
| virtual bool | exportResource (KoResourceSP resource, QIODevice *device)=0 |
| exportResource exports a resource into a QIODevice | |
| virtual KoResourceSP | importResource (const QString &filename, QIODevice *device, const bool allowOverwrite, const QString &storageId=QString(""))=0 |
| importResource imports a resource from a QIODevice | |
| virtual KoResourceSP | importResourceFile (const QString &filename, const bool allowOverwrite, const QString &storageId=QString(""))=0 |
| importResourceFile | |
| 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 QModelIndex | indexForResource (KoResourceSP resource) const =0 |
| indexFromResource | |
| virtual QModelIndex | indexForResourceId (int resourceId) const =0 |
| indexFromResource | |
| virtual bool | reloadResource (KoResourceSP resource)=0 |
| reloadResource | |
| virtual bool | renameResource (KoResourceSP resource, const QString &name)=0 |
| renameResource name the given resource. The resource will have its name field reset, will be saved to the storage and there will be a new version created 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 bool | setResourceMetaData (KoResourceSP resource, QMap< QString, QVariant > metadata)=0 |
| setResourceMetaData | |
| virtual bool | updateResource (KoResourceSP resource)=0 |
| updateResource creates a new version of the resource in the storage and in the database. This will also set the resource to active if it was inactive. | |
| virtual | ~KisAbstractResourceModel () |
KisAbstractResourceModel defines the interface for accessing resources that is used in KisResourceModel and the various filter/proxy models
Definition at line 23 of file KisResourceModel.h.
The Columns enum indexes the columns in the model. To get the thumbnail for a particular resource, create the index with QModelIndex(row, Thumbnail).
Definition at line 32 of file KisResourceModel.h.
|
inlinevirtual |
Definition at line 62 of file KisResourceModel.h.
|
pure virtual |
addResource adds the given resource to the database and storage. If the resource already exists in the given storage with md5, filename or name, the existing resource will be updated instead. If the existing resource was inactive, it will be active (undeleted).
| resource | the resource itself |
| storageId | the id of the storage (could be "memory" for temporary resources, the document's storage id for document storages or empty to save to the default resources folder |
Implemented in KisTagResourceModel, KisAllResourcesModel, KisResourceModel, and KisTagFilterResourceProxyModel.
|
pure virtual |
exportResource exports a resource into a QIODevice
Exporting a resource as a binary blob is the only way to guarantee that its MD5 checksum is kept persistent. The underlying storage will just copy bytes into the device without doing any conversions
| resource | the resource to be exported |
| device | device where the resource should be written to |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.
|
pure virtual |
importResource imports a resource from a QIODevice
Importing a resource from a binary blob is the only way to guarantee that its MD5 checksum is kept persistent. The underlying storage will just copy bytes into its location.
| filename | file name of the resource if preset. File name may be used for addressing the resource, so it is usually preferred to preserve it. |
| device | device where the resource should be read from |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.
|
pure virtual |
importResourceFile
| filename |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.
|
pure virtual |
importWillOverwriteResource checks is importing a resource with this filename will overwrite anything
If this function returns true, then importResource() is guaranteed to fail with 'allowOverwrite' set to false.
| filename | file name of the resource if preset. File name may be used for addressing the resource, so it is usually preferred to preserve it. |
Implemented in KisTagFilterResourceProxyModel, KisTagResourceModel, KisAllResourcesModel, and KisResourceModel.
|
pure virtual |
indexFromResource
| resource |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.
|
pure virtual |
indexFromResource
| resourceId | resource id for which we want to get an index |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.
|
pure virtual |
reloadResource
| resource |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.
|
pure virtual |
renameResource name the given resource. The resource will have its name field reset, will be saved to the storage and there will be a new version created in the database.
| resource | The resource to rename |
| name | The new name |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.
|
pure virtual |
resourceForIndex returns a properly versioned and id'ed resource object
Implemented in KisTagResourceModel, KisAllResourcesModel, KisResourceModel, and KisTagFilterResourceProxyModel.
|
pure virtual |
setResourceActive changes 'active' state of the resource
| index | the index of the resource |
| value | new 'active' state of the resource |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.
|
inline |
A convenience function to put a resource into inactive state
Definition at line 94 of file KisResourceModel.h.
|
pure virtual |
setResourceMetaData
| metadata |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.
|
pure virtual |
updateResource creates a new version of the resource in the storage and in the database. This will also set the resource to active if it was inactive.
Note: if the storage does not support versioning, updating the resource will fail.
| resource |
Implemented in KisAllResourcesModel, KisResourceModel, KisTagFilterResourceProxyModel, and KisTagResourceModel.