Limo
A simple mod manager
Loading...
Searching...
No Matches
modlistmodel.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "../core/modinfo.h"
9#include "modlistproxymodel.h"
10#include <QAbstractTableModel>
11#include <QComboBox>
12
13
17class ModListModel : public QAbstractTableModel
18{
19 Q_OBJECT
20
21public:
27 explicit ModListModel(ModListProxyModel* proxy, QObject* parent = nullptr);
28
30 static constexpr int action_col = 0;
32 static constexpr int name_col = 1;
34 static constexpr int version_col = 2;
36 static constexpr int id_col = 3;
38 static constexpr int time_col = 4;
40 static constexpr int size_col = 5;
42 static constexpr int deployers_col = 6;
44 static constexpr int tags_col = 7;
45
47 static constexpr int version_list_role = 256;
49 static constexpr int mod_id_role = 257;
51 static constexpr int active_index_role = 258;
53 static constexpr int group_members_role = 259;
55 static constexpr int mod_group_role = 260;
57 static constexpr int mod_name_role = 263;
59 static constexpr int deployer_ids_role = 265;
61 static constexpr int sort_role = 266;
63 static constexpr int icon_role = 267;
65 static constexpr int statuses_role = 268;
67 static constexpr int manual_tags_role = 269;
69 static constexpr int auto_tags_role = 270;
72 static constexpr int local_source_role = 271;
74 static constexpr int remote_source_role = 272;
76 static constexpr int has_update_role = 273;
78 static constexpr int mod_size_role = 274;
80 static constexpr int mod_version_role = 275;
81
89 QVariant headerData(int section,
90 Qt::Orientation orientation,
91 int role = Qt::DisplayRole) const override;
97 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
103 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
114 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
120 Qt::ItemFlags flags(const QModelIndex& index) const override;
125 void setModInfo(const std::vector<ModInfo>& mods);
130 const std::map<int, int>& getGroupMap() const;
135 const std::vector<ModInfo>& getModInfo() const;
137 bool isEditable() const;
142 void setIsEditable(bool is_editable);
143
144private:
148 std::vector<ModInfo> active_mods_;
150 std::vector<ModInfo> mods_;
152 std::map<int, int> group_map_;
154 std::map<int, std::vector<int>> groups_;
156 std::map<int, QStringList> group_versions_;
158 std::map<int, int> active_group_members_;
160 std::map<int, std::vector<bool>> deployer_statuses_;
162 bool is_editable_ = true;
164 std::map<int, std::vector<std::string>> manual_tag_map_;
166 std::map<int, std::vector<std::string>> auto_tag_map_;
168 std::map<int, QString> mod_size_strings_;
169
175 bool modHasUpdate(int row) const;
176};
static constexpr int icon_role
Role representing the icon of the current cell.
Definition modlistmodel.h:63
static constexpr int local_source_role
Role representing the path to the local source archive or directory used for installation.
Definition modlistmodel.h:72
const std::vector< ModInfo > & getModInfo() const
Returns all mods stored in this model.
Definition modlistmodel.cpp:252
std::map< int, std::vector< int > > groups_
For every group: A vector of mod ids in that group.
Definition modlistmodel.h:154
static constexpr int mod_id_role
Role representing the id of a mod.
Definition modlistmodel.h:49
std::map< int, int > group_map_
Maps mod ids to the group they belong to.
Definition modlistmodel.h:152
static constexpr int remote_source_role
Role representing the URL from which the mod was downloaded.
Definition modlistmodel.h:74
static constexpr int sort_role
Role used for sorting data.
Definition modlistmodel.h:61
static constexpr int auto_tags_role
Role representing the set of auto tags added to a mod.
Definition modlistmodel.h:69
std::map< int, std::vector< std::string > > auto_tag_map_
Maps mod ids to a vector of auto tags associated with that mod.
Definition modlistmodel.h:166
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns to display.
Definition modlistmodel.cpp:47
static constexpr int mod_group_role
Role representing the id of the group a mod belongs to.
Definition modlistmodel.h:55
static constexpr int tags_col
Index of the tags column.
Definition modlistmodel.h:44
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows to display.
Definition modlistmodel.cpp:42
static constexpr int version_list_role
Role representing the version of a mod.
Definition modlistmodel.h:47
static constexpr int id_col
Index of the mod id column.
Definition modlistmodel.h:36
static constexpr int action_col
Index of the action column.
Definition modlistmodel.h:30
std::map< int, int > active_group_members_
Maps groups to their active members.
Definition modlistmodel.h:158
const std::map< int, int > & getGroupMap() const
Returns a map with mod ids as keys and the group they belong to as values.
Definition modlistmodel.cpp:247
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Used to access the data stored in this model.
Definition modlistmodel.cpp:52
static constexpr int deployers_col
Index of the deployers column.
Definition modlistmodel.h:42
static constexpr int deployer_ids_role
Role representing the ids of all deployers managing the given mod.
Definition modlistmodel.h:59
static constexpr int mod_version_role
Role representing the version of a mod.
Definition modlistmodel.h:80
static constexpr int mod_size_role
Role representing the mod size on disk.
Definition modlistmodel.h:78
std::vector< ModInfo > mods_
All mods.
Definition modlistmodel.h:150
std::map< int, std::vector< bool > > deployer_statuses_
The mods activation status for every deployer it belongs to.
Definition modlistmodel.h:160
bool isEditable() const
Returns true iff this models data is editable in a view.
Definition modlistmodel.cpp:257
static constexpr int statuses_role
Role representing a mods status for every deployer.
Definition modlistmodel.h:65
bool modHasUpdate(int row) const
Checks if the mod at the given mod has an update.
Definition modlistmodel.cpp:267
void setModInfo(const std::vector< ModInfo > &mods)
Updates all data stored in this model with the given data.
Definition modlistmodel.cpp:183
static constexpr int group_members_role
Role representing the members of the group a mod belongs to.
Definition modlistmodel.h:53
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the horizontal header section names.
Definition modlistmodel.cpp:14
std::vector< ModInfo > active_mods_
All mods which are either not part of a group or the groups active member.
Definition modlistmodel.h:148
void setIsEditable(bool is_editable)
Enables or disables the ability to edit this models data in a view.
Definition modlistmodel.cpp:262
static constexpr int manual_tags_role
Role representing the set of manual tags added to a mod.
Definition modlistmodel.h:67
static constexpr int active_index_role
Role representing the active member of the group a mod belongs to.
Definition modlistmodel.h:51
static constexpr int version_col
Index of the mod version column.
Definition modlistmodel.h:34
std::map< int, QString > mod_size_strings_
Maps mod ids to a string representing their size on disk.
Definition modlistmodel.h:168
std::map< int, QStringList > group_versions_
For every group: A QStringList of group version strings.
Definition modlistmodel.h:156
static constexpr int size_col
Index of the mod size column.
Definition modlistmodel.h:40
static constexpr int name_col
Index of the mod name column.
Definition modlistmodel.h:32
static constexpr int has_update_role
Role representing whether or not there is an update available for a mod.
Definition modlistmodel.h:76
static constexpr int mod_name_role
Role representing the name of a mod.
Definition modlistmodel.h:57
ModListProxyModel * proxy_model_
The proxy model used to sort and filter this model.
Definition modlistmodel.h:146
std::map< int, std::vector< std::string > > manual_tag_map_
Maps mod ids to a vector of manual tags associated with that mod.
Definition modlistmodel.h:164
ModListModel(ModListProxyModel *proxy, QObject *parent=nullptr)
Constructor.
Definition modlistmodel.cpp:10
bool is_editable_
Stores whether the model can be edited in a view.
Definition modlistmodel.h:162
static constexpr int time_col
Index of the installation time column.
Definition modlistmodel.h:38
Used to sort or filter the mod list.
Definition modlistproxymodel.h:16
uint8_t flags
Flags indicating compression type.
Definition lspakfilelistentry.h:7
Contains the ModInfo struct.
Header for the ModListProxyModel class.