Qt Model Utilities
2.0.3
A set of utilities for the model/view framework of Qt
|
This proxy will act as a mask on top of the source model to intercept data. More...
Signals | |
void | maskedDataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles) |
void | maskedRolesChanged () |
void | maskHeaderDataChanged (bool val) |
void | mergeDisplayEditChanged (bool val) |
void | transparentIfEmptyChanged (bool val) |
Public Member Functions | |
RoleMaskProxyModel (QObject *parent=Q_NULLPTR) | |
~RoleMaskProxyModel () | |
void | addMaskedRole (int role) |
bool | clearItemData (const QModelIndex &index) override |
void | clearMaskedData (const QModelIndex &index) |
void | clearMaskedFlags (const QModelIndex &index) |
void | clearMaskedRoles () |
QVariant | data (const QModelIndex &proxyIndex, int role=Qt::DisplayRole) const override |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
QMap< int, QVariant > | itemData (const QModelIndex &index) const override |
const Qt::ItemFlags * | maskedFlags (const QModelIndex &index) const |
QMap< int, QVariant > | maskedItemData (const QModelIndex &index) const |
QVariant | maskedRoleDefaultValue (int role) const |
QList< int > | maskedRoles () const |
bool | maskHeaderData () const |
bool | mergeDisplayEdit () const |
void | multiData (const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const override |
void | removeMaskedRole (int role) |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) override |
bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) override |
bool | setMaskedFlags (const QModelIndex &index, Qt::ItemFlags flags) |
bool | setMaskedRoleDefaultValue (int role, const QVariant &value) |
void | setMaskedRoles (const QList< int > &roles) |
void | setMaskHeaderData (bool val) |
void | setMergeDisplayEdit (bool val) |
void | setSourceModel (QAbstractItemModel *sourceModel) override |
void | setTransparentIfEmpty (bool val) |
void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override |
bool | transparentIfEmpty () const |
Protected Member Functions | |
RoleMaskProxyModel (RoleMaskProxyModelPrivate &dptr, QObject *parent) | |
const QSet< int > & | maskedRolesSets () const |
Properties | |
QList< int > | maskedRoles |
Returns the list of roles managed by the proxy model. More... | |
bool | maskHeaderData |
This property determines if the role mask should apply to the headers too. More... | |
bool | mergeDisplayEdit |
This property determines if the Qt::DisplayRole and Qt::EditRole should be merged in the extra row/column. More... | |
bool | transparentIfEmpty |
This property determines if a mapped role containing no data should be transparent. More... | |
This proxy will act as a mask on top of the source model to intercept data.
This proxy model can be used to manage data in roles not supported by the source model. The user can select what roles should be managed by the proxy model and the rest will be left to the source model.
|
explicit |
Constructs a new proxy model with the given parent.
RoleMaskProxyModel::~RoleMaskProxyModel | ( | ) |
Destructor
|
protected |
Constructor used only while subclassing the private class. Not part of the public API
void RoleMaskProxyModel::addMaskedRole | ( | int | role | ) |
Adds role to the list of roles managed by the proxy model
|
override |
Reimplemented from base class
Due to limitations in the architecture, the model might emit 2 separate dataChanged signals, one for the roles that were masked and one for the roles that are managed by the sorce model
void RoleMaskProxyModel::clearMaskedData | ( | const QModelIndex & | index | ) |
Removes all the data managed by the proxy model for a certain index.
void RoleMaskProxyModel::clearMaskedFlags | ( | const QModelIndex & | index | ) |
Removes all the flags managed by the proxy model for a certain index.
void RoleMaskProxyModel::clearMaskedRoles | ( | ) |
Removes all roles managed by the proxy model
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
signal |
This signal is emitted whenever a dataChanged() signal is emitted for a role managed by the proxy
const Qt::ItemFlags * RoleMaskProxyModel::maskedFlags | ( | const QModelIndex & | index | ) | const |
Returns the flags managed by the proxy model for a certain index or nullptr if no flag is stored in the proxy model
QMap< int, QVariant > RoleMaskProxyModel::maskedItemData | ( | const QModelIndex & | index | ) | const |
Returns all the data managed by the proxy model for a certain index. The key of the map is the corresponding role
QVariant RoleMaskProxyModel::maskedRoleDefaultValue | ( | int | role | ) | const |
Returns the default value for the role when the proxy is not transparent
|
signal |
This signal is emitted whenever the list of roles managed by the proxy changes
|
protected |
Same as maskedRoles but returns it in the way it is stored internally rather than converting it to QList
|
override |
Reimplemented from base class
void RoleMaskProxyModel::removeMaskedRole | ( | int | role | ) |
Removes role from the list of roles managed by the proxy model
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
Due to limitations in the architecture, the model might emit 2 separate dataChanged signals, one for the roles that were masked and one for the roles that are managed by the sorce model
bool RoleMaskProxyModel::setMaskedFlags | ( | const QModelIndex & | index, |
Qt::ItemFlags | flags | ||
) |
Sets custom flags for the index that override the ones from the source model
void RoleMaskProxyModel::setMaskedRoles | ( | const QList< int > & | newRoles | ) |
Set the list of roles managed by the proxy model
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
This method will do nothing.
If you want to sort based on the marked data use a QSortFilterProxyModel on top of this proxy.
|
readwrite |
Returns the list of roles managed by the proxy model.
|
readwrite |
This property determines if the role mask should apply to the headers too.
By default this property is set to false
|
readwrite |
This property determines if the Qt::DisplayRole and Qt::EditRole should be merged in the extra row/column.
By default the two roles are one and the same you can use this property to separate them. If there's any data in the role when you set this property to true it will be duplicated for both roles. If there is data both in Qt::DisplayRole and Qt::EditRole when you set this property to false Qt::DisplayRole will prevail. This property only has effect if Qt::DisplayRole and/or Qt::EditRole are masked by the proxy. Data in the source model is not affected.
|
readwrite |
This property determines if a mapped role containing no data should be transparent.
If this property is set to true, roles managed by the proxy will show the source model data unless it gets ovewritten in the proxy