Used to sort or filter the mod list.
More...
#include <modlistproxymodel.h>
|
| ModListProxyModel (QLabel *row_count_label, QObject *parent=nullptr) |
| Constructor.
|
|
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| Maps the given index to the source models index and returns the source models data at that index.
|
|
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
| Maps the given index to the source mods index and sets its data to the given new data.
|
|
void | setFilterMode (FilterMode mode, bool status, bool invalidate_filter=true) |
| Sets the given filter mode to the given status.
|
|
void | addFilter (FilterMode mode, bool invalidate_filter=true) |
| Enables the given filter mode.
|
|
void | removeFilter (FilterMode mode, bool invalidate_filter=true) |
| Disables the given filter mode.
|
|
bool | filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override |
| Checks if the given row will be accepted by the current filter.
|
|
void | clearFilter (bool invalidate_filter=true) |
| Resets the filter to allow all mods.
|
|
int | getFilterMode () |
| Getter for the current filter mode.
|
|
void | addTagFilter (const QString &tag, bool include, bool invalidate_filter) |
| Adds a tag to the tag filters.
|
|
void | removeTagFilter (const QString &tag, bool invalidate_filter) |
| Removes the filter for the given tag.
|
|
void | updateRowCountLabel () |
| Updates the row count label with the current number of rows.
|
|
bool | isEditable () const |
| Returns true if the source model is editable;.
|
|
std::vector< std::pair< QString, bool > > | getTagFilters () const |
| Returns the currently set tag filters.
|
|
void | setFilterString (const QString &filter_string) |
| Sets the string to use for filtering.
|
|
|
bool | lessThan (const QModelIndex &left, const QModelIndex &right) const override |
| Compares two entries for sorting operations. Uses the base class implementation for all rows except for size_row, since the size strings cannot be alphabetically compared.
|
|
|
int | filter_mode_ = 0 |
| Contains the sum of all currently active filter modes.
|
|
std::vector< std::pair< QString, bool > > | tag_filters_ |
| Contains every tag to be filtered as well as a bool indicating whether mods with that tag show be shown or not shown.
|
|
QLabel * | row_count_label_ |
| Used to display to total number of rows.
|
|
QString | filter_string_ |
| String used to filter rows.
|
|
const QRegularExpression | id_regex_ |
| Regex used to check if filter_string_ is used to filter for ids.
|
|
bool | filter_string_is_int_ = false |
| True if the current filter string is an integer.
|
|
QString | filter_string_id_ |
| If the current filter string is an integer, this contains that integer.
|
|
bool | filter_string_targets_id_ = false |
| True if filter string matches id_regex_.
|
|
Used to sort or filter the mod list.
◆ FilterMode
Describes different filter types.
Enumerator |
---|
filter_groups | Show only mods in groups.
|
filter_no_groups | Show only mods without groups.
|
filter_inactive | Show only mods not managed by any deployer.
|
filter_active | Show only mods managed by at least one deployer.
|
filter_tags | Show only mods with the given tags.
|
filter_updates | Show only mods with available updates from their remote source.
|
filter_no_updates | Show only mods without available updates from their remote source.
|
◆ ModListProxyModel()
ModListProxyModel::ModListProxyModel |
( |
QLabel * | row_count_label, |
|
|
QObject * | parent = nullptr ) |
|
explicit |
Constructor.
- Parameters
-
row_count_label | Used to display to total number of rows. |
parent | Parent of this object. |
◆ addFilter()
void ModListProxyModel::addFilter |
( |
FilterMode | mode, |
|
|
bool | invalidate_filter = true ) |
Enables the given filter mode.
- Parameters
-
mode | Filter mode to activate. |
invalidate_filter | If true: Update filtered mods with the current settings. |
◆ addTagFilter()
void ModListProxyModel::addTagFilter |
( |
const QString & | tag, |
|
|
bool | include, |
|
|
bool | invalidate_filter ) |
Adds a tag to the tag filters.
- Parameters
-
tag | Tag to be added. |
include | If true: Only show mods with this tag, else only show mods without. |
invalidate_filter | If true: Update filtered mods with the current settings. |
◆ clearFilter()
void ModListProxyModel::clearFilter |
( |
bool | invalidate_filter = true | ) |
|
Resets the filter to allow all mods.
- Parameters
-
invalidate_filter | If true: Update filtered mods with the current settings. |
◆ data()
QVariant ModListProxyModel::data |
( |
const QModelIndex & | index, |
|
|
int | role = Qt::DisplayRole ) const |
|
override |
Maps the given index to the source models index and returns the source models data at that index.
- Parameters
-
index | Index to remap. |
role | Data role to get. |
- Returns
- The source models data, depending on the given role.
◆ filterAcceptsRow()
bool ModListProxyModel::filterAcceptsRow |
( |
int | source_row, |
|
|
const QModelIndex & | source_parent ) const |
|
override |
Checks if the given row will be accepted by the current filter.
- Parameters
-
source_row | Row to check. |
source_parent | Parent model containing the data filtered by this proxy. |
- Returns
- True if the row is accepted.
◆ getFilterMode()
int ModListProxyModel::getFilterMode |
( |
| ) |
|
Getter for the current filter mode.
- Returns
- The filter mode. The integer is the sum of all currently active FilterModes.
◆ getTagFilters()
std::vector< std::pair< QString, bool > > ModListProxyModel::getTagFilters |
( |
| ) |
const |
Returns the currently set tag filters.
- Returns
- Pairs of tag names and bools indicating if they should be kept or removed while filtering.
◆ isEditable()
bool ModListProxyModel::isEditable |
( |
| ) |
const |
Returns true if the source model is editable;.
- Returns
- True if editable.
◆ lessThan()
bool ModListProxyModel::lessThan |
( |
const QModelIndex & | left, |
|
|
const QModelIndex & | right ) const |
|
overrideprotected |
Compares two entries for sorting operations. Uses the base class implementation for all rows except for size_row, since the size strings cannot be alphabetically compared.
- Parameters
-
left | First index. |
right | Second index. |
- Returns
- True if left < right.
◆ removeFilter()
void ModListProxyModel::removeFilter |
( |
FilterMode | mode, |
|
|
bool | invalidate_filter = true ) |
Disables the given filter mode.
- Parameters
-
mode | Filter mode to activate. |
invalidate_filter | If true: Update filtered mods with the current settings. |
◆ removeTagFilter()
void ModListProxyModel::removeTagFilter |
( |
const QString & | tag, |
|
|
bool | invalidate_filter ) |
Removes the filter for the given tag.
- Parameters
-
tag | Tag to be removed. |
invalidate_filter | If true: Update filtered mods with the current settings. |
◆ setData()
bool ModListProxyModel::setData |
( |
const QModelIndex & | index, |
|
|
const QVariant & | value, |
|
|
int | role = Qt::EditRole ) |
|
override |
Maps the given index to the source mods index and sets its data to the given new data.
- Parameters
-
index | Index to remap. |
value | New data. |
role | Data role to edit. |
- Returns
- True if the data has been changed, else false.
◆ setFilterMode()
void ModListProxyModel::setFilterMode |
( |
FilterMode | mode, |
|
|
bool | status, |
|
|
bool | invalidate_filter = true ) |
Sets the given filter mode to the given status.
- Parameters
-
mode | Filter mode to set. |
status | If true: Enable the filter, else disable it. |
invalidate_filter | If true: Update filtered mods with the current settings. |
◆ setFilterString()
void ModListProxyModel::setFilterString |
( |
const QString & | filter_string | ) |
|
Sets the string to use for filtering.
- Parameters
-
filter_string | The new filter string. |
The documentation for this class was generated from the following files: