Limo
A simple mod manager
Loading...
Searching...
No Matches
ModListProxyModel Class Reference

Used to sort or filter the mod list. More...

#include <modlistproxymodel.h>

Inheritance diagram for ModListProxyModel:
Collaboration diagram for ModListProxyModel:

Public Types

enum  FilterMode {
  filter_groups = 1 , filter_no_groups = 2 , filter_inactive = 4 , filter_active = 8 ,
  filter_tags = 16 , filter_updates = 32 , filter_no_updates = 64
}
 Describes different filter types. More...
 

Public Member Functions

 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.
 

Protected Member Functions

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.
 

Private Attributes

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_.
 

Detailed Description

Used to sort or filter the mod list.

Member Enumeration Documentation

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

Constructor & Destructor Documentation

◆ ModListProxyModel()

ModListProxyModel::ModListProxyModel ( QLabel * row_count_label,
QObject * parent = nullptr )
explicit

Constructor.

Parameters
row_count_labelUsed to display to total number of rows.
parentParent of this object.

Member Function Documentation

◆ addFilter()

void ModListProxyModel::addFilter ( FilterMode mode,
bool invalidate_filter = true )

Enables the given filter mode.

Parameters
modeFilter mode to activate.
invalidate_filterIf 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
tagTag to be added.
includeIf true: Only show mods with this tag, else only show mods without.
invalidate_filterIf 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_filterIf 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
indexIndex to remap.
roleData 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_rowRow to check.
source_parentParent 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
leftFirst index.
rightSecond index.
Returns
True if left < right.

◆ removeFilter()

void ModListProxyModel::removeFilter ( FilterMode mode,
bool invalidate_filter = true )

Disables the given filter mode.

Parameters
modeFilter mode to activate.
invalidate_filterIf 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
tagTag to be removed.
invalidate_filterIf 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
indexIndex to remap.
valueNew data.
roleData 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
modeFilter mode to set.
statusIf true: Enable the filter, else disable it.
invalidate_filterIf 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_stringThe new filter string.

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