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

Provides either a QLineEdit or a QComboBox to edit a mods version. More...

#include <versionboxdelegate.h>

Inheritance diagram for VersionBoxDelegate:
Collaboration diagram for VersionBoxDelegate:

Signals

void activeGroupMemberChanged (int group, int new_id) const
 Signals that the active member of a group has changed.
 
void modVersionChanged (int mod_id, QString version) const
 Signals that the version string of a mod has changed.
 
void activeBackupChanged (int target, int backup) const
 Signals that the active backup for the current backup target has changed.
 
void backupNameEdited (int target, int backup, QString name) const
 Signals that the name of a backup has been edited by the user.
 

Public Member Functions

 VersionBoxDelegate (ModListProxyModel *proxy, QObject *parent)
 Constructor.
 
QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Creates either a QLineEdit or a QComboBox depending on whether or not the mod belongs to a group.
 
void setEditorData (QWidget *editor, const QModelIndex &index) const override
 Initializes either the line edit with the mods version or the combo box with the versions of all mods belonging to the same group.
 
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
 Emits modVersionChanged if the mod version has been edited or activeGroupMemberChanged if the editor is a combo box and its index has been changed.
 
void updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Updates the given editors geometry.
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &view_index) const override
 If the target index references a mod in a group: Paints an editable combo box at the given index into the given view.
 
void setIsBackupDelegate (bool is_backup)
 Sets if this is used to handle the backup list.
 

Private Attributes

ModListProxyModelproxy_model_ = nullptr
 Proxy model used to sort or filter the underlying model.
 
bool is_backup_delegate_ = false
 Indicates if this is used to manage the backup list.
 
ModListViewparent_view_
 Convenience pointer to parent view. Points to the same address as this->parent.
 

Detailed Description

Provides either a QLineEdit or a QComboBox to edit a mods version.

Constructor & Destructor Documentation

◆ VersionBoxDelegate()

VersionBoxDelegate::VersionBoxDelegate ( ModListProxyModel * proxy,
QObject * parent )
explicit

Constructor.

Parameters
proxyProxy model used to sort or filter the underlying model.
parentParent view of this delegate.

Member Function Documentation

◆ activeBackupChanged

void VersionBoxDelegate::activeBackupChanged ( int target,
int backup ) const
signal

Signals that the active backup for the current backup target has changed.

Parameters
targetCurrent target.
backupNew active backup.

◆ activeGroupMemberChanged

void VersionBoxDelegate::activeGroupMemberChanged ( int group,
int new_id ) const
signal

Signals that the active member of a group has changed.

Parameters
groupTarget group.
new_idNew active member.

◆ backupNameEdited

void VersionBoxDelegate::backupNameEdited ( int target,
int backup,
QString name ) const
signal

Signals that the name of a backup has been edited by the user.

Parameters
targetTarget to which the backup belongs.
backupThe edited backup.
nameThe new name.

◆ createEditor()

QWidget * VersionBoxDelegate::createEditor ( QWidget * parent,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const
override

Creates either a QLineEdit or a QComboBox depending on whether or not the mod belongs to a group.

Parameters
parentParent view.
optionStyle options.
indexIndex at which to create the editor.
Returns

◆ modVersionChanged

void VersionBoxDelegate::modVersionChanged ( int mod_id,
QString version ) const
signal

Signals that the version string of a mod has changed.

Parameters
mod_idTarget mod.
versionNew version string.

◆ paint()

void VersionBoxDelegate::paint ( QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & view_index ) const
override

If the target index references a mod in a group: Paints an editable combo box at the given index into the given view.

Parameters
painterPainter used to draw.
optionStyle options.
view_indexThe target views index.

◆ setEditorData()

void VersionBoxDelegate::setEditorData ( QWidget * editor,
const QModelIndex & index ) const
override

Initializes either the line edit with the mods version or the combo box with the versions of all mods belonging to the same group.

Parameters
editorTarget editor.
indexIndex for the editor.

◆ setIsBackupDelegate()

void VersionBoxDelegate::setIsBackupDelegate ( bool is_backup)

Sets if this is used to handle the backup list.

Parameters
is_backupTrue for backup, else false.

◆ setModelData()

void VersionBoxDelegate::setModelData ( QWidget * editor,
QAbstractItemModel * model,
const QModelIndex & index ) const
override

Emits modVersionChanged if the mod version has been edited or activeGroupMemberChanged if the editor is a combo box and its index has been changed.

Parameters
editorEditor used to change the data.
modelIgnored.
indexIndex for the edited mod version.

◆ updateEditorGeometry()

void VersionBoxDelegate::updateEditorGeometry ( QWidget * editor,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const
override

Updates the given editors geometry.

Parameters
editorTarget editor.
optionStyle options.
indexIndex for the editor.

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