Krita Source Code Documentation
Loading...
Searching...
No Matches
FontFamilyTagFilterModel Class Reference

#include <TagFilterProxyModelQmlWrapper.h>

+ Inheritance diagram for FontFamilyTagFilterModel:

Public Member Functions

bool additionalResourceNameChecks (const QModelIndex &index, const KisResourceSearchBoxFilter *filter) const override
 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.
 
QVariant data (const QModelIndex &index, int role) const override
 
 FontFamilyTagFilterModel (QObject *parent=nullptr)
 
- Public Member Functions inherited from KisTagFilterResourceProxyModel
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 ()
 

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 }
 
- Signals inherited from KisTagFilterResourceProxyModel
void afterFilterChanged ()
 
void beforeFilterChanges ()
 
- Protected Member Functions inherited from KisTagFilterResourceProxyModel
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
 

Detailed Description

Definition at line 150 of file TagFilterProxyModelQmlWrapper.h.

Constructor & Destructor Documentation

◆ FontFamilyTagFilterModel()

FontFamilyTagFilterModel::FontFamilyTagFilterModel ( QObject * parent = nullptr)

Definition at line 384 of file TagFilterProxyModelQmlWrapper.cpp.

386{
387}
KisTagFilterResourceProxyModel(const QString &resourceType, QObject *parent=0)
const QString FontFamilies

Member Function Documentation

◆ additionalResourceNameChecks()

bool FontFamilyTagFilterModel::additionalResourceNameChecks ( const QModelIndex & index,
const KisResourceSearchBoxFilter * filter ) const
overridevirtual

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.

Parameters
resourcethe resource index to test, this is provided by the model while testing each row.
filter,thisis the class that handles tokenisation, also provided by the model.
Returns
should return whether the current resource should be accepted by the given filter.

Reimplemented from KisTagFilterResourceProxyModel.

Definition at line 420 of file TagFilterProxyModelQmlWrapper.cpp.

421{
422 bool match = false;
423 if (index.isValid()) {
424 const QStringList resourceTags = sourceModel()->data(index, Qt::UserRole + KisAbstractResourceModel::Tags).toStringList();
425
427 const int resourceId = sourceModel()->data(index, Qt::UserRole + KisResourceModel::Id).toInt();
428 const QVariantMap localizedNames = metadataModel->metaDataValue(resourceId, "localized_font_family").toMap();
429
430 Q_FOREACH(const QVariant localizedName, localizedNames.values()) {
431 match = filter->matchesResource(localizedName.toString(), resourceTags);
432 if (match) {
433 break;
434 }
435 }
436 }
437 return match;
438}
QVariant metaDataValue(int resourceId, const QString &key)
static KisResourceMetaDataModel * resourceMetadataModel()
bool matchesResource(const QString &resourceName, const QStringList &tagList) const

References KisAbstractResourceModel::Id, KisResourceSearchBoxFilter::matchesResource(), KisResourceMetaDataModel::metaDataValue(), KisResourceModelProvider::resourceMetadataModel(), and KisAbstractResourceModel::Tags.

◆ data()

QVariant FontFamilyTagFilterModel::data ( const QModelIndex & index,
int role ) const
override

Definition at line 389 of file TagFilterProxyModelQmlWrapper.cpp.

390{
391 QModelIndex sourceIdx = mapToSource(index);
392 if (sourceIdx.isValid()) {
393 if (role == (Qt::UserRole + KisAbstractResourceModel::Name)) {
394 const int resourceId = sourceModel()->data(sourceIdx, Qt::UserRole + KisAbstractResourceModel::Id).toInt();
395 const QVariantMap localizedNames = KisResourceModelProvider::resourceMetadataModel()->metaDataValue(resourceId, "localized_font_family").toMap();
396 const QString fallBack = sourceModel()->data(sourceIdx, Qt::UserRole + KisAbstractResourceModel::Name).toString();
397 QString name = fallBack.isEmpty()? localizedNames.value("en").toString(): fallBack;
398
399 // the return type of KLocalizedString::languages() is different
400 // between Qt5 and Qt6, so just use `auto` to ignore that
401 for (const auto &locale : KLocalizedString::languages()) {
402 bool found = false;
403 Q_FOREACH(const QString key, localizedNames.keys()) {
404 if (QLocale(key) == QLocale(locale)) {
405 name = localizedNames.value(key, name).toString();
406 found = true;
407 break;
408 }
409 }
410 if (found) break;
411 }
412 return name;
413 } else {
414 return sourceModel()->data(sourceIdx, role);
415 }
416 }
417 return QVariant();
418}
const char * name(StandardAction id)

References KisAbstractResourceModel::Id, KisResourceMetaDataModel::metaDataValue(), KisAbstractResourceModel::Name, and KisResourceModelProvider::resourceMetadataModel().


The documentation for this class was generated from the following files: