NDEVR
API Documentation
QTModelManagerViewfinal

A Qt compatible ItemModel for interfacing with a DesignObjectLookup. More...

Collaboration diagram for QTModelManagerView:
[legend]

Classes

struct  ModelCache
 Cached data for a single model entry in the tree view, storing display properties to avoid repeated lookups. More...

Public Member Functions

 QTModelManagerView (QTModelManager *manager, QObject *parent=nullptr)
 Constructs a model manager view for the given manager.
QTModelManagermanager ()
 Retrieves the underlying model manager.
const Buffer< UUID > & rootModels () const
 Retrieves the current root model UUIDs.
void setIsRootFilter (const std::function< bool(const Model &)> &filter)
 Sets a filter function that determines which models are treated as roots.
void setRootModels (const Buffer< UUID > &roots)
 Sets the root models displayed in the view.

Protected Member Functions

void addModel (UUID id)
 Adds a model to the view and cache.
void clearAll ()
 Clears all cached data and resets the view.
ModelCache createCache (const Model &model, bool recursive, bool parent_visible, bool add_id) const
 Creates a cache entry for a model.
QVariant data (const UUID &id, int role, int column) const
 Retrieves display data for a specific model by UUID, role, and column.
void emitIndexUpdated (const UUID &id, const QList< int > &roles=QList< int >())
 Emits data-changed signals for a specific model index.
QModelIndex getIndex (const Model &model, int column) const
 Retrieves the QModelIndex for a model at a specific column.
QModelIndex getIndex (const UUID &id, int column) const
 Retrieves the QModelIndex for a model UUID at a specific column.
UUID getMaterialID (const QModelIndex &model_index) const
 Retrieves the material UUID for a given QModelIndex.
UUID getModelID (const QModelIndex &model_index) const
 Retrieves the model UUID for a given QModelIndex.
bool hasCached (const UUID &id) const
 Checks whether cached data exists for a given model UUID.
QIcon::Mode iconMode (const QModelIndex &index) const
 Determines the icon display mode for the given index.
void materialUpdatedSlot (const Buffer< UUID > &updated_ids)
 Handles material update events.
Model model (const QModelIndex &model_index) const
 Retrieves a Model object for a given QModelIndex.
Model model (uint04 row, const QModelIndex &parent) const
 Retrieves a Model object by row and parent index.
void modelAdded (Buffer< UUID > id)
 Handles model addition events.
void modelDeleted (Buffer< UUID > id)
 Handles model deletion events.
void modelFocussed (UUID id, bool selected)
 Handles model focus change events.
void modelUpdatedSlot (const Buffer< UUID > &updated_ids)
 Handles model update events.
void objectSelected (Buffer< UUID > id, bool selected)
 Handles object selection change events.
void postMaterialImageRequest (const UUID &id) const
 Posts a request to generate a material preview image.
void projectChanged (UUID id)
 Handles project change events.
void recursiveCacheRemove (const UUID &id)
 Recursively removes a model and its children from the cache.
void refreshAll ()
 Refreshes the entire view by rebuilding all caches.
void setupCache (const Model &model, bool recursive, bool parent_visible, bool add_id) const
 Populates the cache for a model and optionally its children.
void topLevelChanged (Buffer< UUID > id)
 Handles top-level parent change events for models.
void updateModel3DVisible (const UUID &id, bool visible)
 Updates the 3D visibility state of a cached model.

Protected Attributes

Dictionary< UUID, QIcon > m_cached_material_images
 Cached material preview icons.
Dictionary< UUID, Set< UUID > > m_cached_material_indices
 Map of materials to the models using them.
Dictionary< UUID, ModelCachem_cached_model_indices
 Cached display data per model.
bool m_include_materials = true
 Whether to show materials as child items.
Buffer< UUIDm_index_ids
 Flat list mapping cache indices to UUIDs.
QTModelManagerm_manager
 The underlying model manager.
UUID m_project_id
 UUID of the currently active project.
std::function< bool(const Model &)> m_root_filter
 Optional filter for determining root models.
Buffer< UUIDm_root_models
 UUIDs of the root models displayed in the view.
UUID m_tree_capture_id
 UUID of the tree capture request.

Detailed Description

A Qt compatible ItemModel for interfacing with a DesignObjectLookup.


Definition at line 43 of file QTModelManagerView.h.

Constructor & Destructor Documentation

◆ QTModelManagerView()

QTModelManagerView::QTModelManagerView ( QTModelManager * manager,
QObject * parent = nullptr )

Constructs a model manager view for the given manager.

Parameters
[in]managerThe QTModelManager to display.
[in]parentThe parent QObject.

References manager().

Referenced by manager().

Member Function Documentation

◆ addModel()

void QTModelManagerView::addModel ( UUID id)
protected

Adds a model to the view and cache.

Parameters
[in]idThe UUID of the model to add.

◆ createCache()

ModelCache QTModelManagerView::createCache ( const Model & model,
bool recursive,
bool parent_visible,
bool add_id ) const
protected

Creates a cache entry for a model.

Parameters
[in]modelThe model to cache.
[in]recursiveWhether to recursively cache children.
[in]parent_visibleWhether the parent model is visible.
[in]add_idWhether to add the model to the index ID list.
Returns
The newly created ModelCache.

References model().

◆ data()

QVariant QTModelManagerView::data ( const UUID & id,
int role,
int column ) const
protected

Retrieves display data for a specific model by UUID, role, and column.

Parameters
[in]idThe UUID of the model.
[in]roleThe Qt display role.
[in]columnThe column index.
Returns
The display data as a QVariant.

◆ emitIndexUpdated()

void QTModelManagerView::emitIndexUpdated ( const UUID & id,
const QList< int > & roles = QList< int >() )
protected

Emits data-changed signals for a specific model index.

Parameters
[in]idThe UUID of the updated model.
[in]rolesThe Qt roles that changed.

◆ getIndex() [1/2]

QModelIndex QTModelManagerView::getIndex ( const Model & model,
int column ) const
protected

Retrieves the QModelIndex for a model at a specific column.

Parameters
[in]modelThe model to look up.
[in]columnThe column index.
Returns
The corresponding QModelIndex.

References model().

◆ getIndex() [2/2]

QModelIndex QTModelManagerView::getIndex ( const UUID & id,
int column ) const
protected

Retrieves the QModelIndex for a model UUID at a specific column.

Parameters
[in]idThe UUID of the model.
[in]columnThe column index.
Returns
The corresponding QModelIndex.

◆ getMaterialID()

UUID QTModelManagerView::getMaterialID ( const QModelIndex & model_index) const
protected

Retrieves the material UUID for a given QModelIndex.

Parameters
[in]model_indexThe index to query.
Returns
The UUID of the material.

◆ getModelID()

UUID QTModelManagerView::getModelID ( const QModelIndex & model_index) const
protected

Retrieves the model UUID for a given QModelIndex.

Parameters
[in]model_indexThe index to query.
Returns
The UUID of the model.

◆ hasCached()

bool QTModelManagerView::hasCached ( const UUID & id) const
protected

Checks whether cached data exists for a given model UUID.

Parameters
[in]idThe UUID to check.
Returns
True if cache data exists.

◆ iconMode()

QIcon::Mode QTModelManagerView::iconMode ( const QModelIndex & index) const
protected

Determines the icon display mode for the given index.

Parameters
[in]indexThe model index to query.
Returns
The QIcon::Mode appropriate for the index state.

◆ manager()

QTModelManager & QTModelManagerView::manager ( )

Retrieves the underlying model manager.

Returns
A reference to the QTModelManager.

References QTModelManagerView().

Referenced by QTModelManagerView().

◆ materialUpdatedSlot()

void QTModelManagerView::materialUpdatedSlot ( const Buffer< UUID > & updated_ids)
protected

Handles material update events.

Parameters
[in]updated_idsThe UUIDs of the updated materials.

◆ model() [1/2]

Model QTModelManagerView::model ( const QModelIndex & model_index) const
protected

Retrieves a Model object for a given QModelIndex.

Parameters
[in]model_indexThe index to query.
Returns
The Model at the given index.

Referenced by createCache(), getIndex(), and setupCache().

◆ model() [2/2]

Model QTModelManagerView::model ( uint04 row,
const QModelIndex & parent ) const
protected

Retrieves a Model object by row and parent index.

Parameters
[in]rowThe row number.
[in]parentThe parent index.
Returns
The Model at the given position.

◆ modelAdded()

void QTModelManagerView::modelAdded ( Buffer< UUID > id)
protected

Handles model addition events.

Parameters
[in]idThe UUIDs of the added models.

◆ modelDeleted()

void QTModelManagerView::modelDeleted ( Buffer< UUID > id)
protected

Handles model deletion events.

Parameters
[in]idThe UUIDs of the deleted models.

◆ modelFocussed()

void QTModelManagerView::modelFocussed ( UUID id,
bool selected )
protected

Handles model focus change events.

Parameters
[in]idThe UUID of the focused model.
[in]selectedWhether the model gained or lost focus.

◆ modelUpdatedSlot()

void QTModelManagerView::modelUpdatedSlot ( const Buffer< UUID > & updated_ids)
protected

Handles model update events.

Parameters
[in]updated_idsThe UUIDs of the updated models.

◆ objectSelected()

void QTModelManagerView::objectSelected ( Buffer< UUID > id,
bool selected )
protected

Handles object selection change events.

Parameters
[in]idThe UUIDs of the affected objects.
[in]selectedWhether the objects were selected or deselected.

◆ postMaterialImageRequest()

void QTModelManagerView::postMaterialImageRequest ( const UUID & id) const
protected

Posts a request to generate a material preview image.

Parameters
[in]idThe UUID of the material.

◆ projectChanged()

void QTModelManagerView::projectChanged ( UUID id)
protected

Handles project change events.

Parameters
[in]idThe UUID of the new active project.

◆ recursiveCacheRemove()

void QTModelManagerView::recursiveCacheRemove ( const UUID & id)
protected

Recursively removes a model and its children from the cache.

Parameters
[in]idThe UUID of the model to remove.

◆ rootModels()

const Buffer< UUID > & QTModelManagerView::rootModels ( ) const
inline

Retrieves the current root model UUIDs.

Returns
A reference to the buffer of root model UUIDs.

Definition at line 100 of file QTModelManagerView.h.

References m_root_models.

◆ setIsRootFilter()

void QTModelManagerView::setIsRootFilter ( const std::function< bool(const Model &)> & filter)
inline

Sets a filter function that determines which models are treated as roots.

Parameters
[in]filterA function returning true for models that should be roots.

Definition at line 105 of file QTModelManagerView.h.

References m_root_filter.

◆ setRootModels()

void QTModelManagerView::setRootModels ( const Buffer< UUID > & roots)

Sets the root models displayed in the view.

Parameters
[in]rootsThe UUIDs of the root models.

◆ setupCache()

void QTModelManagerView::setupCache ( const Model & model,
bool recursive,
bool parent_visible,
bool add_id ) const
protected

Populates the cache for a model and optionally its children.

Parameters
[in]modelThe model to cache.
[in]recursiveWhether to recursively cache children.
[in]parent_visibleWhether the parent model is visible.
[in]add_idWhether to add the model to the index ID list.

References model().

◆ topLevelChanged()

void QTModelManagerView::topLevelChanged ( Buffer< UUID > id)
protected

Handles top-level parent change events for models.

Parameters
[in]idThe UUIDs of the affected models.

◆ updateModel3DVisible()

void QTModelManagerView::updateModel3DVisible ( const UUID & id,
bool visible )
protected

Updates the 3D visibility state of a cached model.

Parameters
[in]idThe UUID of the model.
[in]visibleThe new visibility state.

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