Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::CommonItemDelegate Class Reference

Allows a list model to determine the editor for a field. More...

#include <CommonItemDelegate.h>

Inheritance diagram for sf::CommonItemDelegate:
Collaboration diagram for sf::CommonItemDelegate:

Public Types

enum  EItemDataRole : int {
  TypeRole = Qt::ItemDataRole::UserRole , OptionsRole , MinimumRole , MaximumRole ,
  IncrementRole , TextColorRole , AlignmentRole
}
 Extension on the Qt::ItemDataRole enumerate. More...
 
enum  EEditorType {
  etDefault , etTextEdit , etDropDown , etDropDownIndex ,
  etDropDownEdit , etDropDownFlags , etShortcut , etSpinBox ,
  etDoubleSpinBox , etULongLong , etColorEdit , etStringList ,
  etString
}
 Possible inline editors for a column in the list model. More...
 
typedef QList< QPair< QVariant, QString > > OptionsType
 Type for the named options available in case of a dropdown.
 

Public Member Functions

Q_SIGNAL void addLineEditActions (QLineEdit *lineEdit, const QModelIndex &index) const
 Signal allowing adding actions to a line edit.
 
 CommonItemDelegate (QObject *parent=nullptr)
 Constructor.
 
QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Overridden from base class.
 
void setEditorData (QWidget *editor, const QModelIndex &index) const override
 Overridden from base class.
 
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
 Overridden from base class.
 
void updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Overridden from base class.
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Overridden from base class.
 

Static Public Member Functions

static EEditorType getEditorType (const QModelIndex &index)
 Gets the editor type by calling the modal data() method with TypeRole.
 

Detailed Description

Allows a list model to determine the editor for a field.

Member Typedef Documentation

◆ OptionsType

typedef QList<QPair<QVariant, QString> > sf::CommonItemDelegate::OptionsType

Type for the named options available in case of a dropdown.

Member Enumeration Documentation

◆ EEditorType

Possible inline editors for a column in the list model.

Enumerator
etDefault 
etTextEdit 
etDropDown 
etDropDownIndex 
etDropDownEdit 
etDropDownFlags 
etShortcut 
etSpinBox 
etDoubleSpinBox 
etULongLong 
etColorEdit 
etStringList 
etString 

◆ EItemDataRole

Extension on the Qt::ItemDataRole enumerate.

Enumerator
TypeRole 

Type of editor from the model.

OptionsRole 

For retrieving the options list for a dropdown edit.

MinimumRole 

Minimum for scalar value e.g. a spin box.

MaximumRole 

Maximum for scalar value e.g. a spin box.

IncrementRole 

Increment for scalar value e.g. a spin box.

TextColorRole 

Determines the text color of the text. Can be a QColor or QPalette::ColorRole (integer) type.

AlignmentRole 

Determines how the item should be aligned. using

Constructor & Destructor Documentation

◆ CommonItemDelegate()

sf::CommonItemDelegate::CommonItemDelegate ( QObject *  parent = nullptr)
explicit

Constructor.

Member Function Documentation

◆ addLineEditActions()

Q_SIGNAL void sf::CommonItemDelegate::addLineEditActions ( QLineEdit *  lineEdit,
const QModelIndex &  index 
) const

Signal allowing adding actions to a line edit.

Parameters
lineEditLine edit in question.
indexIndex of the edited item.

◆ createEditor()

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

Overridden from base class.

◆ getEditorType()

static EEditorType sf::CommonItemDelegate::getEditorType ( const QModelIndex &  index)
static

Gets the editor type by calling the modal data() method with TypeRole.

Parameters
indexModel-index of the field to get the editor type for.
Returns
Type of the editor.

◆ paint()

void sf::CommonItemDelegate::paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
override

Overridden from base class.

◆ setEditorData()

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

Overridden from base class.

◆ setModelData()

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

Overridden from base class.

◆ updateEditorGeometry()

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

Overridden from base class.


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