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

Used to sort and filter the deployer list. More...

#include <deployerlistproxymodel.h>

Inheritance diagram for DeployerListProxyModel:
Collaboration diagram for DeployerListProxyModel:

Public Types

enum  FilterMode { filter_inactive = 1 , filter_active = 2 , filter_conflicts = 4 , filter_tags = 8 }
 Describes different filter types. More...
 

Public Member Functions

 DeployerListProxyModel (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 setConflicts (const std::unordered_set< int > &conflicts)
 Sets data for the conflicts filter.
 
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 setConflictGroups (const std::vector< std::vector< int > > &groups)
 Generates a map used for row coloring from the given conflict groups.
 
void updateRowCountLabel ()
 Updates the row count label with the current number of rows.
 
void updateFilter (bool invalidate=true)
 Updates the filter and row coloring.
 
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.
 

Private Attributes

int filter_mode_ = 0
 Contains the sum of all currently active filter modes.
 
std::unordered_set< int > conflicts_
 Contains all mod ids to be shown when the conflicts filter is active.
 
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.
 
std::map< int, int > conflict_groups_
 Maps mod ids to their conflict group.
 
int no_conflict_group_ = 0
 Id of the conflict group that contains mods without conflicts.
 
std::vector< QBrush > row_text_colors_
 For every displayed row: The text color used.
 
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 and filter the deployer list.

Member Enumeration Documentation

◆ FilterMode

Describes different filter types.

Enumerator
filter_inactive 

Show only inactive mods.

filter_active 

Show only active mods.

filter_conflicts 

Show only mods in the conflicts_ set.

filter_tags 

Show only mods with given tags.

Constructor & Destructor Documentation

◆ DeployerListProxyModel()

DeployerListProxyModel::DeployerListProxyModel ( 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 DeployerListProxyModel::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 DeployerListProxyModel::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 DeployerListProxyModel::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 DeployerListProxyModel::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 DeployerListProxyModel::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 DeployerListProxyModel::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 > > DeployerListProxyModel::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.

◆ removeFilter()

void DeployerListProxyModel::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 DeployerListProxyModel::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.

◆ setConflictGroups()

void DeployerListProxyModel::setConflictGroups ( const std::vector< std::vector< int > > & groups)

Generates a map used for row coloring from the given conflict groups.

Parameters
groupsFor every conflict group: A vector of mod ids belonging to that group.

◆ setConflicts()

void DeployerListProxyModel::setConflicts ( const std::unordered_set< int > & conflicts)

Sets data for the conflicts filter.

Parameters
conflictsA set containing ids of all mods with conflicts. Only mods in this set will be shown when the conflicts filter mode is active.

◆ setData()

bool DeployerListProxyModel::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 DeployerListProxyModel::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 DeployerListProxyModel::setFilterString ( const QString & filter_string)

Sets the string to use for filtering.

Parameters
filter_stringThe new filter string.

◆ updateFilter()

void DeployerListProxyModel::updateFilter ( bool invalidate = true)

Updates the filter and row coloring.

Parameters
Iftrue: Update filtered mods with the current settings.

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