digiKam
Digikam::CheckableAlbumFilterModel Class Reference
+ Inheritance diagram for Digikam::CheckableAlbumFilterModel:

Public Types

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

Public Slots

void setSearchTextSettings (const SearchTextSettings &settings)
 

Signals

void hasSearchResult (bool hasResult)
 
void searchTextSettingsAboutToChange (bool searched, bool willSearch)
 
void searchTextSettingsChanged (bool wasSearching, bool searched)
 
void signalFilterChanged ()
 

Public Member Functions

AlbumalbumForIndex (const QModelIndex &index) const
 Convenience methods. More...
 
 CheckableAlbumFilterModel (QObject *const parent=nullptr)
 
QVariant dataForCurrentSortRole (Album *album) const
 
QModelIndex indexForAlbum (Album *album) const
 
bool isFiltering () const override
 
QModelIndex mapFromSourceAlbumModel (const QModelIndex &index) const
 
QModelIndex mapToSourceAlbumModel (const QModelIndex &index) const
 
MatchResult matchResult (const QModelIndex &index) const
 
QModelIndex rootAlbumIndex () const
 
SearchTextSettings searchTextSettings () const
 
void setFilterBehavior (FilterBehavior behavior)
 
void setFilterChecked (bool filter)
 
void setFilterPartiallyChecked (bool filter)
 
void setSourceAlbumModel (AbstractAlbumModel *const source)
 
void setSourceAlbumModel (AbstractCheckableAlbumModel *const source)
 
void setSourceFilterModel (AlbumFilterModel *const source)
 
void setSourceFilterModel (CheckableAlbumFilterModel *const source)
 
AbstractCheckableAlbumModelsourceAlbumModel () const
 
AlbumFilterModelsourceFilterModel () const
 
void updateFilter ()
 

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)
 
template<typename T >
static int compareValue (const T &a, const T &b)
 

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
 
bool matches (Album *album) const override
 
MatchResult matchResult (Album *album) const
 
void setSourceModel (QAbstractItemModel *const model) override
 

Protected Attributes

QPointer< AlbumFilterModelm_chainedModel
 
FilterBehavior m_filterBehavior
 
bool m_filterChecked
 
bool m_filterPartiallyChecked
 
QObject * m_parent
 
SearchTextSettings m_settings
 

Detailed Description

Filter model for checkable album models that allows more filtering options based on check state.

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.

Constructor & Destructor Documentation

◆ CheckableAlbumFilterModel()

Digikam::CheckableAlbumFilterModel::CheckableAlbumFilterModel ( QObject *const  parent = nullptr)
explicit

Member Function Documentation

◆ albumForIndex()

◆ compareByOrder() [1/2]

template<typename T >
static int Digikam::AlbumFilterModel::compareByOrder ( const T a,
const T b,
Qt::SortOrder  sortOrder 
)
inlinestaticinherited

◆ compareByOrder() [2/2]

static int Digikam::AlbumFilterModel::compareByOrder ( int  compareResult,
Qt::SortOrder  sortOrder 
)
inlinestaticinherited

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.

Referenced by Digikam::AlbumFilterModel::lessThan().

◆ compareValue()

template<typename T >
static int Digikam::AlbumFilterModel::compareValue ( const T a,
const T b 
)
inlinestaticinherited

Returns the usual compare result of -1, 0, or 1 for lessThan, equals and greaterThan.

◆ dataForCurrentSortRole()

◆ filterAcceptsRow()

bool Digikam::AlbumFilterModel::filterAcceptsRow ( int  source_row,
const QModelIndex &  source_parent 
) const
overrideprotectedinherited

◆ hasSearchResult

void Digikam::AlbumFilterModel::hasSearchResult ( bool  hasResult)
signalinherited

Indicates whether the newly applied filter results in a search result or not.

Parameters
hasResulttrue if the new filter matches any album, else false

Referenced by Digikam::AlbumFilterModel::setSearchTextSettings().

◆ indexForAlbum()

◆ isFiltering()

bool Digikam::CheckableAlbumFilterModel::isFiltering ( ) const
overridevirtual

Returns if the currently applied filters will result in any filtering.

Returns
true if the current selected filter could result in any filtering without checking if this really happens.

Reimplemented from Digikam::AlbumFilterModel.

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

References Digikam::AlbumFilterModel::isFiltering(), m_filterChecked, and m_filterPartiallyChecked.

◆ lessThan()

◆ mapFromSourceAlbumModel()

QModelIndex Digikam::AlbumFilterModel::mapFromSourceAlbumModel ( const QModelIndex &  index) const
inherited

◆ mapToSourceAlbumModel()

QModelIndex Digikam::AlbumFilterModel::mapToSourceAlbumModel ( const QModelIndex &  index) const
inherited

◆ matches()

bool Digikam::CheckableAlbumFilterModel::matches ( Album album) const
overrideprotectedvirtual

This method provides the basic match checking algorithm. 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 from Digikam::AlbumFilterModel.

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

References Digikam::AbstractCheckableAlbumModel::checkState(), m_filterChecked, m_filterPartiallyChecked, Digikam::AlbumFilterModel::matches(), and sourceAlbumModel().

Referenced by Digikam::SearchFilterModel::matches(), and Digikam::TagPropertiesFilterModel::matches().

◆ matchResult() [1/2]

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

◆ matchResult() [2/2]

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

Returns the MatchResult of an index of this model. Never returns NoMatch for a valid index, because in this case, the index would rather be filtered out.

References Digikam::AlbumFilterModel::albumForIndex().

Referenced by Digikam::AbstractAlbumTreeView::expandMatches(), and Digikam::AlbumFilterModel::filterAcceptsRow().

◆ rootAlbumIndex()

◆ searchTextSettings()

SearchTextSettings Digikam::AlbumFilterModel::searchTextSettings ( ) const
inherited

Returns the settings currently used for filtering.

Returns
current settings for filtering.

References Digikam::AlbumFilterModel::m_settings.

◆ searchTextSettingsAboutToChange

void Digikam::AlbumFilterModel::searchTextSettingsAboutToChange ( bool  searched,
bool  willSearch 
)
signalinherited

This signal indicates that a new SearchTextSettings arrived and is about to be applied to the model.

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.

Referenced by Digikam::AlbumFilterModel::setSearchTextSettings().

◆ searchTextSettingsChanged

void Digikam::AlbumFilterModel::searchTextSettingsChanged ( bool  wasSearching,
bool  searched 
)
signalinherited

Indicates that new search text settings were applied.

Parameters
wasSearchingtrue if this is not a new search that
searchedtrue if the new settings result in any filtering

Referenced by Digikam::AlbumFilterModel::setSearchTextSettings().

◆ setFilterBehavior()

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

Sets the filter behavior. Default is FullFiltering.

References Digikam::AlbumFilterModel::m_filterBehavior.

◆ setFilterChecked()

void Digikam::CheckableAlbumFilterModel::setFilterChecked ( bool  filter)

◆ setFilterPartiallyChecked()

void Digikam::CheckableAlbumFilterModel::setFilterPartiallyChecked ( bool  filter)

◆ setSearchTextSettings

◆ setSourceAlbumModel() [1/2]

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

Sets the source model. 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.

References Digikam::AlbumFilterModel::m_chainedModel, and Digikam::AlbumFilterModel::setSourceModel().

Referenced by Digikam::AbstractAlbumTreeView::setAlbumFilterModel(), Digikam::AbstractAlbumTreeView::setAlbumModel(), Digikam::SearchFilterModel::setSourceAlbumModel(), setSourceAlbumModel(), and Digikam::AlbumFilterModel::setSourceFilterModel().

◆ setSourceAlbumModel() [2/2]

void Digikam::CheckableAlbumFilterModel::setSourceAlbumModel ( AbstractCheckableAlbumModel *const  source)

◆ setSourceFilterModel() [1/2]

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

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

References Digikam::AlbumFilterModel::m_chainedModel, Digikam::AlbumFilterModel::setSourceAlbumModel(), Digikam::AlbumFilterModel::setSourceModel(), and Digikam::AlbumFilterModel::sourceAlbumModel().

Referenced by setSourceFilterModel().

◆ setSourceFilterModel() [2/2]

◆ setSourceModel()

void Digikam::AlbumFilterModel::setSourceModel ( QAbstractItemModel *const  model)
overrideprotectedinherited

Use setSourceAlbumModel.

See also
setSourceAlbumModel
Parameters
modelsource model

Referenced by Digikam::AlbumFilterModel::setSourceAlbumModel(), and Digikam::AlbumFilterModel::setSourceFilterModel().

◆ signalFilterChanged

◆ slotAlbumRenamed

void Digikam::AlbumFilterModel::slotAlbumRenamed ( Album album)
protectedslotinherited

◆ slotAlbumsHaveBeenUpdated

void Digikam::AlbumFilterModel::slotAlbumsHaveBeenUpdated ( int  type)
protectedslotinherited

◆ sourceAlbumModel()

AbstractCheckableAlbumModel * Digikam::CheckableAlbumFilterModel::sourceAlbumModel ( ) const

◆ sourceFilterModel()

AlbumFilterModel * Digikam::AlbumFilterModel::sourceFilterModel ( ) const
inherited

◆ updateFilter()

void Digikam::AlbumFilterModel::updateFilter ( )
inherited

Force invalidateFilter() externally.

References Digikam::AlbumFilterModel::isFiltering().

Member Data Documentation

◆ m_chainedModel

◆ m_filterBehavior

FilterBehavior Digikam::AlbumFilterModel::m_filterBehavior
protectedinherited

◆ m_filterChecked

bool Digikam::CheckableAlbumFilterModel::m_filterChecked
protected

◆ m_filterPartiallyChecked

bool Digikam::CheckableAlbumFilterModel::m_filterPartiallyChecked
protected

◆ m_parent

QObject* Digikam::AlbumFilterModel::m_parent
protectedinherited

◆ m_settings


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