NDEVR
API Documentation
DesignTableModel

Provides the ability to pull data from a DesignObjectLookup for display in tables within the NDEVR API. More...

Collaboration diagram for DesignTableModel:
[legend]

Public Member Functions

 DesignTableModel (QObject *parent=nullptr)
 Constructs a DesignTableModel.
uint04 addColumn (const DesignParameter &parameter, bool is_editable)
 Adds a column displaying the given design parameter.
uint04 addColumn (const ModelTableColumnSpec &column)
 Adds a column from a fully specified ModelTableColumnSpec.
uint04 addColumn (const TranslatedString &name, const StringView &icon, const std::function< void(UUID)> &callback)
 Adds a button column with a label, icon, and click callback.
uint04 addColumn (NDPO property, bool is_editable)
 Adds a column displaying the given NDPO property.
uint04 addGrandparentNameColumn (const TranslatedString &custom_column_name=TranslatedString())
 Adds a column showing the grandparent name of each object.
uint04 addMaterialDataColumn (const TranslatedString &custom_column_name=TranslatedString())
 Adds a column showing the material of each object.
uint04 addParentDataColumn (const DesignParameter &param, bool is_editable, const TranslatedString &custom_column_name=TranslatedString())
 Adds a column showing a parent design parameter value.
uint04 addParentPathColumn (const TranslatedString &custom_column_name=TranslatedString())
 Adds a column showing the parent path of each object.
bool canAddObject (const Model &object) const
 Returns whether the given Model can be added to the table.
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of columns in the table.
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Returns the data for the given index and role.
Qt::ItemFlags flags (const QModelIndex &index) const override
 Returns the item flags for the given index.
const ModelTableColumnSpecgetColumnSpec (uint04 column) const
 Returns the column specification for the given column index.
DynamicPointer< QTDesignObjectgetDesignObject (QModelIndex index) const
 Returns the QTDesignObject for the row of the given index.
DynamicPointer< QTDesignObjectgetDesignObject (QModelIndex index, int row) const
 Returns the QTDesignObject for the given row number.
Model getModel (QModelIndex index) const
 Returns the Model for the row of the given index.
DesignObject getObject (QModelIndex index) const
 Returns the DesignObject for the row of the given index.
DesignObject getObject (QModelIndex index, int row) const
 Returns the DesignObject for the given row number.
UUID getUUID (QModelIndex index) const
 Returns the UUID for the row of the given index.
UUID getUUID (QModelIndex index, int row) const
 Returns the UUID for the given row number.
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Returns the header data for the given section, orientation, and role.
bool isEditable () const
 Returns whether the table is currently editable.
bool isMaterialIndex (const QModelIndex &index) const
 Returns whether the given index represents a material column.
bool isObjectAllowed (const Model &object) const
 Returns whether the given Model passes the added filter.
bool isObjectAllowed (const UUID &object) const
 Returns whether the given object UUID passes the added filter.
bool isSpecialCallbackIndex (const QModelIndex &index) const
 Returns whether the given index represents a custom callback column.
QTModelManagermodelManager () const
 Returns the model manager.
virtual void modelUpdated (const Buffer< UUID > &ids)
 Called when existing design objects are updated.
void modelUpdatedSlot (const Buffer< UUID > &ids)
 Slot connected to the model manager's model-updated signal.
virtual void objectAdded (const Buffer< UUID > &ids)
 Called when new design objects are added to the model manager.
void objectAddedSlot (const Buffer< UUID > &ids)
 Slot connected to the model manager's object-added signal.
virtual void objectDeleted (const Buffer< UUID > &ids)
 Called when design objects are deleted from the model manager.
void objectDeletedSlot (const Buffer< UUID > &ids)
 Slot connected to the model manager's object-deleted signal.
void onSelected (QModelIndex index, const QRect &rect)
 Handles a row selection event, invoking the selected callback.
void refreshAll ()
 Forces a full refresh of all rows and columns.
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of rows in the table.
void setAddedFilter (const std::function< bool(const Model &)> &callback)
 Sets a filter callback applied when objects are added to the table.
void setColumnEditable (uint04 column, bool is_editable)
 Sets whether a specific column is editable.
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 Sets data at the given index for the specified role.
void setIsEditable (bool is_editable)
 Sets whether the table is editable.
void setList (const Buffer< UUID > &models)
 Sets the list of object UUIDs to display as rows.
void setModelManager (QTModelManager *manager)
 Sets the model manager and connects its signals.
void setup ()
 Performs initial setup, connecting to the model manager signals.
QVariant userData (const QModelIndex &index, int role) const
 Returns custom user-role data for the given index.

Protected Member Functions

void updateColumn (uint04 index)
 Updates a single column specification at the given index.

Protected Attributes

std::function< bool(const Model &)> m_added_filter
 Filter callback for added/valid objects.
QTResourceListenerm_angle_listener = nullptr
 Listener for angle unit changes.
Buffer< BitFlagm_callback_clicked
 Tracks which callback buttons have been clicked per row.
Buffer< ModelTableColumnSpecm_columns
 The column specifications for the table.
QTResourceListenerm_coord_listener = nullptr
 Listener for coordinate unit changes.
bool m_is_editable
 Whether the table is currently editable.
QTModelManagerm_manager
 The model manager providing design objects.
Buffer< UUIDm_models
 List of all model UUIDs displayed in the table.
QTResourceListenerm_orientation_listener = nullptr
 Listener for orientation unit changes.

Detailed Description

Provides the ability to pull data from a DesignObjectLookup for display in tables within the NDEVR API.


Definition at line 225 of file DesignTableModel.h.

Constructor & Destructor Documentation

◆ DesignTableModel()

DesignTableModel::DesignTableModel ( QObject * parent = nullptr)
explicit

Constructs a DesignTableModel.

Parameters
[in]parentThe parent QObject.

References DesignTableModel().

Referenced by DesignTableModel().

Member Function Documentation

◆ addColumn() [1/4]

uint04 DesignTableModel::addColumn ( const DesignParameter & parameter,
bool is_editable )

Adds a column displaying the given design parameter.

Parameters
[in]parameterThe design parameter.
[in]is_editableWhether the column allows editing.
Returns
The index of the added column.

◆ addColumn() [2/4]

uint04 DesignTableModel::addColumn ( const ModelTableColumnSpec & column)

Adds a column from a fully specified ModelTableColumnSpec.

Parameters
[in]columnThe column specification.
Returns
The index of the added column.

◆ addColumn() [3/4]

uint04 DesignTableModel::addColumn ( const TranslatedString & name,
const StringView & icon,
const std::function< void(UUID)> & callback )

Adds a button column with a label, icon, and click callback.

Parameters
[in]nameThe column header name.
[in]iconThe icon name.
[in]callbackThe function called with the object UUID when clicked.
Returns
The index of the added column.

◆ addColumn() [4/4]

uint04 DesignTableModel::addColumn ( NDPO property,
bool is_editable )

Adds a column displaying the given NDPO property.

Parameters
[in]propertyThe property to display.
[in]is_editableWhether the column allows editing.
Returns
The index of the added column.

◆ addGrandparentNameColumn()

uint04 DesignTableModel::addGrandparentNameColumn ( const TranslatedString & custom_column_name = TranslatedString())

Adds a column showing the grandparent name of each object.

Parameters
[in]custom_column_nameAn optional custom header name.
Returns
The index of the added column.

◆ addMaterialDataColumn()

uint04 DesignTableModel::addMaterialDataColumn ( const TranslatedString & custom_column_name = TranslatedString())

Adds a column showing the material of each object.

Parameters
[in]custom_column_nameAn optional custom header name.
Returns
The index of the added column.

◆ addParentDataColumn()

uint04 DesignTableModel::addParentDataColumn ( const DesignParameter & param,
bool is_editable,
const TranslatedString & custom_column_name = TranslatedString() )

Adds a column showing a parent design parameter value.

Parameters
[in]paramThe design parameter to display from the parent.
[in]is_editableWhether the column allows editing.
[in]custom_column_nameAn optional custom header name.
Returns
The index of the added column.

◆ addParentPathColumn()

uint04 DesignTableModel::addParentPathColumn ( const TranslatedString & custom_column_name = TranslatedString())

Adds a column showing the parent path of each object.

Parameters
[in]custom_column_nameAn optional custom header name.
Returns
The index of the added column.

◆ canAddObject()

bool DesignTableModel::canAddObject ( const Model & object) const

Returns whether the given Model can be added to the table.

Parameters
[in]objectThe model to check.
Returns
True if the model can be added.

◆ columnCount()

int DesignTableModel::columnCount ( const QModelIndex & parent = QModelIndex()) const
nodiscardoverride

Returns the number of columns in the table.

Parameters
[in]parentThe parent index (unused for flat tables).
Returns
The column count.

◆ data()

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

Returns the data for the given index and role.

Parameters
[in]indexThe model index.
[in]roleThe Qt data role.
Returns
The data as a QVariant.

◆ flags()

Qt::ItemFlags DesignTableModel::flags ( const QModelIndex & index) const
nodiscardoverride

Returns the item flags for the given index.

Parameters
[in]indexThe model index.
Returns
The Qt item flags.

◆ getColumnSpec()

const ModelTableColumnSpec & DesignTableModel::getColumnSpec ( uint04 column) const
nodiscard

Returns the column specification for the given column index.

Parameters
[in]columnThe column index.
Returns
A const reference to the ModelTableColumnSpec.

◆ getDesignObject() [1/2]

DynamicPointer< QTDesignObject > DesignTableModel::getDesignObject ( QModelIndex index) const
nodiscard

Returns the QTDesignObject for the row of the given index.

Parameters
[in]indexThe model index.
Returns
A DynamicPointer to the QTDesignObject.

◆ getDesignObject() [2/2]

DynamicPointer< QTDesignObject > DesignTableModel::getDesignObject ( QModelIndex index,
int row ) const
nodiscard

Returns the QTDesignObject for the given row number.

Parameters
[in]indexThe model index (used for validation).
[in]rowThe row number.
Returns
A DynamicPointer to the QTDesignObject.

◆ getModel()

Model DesignTableModel::getModel ( QModelIndex index) const
nodiscard

Returns the Model for the row of the given index.

Parameters
[in]indexThe model index.
Returns
The Model at that row.

◆ getObject() [1/2]

DesignObject DesignTableModel::getObject ( QModelIndex index) const
nodiscard

Returns the DesignObject for the row of the given index.

Parameters
[in]indexThe model index.
Returns
The DesignObject at that row.

◆ getObject() [2/2]

DesignObject DesignTableModel::getObject ( QModelIndex index,
int row ) const
nodiscard

Returns the DesignObject for the given row number.

Parameters
[in]indexThe model index (used for validation).
[in]rowThe row number.
Returns
The DesignObject at that row.

◆ getUUID() [1/2]

UUID DesignTableModel::getUUID ( QModelIndex index) const
nodiscard

Returns the UUID for the row of the given index.

Parameters
[in]indexThe model index.
Returns
The UUID of the object at that row.

◆ getUUID() [2/2]

UUID DesignTableModel::getUUID ( QModelIndex index,
int row ) const
nodiscard

Returns the UUID for the given row number.

Parameters
[in]indexThe model index (used for validation).
[in]rowThe row number.
Returns
The UUID of the object at that row.

◆ headerData()

QVariant DesignTableModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const
nodiscardoverride

Returns the header data for the given section, orientation, and role.

Parameters
[in]sectionThe section (column or row) index.
[in]orientationThe header orientation.
[in]roleThe Qt data role.
Returns
The header data as a QVariant.

◆ isEditable()

bool DesignTableModel::isEditable ( ) const

Returns whether the table is currently editable.

Returns
True if editable.

◆ isMaterialIndex()

bool DesignTableModel::isMaterialIndex ( const QModelIndex & index) const
nodiscard

Returns whether the given index represents a material column.

Parameters
[in]indexThe model index.
Returns
True if it is a material index.

◆ isObjectAllowed() [1/2]

bool DesignTableModel::isObjectAllowed ( const Model & object) const

Returns whether the given Model passes the added filter.

Parameters
[in]objectThe model to check.
Returns
True if the model is allowed.

◆ isObjectAllowed() [2/2]

bool DesignTableModel::isObjectAllowed ( const UUID & object) const

Returns whether the given object UUID passes the added filter.

Parameters
[in]objectThe UUID to check.
Returns
True if the object is allowed.

◆ isSpecialCallbackIndex()

bool DesignTableModel::isSpecialCallbackIndex ( const QModelIndex & index) const
nodiscard

Returns whether the given index represents a custom callback column.

Parameters
[in]indexThe model index.
Returns
True if it is a special callback index.

◆ modelManager()

QTModelManager * DesignTableModel::modelManager ( ) const
inlinenodiscard

Returns the model manager.

Returns
A pointer to the QTModelManager.

Definition at line 379 of file DesignTableModel.h.

References m_manager.

◆ modelUpdated()

virtual void DesignTableModel::modelUpdated ( const Buffer< UUID > & ids)
virtual

Called when existing design objects are updated.

Parameters
[in]idsThe UUIDs of the updated objects.

◆ modelUpdatedSlot()

void DesignTableModel::modelUpdatedSlot ( const Buffer< UUID > & ids)

Slot connected to the model manager's model-updated signal.

Parameters
[in]idsThe UUIDs of the updated objects.

◆ objectAdded()

virtual void DesignTableModel::objectAdded ( const Buffer< UUID > & ids)
virtual

Called when new design objects are added to the model manager.

Parameters
[in]idsThe UUIDs of the added objects.

◆ objectAddedSlot()

void DesignTableModel::objectAddedSlot ( const Buffer< UUID > & ids)

Slot connected to the model manager's object-added signal.

Parameters
[in]idsThe UUIDs of the added objects.

◆ objectDeleted()

virtual void DesignTableModel::objectDeleted ( const Buffer< UUID > & ids)
virtual

Called when design objects are deleted from the model manager.

Parameters
[in]idsThe UUIDs of the deleted objects.

◆ objectDeletedSlot()

void DesignTableModel::objectDeletedSlot ( const Buffer< UUID > & ids)

Slot connected to the model manager's object-deleted signal.

Parameters
[in]idsThe UUIDs of the deleted objects.

◆ onSelected()

void DesignTableModel::onSelected ( QModelIndex index,
const QRect & rect )

Handles a row selection event, invoking the selected callback.

Parameters
[in]indexThe model index of the selected row.
[in]rectThe bounding rectangle of the selected cell.

◆ rowCount()

int DesignTableModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
nodiscardoverride

Returns the number of rows in the table.

Parameters
[in]parentThe parent index (unused for flat tables).
Returns
The row count.

◆ setAddedFilter()

void DesignTableModel::setAddedFilter ( const std::function< bool(const Model &)> & callback)
inline

Sets a filter callback applied when objects are added to the table.

Parameters
[in]callbackA function returning true for models that should be included.

Definition at line 307 of file DesignTableModel.h.

References m_added_filter.

◆ setColumnEditable()

void DesignTableModel::setColumnEditable ( uint04 column,
bool is_editable )

Sets whether a specific column is editable.

Parameters
[in]columnThe column index.
[in]is_editableWhether editing is allowed for that column.

◆ setData()

bool DesignTableModel::setData ( const QModelIndex & index,
const QVariant & value,
int role )
nodiscardoverride

Sets data at the given index for the specified role.

Parameters
[in]indexThe model index.
[in]valueThe new value.
[in]roleThe Qt data role.
Returns
True if the data was set successfully.

◆ setIsEditable()

void DesignTableModel::setIsEditable ( bool is_editable)

Sets whether the table is editable.

Parameters
[in]is_editableWhether editing is allowed.

◆ setList()

void DesignTableModel::setList ( const Buffer< UUID > & models)

Sets the list of object UUIDs to display as rows.

Parameters
[in]modelsThe UUIDs to display.

◆ setModelManager()

void DesignTableModel::setModelManager ( QTModelManager * manager)

Sets the model manager and connects its signals.

Parameters
[in]managerThe QTModelManager instance.

◆ updateColumn()

void DesignTableModel::updateColumn ( uint04 index)
protected

Updates a single column specification at the given index.

Parameters
[in]indexThe column index to update.

◆ userData()

QVariant DesignTableModel::userData ( const QModelIndex & index,
int role ) const
nodiscard

Returns custom user-role data for the given index.

Parameters
[in]indexThe model index.
[in]roleThe user data role.
Returns
The user data as a QVariant.

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