QAbstractItemModel implementation for vtkDataAssembly. More...
#include <pqDataAssemblyTreeModel.h>
Inherits QAbstractItemModel.
Public Types | |
enum | RoleProperties { Standard, Inherited, InheritedUntilOverridden } |
Supported role properties. More... | |
Signals | |
void | modelDataChanged (int role) |
This signal is fired in setData if the data is changed. More... | |
Public Member Functions | |
pqDataAssemblyTreeModel (QObject *parent=nullptr) | |
~pqDataAssemblyTreeModel () override | |
void | setDataAssembly (vtkDataAssembly *assembly) |
Get/Set the vtkDataAssembly to represent in this model. More... | |
vtkDataAssembly * | dataAssembly () const |
void | setUserCheckable (bool) |
Get whether the model is user-checkable. More... | |
bool | userCheckable () const |
Get whether the model is user-checkable. More... | |
int | nodeId (const QModelIndex &idx) const |
Given a QModelIndex, returns the vtkDataAssembly node id, if any. More... | |
QList< int > | nodeId (const QModelIndexList &idxes) const |
Given a QModelIndex, returns the vtkDataAssembly node id, if any. More... | |
QModelIndex | index (int nodeId) const |
Get a node id, returns the QModelIndex for the same. More... | |
QModelIndexList | index (const QList< int > &nodeIds) const |
Get a node id, returns the QModelIndex for the same. More... | |
void | setCheckedNodes (const QStringList &paths) |
Get/Set the check state for Qt::Checked for nodes selected using the path names specified. More... | |
QStringList | checkedNodes () const |
Get/Set the check state for Qt::Checked for nodes selected using the path names specified. More... | |
void | setRoleProperty (int role, RoleProperties property) |
Set properties for custom roles. More... | |
RoleProperties | roleProperty (int role) const |
Set properties for custom roles. More... | |
bool | setData (const QList< QPair< QString, QVariant >> &values, int role) |
Get/Set the values for a specific role using selectors. More... | |
QList< QPair< QString, QVariant > > | data (int role) const |
Get/Set the values for a specific role using selectors. More... | |
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
QAbstractItemModel interface implementation. More... | |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
QAbstractItemModel interface implementation. More... | |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
QAbstractItemModel interface implementation. More... | |
QModelIndex | parent (const QModelIndex &index=QModelIndex()) const override |
QAbstractItemModel interface implementation. More... | |
QVariant | data (const QModelIndex &index, int role) const override |
QAbstractItemModel interface implementation. More... | |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
QAbstractItemModel interface implementation. More... | |
bool | setData (const QModelIndex &index, const QVariant &value, int role) override |
QAbstractItemModel interface implementation. More... | |
Static Public Member Functions | |
static int | GetIsDerivedRole (int role) |
For custom roles, use this function to convert that role into a role that can be used in data() to get a boolean indicating if the value is derived or explicitly set. More... | |
QAbstractItemModel implementation for vtkDataAssembly.
pqDataAssemblyTreeModel builds a tree-model from a vtkDataAssembly. The vtkDataAssembly to shown is set using setDataAssembly
. To allow user-settable check-states, use setUserCheckable(true)
.
One can store additional data associated with nodes using custom roles (Qt::UserRole
). For custom roles, one can define how a value for that specific role get inherited by child nodes or overridden when set on a parent node. This is done using setRoleProperty
.
Definition at line 28 of file pqDataAssemblyTreeModel.h.
Supported role properties.
Standard
implies no special handling i.e. the role does not affect the value of the value for child nodes in the hierarchy. Inherited
means for any node, if a value for this role is not explicitly specified, then it is inherited from its parent node. Likewise, if one sets a explicitly on a node (using setData
), the it overrides values for this role on all children recursively. InheritedUntilOverridden
is similar to Inherited
except that the recursion down the subtree stops when a child node with an explicitly set value is encountered.
Enumerator | |
---|---|
Standard | |
Inherited | |
InheritedUntilOverridden |
Definition at line 107 of file pqDataAssemblyTreeModel.h.
pqDataAssemblyTreeModel::pqDataAssemblyTreeModel | ( | QObject * | parent = nullptr | ) |
|
override |
void pqDataAssemblyTreeModel::setDataAssembly | ( | vtkDataAssembly * | assembly | ) |
Get/Set the vtkDataAssembly to represent in this model.
vtkDataAssembly* pqDataAssemblyTreeModel::dataAssembly | ( | ) | const |
void pqDataAssemblyTreeModel::setUserCheckable | ( | bool | ) |
Get whether the model is user-checkable.
|
inline |
Get whether the model is user-checkable.
Definition at line 48 of file pqDataAssemblyTreeModel.h.
Given a QModelIndex, returns the vtkDataAssembly node id, if any.
-1 is returned for invalid index.
Given a QModelIndex, returns the vtkDataAssembly node id, if any.
-1 is returned for invalid index.
QModelIndex pqDataAssemblyTreeModel::index | ( | int | nodeId | ) | const |
Get a node id, returns the QModelIndex for the same.
Get a node id, returns the QModelIndex for the same.
void pqDataAssemblyTreeModel::setCheckedNodes | ( | const QStringList & | paths | ) |
Get/Set the check state for Qt::Checked for nodes selected using the path names specified.
setCheckedNodes
has effect as setData(.., Qt::CheckStateRole)
, only differing in how the values are specified. For setCheckedNodes
, one only lists the selectors for checked nodes, while setData
accept pairs where the first value is the selector while the second value is the check state.
checkedNodes()
may not returns exactly the same paths passed to setCheckedNodes
even if the check-states were not changed in between the two calls.QStringList pqDataAssemblyTreeModel::checkedNodes | ( | ) | const |
Get/Set the check state for Qt::Checked for nodes selected using the path names specified.
setCheckedNodes
has effect as setData(.., Qt::CheckStateRole)
, only differing in how the values are specified. For setCheckedNodes
, one only lists the selectors for checked nodes, while setData
accept pairs where the first value is the selector while the second value is the check state.
checkedNodes()
may not returns exactly the same paths passed to setCheckedNodes
even if the check-states were not changed in between the two calls.For custom roles, use this function to convert that role into a role that can be used in data()
to get a boolean indicating if the value is derived or explicitly set.
Definition at line 94 of file pqDataAssemblyTreeModel.h.
void pqDataAssemblyTreeModel::setRoleProperty | ( | int | role, |
RoleProperties | property | ||
) |
Set properties for custom roles.
If none specified, Standard is assumed. For Qt::CheckStateRole
, it is initialized to Inherited
.
RoleProperties pqDataAssemblyTreeModel::roleProperty | ( | int | role | ) | const |
Set properties for custom roles.
If none specified, Standard is assumed. For Qt::CheckStateRole
, it is initialized to Inherited
.
bool pqDataAssemblyTreeModel::setData | ( | const QList< QPair< QString, QVariant >> & | values, |
int | role | ||
) |
Get/Set the values for a specific role using selectors.
The values are specified as a list of pairs which pair comprising of a selector and the associated value for that selector. This model is not capable of generating advanced selectors, so data()
will simply return paths as selectors. setData
can use any for for selector specification supported by the underlying vtkDataAssembly
.
This model does not cache set values. When setData
is called, nodes matching the selectors are immediately located and updated. Hence, if this method is called before any assembly is set, the values will be lost. In this case, setData
will return false.
QList<QPair<QString, QVariant> > pqDataAssemblyTreeModel::data | ( | int | role | ) | const |
Get/Set the values for a specific role using selectors.
The values are specified as a list of pairs which pair comprising of a selector and the associated value for that selector. This model is not capable of generating advanced selectors, so data()
will simply return paths as selectors. setData
can use any for for selector specification supported by the underlying vtkDataAssembly
.
This model does not cache set values. When setData
is called, nodes matching the selectors are immediately located and updated. Hence, if this method is called before any assembly is set, the values will be lost. In this case, setData
will return false.
|
override |
QAbstractItemModel interface implementation.
QAbstractItemModel interface implementation.
|
override |
QAbstractItemModel interface implementation.
|
override |
QAbstractItemModel interface implementation.
QAbstractItemModel interface implementation.
|
override |
QAbstractItemModel interface implementation.
|
override |
QAbstractItemModel interface implementation.
|
signal |
This signal is fired in setData
if the data is changed.
setData
can result in multiple calls to dataChanged
signal as the data is updated on nodes in the hierarchy. This signal is fired only once for setData
call irrespective of how many internal nodes are updated.