![]() |
LeechCraft 0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
|
Provides filter model with additional tags filter mode. More...
#include "tagsfiltermodel.h"
Public Types | |
| enum class | TagsInclusionMode { Any , 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. | |
| void | SetTagsRole (int role, const ITagsManager &tm) |
| Makes the default GetTagsForIndex() read the tags from role. | |
| void | SetSeparator (const QString &separator) |
| Sets the separator for the tags. | |
| void | SetTagsInclusionMode (TagsInclusionMode mode) |
| Sets the tags inclusion mode. | |
| void | SetTagsMode (bool enabled) |
| Sets whether the tags filtering mode is enabled. | |
| Public Member Functions inherited from LC::Util::FixedStringFilterProxyModel | |
| FixedStringFilterProxyModel (QObject *=nullptr) | |
| FixedStringFilterProxyModel (Qt::CaseSensitivity, QObject *=nullptr) | |
| void | SetFilterString (const QString &) |
| 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 | |
| void | UpdateDerivedFilter (const QString &) override |
| bool | filterAcceptsRow (int, const QModelIndex &) const override |
| virtual QStringList | GetTagsForIndex (int row) const |
| Returns the list of tags for the given row. | |
| Protected Member Functions inherited from LC::Util::FixedStringFilterProxyModel | |
| bool | IsMatch (const QString &) const |
| bool | filterAcceptsRow (int row, const QModelIndex &parent) const override |
Provides filter model with additional tags filter mode.
This model behaves just like FixedStringFilterProxyModel 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 string by the separator, which is ; by default but can be set via the SetSeparator() method.
Definition at line 30 of file tagsfiltermodel.h.
|
strong |
Describes the modes of matching two sets of tags.
| 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 42 of file tagsfiltermodel.h.
|
explicit |
Creates the model with the given parent.
| [in] | parent | The parent object of this model. |
Definition at line 17 of file tagsfiltermodel.cpp.
References LC::Util::FixedStringFilterProxyModel::FixedStringFilterProxyModel(), and LC::Util::GetDefaultTagsSeparator().
|
overrideprotected |
Definition at line 59 of file tagsfiltermodel.cpp.
References LC::Util::FixedStringFilterProxyModel::filterAcceptsRow().
|
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.
| [in] | row | The source row for which tags should be fetched. |
Definition at line 67 of file tagsfiltermodel.cpp.
| void LC::Util::TagsFilterModel::SetSeparator | ( | const QString & | separator | ) |
Sets the separator for the tags.
The separator is used to split the filter string (the one set via SetFilterString()) into the list of tags.
Setting this property re-filters the model.
| [in] | separator | The separator string. |
Definition at line 31 of file tagsfiltermodel.cpp.
| void LC::Util::TagsFilterModel::SetTagsInclusionMode | ( | TagsFilterModel::TagsInclusionMode | mode | ) |
Sets the tags inclusion mode.
Setting this property re-filters the model.
| [in] | mode | The tags inclusion mode. |
Definition at line 38 of file tagsfiltermodel.cpp.
| void LC::Util::TagsFilterModel::SetTagsMode | ( | bool | enabled | ) |
Sets whether the tags filtering mode is enabled.
By default the tags mode is disabled.
| [in] | enabled | Whether the tags mode should be enabled. |
Definition at line 45 of file tagsfiltermodel.cpp.
| void LC::Util::TagsFilterModel::SetTagsRole | ( | int | role, |
| const ITagsManager & | tm ) |
Makes the default GetTagsForIndex() read the tags from role.
The role is expected to hold the QList<TagId> of the row, and tm resolves the IDs to the names the filter matches. tm must outlive this model.
| [in] | role | The role holding the tag IDs of a row. |
| [in] | tm | The tags manager resolving the IDs. |
Definition at line 23 of file tagsfiltermodel.cpp.
|
overrideprotectedvirtual |
Reimplemented from LC::Util::FixedStringFilterProxyModel.
Definition at line 52 of file tagsfiltermodel.cpp.