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

Manages and provides access to the data displayed in the backup list. More...

#include <backuplistmodel.h>

Inheritance diagram for BackupListModel:
Collaboration diagram for BackupListModel:

Public Member Functions

 BackupListModel (QObject *parent=nullptr)
 Constructor.
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Returns the horizontal header section names.
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of rows to display.
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of columns to display.
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Used to access the data stored in this model.
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Returns the flags for the given index. Adds editing flags for editable columns.
 
void setBackupTargets (const std::vector< BackupTarget > &targets)
 Sets the data for all backup targets.
 
void setIsEditable (bool is_editable)
 Enables or disables the ability to edit this models data in a view.
 
bool isEditable () const
 Checks if the model is currently editable.
 

Static Public Attributes

static constexpr int action_col = 0
 Index of the action column.
 
static constexpr int target_col = 1
 Index of the target column.
 
static constexpr int backup_col = 2
 Index of the backup column.
 
static constexpr int path_col = 3
 Index of the path column.
 
static constexpr int backup_list_role = 256
 Role representing the list of backups for a target.
 
static constexpr int active_index_role = ModListModel::active_index_role
 Role representing the id of the currently active backup for a target.
 
static constexpr int num_backups_role = active_index_role + 1
 Role representing the number of backups for a target.
 
static constexpr int num_targets_role = num_backups_role + 1
 Role representing the total number of target.
 
static constexpr int target_name_role = num_targets_role + 1
 Role representing the name of a target.
 
static constexpr int backup_name_role = target_name_role + 1
 Role representing the name of the currently active backup for a target.
 
static constexpr int target_path_role = backup_name_role + 1
 Role representing the path for a target.
 

Private Attributes

std::vector< BackupTargettargets_
 Stores data for all displayed backup targets.
 
bool is_editable_ = true
 Stores whether the model can be edited in a view.
 

Detailed Description

Manages and provides access to the data displayed in the backup list.

Constructor & Destructor Documentation

◆ BackupListModel()

BackupListModel::BackupListModel ( QObject * parent = nullptr)
explicit

Constructor.

Parameters
parentThe QTableView used to display the data in this mode.

Member Function Documentation

◆ columnCount()

int BackupListModel::columnCount ( const QModelIndex & parent = QModelIndex()) const
override

Returns the number of columns to display.

Parameters
parentParent index.
Returns
The number of columns.

◆ data()

QVariant BackupListModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

Used to access the data stored in this model.

Returns data depending on the given role and index. Qt standard roles are used to provide data displayed in views. Custom roles defined in this file provide access to the raw data.

Parameters
indexHold row and column for which to return data. Column data is ignored.
roleDescribes type of data to return.
Returns
The requested data.

◆ flags()

Qt::ItemFlags BackupListModel::flags ( const QModelIndex & index) const
override

Returns the flags for the given index. Adds editing flags for editable columns.

Parameters
indexTarget index.
Returns
The flags.

◆ headerData()

QVariant BackupListModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const
override

Returns the horizontal header section names.

Parameters
sectionTarget section.
orientationHeader orientation.
roleData role.
Returns
Name of the section.

◆ isEditable()

bool BackupListModel::isEditable ( ) const

Checks if the model is currently editable.

Returns
True if the model is editable, else false.

◆ rowCount()

int BackupListModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

Returns the number of rows to display.

Parameters
parentParent index.
Returns
The number of rows.

◆ setBackupTargets()

void BackupListModel::setBackupTargets ( const std::vector< BackupTarget > & targets)

Sets the data for all backup targets.

Parameters
targetsThe new targets.

◆ setIsEditable()

void BackupListModel::setIsEditable ( bool is_editable)

Enables or disables the ability to edit this models data in a view.

Parameters
is_editableModel data will be editable if this is true.

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