Public Types | Signals | Public Member Functions | Static Public Member Functions | List of all members
pqDataAssemblyTreeModel Class Reference

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< intnodeId (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...
 

Detailed Description

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.

Member Enumeration Documentation

◆ RoleProperties

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.

Constructor & Destructor Documentation

◆ pqDataAssemblyTreeModel()

pqDataAssemblyTreeModel::pqDataAssemblyTreeModel ( QObject *  parent = nullptr)

◆ ~pqDataAssemblyTreeModel()

pqDataAssemblyTreeModel::~pqDataAssemblyTreeModel ( )
override

Member Function Documentation

◆ setDataAssembly()

void pqDataAssemblyTreeModel::setDataAssembly ( vtkDataAssembly *  assembly)

Get/Set the vtkDataAssembly to represent in this model.

◆ dataAssembly()

vtkDataAssembly* pqDataAssemblyTreeModel::dataAssembly ( ) const

◆ setUserCheckable()

void pqDataAssemblyTreeModel::setUserCheckable ( bool  )

Get whether the model is user-checkable.

◆ userCheckable()

bool pqDataAssemblyTreeModel::userCheckable ( ) const
inline

Get whether the model is user-checkable.

Definition at line 48 of file pqDataAssemblyTreeModel.h.

◆ nodeId() [1/2]

int pqDataAssemblyTreeModel::nodeId ( const QModelIndex &  idx) const

Given a QModelIndex, returns the vtkDataAssembly node id, if any.

-1 is returned for invalid index.

◆ nodeId() [2/2]

QList<int> pqDataAssemblyTreeModel::nodeId ( const QModelIndexList &  idxes) const

Given a QModelIndex, returns the vtkDataAssembly node id, if any.

-1 is returned for invalid index.

◆ index() [1/3]

QModelIndex pqDataAssemblyTreeModel::index ( int  nodeId) const

Get a node id, returns the QModelIndex for the same.

◆ index() [2/3]

QModelIndexList pqDataAssemblyTreeModel::index ( const QList< int > &  nodeIds) const

Get a node id, returns the QModelIndex for the same.

◆ setCheckedNodes()

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.

Note
checking a node causes all it child nodes to be checked as well.
checkedNodes() may not returns exactly the same paths passed to setCheckedNodes even if the check-states were not changed in between the two calls.
See also
vtkDataAssembly::SelectNodes

◆ checkedNodes()

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.

Note
checking a node causes all it child nodes to be checked as well.
checkedNodes() may not returns exactly the same paths passed to setCheckedNodes even if the check-states were not changed in between the two calls.
See also
vtkDataAssembly::SelectNodes

◆ GetIsDerivedRole()

static int pqDataAssemblyTreeModel::GetIsDerivedRole ( int  role)
inlinestatic

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.

◆ setRoleProperty()

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.

◆ roleProperty()

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.

◆ setData() [1/2]

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.

See also
vtkDataAssembly::SelectNodes

◆ data() [1/2]

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.

See also
vtkDataAssembly::SelectNodes

◆ columnCount()

int pqDataAssemblyTreeModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

QAbstractItemModel interface implementation.

◆ rowCount()

int pqDataAssemblyTreeModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

QAbstractItemModel interface implementation.

◆ index() [3/3]

QModelIndex pqDataAssemblyTreeModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

QAbstractItemModel interface implementation.

◆ parent()

QModelIndex pqDataAssemblyTreeModel::parent ( const QModelIndex &  index = QModelIndex()) const
override

QAbstractItemModel interface implementation.

◆ data() [2/2]

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

QAbstractItemModel interface implementation.

◆ flags()

Qt::ItemFlags pqDataAssemblyTreeModel::flags ( const QModelIndex &  index) const
override

QAbstractItemModel interface implementation.

◆ setData() [2/2]

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

QAbstractItemModel interface implementation.

◆ modelDataChanged

void pqDataAssemblyTreeModel::modelDataChanged ( int  role)
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.


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