Limo
A simple mod manager
Loading...
Searching...
No Matches
deployerlistproxymodel.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <QLabel>
9#include <QSortFilterProxyModel>
10#include <unordered_set>
11
12
16class DeployerListProxyModel : public QSortFilterProxyModel
17{
18 Q_OBJECT
19public:
32
38 explicit DeployerListProxyModel(QLabel* row_count_label, QObject* parent = nullptr);
39
47 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
55 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
62 void setFilterMode(FilterMode mode, bool status, bool invalidate_filter = true);
68 void addFilter(FilterMode mode, bool invalidate_filter = true);
74 void removeFilter(FilterMode mode, bool invalidate_filter = true);
81 bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
86 void clearFilter(bool invalidate_filter = true);
91 int getFilterMode();
97 void setConflicts(const std::unordered_set<int>& conflicts);
104 void addTagFilter(const QString& tag, bool include, bool invalidate_filter);
110 void removeTagFilter(const QString& tag, bool invalidate_filter);
115 void setConflictGroups(const std::vector<std::vector<int>>& groups);
117 void updateRowCountLabel();
122 void updateFilter(bool invalidate = true);
127 std::vector<std::pair<QString, bool>> getTagFilters() const;
132 void setFilterString(const QString& filter_string);
133
134private:
138 std::unordered_set<int> conflicts_;
143 std::vector<std::pair<QString, bool>> tag_filters_;
145 std::map<int, int> conflict_groups_;
149 std::vector<QBrush> row_text_colors_;
155 const QRegularExpression id_regex_;
162};
int filter_mode_
Contains the sum of all currently active filter modes.
Definition deployerlistproxymodel.h:136
void addTagFilter(const QString &tag, bool include, bool invalidate_filter)
Adds a tag to the tag filters.
Definition deployerlistproxymodel.cpp:134
std::vector< QBrush > row_text_colors_
For every displayed row: The text color used.
Definition deployerlistproxymodel.h:149
void updateRowCountLabel()
Updates the row count label with the current number of rows.
Definition deployerlistproxymodel.cpp:168
bool filter_string_targets_id_
True if filter string matches id_regex_.
Definition deployerlistproxymodel.h:161
const QRegularExpression id_regex_
Regex used to check if filter_string_ is used to filter for ids.
Definition deployerlistproxymodel.h:155
void setFilterString(const QString &filter_string)
Sets the string to use for filtering.
Definition deployerlistproxymodel.cpp:208
std::unordered_set< int > conflicts_
Contains all mod ids to be shown when the conflicts filter is active.
Definition deployerlistproxymodel.h:138
void addFilter(FilterMode mode, bool invalidate_filter=true)
Enables the given filter mode.
Definition deployerlistproxymodel.cpp:47
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 sho...
Definition deployerlistproxymodel.h:143
QString filter_string_id_
If the current filter string is an integer, this contains that integer.
Definition deployerlistproxymodel.h:159
DeployerListProxyModel(QLabel *row_count_label, QObject *parent=nullptr)
Constructor.
Definition deployerlistproxymodel.cpp:11
void removeTagFilter(const QString &tag, bool invalidate_filter)
Removes the filter for the given tag.
Definition deployerlistproxymodel.cpp:145
std::map< int, int > conflict_groups_
Maps mod ids to their conflict group.
Definition deployerlistproxymodel.h:145
void setConflicts(const std::unordered_set< int > &conflicts)
Sets data for the conflicts filter.
Definition deployerlistproxymodel.cpp:129
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Checks if the given row will be accepted by the current filter.
Definition deployerlistproxymodel.cpp:67
void removeFilter(FilterMode mode, bool invalidate_filter=true)
Disables the given filter mode.
Definition deployerlistproxymodel.cpp:57
QLabel * row_count_label_
Used to display to total number of rows.
Definition deployerlistproxymodel.h:151
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.
Definition deployerlistproxymodel.cpp:16
void updateFilter(bool invalidate=true)
Updates the filter and row coloring.
Definition deployerlistproxymodel.cpp:173
bool filter_string_is_int_
True if the current filter string is an integer.
Definition deployerlistproxymodel.h:157
void setFilterMode(FilterMode mode, bool status, bool invalidate_filter=true)
Sets the given filter mode to the given status.
Definition deployerlistproxymodel.cpp:37
std::vector< std::pair< QString, bool > > getTagFilters() const
Returns the currently set tag filters.
Definition deployerlistproxymodel.cpp:203
void setConflictGroups(const std::vector< std::vector< int > > &groups)
Generates a map used for row coloring from the given conflict groups.
Definition deployerlistproxymodel.cpp:155
void clearFilter(bool invalidate_filter=true)
Resets the filter to allow all mods.
Definition deployerlistproxymodel.cpp:115
int getFilterMode()
Getter for the current filter mode.
Definition deployerlistproxymodel.cpp:124
QString filter_string_
String used to filter rows.
Definition deployerlistproxymodel.h:153
int no_conflict_group_
Id of the conflict group that contains mods without conflicts.
Definition deployerlistproxymodel.h:147
FilterMode
Describes different filter types.
Definition deployerlistproxymodel.h:22
@ filter_inactive
Show only inactive mods.
Definition deployerlistproxymodel.h:24
@ filter_conflicts
Show only mods in the conflicts_ set.
Definition deployerlistproxymodel.h:28
@ filter_active
Show only active mods.
Definition deployerlistproxymodel.h:26
@ filter_tags
Show only mods with given tags.
Definition deployerlistproxymodel.h:30
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.
Definition deployerlistproxymodel.cpp:32