|
Krita Source Code Documentation
|
The KisTagFilterResourceProxyModel class filters the resources by tag or resource name. More...
#include <KisTagFilterResourceProxyModel.h>
Inheritance diagram for KisTagFilterResourceProxyModel:Classes | |
| struct | Private |
Signals | |
| void | afterFilterChanged () |
| void | beforeFilterChanges () |
Public Member Functions | |
| virtual bool | additionalResourceNameChecks (const QModelIndex &index, const KisResourceSearchBoxFilter *filter) const |
| additionalResourceNameChecks Some resources, like fonts, have multiple names that need to be tested. Implementers should override this function if they want additional checks on the name. | |
| 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 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). | |
| KisTagSP | currentTagFilter () const |
| currentTagFilter | |
| bool | exportResource (KoResourceSP resource, QIODevice *device) override |
| exportResource exports a resource into a QIODevice | |
| bool | filterInCurrentTag () const |
| KoResourceSP | importResource (const QString &filename, QIODevice *device, const bool allowOverwrite, const QString &storageId=QString()) override |
| importResource imports a resource from a QIODevice | |
| KoResourceSP | importResourceFile (const QString &filename, const bool allowOverwrite, const QString &storageId=QString()) override |
| importResourceFile | |
| bool | importWillOverwriteResource (const QString &fileName, const QString &storageLocation) const override |
| importWillOverwriteResource checks is importing a resource with this filename will overwrite anything | |
| QModelIndex | indexForResource (KoResourceSP resource) const override |
| indexFromResource | |
| QModelIndex | indexForResourceId (int resourceId) const override |
| indexFromResource | |
| int | isResourceTagged (const KisTagSP tag, const int resourceId) |
| KisTagFilterResourceProxyModel (const QString &resourceType, QObject *parent=0) | |
| bool | reloadResource (KoResourceSP resource) override |
| reloadResource | |
| bool | renameResource (KoResourceSP resource, const QString &name) override |
| 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. | |
| KoResourceSP | resourceForIndex (QModelIndex index=QModelIndex()) const override |
| resourceForIndex returns a properly versioned and id'ed resource object | |
| void | setFilterInCurrentTag (bool filterInCurrentTag) |
| void | setMetaDataFilter (QMap< QString, QVariant > metaDataMap) |
| setMetaDataFilter provides a set of metadata to filter on, for instance by paintop id category. | |
| bool | setResourceActive (const QModelIndex &index, bool value) override |
| setResourceActive changes 'active' state of the resource | |
| void | setResourceFilter (const KoResourceSP resource) |
| setResourceFilter sets the resource to filter with | |
| void | setResourceFilter (ResourceFilter filter) override |
| bool | setResourceMetaData (KoResourceSP resource, QMap< QString, QVariant > metadata) override |
| setResourceMetaData | |
| void | setResourceModel (KisResourceModel *resourceModel) |
| void | setSearchText (const QString &searchText) |
| void | setStorageFilter (bool useFilter, int storageId) |
| void | setStorageFilter (StorageFilter filter) override |
| void | setTagFilter (const KisTagSP tag) |
| setTagFilter sets the tag to filter with | |
| bool | tagResources (const KisTagSP tag, const QVector< int > &resourceIds) |
| bool | untagResources (const KisTagSP tag, const QVector< int > &resourceIds) |
| bool | updateResource (KoResourceSP resource) override |
| 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. | |
| ~KisTagFilterResourceProxyModel () override | |
Public Member Functions inherited from KisAbstractResourceModel | |
| bool | setResourceInactive (const QModelIndex &index) |
| virtual | ~KisAbstractResourceModel () |
Public Member Functions inherited from KisAbstractResourceFilterInterface | |
| virtual | ~KisAbstractResourceFilterInterface () |
Protected Member Functions | |
| bool | filterAcceptsColumn (int source_column, const QModelIndex &source_parent) const override |
| bool | filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override |
| bool | lessThan (const QModelIndex &source_left, const QModelIndex &source_right) const override |
Private Member Functions | |
| void | updateTagFilter () |
Private Attributes | |
| Private *const | d |
Additional Inherited Members | |
Public Types inherited from KisAbstractResourceModel | |
| 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 Types inherited from KisAbstractResourceFilterInterface | |
| enum | ResourceFilter { ShowInactiveResources = 0 , ShowActiveResources , ShowAllResources } |
| enum | StorageFilter { ShowInactiveStorages = 0 , ShowActiveStorages , ShowAllStorages } |
The KisTagFilterResourceProxyModel class filters the resources by tag or resource name.
Definition at line 25 of file KisTagFilterResourceProxyModel.h.
| KisTagFilterResourceProxyModel::KisTagFilterResourceProxyModel | ( | const QString & | resourceType, |
| QObject * | parent = 0 ) |
Definition at line 43 of file KisTagFilterResourceProxyModel.cpp.
References d, KisTagFilterResourceProxyModel::Private::resourceModel, KisTagFilterResourceProxyModel::Private::resourceType, and KisTagFilterResourceProxyModel::Private::tagResourceModel.
|
override |
Definition at line 54 of file KisTagFilterResourceProxyModel.cpp.
References d, KisTagFilterResourceProxyModel::Private::resourceModel, and KisTagFilterResourceProxyModel::Private::tagResourceModel.
|
virtual |
additionalResourceNameChecks Some resources, like fonts, have multiple names that need to be tested. Implementers should override this function if they want additional checks on the name.
| resource | the resource index to test, this is provided by the model while testing each row. |
| filter,this | is the class that handles tokenisation, also provided by the model. |
Reimplemented in FontFamilyTagFilterModel.
Definition at line 207 of file KisTagFilterResourceProxyModel.cpp.
|
overridevirtual |
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 |
Implements KisAbstractResourceModel.
Definition at line 162 of file KisTagFilterResourceProxyModel.cpp.
References source().
|
signal |
|
signal |
| KisTagSP KisTagFilterResourceProxyModel::currentTagFilter | ( | ) | const |
currentTagFilter
Definition at line 228 of file KisTagFilterResourceProxyModel.cpp.
References KisTagFilterResourceProxyModel::Private::currentTagFilter, and d.
|
overridevirtual |
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 |
Implements KisAbstractResourceModel.
Definition at line 152 of file KisTagFilterResourceProxyModel.cpp.
References source().
|
overrideprotected |
Definition at line 342 of file KisTagFilterResourceProxyModel.cpp.
|
overrideprotected |
Definition at line 347 of file KisTagFilterResourceProxyModel.cpp.
References additionalResourceNameChecks(), d, KisTagFilterResourceProxyModel::Private::filter, KisAbstractResourceModel::Id, KisTagFilterResourceProxyModel::Private::metaDataMapFilter, KisResourceMetaDataModel::metaDataValue(), KisAbstractResourceModel::Name, ResourceType::PaintOpPresets, KisResourceModelProvider::resourceMetadataModel(), KisAbstractResourceModel::ResourceType, KisAbstractResourceModel::StorageId, KisTagFilterResourceProxyModel::Private::storageId, KisAbstractResourceModel::Tags, KisTagFilterResourceProxyModel::Private::useStorageIdFilter, and value().
| bool KisTagFilterResourceProxyModel::filterInCurrentTag | ( | ) | const |
Definition at line 322 of file KisTagFilterResourceProxyModel.cpp.
References d, and KisTagFilterResourceProxyModel::Private::filteringWithinCurrentTag.
|
overridevirtual |
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 |
Implements KisAbstractResourceModel.
Definition at line 136 of file KisTagFilterResourceProxyModel.cpp.
References source().
|
overridevirtual |
importResourceFile
| filename |
Implements KisAbstractResourceModel.
Definition at line 126 of file KisTagFilterResourceProxyModel.cpp.
References source().
|
overridevirtual |
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. |
Implements KisAbstractResourceModel.
Definition at line 146 of file KisTagFilterResourceProxyModel.cpp.
References source().
|
overridevirtual |
indexFromResource
| resource |
Implements KisAbstractResourceModel.
Definition at line 93 of file KisTagFilterResourceProxyModel.cpp.
|
overridevirtual |
indexFromResource
| resourceId | resource id for which we want to get an index |
Implements KisAbstractResourceModel.
Definition at line 107 of file KisTagFilterResourceProxyModel.cpp.
References source().
| int KisTagFilterResourceProxyModel::isResourceTagged | ( | const KisTagSP | tag, |
| const int | resourceId ) |
Definition at line 337 of file KisTagFilterResourceProxyModel.cpp.
References d, KisTagResourceModel::isResourceTagged(), and KisTagFilterResourceProxyModel::Private::tagResourceModel.
|
overrideprotected |
Definition at line 393 of file KisTagFilterResourceProxyModel.cpp.
References KisAbstractResourceModel::Name.
|
overridevirtual |
reloadResource
| resource |
Implements KisAbstractResourceModel.
Definition at line 180 of file KisTagFilterResourceProxyModel.cpp.
References source().
|
overridevirtual |
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 |
Implements KisAbstractResourceModel.
Definition at line 189 of file KisTagFilterResourceProxyModel.cpp.
References source().
|
overridevirtual |
resourceForIndex returns a properly versioned and id'ed resource object
Implements KisAbstractResourceModel.
Definition at line 84 of file KisTagFilterResourceProxyModel.cpp.
References source().
| void KisTagFilterResourceProxyModel::setFilterInCurrentTag | ( | bool | filterInCurrentTag | ) |
Definition at line 316 of file KisTagFilterResourceProxyModel.cpp.
References d, filterInCurrentTag(), KisTagFilterResourceProxyModel::Private::filteringWithinCurrentTag, and updateTagFilter().
| void KisTagFilterResourceProxyModel::setMetaDataFilter | ( | QMap< QString, QVariant > | metaDataMap | ) |
setMetaDataFilter provides a set of metadata to filter on, for instance by paintop id category.
| metaDataMap |
Definition at line 214 of file KisTagFilterResourceProxyModel.cpp.
References afterFilterChanged(), beforeFilterChanges(), d, and KisTagFilterResourceProxyModel::Private::metaDataMapFilter.
|
overridevirtual |
setResourceActive changes 'active' state of the resource
| index | the index of the resource |
| value | new 'active' state of the resource |
Implements KisAbstractResourceModel.
Definition at line 117 of file KisTagFilterResourceProxyModel.cpp.
| void KisTagFilterResourceProxyModel::setResourceFilter | ( | const KoResourceSP | resource | ) |
setResourceFilter sets the resource to filter with
| resource | a valid resource with a valid id, or 0 to clear the filter |
Definition at line 304 of file KisTagFilterResourceProxyModel.cpp.
References KisTagFilterResourceProxyModel::Private::currentResourceFilter, d, and updateTagFilter().
|
overridevirtual |
Select status of the resources that should be shown
Implements KisAbstractResourceFilterInterface.
Definition at line 61 of file KisTagFilterResourceProxyModel.cpp.
References afterFilterChanged(), beforeFilterChanges(), d, KisTagFilterResourceProxyModel::Private::resourceModel, KisResourceModel::setResourceFilter(), KisTagResourceModel::setResourceFilter(), and KisTagFilterResourceProxyModel::Private::tagResourceModel.
|
overridevirtual |
setResourceMetaData
| metadata |
Implements KisAbstractResourceModel.
Definition at line 198 of file KisTagFilterResourceProxyModel.cpp.
References source().
| void KisTagFilterResourceProxyModel::setResourceModel | ( | KisResourceModel * | resourceModel | ) |
Definition at line 79 of file KisTagFilterResourceProxyModel.cpp.
References d, and KisTagFilterResourceProxyModel::Private::resourceModel.
| void KisTagFilterResourceProxyModel::setSearchText | ( | const QString & | searchText | ) |
Definition at line 310 of file KisTagFilterResourceProxyModel.cpp.
References d, KisTagFilterResourceProxyModel::Private::filter, and updateTagFilter().
| void KisTagFilterResourceProxyModel::setStorageFilter | ( | bool | useFilter, |
| int | storageId ) |
Definition at line 233 of file KisTagFilterResourceProxyModel.cpp.
References afterFilterChanged(), beforeFilterChanges(), d, KisTagFilterResourceProxyModel::Private::storageId, and KisTagFilterResourceProxyModel::Private::useStorageIdFilter.
|
overridevirtual |
Select status of the storages that should be shown
Implements KisAbstractResourceFilterInterface.
Definition at line 70 of file KisTagFilterResourceProxyModel.cpp.
References afterFilterChanged(), beforeFilterChanges(), d, KisTagFilterResourceProxyModel::Private::resourceModel, KisResourceModel::setStorageFilter(), KisTagResourceModel::setStorageFilter(), and KisTagFilterResourceProxyModel::Private::tagResourceModel.
setTagFilter sets the tag to filter with
| tag | a valid tag with a valid id, or 0 to clear the filter |
Definition at line 222 of file KisTagFilterResourceProxyModel.cpp.
References KisTagFilterResourceProxyModel::Private::currentTagFilter, d, and updateTagFilter().
| bool KisTagFilterResourceProxyModel::tagResources | ( | const KisTagSP | tag, |
| const QVector< int > & | resourceIds ) |
Definition at line 327 of file KisTagFilterResourceProxyModel.cpp.
References d, KisTagFilterResourceProxyModel::Private::tagResourceModel, and KisTagResourceModel::tagResources().
| bool KisTagFilterResourceProxyModel::untagResources | ( | const KisTagSP | tag, |
| const QVector< int > & | resourceIds ) |
Definition at line 332 of file KisTagFilterResourceProxyModel.cpp.
References d, KisTagFilterResourceProxyModel::Private::tagResourceModel, and KisTagResourceModel::untagResources().
|
overridevirtual |
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 |
Implements KisAbstractResourceModel.
Definition at line 171 of file KisTagFilterResourceProxyModel.cpp.
References source().
|
private |
Definition at line 244 of file KisTagFilterResourceProxyModel.cpp.
References afterFilterChanged(), beforeFilterChanges(), KisTagFilterResourceProxyModel::Private::currentResourceFilter, KisTagFilterResourceProxyModel::Private::currentTagFilter, d, KisTagFilterResourceProxyModel::Private::filter, KisTagFilterResourceProxyModel::Private::filteringWithinCurrentTag, KIS_SAFE_ASSERT_RECOVER_NOOP, KisTagFilterResourceProxyModel::Private::resourceModel, KisTagResourceModel::setResourcesFilter(), KisTagResourceModel::setTagsFilter(), KisResourceModel::showOnlyUntaggedResources(), KisTagFilterResourceProxyModel::Private::tagResourceModel, KisAllTagsModel::urlAll(), and KisAllTagsModel::urlAllUntagged().
|
private |
Definition at line 123 of file KisTagFilterResourceProxyModel.h.