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

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...
 
QVariant dataForCurrentSortRole (Album *album) const
 
QModelIndex indexForAlbum (Album *album) const
 
bool isFiltering () const override
 
void listAllSearches ()
 
void listDuplicatesSearches ()
 
void listHaarSearches ()
 
void listMapSearches ()
 
void listNormalSearches ()
 
void listTimelineSearches ()
 
QModelIndex mapFromSourceAlbumModel (const QModelIndex &index) const
 
QModelIndex mapToSourceAlbumModel (const QModelIndex &index) const
 
MatchResult matchResult (const QModelIndex &index) const
 
QModelIndex rootAlbumIndex () const
 
 SearchFilterModel (QObject *const parent=nullptr)
 
SearchTextSettings searchTextSettings () const
 
void setFilterBehavior (FilterBehavior behavior)
 
void setFilterChecked (bool filter)
 
void setFilterPartiallyChecked (bool filter)
 
void setFilterSearchType (DatabaseSearch::Type)
 
void setListTemporarySearches (bool list)
 
void setSourceAlbumModel (AbstractCheckableAlbumModel *const source)
 
void setSourceFilterModel (AlbumFilterModel *const source)
 
void setSourceFilterModel (CheckableAlbumFilterModel *const source)
 
void setSourceSearchModel (SearchModel *const source)
 
AbstractCheckableAlbumModelsourceAlbumModel () const
 
AlbumFilterModelsourceFilterModel () const
 
SearchModelsourceSearchModel () 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 setSourceAlbumModel (AbstractAlbumModel *const source)
 
void setSourceModel (QAbstractItemModel *const model) override
 
void setTypeFilter (int type)
 

Protected Attributes

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

Detailed Description

Filter model for searches that can filter by search type

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

◆ SearchFilterModel()

Digikam::SearchFilterModel::SearchFilterModel ( 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::SearchFilterModel::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::CheckableAlbumFilterModel.

References m_listTemporary, and m_searchType.

◆ lessThan()

◆ listAllSearches()

void Digikam::SearchFilterModel::listAllSearches ( )

References setTypeFilter().

◆ listDuplicatesSearches()

void Digikam::SearchFilterModel::listDuplicatesSearches ( )

◆ listHaarSearches()

void Digikam::SearchFilterModel::listHaarSearches ( )

◆ listMapSearches()

void Digikam::SearchFilterModel::listMapSearches ( )

◆ listNormalSearches()

void Digikam::SearchFilterModel::listNormalSearches ( )

References setTypeFilter().

◆ listTimelineSearches()

void Digikam::SearchFilterModel::listTimelineSearches ( )

◆ mapFromSourceAlbumModel()

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

◆ mapToSourceAlbumModel()

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

◆ matches()

bool Digikam::SearchFilterModel::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::CheckableAlbumFilterModel.

References Digikam::SAlbum::isNormalSearch(), Digikam::SAlbum::isTemporarySearch(), m_listTemporary, m_searchType, Digikam::CheckableAlbumFilterModel::matches(), and Digikam::SAlbum::searchType().

◆ 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)
inherited

◆ setFilterPartiallyChecked()

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

◆ setFilterSearchType()

void Digikam::SearchFilterModel::setFilterSearchType ( DatabaseSearch::Type  type)

Set the DatabaseSearch::Type.

References setTypeFilter().

◆ setListTemporarySearches()

void Digikam::SearchFilterModel::setListTemporarySearches ( bool  list)

Sets if temporary search albums shall be listed

References m_listTemporary, and Digikam::AlbumFilterModel::signalFilterChanged().

Referenced by Digikam::FuzzySearchView::FuzzySearchView().

◆ setSearchTextSettings

◆ setSourceAlbumModel() [1/2]

void Digikam::SearchFilterModel::setSourceAlbumModel ( AbstractAlbumModel *const  source)
protected

◆ setSourceAlbumModel() [2/2]

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

◆ 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 Digikam::CheckableAlbumFilterModel::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().

◆ setSourceSearchModel()

void Digikam::SearchFilterModel::setSourceSearchModel ( SearchModel *const  source)

◆ setTypeFilter()

◆ signalFilterChanged

◆ slotAlbumRenamed

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

◆ slotAlbumsHaveBeenUpdated

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

◆ sourceAlbumModel()

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

◆ sourceFilterModel()

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

◆ sourceSearchModel()

SearchModel * Digikam::SearchFilterModel::sourceSearchModel ( ) const

◆ 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
protectedinherited

◆ m_filterPartiallyChecked

bool Digikam::CheckableAlbumFilterModel::m_filterPartiallyChecked
protectedinherited

◆ m_listTemporary

bool Digikam::SearchFilterModel::m_listTemporary
protected

◆ m_parent

QObject* Digikam::AlbumFilterModel::m_parent
protectedinherited

◆ m_searchType

int Digikam::SearchFilterModel::m_searchType
protected

Referenced by isFiltering(), matches(), and setTypeFilter().

◆ m_settings


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