LeechCraft  0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
LC::Util::TagsFilterModel Class Reference

Provides filter model with additional tags filter mode. More...

#include "tagsfiltermodel.h"

+ Inheritance diagram for LC::Util::TagsFilterModel:
+ Collaboration diagram for LC::Util::TagsFilterModel:

Public Types

enum  TagsInclusionMode {
  TagsInclusionMode::Any,
  TagsInclusionMode::All
}
 Describes the modes of matching two sets of tags. More...
 

Public Member Functions

 TagsFilterModel (QObject *parent=nullptr)
 Creates the model with the given parent. More...
 
void SetFilterString (const QString &) override
 
void SetTagsRole (int role)
 
void SetSeparator (const QString &separator)
 Sets the separator for the tags. More...
 
void SetTagsInclusionMode (TagsInclusionMode mode)
 Sets the tags inclusion mode. More...
 
void SetTagsMode (bool enabled)
 Sets whether the tags filtering mode is enabled. More...
 
- Public Member Functions inherited from LC::Util::FixedStringFilterProxyModel
 FixedStringFilterProxyModel (QObject *=nullptr)
 
 FixedStringFilterProxyModel (Qt::CaseSensitivity, QObject *=nullptr)
 
QString GetFilterString () const
 
bool IsFilterSet () const
 
void SetCaseSensitivity (Qt::CaseSensitivity)
 
Qt::CaseSensitivity GetCaseSensitivity () const
 
void SetFilterRoles (const QList< int > &)
 
QList< int > GetFilterRoles () const
 
void SetFilterColumns (const QList< int > &)
 
QList< int > GetFilterColumns () const
 

Protected Member Functions

bool filterAcceptsRow (int, const QModelIndex &) const override
 Reimplemented from QSortFilterProxyModel::filterAcceptsRow(). More...
 
virtual QStringList GetTagsForIndex (int row) const
 Returns the list of tags for the given row. More...
 
- Protected Member Functions inherited from LC::Util::FixedStringFilterProxyModel
bool IsMatch (const QString &) const
 
bool filterAcceptsRow (int row, const QModelIndex &parent) const override
 

Detailed Description

Provides filter model with additional tags filter mode.

This model behaves just like a normal QSortFilterProxyModel except it supports filtering by tags. In this mode row is accepted either if all tags from the request are found in the row (the default mode) or if the intersection of the two sets is just non-empty. The mode can be set via SetTagsInclusionMode() function. The tags filtering mode itself is enabled via SetTagsMode() function.

The tags are obtained by splitting the filter pattern by the separator, which is ; by default but can be set via the SetSeparator() method.

Definition at line 29 of file tagsfiltermodel.h.

Member Enumeration Documentation

◆ TagsInclusionMode

Describes the modes of matching two sets of tags.

See also
SetTagsInclusionMode()
Enumerator
Any 

Tags intersection should be non-empty.

In other words, at least one tag from the filter string should be found in the list of tags of a row.

All 

Filter string tags should be a subset of row tags.

In other words, all of the tags from the filter string should be found in the list of tags of a row.

Definition at line 40 of file tagsfiltermodel.h.

Constructor & Destructor Documentation

◆ TagsFilterModel()

LC::Util::TagsFilterModel::TagsFilterModel ( QObject *  parent = nullptr)
explicit

Creates the model with the given parent.

Parameters
[in]parentThe parent object of this model.

Definition at line 17 of file tagsfiltermodel.cpp.

Member Function Documentation

◆ filterAcceptsRow()

bool LC::Util::TagsFilterModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  index 
) const
overrideprotected

Reimplemented from QSortFilterProxyModel::filterAcceptsRow().

Definition at line 56 of file tagsfiltermodel.cpp.

References LC::Util::FixedStringFilterProxyModel::filterAcceptsRow().

+ Here is the call graph for this function:

◆ GetTagsForIndex()

QStringList LC::Util::TagsFilterModel::GetTagsForIndex ( int  row) const
protectedvirtual

Returns the list of tags for the given row.

This function should return the list of tags for the given row. Reimplement it in your subclass to provide this filter model with correct tags for rows.

Parameters
[in]rowThe source row for which tags should be fetched.
Returns
The list of tags for the row.

Definition at line 64 of file tagsfiltermodel.cpp.

◆ SetFilterString()

void LC::Util::TagsFilterModel::SetFilterString ( const QString &  string)
overridevirtual

Reimplemented from LC::Util::FixedStringFilterProxyModel.

Definition at line 23 of file tagsfiltermodel.cpp.

References LC::Util::FixedStringFilterProxyModel::SetFilterString().

+ Here is the call graph for this function:

◆ SetSeparator()

void LC::Util::TagsFilterModel::SetSeparator ( const QString &  separator)

Sets the separator for the tags.

The separator is used to split the regexp filter string (the one set via setFilterFixedString() method) into the list of tags.

Setting this property will invalidate the model if the dynamicSortFilter() property is true.

Parameters
[in]separatorThe separator string.
See also
GetDefaultTagsSeparator()

Definition at line 38 of file tagsfiltermodel.cpp.

◆ SetTagsInclusionMode()

void LC::Util::TagsFilterModel::SetTagsInclusionMode ( TagsFilterModel::TagsInclusionMode  mode)

Sets the tags inclusion mode.

Setting this property will invalidate the model if the dynamicSortFilter() property is true.

Parameters
[in]modeThe tags inclusion mode.

Definition at line 44 of file tagsfiltermodel.cpp.

◆ SetTagsMode()

void LC::Util::TagsFilterModel::SetTagsMode ( bool  enabled)

Sets whether the tags filtering mode is enabled.

By default the tags mode is disabled.

Parameters
[in]enabledWhether the tags mode should be enabled.

Definition at line 50 of file tagsfiltermodel.cpp.

◆ SetTagsRole()

void LC::Util::TagsFilterModel::SetTagsRole ( int  role)

Definition at line 32 of file tagsfiltermodel.cpp.


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