ImFusion SDK 4.3
DataDisplayModel Class Reference

#include <ImFusion/GUI/DataDisplayModel.h>

This class extends a DataItemModel with data visibility information from a DisplayWidgetMulti. More...

+ Inheritance diagram for DataDisplayModel:

Detailed Description

This class extends a DataItemModel with data visibility information from a DisplayWidgetMulti.

Instances of this class wrap a DataItemModel and add one additional column. The columns are added at the end on each rows and do not override any existing columns. The DataVisibleRole of a column represent if the data in a row is visible in the DisplayWidgetMulti or not. This is also represented by the Qt::CheckStateRole.

Note
While this behaves like a QAbstractProxyModel it cannot be implemented as one because QAbstractProxyModel is expected to have a 1:1 mapping to the source model. Appending a column at the end would work but adding it in the front breaks editing.

Public Types

enum  Roles { DataVisibleRole = Qt::UserRole + 100 , DataIsShowableRole = Qt::UserRole + 101 }
 
enum  Columns { COLUMN_DATA = 1 , COLUMN_VISIBLE = 0 }
 

Public Member Functions

 DataDisplayModel (DataItemModel *sourceModel, DisplayWidgetMulti *display, QObject *parent=0)
 
QModelIndex mapToSource (const QModelIndex &proxyIndex) const
 Maps an index in the proxy model to the corresponding index in the source model.
 
QModelIndex mapFromSource (const QModelIndex &sourceIndex) const
 Maps an index in the source model to the corresponding index in the proxy model.
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the column count of the source model plus the number of scenes.
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the row count of the source model.
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 Creates an index.
 
QModelIndex index (const Data *data, int column) const
 
QModelIndex parent (const QModelIndex &index) const override
 Returns the parent of index.
 
Qt::ItemFlags flags (const QModelIndex &index=QModelIndex()) const override
 Returns Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable for all additional columns or the flags of the source model.
 
void setSourceModel (DataItemModel *model)
 Sets the source model.
 
const DataItemModelsourceModel () const
 
DataItemModelsourceModel ()
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Returns true or false for DataVisibleRole for the additional columns.
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 Adds or removes the Data from the Display if role is DataVisibleRole.
 

Protected Slots

void onDataRowsRemoved (const QModelIndex &parent, int first, int last)
 Removes data from the Display before it is deleted.
 
void onVisibleDataChanged (const DataList &before, const DataList &visible)
 Updates model state.
 

Member Enumeration Documentation

◆ Roles

enum Roles
Enumerator
DataVisibleRole 

Flag whether the data is currently shown in any view.

DataIsShowableRole 

Flag whether data can be shown in any view.

Member Function Documentation

◆ data()

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

Returns true or false for DataVisibleRole for the additional columns.

The CheckStateRole of an additional column will returned Checked if the DataVisibleRole is true or false otherwise. All other columns are directed to the source model. The DataItemModel::DataRole for the additional columns will return the Data* represented by the row.

◆ setData()

bool setData ( const QModelIndex & index,
const QVariant & value,
int role = Qt::EditRole )
override

Adds or removes the Data from the Display if role is DataVisibleRole.

If value is true the Data is added to the Display, otherwise it's removed. The CheckStateRole will be redirected to the DataVisibleRole and the value changed to true if it was Qt::Checked or false for Qt::Unchecked.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close