Limo
A simple mod manager
Loading...
Searching...
No Matches
backuplistmodel.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "core/backuptarget.h"
9#include "ui/modlistmodel.h"
10#include <QAbstractTableModel>
11
15class BackupListModel : public QAbstractTableModel
16{
17 Q_OBJECT
18
19public:
24 explicit BackupListModel(QObject* parent = nullptr);
25
27 static constexpr int action_col = 0;
29 static constexpr int target_col = 1;
31 static constexpr int backup_col = 2;
33 static constexpr int path_col = 3;
35 static constexpr int backup_list_role = 256;
39 static constexpr int num_backups_role = active_index_role + 1;
41 static constexpr int num_targets_role = num_backups_role + 1;
43 static constexpr int target_name_role = num_targets_role + 1;
45 static constexpr int backup_name_role = target_name_role + 1;
47 static constexpr int target_path_role = backup_name_role + 1;
48
56 QVariant headerData(int section,
57 Qt::Orientation orientation,
58 int role = Qt::DisplayRole) const override;
64 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
70 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
81 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
87 Qt::ItemFlags flags(const QModelIndex& index) const override;
92 void setBackupTargets(const std::vector<BackupTarget>& targets);
97 void setIsEditable(bool is_editable);
102 bool isEditable() const;
103
104private:
106 std::vector<BackupTarget> targets_;
108 bool is_editable_ = true;
109};
Header for the BackupTarget struct.
static constexpr int num_targets_role
Role representing the total number of target.
Definition backuplistmodel.h:41
static constexpr int backup_name_role
Role representing the name of the currently active backup for a target.
Definition backuplistmodel.h:45
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns to display.
Definition backuplistmodel.cpp:32
std::vector< BackupTarget > targets_
Stores data for all displayed backup targets.
Definition backuplistmodel.h:106
static constexpr int path_col
Index of the path column.
Definition backuplistmodel.h:33
static constexpr int target_path_role
Role representing the path for a target.
Definition backuplistmodel.h:47
static constexpr int num_backups_role
Role representing the number of backups for a target.
Definition backuplistmodel.h:39
void setBackupTargets(const std::vector< BackupTarget > &targets)
Sets the data for all backup targets.
Definition backuplistmodel.cpp:105
void setIsEditable(bool is_editable)
Enables or disables the ability to edit this models data in a view.
Definition backuplistmodel.cpp:112
static constexpr int active_index_role
Role representing the id of the currently active backup for a target.
Definition backuplistmodel.h:37
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the horizontal header section names.
Definition backuplistmodel.cpp:9
bool is_editable_
Stores whether the model can be edited in a view.
Definition backuplistmodel.h:108
static constexpr int backup_col
Index of the backup column.
Definition backuplistmodel.h:31
static constexpr int action_col
Index of the action column.
Definition backuplistmodel.h:27
static constexpr int target_name_role
Role representing the name of a target.
Definition backuplistmodel.h:43
static constexpr int target_col
Index of the target column.
Definition backuplistmodel.h:29
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Used to access the data stored in this model.
Definition backuplistmodel.cpp:37
BackupListModel(QObject *parent=nullptr)
Constructor.
Definition backuplistmodel.cpp:7
bool isEditable() const
Checks if the model is currently editable.
Definition backuplistmodel.cpp:117
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows to display.
Definition backuplistmodel.cpp:27
static constexpr int backup_list_role
Role representing the list of backups for a target.
Definition backuplistmodel.h:35
static constexpr int active_index_role
Role representing the active member of the group a mod belongs to.
Definition modlistmodel.h:51
uint8_t flags
Flags indicating compression type.
Definition lspakfilelistentry.h:7
Header for the ModListModel class.