Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::VariableListModel Class Referencefinal

List model for a sf::Variable list. More...

#include <VariableListModel.h>

Inheritance diagram for sf::VariableListModel:
Collaboration diagram for sf::VariableListModel:

Public Types

enum  EField : int {
  cId , cName , cValue , cUnit ,
  cFlags
}
 Displayable columns. More...
 

Public Member Functions

 VariableListModel (QObject *parent=nullptr)
 Constructor.
 
int nameLevel () const
 Gets the levels of names displayed of the variables in the list.
 
void setNameLevel (int level)
 Sets the levels of names displayed of the variables in the list.
 
bool hasRowCheckBox () const
 Gets if the row selection is enabled. By default, the row selection is enabled.
 
void setRowCheckBox (bool enabled)
 Enables the selection of rows. The sf::Variable::getData() returns true when selected.
 
void setDelegates (QAbstractItemView *view)
 Creates a sf::CommonItemDelegate instance for the passed view.
 
void refresh ()
 Refresh the attached viewer.
 
EField getField (int column) const
 Gets the field displayed in the column.
 
int getColumn (EField field) const
 Gets the column position or number where the field is displayed.
 
void update (int row=-1, int column=-1, const QList< int > &roles=QList< int >())
 Update values in the given column and row.
 
void updateField (int row, EField field, const QList< int > &roles=QList< int >())
 Update the column for the given field for all rows.
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const override
 Overridden from base class to provide column display names.
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Overridden from base class to provide the amount of rows.
 
QVariant data (const QModelIndex &index, int role) const override
 Overridden from base class to provide the data to present.
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Overridden from base class to provide the amount of columns.
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Overridden from base class to provide flags on an item by index.
 
void addVariable (const Variable &var)
 Adds local or global variable to this instance by pointer. Internally a client copy of the sf::Variable is added.
 
void addVariables (const Vector &list)
 Adds local or global variables to this instance.
 
void setVariables (const Vector &list)
 Set local or global variables to this instance.
 
void clearVariables ()
 Clear the variables added.
 
void setVariablesConvert (bool enable)
 Sets the variable conversion for floating point values.
 
IdVector getVariablesChecked () const
 Gets the Variable id's of all checked items in the list.
 
void setVariablesChecked (const IdVector &ids)
 Gets the Variable id's of all checked items in the list. Returns a list of id numbers to the passed referenced vector.
 
void addVariable (id_type id, bool desired=true)
 Adds global variable to this instance by id.
 
void addVariables (const IdVector &ids, bool desired=true)
 Adds local or global variables to this instance.
 
VariablegetVariable (const QModelIndex &index) const
 Gets the underlying variable pointer.
 
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 Overridden from base class to provide assignment of an item when edited.
 
int getRow (Variable &link) const
 Finds the row beloning to the given variable.
 
void setChecked (int row, bool checked)
 Sets or unsets the checkbox of a row.
 
Q_SIGNAL void changed (const Variable *var)
 Signals a change of the Variable's property.
 

Additional Inherited Members

- Protected Types inherited from sf::VariableTypes
enum  EEvent : int {
  veConvert = 64000 , veNewId = -32000 , veUserGlobal , veFirstLocal = 0 ,
  veFlagsChange = 1 , veValueChange = 2 , veInvalid = 3 , veConverted = 4 ,
  veUserLocal = 5 , veFirstPrivate = 16000 , veIdChanged = 16001 , veDesiredId = 16002 ,
  veRemove = 16003 , veGetOwner = 16004 , veLostOwner = 16005 , veLinked = 16006 ,
  veUnlinked = 16007 , veSetup = 16008 , veUserPrivate = 16009
}
 Events send to the handler set with sf::Variable::setHandler. More...
 
enum  EField : int {
  vfId = 0 , vfName , vfUnit , vfFlags ,
  vfDescription , vfType , vfConversionType , vfRound ,
  vfDefault , vfMinimum , vfMaximum , vfFirstState
}
 Enumeration of the order of fields in the setup string. More...
 
enum  EFlag : flags_type {
  flgReadonly = 1 << 0 , flgArchive = 1 << 1 , flgShare = 1 << 2 , flgLink = 1 << 3 ,
  flgFunction = 1 << 4 , flgParameter = 1 << 5 , flgHidden = 1 << 6 , flgExport = 1 << 7 ,
  flgWriteable = 1 << 8
}
 Enumeration type for specifying flags. More...
 
enum  EStringType : int {
  stNormal = 0 , stMulti , stPath , stDirectory ,
  stFilename , stSubdirectory
}
 Enumeration of string types used for filtering. More...
 
typedef TVector< Variable * > PtrVector
 Vector for pointers to variables.
 
typedef TVector< VariableVector
 Vector for instances of variables.
 
typedef TVector< VariableReference * > ReferenceVector
 Types for internal use.
 
- Protected Types inherited from sf::InformationTypes
typedef unsigned long long id_type
 Type used for the identifying integer (64-bits).
 
typedef int32_t flags_type
 Type used for the flag integer.
 
typedef size_t size_type
 Type used for size of vectors.
 
typedef uint64_t data_type
 Type used for containing a single data element which is the largest integer.
 
typedef int64_t sdata_type
 Type used for containing a single data element which is the largest signed integer.
 
typedef TVector< id_typeIdVector
 Vector for lists of information ID's.
 
typedef TVector< InformationBase * > Vector
 Vector for containing different information base derived classes.
 
- Protected Member Functions inherited from sf::VariableHandler
virtual ~VariableHandler ()
 Destructor clears the link with variable instances so no errors occur when the link is destructed before the variable is.
 
- Protected Member Functions inherited from sf::InformationTypes
template<typename T >
constexpr std::enable_if_t<(sizeof(T)<=sizeof(data_type)), data_typetoDataType (T value) const
 Casts any type to a data_type value.
 
template<typename T >
constexpr std::enable_if_t<(sizeof(T)<=sizeof(data_type)), T > fromDataType (data_type value) const
 Casts a data_type value to a given type.
 
- Static Protected Attributes inherited from sf::InformationTypes
static constexpr size_t npos = std::numeric_limits<size_type>::max()
 Unsigned size value indicating not found or no index.
 

Detailed Description

List model for a sf::Variable list.

Member Enumeration Documentation

◆ EField

Displayable columns.

Enumerator
cId 
cName 
cValue 
cUnit 
cFlags 

Constructor & Destructor Documentation

◆ VariableListModel()

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

Constructor.

Member Function Documentation

◆ addVariable() [1/2]

void sf::VariableListModel::addVariable ( const Variable var)

Adds local or global variable to this instance by pointer. Internally a client copy of the sf::Variable is added.

Parameters
varVariable to add.

◆ addVariable() [2/2]

void sf::VariableListModel::addVariable ( id_type  id,
bool  desired = true 
)

Adds global variable to this instance by id.

Parameters
idVariable id to add.
desiredSets the desired flag on the variable.

◆ addVariables() [1/2]

void sf::VariableListModel::addVariables ( const IdVector ids,
bool  desired = true 
)

Adds local or global variables to this instance.

Parameters
idsList of Variable ids.
desiredSets the desired flag on the variable.

◆ addVariables() [2/2]

void sf::VariableListModel::addVariables ( const Vector list)

Adds local or global variables to this instance.

Parameters
listList of Variables.

◆ changed()

Q_SIGNAL void sf::VariableListModel::changed ( const Variable var)

Signals a change of the Variable's property.

Parameters
varVariable concerned.

◆ clearVariables()

void sf::VariableListModel::clearVariables ( )

Clear the variables added.

◆ columnCount()

int sf::VariableListModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

Overridden from base class to provide the amount of columns.

◆ data()

QVariant sf::VariableListModel::data ( const QModelIndex &  index,
int  role 
) const
override

Overridden from base class to provide the data to present.

◆ flags()

Qt::ItemFlags sf::VariableListModel::flags ( const QModelIndex &  index) const
override

Overridden from base class to provide flags on an item by index.

◆ getColumn()

int sf::VariableListModel::getColumn ( EField  field) const

Gets the column position or number where the field is displayed.

Parameters
field
Returns
-1 when field is not displayed.

◆ getField()

EField sf::VariableListModel::getField ( int  column) const

Gets the field displayed in the column.

Parameters
columnPosition or number of the column
Returns
Field displayed.

◆ getRow()

int sf::VariableListModel::getRow ( Variable link) const

Finds the row beloning to the given variable.

Parameters
linkLinked variable reference.
Returns
Row number and -1 when not found.

◆ getVariable()

Variable * sf::VariableListModel::getVariable ( const QModelIndex &  index) const

Gets the underlying variable pointer.

Parameters
indexList index to get the variable from.
Returns
nullptr when the index is not valid.

◆ getVariablesChecked()

IdVector sf::VariableListModel::getVariablesChecked ( ) const

Gets the Variable id's of all checked items in the list.

Returns
List of id numbers.

◆ hasRowCheckBox()

bool sf::VariableListModel::hasRowCheckBox ( ) const

Gets if the row selection is enabled. By default, the row selection is enabled.

◆ headerData()

QVariant sf::VariableListModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const
override

Overridden from base class to provide column display names.

◆ nameLevel()

int sf::VariableListModel::nameLevel ( ) const

Gets the levels of names displayed of the variables in the list.

◆ refresh()

void sf::VariableListModel::refresh ( )

Refresh the attached viewer.

◆ rowCount()

int sf::VariableListModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Overridden from base class to provide the amount of rows.

◆ setChecked()

void sf::VariableListModel::setChecked ( int  row,
bool  checked 
)

Sets or unsets the checkbox of a row.

◆ setData()

bool sf::VariableListModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)
override

Overridden from base class to provide assignment of an item when edited.

◆ setDelegates()

void sf::VariableListModel::setDelegates ( QAbstractItemView *  view)

Creates a sf::CommonItemDelegate instance for the passed view.

◆ setNameLevel()

void sf::VariableListModel::setNameLevel ( int  level)

Sets the levels of names displayed of the variables in the list.

◆ setRowCheckBox()

void sf::VariableListModel::setRowCheckBox ( bool  enabled)

Enables the selection of rows. The sf::Variable::getData() returns true when selected.

◆ setVariables()

void sf::VariableListModel::setVariables ( const Vector list)

Set local or global variables to this instance.

Parameters
listList of Variables.

◆ setVariablesChecked()

void sf::VariableListModel::setVariablesChecked ( const IdVector ids)

Gets the Variable id's of all checked items in the list. Returns a list of id numbers to the passed referenced vector.

◆ setVariablesConvert()

void sf::VariableListModel::setVariablesConvert ( bool  enable)

Sets the variable conversion for floating point values.

Parameters
enableTrue to enable conversion and false for not.

◆ update()

void sf::VariableListModel::update ( int  row = -1,
int  column = -1,
const QList< int > &  roles = QList< int >() 
)

Update values in the given column and row.

Parameters
rowWhen -1 all rows are selected.
columnWhen -1 all columns are selected.
rolesRoles to update.

◆ updateField()

void sf::VariableListModel::updateField ( int  row,
EField  field,
const QList< int > &  roles = QList< int >() 
)

Update the column for the given field for all rows.

Parameters
rowWhen -1 all rows are selected.
fieldTranslated to the column containing the field.
rolesRoles to update.

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