digiKam Developer Documentation: Digikam::ItemFilterModel Class Reference

| digiKam Developer Documentation Professional Photo Management with the Power of Open Source

Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
Digikam::ItemFilterModel Class Reference
Inheritance diagram for Digikam::ItemFilterModel:

## Public Types
enum | ItemFilterModelRoles { CategorizationModeRole = ItemModel::FilterModelRoles + 1 , SortOrderRole = ItemModel::FilterModelRoles + 2 , CategoryAlbumIdRole = ItemModel::FilterModelRoles + 3 , CategoryFormatRole = ItemModel::FilterModelRoles + 4 , CategoryDateRole = ItemModel::FilterModelRoles + 5 , CategoryFaceRole = ItemModel::FilterModelRoles + 6 , GroupIsOpenRole = ItemModel::FilterModelRoles + 7 , ItemFilterModelPointerRole = ItemModel::FilterModelRoles + 50 }
Public Types inherited from Digikam::DCategorizedSortFilterProxyModel
enum | AdditionalRoles { CategoryDisplayRole = 0x17CE990A , CategorySortRole = 0x27857E60 }

## Public Slots
void | setAllGroupsOpen (bool open)
void | setCategorizationMode (ItemSortSettings::CategorizationMode mode)
void | setCategorizationSortOrder (ItemSortSettings::SortOrder order)
void | setDayFilter (const QList< QDateTime > &days)
| Adjust the current ItemFilterSettings.
void | setExceptionList (const QList< qlonglong > &idlist, const QString &id)
void | setGeolocationFilter (const ItemFilterSettings::GeolocationCondition &condition)
void | setGroupItemFilterSettings (const GroupItemFilterSettings &settings)
| Changes the current version image filter settings and refilters.
void | setGroupOpen (qlonglong group, bool open)
void | setIdWhitelist (const QList< qlonglong > &idList, const QString &id)
virtual void | setItemFilterSettings (const ItemFilterSettings &settings)
| Changes the current image filter settings and refilters.
virtual void | setItemSortSettings (const ItemSortSettings &settings)
| Changes the current image sort settings and resorts.
void | setMimeTypeFilter (int mimeTypeFilter)
void | setRatingFilter (int rating, ItemFilterSettings::RatingCondition ratingCond, bool isUnratedExcluded)
void | setSortOrder (ItemSortSettings::SortOrder order)
void | setSortRole (ItemSortSettings::SortRole role)
void | setStringTypeNatural (bool natural)
void | setTagFilter (const QList< int > &includedTags, const QList< int > &excludedTags, ItemFilterSettings::MatchingCondition matchingCond, bool showUnTagged, const QList< int > &clTagIds, const QList< int > &plTagIds)
void | setTextFilter (const SearchTextFilterSettings &settings)
void | setUrlWhitelist (const QList< QUrl > &urlList, const QString &id)
void | setVersionItemFilterSettings (const VersionItemFilterSettings &settings)
| Changes the current version image filter settings and refilters.
void | setVersionManagerSettings (const VersionManagerSettings &settings)
void | toggleGroupOpen (qlonglong group)

## Signals
void | filterMatches (bool matches)
| Signals that the set filter matches at least one index.
void | filterMatchesForText (bool matchesByText)
| Signals that the set text filter matches at least one entry.
void | filterSettingsChanged (const ItemFilterSettings &settings)
| Emitted when the filter settings have been changed (the model may not yet have been updated)
void | imageInfosAboutToBeRemoved (const QList< ItemInfo > &infos)
void | imageInfosAdded (const QList< ItemInfo > &infos)
| These signals need to be explicitly enabled with setSendItemInfoSignals()
void | signalGroupIsOpen (qlonglong group, bool open)
| This signal is emitted when a group is open or closed.

## Public Member Functions
| ItemFilterModel (QObject *const parent=nullptr)
void | addPrepareHook (ItemFilterModelPrepareHook *const hook)
| Add a hook to get added images for preparation tasks before they are added in the model.
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override
GroupItemFilterSettings | groupItemFilterSettings () const
ItemFilterModel * | imageFilterModel () const override
ItemFilterSettings | imageFilterSettings () const
ItemSortSettings | imageSortSettings () const
bool | isAllGroupsOpen () const
bool | isGroupOpen (qlonglong group) const
| Group is identified by the id of its group leader.
void | removePrepareHook (ItemFilterModelPrepareHook *const hook)
void | setSendItemInfoSignals (bool sendSignals)
| Enables sending imageInfosAdded and imageInfosAboutToBeRemoved.
DatabaseFields::Set | suggestedWatchFlags () const
VersionItemFilterSettings | versionItemFilterSettings () const
Public Member Functions inherited from Digikam::ImageSortFilterModel
| ImageSortFilterModel (QObject *const parent=nullptr)
qlonglong | imageId (const QModelIndex &index) const
QList< qlonglong > | imageIds (const QList< QModelIndex > &indexes) const
ItemInfo | imageInfo (const QModelIndex &index) const
QList< ItemInfo > | imageInfos (const QList< QModelIndex > &indexes) const
QList< ItemInfo > | imageInfosSorted () const
QModelIndex | indexForImageId (qlonglong id) const
QModelIndex | indexForItemInfo (const ItemInfo &info) const
QModelIndex | indexForPath (const QString &filePath) const
QModelIndex | mapFromDirectSourceToSourceItemModel (const QModelIndex &sourceModel_index) const
QModelIndex | mapFromSourceItemModel (const QModelIndex &imagemodel_index) const
QList< QModelIndex > | mapListFromSource (const QList< QModelIndex > &sourceIndexes) const
QList< QModelIndex > | mapListToSource (const QList< QModelIndex > &indexes) const
| Convenience methods mapped to ItemModel.
QModelIndex | mapToSourceItemModel (const QModelIndex &index) const
void | setSourceFilterModel (ImageSortFilterModel *const model)
void | setSourceItemModel (ItemModel *const model)
ImageSortFilterModel * | sourceFilterModel () const
ItemModel * | sourceItemModel () const
Public Member Functions inherited from Digikam::DCategorizedSortFilterProxyModel
| DCategorizedSortFilterProxyModel (QObject *const parent=nullptr)
bool | isCategorizedModel () const
void | setCategorizedModel (bool categorizedModel)
| Enables or disables the categorization feature.
void | setSortCategoriesByNaturalComparison (bool sortCategoriesByNaturalComparison)
| Set if the sorting using CategorySortRole will use a natural comparison in the case that strings were returned.
void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override
| Overridden from QSortFilterProxyModel.
bool | sortCategoriesByNaturalComparison () const
int | sortColumn () const
Qt::SortOrder | sortOrder () const

## Protected Slots
void | slotImageChange (const ImageChangeset &changeset)
void | slotImageTagChange (const ImageTagChangeset &changeset)
void | slotModelReset ()
void | slotRowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
void | slotRowsInserted (const QModelIndex &parent, int start, int end)
void | slotUpdateFilter ()

## Protected Member Functions
| ItemFilterModel (ItemFilterModelPrivate &dd, QObject *const parent)
virtual QString | categoryIdentifier (const ItemInfo &info, const FaceTagsIface &face) const
int | compareCategories (const QModelIndex &left, const QModelIndex &right) const override
| This method compares the category of the `left` index with the category of the `right` index.
virtual int | compareInfosCategories (const ItemInfo &left, const ItemInfo &right) const
| Reimplement to customize category sorting,.
virtual int | compareInfosCategories (const ItemInfo &left, const ItemInfo &right, const FaceTagsIface &leftFace, const FaceTagsIface &rightFace) const
| In order to be able to Categorize by Faces, it's necessary to pass in the face as well.
bool | filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override
virtual bool | infosLessThan (const ItemInfo &left, const ItemInfo &right) const
| Reimplement to customize sorting.
void | setDirectSourceItemModel (ItemModel *const model) override
| Reimplement if needed.
bool | subSortLessThan (const QModelIndex &left, const QModelIndex &right) const override
| This method has a similar purpose as lessThan() has on QSortFilterProxyModel.
Protected Member Functions inherited from Digikam::ImageSortFilterModel
void | setSourceModel (QAbstractItemModel *const model) override
Protected Member Functions inherited from Digikam::DCategorizedSortFilterProxyModel
bool | lessThan (const QModelIndex &left, const QModelIndex &right) const override
| Overridden from QSortFilterProxyModel.

## Protected Attributes
ItemFilterModelPrivate *const | d_ptr = nullptr
Protected Attributes inherited from Digikam::ImageSortFilterModel
ImageSortFilterModel * | m_chainedModel = nullptr

## Member Enumeration Documentation

## ◆ ItemFilterModelRoles

enum Digikam::ItemFilterModel::ItemFilterModelRoles

Enumerator
CategorizationModeRole | Returns The current categorization mode
SortOrderRole | Returns The current sort order
CategoryAlbumIdRole | Returns The number of items in the index category The id of the PAlbum of the index which is used for category
CategoryFormatRole | Returns The format of the index which is used for category
CategoryDateRole | Returns The date of the index which is used for category
CategoryFaceRole | Returns The suggested name for the face in this index
GroupIsOpenRole | Returns True if the given image is a group leader, and the group is opened

## Member Function Documentation

## ◆ categoryIdentifier()

QString Digikam::ItemFilterModel::categoryIdentifier | ( | const ItemInfo & | info,
|  | const FaceTagsIface & | face
| ) |  | const
| protectedvirtual

Returns
  A unique identifier for the category if info. The string need not be for user display.

## ◆ compareCategories()

int Digikam::ItemFilterModel::compareCategories | ( | const QModelIndex & | left,
|  | const QModelIndex & | right
| ) |  | const
| overrideprotectedvirtual

Internally and if not reimplemented, this method will ask for `left` and `right` models for role CategorySortRole. In order to correctly sort categories, the data() method of the model should return a qlonglong (or numeric) value, or a QString object. QString objects will be sorted with QString::localeAwareCompare if sortCategoriesByNaturalComparison() is true.

Note
  Please have present that: QString(QChar(QChar::ObjectReplacementCharacter)) > QString(QChar(QChar::ReplacementCharacter)) > [ all possible strings ] > QString();

This means that QString() will be sorted the first one, while QString(QChar(QChar::ObjectReplacementCharacter)) and QString(QChar(QChar::ReplacementCharacter)) will be sorted in last position.

Warning
  Please note that data() method of the model should return always information of the same type. If you return a QString for an index, you should return always QStrings for all indexes for role CategorySortRole in order to correctly sort categories. You cannot mix by returning a QString for one index, and a qlonglong for other.

Note
  If you need a more complex layout, you will have to reimplement this method.

Returns
  A negative value if the category of `left` should be placed before the category of `right`. 0 if `left` and `right` are on the same category, and a positive value if the category of `left` should be placed after the category of `right`.

Reimplemented from Digikam::DCategorizedSortFilterProxyModel.

## ◆ compareInfosCategories() [1/2]

int Digikam::ItemFilterModel::compareInfosCategories | ( | const ItemInfo & | left,
|  | const ItemInfo & | right
| ) |  | const
| protectedvirtual

Returns
  negative if category of left < category right, or 0 if left and right are in the same category, else return positive.

Reimplemented in Digikam::ItemAlbumFilterModel.

## ◆ compareInfosCategories() [2/2]

int Digikam::ItemFilterModel::compareInfosCategories | ( | const ItemInfo & | left,
|  | const ItemInfo & | right,
|  | const FaceTagsIface & | leftFace,
|  | const FaceTagsIface & | rightFace
| ) |  | const
| protectedvirtual

One image may have multiple Faces in it, hence just the ItemInfo isn't sufficient.

Reimplemented in Digikam::ItemAlbumFilterModel.

## ◆ data()

QVariant Digikam::ItemFilterModel::data | ( | const QModelIndex & | index,
|  | int | role = `Qt::DisplayRole`
| ) |  | const
| override

Keeping track of the Face (if any) associated with this Model Index is important to allow categorization by Face.

## ◆ filterMatchesForText

void Digikam::ItemFilterModel::filterMatchesForText | ( | bool | matchesByText | ) |
| signal

If no text filter is set, this signal is emitted with 'false' when filterMatches() is emitted.

## ◆ imageFilterModel()

ItemFilterModel * Digikam::ItemFilterModel::imageFilterModel | ( |  | ) | const
| overridevirtual

Returns
  This instance if any chained ItemFilterModel, or nullptr.

Reimplemented from Digikam::ImageSortFilterModel.

## ◆ infosLessThan()

bool Digikam::ItemFilterModel::infosLessThan | ( | const ItemInfo & | left,
|  | const ItemInfo & | right
| ) |  | const
| protectedvirtual

Do not take categories into account here.

## ◆ setDayFilter

void Digikam::ItemFilterModel::setDayFilter | ( | const QList< QDateTime > & | days | ) |
| slot

Equivalent to retrieving the current filter settings, adjusting the parameter and calling setItemFilterSettings. Provided for convenience. It is encouraged to use setItemFilterSettings if you change more than one parameter at a time.

## ◆ setDirectSourceItemModel()

void Digikam::ItemFilterModel::setDirectSourceItemModel | ( | ItemModel *const | model | ) |
| overrideprotectedvirtual

Called only when model shall be set as (direct) sourceModel.

Reimplemented from Digikam::ImageSortFilterModel.

## ◆ setItemFilterSettings

void Digikam::ItemFilterModel::setItemFilterSettings | ( | const ItemFilterSettings & | settings | ) |
| virtualslot

Reimplemented in Digikam::ItemAlbumFilterModel.

## ◆ subSortLessThan()

bool Digikam::ItemFilterModel::subSortLessThan | ( | const QModelIndex & | left,
|  | const QModelIndex & | right
| ) |  | const
| overrideprotectedvirtual

It is used for sorting items that are in the same category.

Returns
  Returns true if the item `left` is less than the item `right` when sorting.

Reimplemented from Digikam::DCategorizedSortFilterProxyModel.

## ◆ suggestedWatchFlags()

DatabaseFields::Set Digikam::ItemFilterModel::suggestedWatchFlags | ( |  | ) | const

Returns
  a set of DatabaseFields suggested to set as watch flags on the source ItemModel. The contained flags will be those that this model can sort or filter by.