digiKam Developer Documentation
Professional Photo Management with the Power of Open Source
Loading...
Searching...
No Matches
Digikam::AlbumFilterModel Class Reference
+ Inheritance diagram for Digikam::AlbumFilterModel:

Public Types

enum  FilterBehavior { SimpleFiltering , FullFiltering , StrictFiltering }
 
enum  MatchResult {
  NoMatch = 0 , DirectMatch , ParentMatch , ChildMatch ,
  SpecialMatch
}
 

Public Slots

void setSearchTextSettings (const SearchTextSettings &settings)
 Accepts new settings used for filtering and applies them to the model.
 

Signals

void hasSearchResult (bool hasResult)
 Indicates whether the newly applied filter results in a search result or not.
 
void searchTextSettingsAboutToChange (bool searched, bool willSearch)
 This signal indicates that a new SearchTextSettings arrived and is about to be applied to the model.
 
void searchTextSettingsChanged (bool wasSearching, bool searched)
 Indicates that new search text settings were applied.
 
void signalFilterChanged ()
 Indicates that a new filter was applied to the model.
 

Public Member Functions

 AlbumFilterModel (QObject *const parent=nullptr)
 
AlbumalbumForIndex (const QModelIndex &index) const
 Convenience methods.
 
QVariant dataForCurrentSortRole (Album *album) const
 
QModelIndex indexForAlbum (Album *album) const
 
virtual bool isFiltering () const
 Returns if the currently applied filters will result in any filtering.
 
QModelIndex mapFromSourceAlbumModel (const QModelIndex &index) const
 
QModelIndex mapToSourceAlbumModel (const QModelIndex &index) const
 
MatchResult matchResult (const QModelIndex &index) const
 Returns the MatchResult of an index of this model.
 
QModelIndex rootAlbumIndex () const
 
SearchTextSettings searchTextSettings () const
 Returns the settings currently used for filtering.
 
void setFilterBehavior (FilterBehavior behavior)
 Sets the filter behavior.
 
void setSourceAlbumModel (AbstractAlbumModel *const source)
 Sets the source model.
 
void setSourceFilterModel (AlbumFilterModel *const source)
 Sets a chained filter model.
 
AbstractAlbumModelsourceAlbumModel () const
 
AlbumFilterModelsourceFilterModel () const
 
void updateFilter ()
 Force invalidateFilter() externally.
 

Static Public Member Functions

template<typename T >
static int compareByOrder (const T &a, const T &b, Qt::SortOrder sortOrder)
 
static int compareByOrder (int compareResult, Qt::SortOrder sortOrder)
 Takes a typical result from a compare method (0 is equal, -1 is less than, 1 is greater than) and applies the given sort order to it.
 
template<typename T >
static int compareValue (const T &a, const T &b)
 Returns the usual compare result of -1, 0, or 1 for lessThan, equals and greaterThan.
 

Protected Slots

void slotAlbumRenamed (Album *album)
 
void slotAlbumsHaveBeenUpdated (int type)
 

Protected Member Functions

bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override
 
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override
 
virtual bool matches (Album *album) const
 This method provides the basic match checking algorithm.
 
MatchResult matchResult (Album *album) const
 Returns if the filter matches this album (same logic as filterAcceptsRow).
 
void setSourceModel (QAbstractItemModel *const model) override
 Use setSourceAlbumModel.
 

Protected Attributes

QPointer< AlbumFilterModelm_chainedModel = nullptr
 
FilterBehavior m_filterBehavior = FullFiltering
 
QObject * m_parent = nullptr
 
SearchTextSettings m_settings
 

Member Enumeration Documentation

◆ FilterBehavior

Enumerator
SimpleFiltering 

If an index does not matched, the index and all its children are filtered out.

This is the Qt default behavior, but undesirable for album trees.

FullFiltering 

Default behavior.

If an index matches, it is shown, which directly means all its parents are shown as well. In addition, all its children are shown as well.

StrictFiltering 

If an index matches, it is shown, which directly means all its parents are shown as well.

Its children are not shown unless they also match.

◆ MatchResult

Enumerator
NoMatch 

This enum can be used as a boolean value if match/no match only is needed.

DirectMatch 

The index itself is matched.

ParentMatch 

A parent if the index is matched.

ChildMatch 

A child of the index is matched.

SpecialMatch 

The index is matched not because of search settings, but because it has a special type.

Member Function Documentation

◆ hasSearchResult

void Digikam::AlbumFilterModel::hasSearchResult ( bool  hasResult)
signal
Parameters
hasResulttrue if the new filter matches any album, else false

◆ isFiltering()

bool Digikam::AlbumFilterModel::isFiltering ( ) const
virtual
Returns
true if the current selected filter could result in any filtering without checking if this really happens.

Reimplemented in Digikam::CheckableAlbumFilterModel, Digikam::SearchFilterModel, and Digikam::TagPropertiesFilterModel.

◆ lessThan()

bool Digikam::AlbumFilterModel::lessThan ( const QModelIndex &  left,
const QModelIndex &  right 
) const
overrideprotected

Implementation to sort Tags that contain Unconfirmed Faces, according to the Unconfirmed Face Count.

◆ matches()

bool Digikam::AlbumFilterModel::matches ( Album album) const
protectedvirtual

Return true if this single album matches the current criteria. This method can be overridden to provide custom filtering.

Parameters
albumthe album to tell if it matches the filter criteria or not.

Reimplemented in Digikam::CheckableAlbumFilterModel, Digikam::SearchFilterModel, Digikam::TagPropertiesFilterModel, and Digikam::TagsManagerFilterModel.

◆ matchResult() [1/2]

AlbumFilterModel::MatchResult Digikam::AlbumFilterModel::matchResult ( Album album) const
protected

An album matches if the search text settings are found in a parent album's title, in the album's title or in a child album's title, or if it is a special album (root) that is never filtered out.

◆ matchResult() [2/2]

AlbumFilterModel::MatchResult Digikam::AlbumFilterModel::matchResult ( const QModelIndex &  index) const

Never returns NoMatch for a valid index, because in this case, the index would rather be filtered out.

◆ searchTextSettings()

SearchTextSettings Digikam::AlbumFilterModel::searchTextSettings ( ) const
Returns
current settings for filtering.

◆ searchTextSettingsAboutToChange

void Digikam::AlbumFilterModel::searchTextSettingsAboutToChange ( bool  searched,
bool  willSearch 
)
signal
Parameters
searchedtrue if filtering by text was enabled before applying the new settings
willSearchtrue if the new settings can result in any filtering by text, else false.

◆ searchTextSettingsChanged

void Digikam::AlbumFilterModel::searchTextSettingsChanged ( bool  wasSearching,
bool  searched 
)
signal
Parameters
wasSearchingtrue if this is not a new search that
searchedtrue if the new settings result in any filtering

◆ setFilterBehavior()

void Digikam::AlbumFilterModel::setFilterBehavior ( FilterBehavior  behavior)

Default is FullFiltering.

◆ setSearchTextSettings

void Digikam::AlbumFilterModel::setSearchTextSettings ( const SearchTextSettings settings)
slot
Parameters
settingsnew settings to apply. An empty text will be interpreted as no filtering

◆ setSourceAlbumModel()

void Digikam::AlbumFilterModel::setSourceAlbumModel ( AbstractAlbumModel *const  source)

Note: If a chained filter model is set, it will not be reset, but the source album model will be made source of the chained filter model.

◆ setSourceFilterModel()

void Digikam::AlbumFilterModel::setSourceFilterModel ( AlbumFilterModel *const  source)

Note: If a direct source album model is set as current source, it will be set as sourceAlbumModel of the new source filter model.

◆ setSourceModel()

void Digikam::AlbumFilterModel::setSourceModel ( QAbstractItemModel *const  model)
overrideprotected
See also
setSourceAlbumModel
Parameters
modelsource model