![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/DataItemModel.h>
Wrapper class to transform the DataModel into a QAbstractItemModel so that it can be used in Qt views. More...
Inheritance diagram for DataItemModel:Wrapper class to transform the DataModel into a QAbstractItemModel so that it can be used in Qt views.
The underlying parentModel() will be represented as a tree with a single column. If a DataGroup has a proxy child, the index of the group will represent the proxy child data instead of the group. Furthermore, if a dataset implements the CompoundData interface (without being a DataGroup) the corresponding DataItemModel index will have the nested datasets (CompoundData::children()) as children. These children have the ElementType::Internal instead of ElementType::Regular to illustrate their nature that they are internal to the parent dataset and not owned by/accessible through the underlying DataModel.
A set of custom Roles enables you to query additional metadata from the datasets.
Classes | |
| struct | Item |
| Internal record to implement bookkeeping of the hierarchy in the underlying DataModel. More... | |
Public Types | |
| enum | Roles { DataRole = Qt::UserRole + 1 , DescriptionRole = Qt::UserRole + 2 , AttributesRole = Qt::UserRole + 3 , AttributesToolTipRole = Qt::UserRole + 4 , LinksRole = Qt::UserRole + 7 , LinksToolTipRole = Qt::UserRole + 8 , LinksIndexRole = Qt::UserRole + 9 , ElementTypeRole = Qt::UserRole + 10 } |
| Enumeration of special roles supported by the model. More... | |
| enum class | ElementType { Regular , Internal } |
| Value type of Roles::ElementTypeRole. More... | |
Signals | |
| void | dataAdded (Data *data) |
| Signal emitted whenever a new dataset has been added. | |
| void | dataAboutToBeRemoved (Data *data) |
| Signal emitted directly before a dataset will be removed from the model. | |
| void | dataRemoved (Data *data) |
| Signal emitted whenever a new dataset has been removed; careful: data is no longer valid. | |
Public Member Functions | |
| Q_ENUM (ElementType) | |
| DataItemModel (DataModel &parentModel) | |
| Instantiates a new DataItemModel representing the given DataModel, which must remain valid for the entire lifetime. | |
| DataModel & | parentModel () |
| Returns the underlying DataModel. | |
| const DataModel & | parentModel () const |
| QModelIndex | index (const Data *data) const |
| QModelIndices for this item model are constructed as follows: | |
| Data * | get (const QModelIndex &index) const |
Returns the data at the index or nullptr if the index does not exist. | |
| void | enableThumbnails (bool enabled, int thumbnailSizePx) |
| Enables thumbnail generation when data with Qt::DecorationRole is requested (default is enabled) | |
| bool | thumbnailsEnabled () const |
| Returns whether thumbnail generation is enabled. | |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
| Qt::ItemFlags | flags (const QModelIndex &index) const override |
| QModelIndex | parent (const QModelIndex &index) const override |
| int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
Public Member Functions inherited from SignalReceiver | |
| SignalReceiver ()=default | |
| Default constructor. | |
| SignalReceiver (const SignalReceiver &other) | |
| Copy constructor, does not copy any existing signal connections from other. | |
| SignalReceiver & | operator= (SignalReceiver rhs) |
| Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs. | |
| virtual | ~SignalReceiver () |
| Virtual destructor disconnects from all connected signals. | |
Protected Member Functions | |
| QModelIndex | index (const Item *item) const |
| QString | description (const Data *data) const |
| void | registerData (Data *data, const Data *parent, bool isInternalRestructuring) |
| Updates the internal bookkeeping to track data being added as a child of parent. | |
| void | unregisterData (Data *data, bool isInternalRestructuring) |
| Updates the internal bookkeeping to no longer track data. | |
| void | moveRegisteredData (Data *data, const Data *newParent) |
| Updates the internal bookkeeping after data has moved inside/to newParent. | |
| void | onParentModelDataAdded (Data *data) |
| void | onParentModelDataAboutToBeRemoved (Data *data) |
| void | onParentModelDataMoved (Data *data) |
| void | onProxyChildChanged (DataGroup *parent, bool isInternalRestructuring) |
| void | assertItemMapConsistency (bool checkChildren, bool checkProxyChildSignal) const |
Protected Member Functions inherited from SignalReceiver | |
| void | disconnectAll () |
| Disconnects all existing connections. | |
Protected Attributes | |
| DataModel * | m_parentModel |
| Item | m_rootItem |
| std::unordered_map< const Data *, Item * > | m_itemMap |
| bool | m_thumbnailsEnabled = true |
| int | m_thumbnailSizePx = 32 |
| enum Roles |
Enumeration of special roles supported by the model.
| Enumerator | |
|---|---|
| DataRole | The pointer to the data (use with variant.value<ImFusion::Data*>()) |
| DescriptionRole | A short description of the data type (e.g. '2D Image' or 'Ultrasound Sweep') |
| AttributesRole | A QList of QIcons representing special attributes of the data (e.g. multichannel, stream, mask, deformation...) |
| AttributesToolTipRole | A QList of QString representing a tool tip for the elements of AttributesRole. |
| LinksRole | A QList of QIcons representing links of the data. |
| LinksToolTipRole | A QList of QString representing a tool tip for the elements of LinksRole. |
| LinksIndexRole | A QList of the indices of the links in the DataModels list. |
| ElementTypeRole | The ElementType of the data. |
|
strong |
Value type of Roles::ElementTypeRole.
| Enumerator | |
|---|---|
| Regular | A regular Data instance owned and maintained by the underlying DataModel. |
| Internal | A Data instance that is implicitly bound to/owned by the parent dataset, not accessible through the underlying DataModel. |
| QModelIndex index | ( | const Data * | data | ) | const |
QModelIndices for this item model are constructed as follows:
Updates the internal bookkeeping to track data being added as a child of parent.
Will emit the dataAdded() signal unless isInternalRestructuring is true.
|
protected |
Updates the internal bookkeeping to no longer track data.
Will emit the dataAboutToBeRemoved() signal unless isInternalRestructuring is true.