NDEVR
API Documentation
ModelChooserCombo

A combo box that allows the user to select from a filtered list of Models in the scene. More...

Inheritance diagram for ModelChooserCombo:
[legend]
Collaboration diagram for ModelChooserCombo:
[legend]

Public Member Functions

 ModelChooserCombo (QWidget *parent=nullptr)
 Constructs the model chooser combo box.
void addID (const UUID &id)
 Adds a model identified by UUID to the combo box.
void addModels (const Buffer< Model > &models)
 Adds multiple models to the combo box.
void addModelType (const StringView &type)
 Adds an additional model type to the type filter list.
bool canAddModel (const Model &model)
 Checks whether a model can be added to the combo box.
TranslatedString displayName (const Model &m)
 Returns the translated display name for the given model.
bool isModelAllowed (const Model &model)
 Checks whether the model passes the current type and custom filters.
bool isNewSelected () const
 Checks whether the "New Model" entry is currently selected.
QTModelManagermanager () const
 Returns the model manager associated with this combo box.
void modelSelectedSignal (UUID id)
 Emitted when a model is selected in the combo box.
void newModelSelectedSignal ()
 Emitted when the "New Model" entry is selected.
virtual void onSorted (const Buffer< uint04 > &sorted_indices)
 Called when the combo box items are sorted, to update internal state.
void refreshFromManager ()
 Refreshes the combo box contents from the model manager.
void removeID (const UUID &id)
 Removes a model identified by UUID from the combo box.
UUID selectedID () const
 Returns the UUID of the currently selected model, or Invalid if "New Model" is selected.
void setAllowNew (bool allow_new, const TranslatedString &new_title)
 Enables or disables a "New Model" entry in the combo box.
void setCurrentSelection (UUID id)
 Sets the current combo box selection to the model with the given UUID.
void setDisplayNameCallback (std::function< TranslatedString(const Model &)> &callback)
 Sets a custom callback for generating model display names.
void setExclusionList (const Buffer< UUID > &exclusion_list)
 Sets a list of model UUIDs to exclude from the combo box.
void setIDs (const Buffer< UUID > &ids)
 Populates the combo box with models identified by the given UUIDs.
void setIncludeParentName (bool include_parent_name, const StringView &parent_type=String())
 Configures whether the parent model name is shown in display labels.
void setIncludePath (bool include_parent_name, const StringView &parent_type=String())
 Configures whether the full model path is shown in display labels.
void setManager (QTModelManager *manager)
 Sets the model manager used to query models for the combo box.
void setModelFilter (const std::function< bool(const Model &)> &model_filter)
 Sets a custom filter function for determining which models to include.
void setModelParentID (const UUID &parent)
 Filters the combo box to only show children of the specified parent model.
void setModels (const Buffer< Model > &models)
 Replaces the combo box contents with the given models.
void setModelType (const StringView &type)
 Sets a single model type filter, replacing any existing type filters.
void setToNew ()
 Sets the combo box selection to the "New Model" entry.
Public Member Functions inherited from QCustomComboBox
 QCustomComboBox (QWidget *parent=nullptr)
 Constructs a QCustomComboBox with the given parent widget.
template<class t_type>
void add (const t_type &value, const TranslatedString &display_value, bool refresh_widget=false)
 Adds a value and its display string to the combo box.
void clearValue ()
 Clears the current selection and value.
TranslatedString currentDisplayValue () const
 Returns the currently displayed translated string.
QCustomValidatorcustomValidator ()
 Returns a mutable reference to the custom validator used for input validation.
const QCustomValidatorcustomValidator () const
 Returns a const reference to the custom validator used for input validation.
const Buffer< TranslatedString > & displayValues () const
 Returns the translated display values of the combo box.
void edited ()
 Emitted when the combo box value is edited by the user.
bool event (QEvent *event) override
 Handles generic events for the combo box, including tooltip and theme updates.
void focusInEvent (QFocusEvent *e) override
 Handles focus-in events for the combo box.
template<class t_type>
t_type getAs () const
 Returns the current value converted to the requested type.
template<class t_type>
t_type getAs (uint04 index) const
 Returns the value at the given index converted to the requested type.
Angle< fltp08getUnitAngle () const
 Returns the current value as an Angle in internal representation.
fltp08 getUnitValue () const
 Returns the current value as a floating-point number in user-facing units.
void hidePopup () override
 Hides the popup list of items.
bool isUsingCustom () const
 Returns whether the combo box is currently using a custom (user-entered) value.
void lockInCustomValue ()
 Locks in the current custom value as the definitive selection.
QSize minimumSizeHint () const override
 Returns the minimum size hint for layout purposes.
void paintEvent (QPaintEvent *) override
 Custom paint event for rendering the combo box.
void refresh ()
 Refreshes the widget contents and updates its geometry.
template<class t_type>
void remove (const t_type &value, bool refresh_widget=false)
 Removes a value and its corresponding display string from the combo box.
void resizeEvent (QResizeEvent *event) override
 Handles widget resize events.
template<class t_enum>
std::enable_if< ObjectInfo< t_enum >::Enum >::type set (t_enum value)
 Sets the current selection to the given enum value.
void setAllowCustom (bool allow_custom)
 Sets whether the user can enter a custom value not in the predefined list.
void setAutoFormat (bool auto_format)
 Sets whether the combo box should automatically format display values.
void setConstantUnit (const ConstPointer< Unit > &unit, uint01 dimension=Constant< uint01 >::Invalid)
 Sets a constant unit for value formatting and conversion.
void setCustomUnit (const StringView &unit, UnitCategory fallback_unit, uint01 dimension=Constant< uint01 >::Invalid)
 Sets a custom unit string with a fallback unit category.
void setCustomValidator (const QCustomValidator &validator)
 Sets the custom validator used for input validation and formatting.
void setSuffix (const TranslatedString &suffix)
 Sets a suffix appended to each display value.
void setTitle (const TranslatedString &title)
 Sets the display title for the combo box.
void setToolTip (const TranslatedString &tooltip)
 Sets the tooltip text for the combo box.
void setUnitType (UnitCategory unit, uint01 dimension=Constant< uint01 >::Invalid)
 Sets the unit type used for value formatting and conversion.
void setUnitValue (fltp08 value, uint01 unit_dimension=0)
 Sets the value as a floating-point number in user-facing units.
template<class t_object>
void setup (const TranslatedString &title, const Buffer< std::pair< String, t_object > > &items)
 Sets up the combo box from a buffer of String/value pairs.
template<class t_object>
void setup (const TranslatedString &title, const Buffer< std::pair< TranslatedString, t_object > > &items)
 Sets up the combo box from a buffer of TranslatedString/value pairs.
void setup (const TranslatedString &title, const Buffer< String > &values, const Buffer< TranslatedString > &display_values)
 Sets up the combo box with a title, raw values, and corresponding translated display values.
template<class t_object>
std::enable_if<!ObjectInfo< t_object >::Enum &&!ObjectInfo< t_object >::Number >::type setup (const TranslatedString &title, const Buffer< t_object > &items)
 Sets up the combo box from a buffer of non-enum, non-number values using display strings.
template<class t_object>
std::enable_if< ObjectInfo< t_object >::Number >::type setup (const TranslatedString &title, const Buffer< t_object > &items)
 Sets up the combo box from a buffer of numeric values, formatting each with the validator.
template<class t_object>
std::enable_if< ObjectInfo< t_object >::Enum >::type setup (const TranslatedString &title, const Buffer< t_object > &items)
 Sets up the combo box from a buffer of enum values, using display strings for each.
void setup (const TranslatedString &title, const Buffer< TranslatedString > &values)
 Sets up the combo box with a title and a list of translated display values.
template<class t_enum>
std::enable_if< ObjectInfo< t_enum >::Enum >::type setup (const TranslatedString &title, t_enum first, t_enum last)
 Sets up the combo box with a range of enum values from first to last (inclusive).
template<class t_enum>
std::enable_if< ObjectInfo< t_enum >::Enum >::type setup (const TranslatedString &title, uint04 size)
 Sets up the combo box with all values of an enum type, given the total count.
template<class t_type>
void setupResource (const TranslatedString &title, Resource< t_type > &resource)
 Sets up two-way binding between this combo box and a Resource.
void setValue (const String &value)
 Sets the current value from a raw String.
template<class t_type>
void setValue (const t_type &t_value)
 Sets the current value of the combo box.
void setValue (const TranslatedString &t_value)
 Sets the current value from a TranslatedString.
void showPopup () override
 Shows the popup list of items.
QSize sizeHint () const override
 Returns the recommended size for layout purposes.
void sortAlphabetically (uint04 start=0, uint04 size=Constant< uint04 >::Invalid)
 Sorts the combo box entries alphabetically by display value.
const TranslatedStringsuffix () const
 Returns the current suffix appended to display values.
void updateFontSize ()
 Updates the font size to match the current application theme settings.
const Buffer< String > & values () const
 Returns the internal string values of the combo box.
void wheelEvent (QWheelEvent *e) override
 Handles mouse wheel events, typically to scroll through values.

Protected Member Functions

void addModel (const Model &m)
 Adds a model to the combo box if it passes the current filters.
void onEdited ()
 Slot called when the user edits the combo box selection.
void onObjectAddedSlot (const Buffer< UUID > &ids)
 Slot called when objects are added to the scene, potentially adding them to the combo box.
void onObjectsDeletedSlot ()
 Slot called when objects are deleted from the scene, removing them from the combo box.
void onObjectUpdatedSlot (Buffer< UUID > ids)
 Slot called when objects are updated, refreshing their display names.
Protected Member Functions inherited from QCustomComboBox
void adjustLineEditSize ()
 Adjusts the embedded line edit size to fit the current combo box dimensions.
void onChange ()
 Slot invoked when the selected index changes.
void onEdit ()
 Slot invoked when the user finishes editing the custom line edit.
void onEditTextChangedSlot ()
 Slot invoked when the editable line edit text changes.
void refreshWidget ()
 Rebuilds the widget contents from the internal value and display buffers.

Protected Attributes

bool m_allow_add_new
 Whether the "New Model" entry is enabled.
std::function< TranslatedString(const Model &)> m_display_name_callback
 Custom callback for generating display names.
Set< UUIDm_exclusion_list
 Set of model UUIDs excluded from the combo box.
bool m_include_parent_name
 Whether to include the parent name in display labels.
bool m_include_path
 Whether to include the full path in display labels.
QTModelManagerm_manager
 The model manager providing scene data.
std::function< bool(const Model &)> m_model_filter
 Custom filter predicate for model inclusion.
UUID m_model_parent = Constant<UUID>::Invalid
 Optional parent model UUID for filtering.
Dictionary< UUID, Buffer< UUID > > m_model_parents
 Maps model UUIDs to their parent chain.
Buffer< Stringm_model_types
 Model type names used for filtering.
Dictionary< UUID, uint04m_models
 Maps model UUIDs to their combo box indices.
String m_parent_type
 Parent type name used for display name generation.
Protected Attributes inherited from QCustomComboBox
Dictionary< uint04, uint04enum_to_index
 Maps enum numeric values to combo box indices.
Dictionary< uint04, uint04index_to_enum
 Maps combo box indices to enum numeric values.
bool m_allow_custom
 Whether custom user-entered values are permitted.
bool m_auto_format
 Whether values are automatically formatted before display.
String m_current_custom
 The current custom value entered by the user.
uint04 m_custom_index
 The index of the custom value entry in the list.
Buffer< TranslatedStringm_display_values
 The translated display strings for each option.
bool m_is_changing = false
 Whether the selection is currently being changed programmatically.
bool m_is_refreshing = false
 Whether the widget is currently being refreshed.
bool m_is_showing_popup = false
 Whether the popup list is currently visible.
uint04 m_last_index
 The last selected index before the current change.
QCustomLineEditm_line_edit
 The embedded line edit for custom value entry.
QTResourceListenerm_resource_changed_listener
 Listener for external resource changes.
bool m_sort_alphabetically = false
 Whether items should be sorted alphabetically.
uint04 m_sort_offset = 0
 The starting index offset for alphabetical sorting.
TranslatedString m_suffix
 A suffix appended to each display value.
TranslatedString m_title
 The display title of the combo box.
TranslatedString m_tooltip
 The tooltip text for the combo box.
bool m_using_custom
 Whether the current selection is a custom value.
Buffer< Stringm_values
 The internal string values for each option.

Detailed Description

A combo box that allows the user to select from a filtered list of Models in the scene.


Supports filtering by type, custom predicates, exclusion lists, and optional "New Model" entry.

Definition at line 42 of file ModelChooserCombo.h.

Constructor & Destructor Documentation

◆ ModelChooserCombo()

ModelChooserCombo::ModelChooserCombo ( QWidget * parent = nullptr)

Constructs the model chooser combo box.

Parameters
[in]parentThe optional parent widget.

Member Function Documentation

◆ addID()

void ModelChooserCombo::addID ( const UUID & id)

Adds a model identified by UUID to the combo box.

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

◆ addModel()

void ModelChooserCombo::addModel ( const Model & m)
inlineprotected

Adds a model to the combo box if it passes the current filters.

Parameters
[in]mThe model to add.

Definition at line 247 of file ModelChooserCombo.h.

References canAddModel(), and QCustomComboBox::refreshWidget().

◆ addModels()

void ModelChooserCombo::addModels ( const Buffer< Model > & models)

Adds multiple models to the combo box.

Parameters
[in]modelsThe models to add.

◆ addModelType()

void ModelChooserCombo::addModelType ( const StringView & type)

Adds an additional model type to the type filter list.

Parameters
[in]typeThe model type name to add.

◆ canAddModel()

bool ModelChooserCombo::canAddModel ( const Model & model)
inline

Checks whether a model can be added to the combo box.

Parameters
[in]modelThe model to check.
Returns
True if the model is not already present and passes the filter.

Definition at line 78 of file ModelChooserCombo.h.

References DesignObject::get(), guid, isModelAllowed(), and m_models.

Referenced by addModel().

◆ displayName()

TranslatedString ModelChooserCombo::displayName ( const Model & m)

Returns the translated display name for the given model.

Parameters
[in]mThe model whose display name is requested.
Returns
The translated display name.

◆ isModelAllowed()

bool ModelChooserCombo::isModelAllowed ( const Model & model)

Checks whether the model passes the current type and custom filters.

Parameters
[in]modelThe model to check.
Returns
True if the model is allowed by the current filters.

Referenced by canAddModel().

◆ isNewSelected()

bool ModelChooserCombo::isNewSelected ( ) const
inline

Checks whether the "New Model" entry is currently selected.

Returns
True if the new model option is selected.

Definition at line 180 of file ModelChooserCombo.h.

References UUID::CreateUUID(), and QCustomComboBox::getAs().

◆ manager()

QTModelManager * ModelChooserCombo::manager ( ) const
inline

Returns the model manager associated with this combo box.

Returns
A pointer to the QTModelManager.

Definition at line 72 of file ModelChooserCombo.h.

References m_manager.

Referenced by setManager().

◆ modelSelectedSignal()

void ModelChooserCombo::modelSelectedSignal ( UUID id)

Emitted when a model is selected in the combo box.

Parameters
[in]idThe UUID of the selected model.

◆ onObjectAddedSlot()

void ModelChooserCombo::onObjectAddedSlot ( const Buffer< UUID > & ids)
protected

Slot called when objects are added to the scene, potentially adding them to the combo box.

Parameters
[in]idsThe UUIDs of the newly added objects.

◆ onObjectUpdatedSlot()

void ModelChooserCombo::onObjectUpdatedSlot ( Buffer< UUID > ids)
protected

Slot called when objects are updated, refreshing their display names.

Parameters
[in]idsThe UUIDs of the updated objects.

◆ onSorted()

virtual void ModelChooserCombo::onSorted ( const Buffer< uint04 > & sorted_indices)
virtual

Called when the combo box items are sorted, to update internal state.

Parameters
[in]sorted_indicesThe new sort order indices.

Reimplemented from QCustomComboBox.

◆ refreshFromManager()

void ModelChooserCombo::refreshFromManager ( )
inline

Refreshes the combo box contents from the model manager.

Currently a no-op placeholder.

Definition at line 153 of file ModelChooserCombo.h.

◆ removeID()

void ModelChooserCombo::removeID ( const UUID & id)
inline

Removes a model identified by UUID from the combo box.

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

Definition at line 126 of file ModelChooserCombo.h.

References m_models, and QCustomComboBox::refreshWidget().

◆ selectedID()

UUID ModelChooserCombo::selectedID ( ) const
inline

Returns the UUID of the currently selected model, or Invalid if "New Model" is selected.

Returns
The selected model UUID.

Definition at line 198 of file ModelChooserCombo.h.

References UUID::CreateUUID(), and QCustomComboBox::getAs().

◆ setAllowNew()

void ModelChooserCombo::setAllowNew ( bool allow_new,
const TranslatedString & new_title )

Enables or disables a "New Model" entry in the combo box.

Parameters
[in]allow_newWhether to show the new model option.
[in]new_titleThe display title for the new model entry.

◆ setCurrentSelection()

void ModelChooserCombo::setCurrentSelection ( UUID id)

Sets the current combo box selection to the model with the given UUID.

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

◆ setDisplayNameCallback()

void ModelChooserCombo::setDisplayNameCallback ( std::function< TranslatedString(const Model &)> & callback)
inline

Sets a custom callback for generating model display names.

Parameters
[in]callbackThe display name callback function.

Definition at line 214 of file ModelChooserCombo.h.

References m_display_name_callback.

◆ setExclusionList()

void ModelChooserCombo::setExclusionList ( const Buffer< UUID > & exclusion_list)
inline

Sets a list of model UUIDs to exclude from the combo box.

Parameters
[in]exclusion_listThe UUIDs to exclude.

Definition at line 188 of file ModelChooserCombo.h.

References m_exclusion_list.

◆ setIDs()

void ModelChooserCombo::setIDs ( const Buffer< UUID > & ids)
inline

Populates the combo box with models identified by the given UUIDs.

Parameters
[in]idsThe UUIDs of models to include.

Definition at line 111 of file ModelChooserCombo.h.

References m_manager, and setModels().

◆ setIncludeParentName()

void ModelChooserCombo::setIncludeParentName ( bool include_parent_name,
const StringView & parent_type = String() )

Configures whether the parent model name is shown in display labels.

Parameters
[in]include_parent_nameWhether to include the parent name.
[in]parent_typeOptional type filter for the parent name lookup.

◆ setIncludePath()

void ModelChooserCombo::setIncludePath ( bool include_parent_name,
const StringView & parent_type = String() )

Configures whether the full model path is shown in display labels.

Parameters
[in]include_parent_nameWhether to include the full path.
[in]parent_typeOptional type filter for path construction.

◆ setManager()

void ModelChooserCombo::setManager ( QTModelManager * manager)

Sets the model manager used to query models for the combo box.

Parameters
[in]managerThe model manager to use.

References manager().

◆ setModelFilter()

void ModelChooserCombo::setModelFilter ( const std::function< bool(const Model &)> & model_filter)
inline

Sets a custom filter function for determining which models to include.

Parameters
[in]model_filterThe filter predicate returning true for allowed models.

Definition at line 92 of file ModelChooserCombo.h.

References m_model_filter, and m_model_types.

◆ setModelParentID()

void ModelChooserCombo::setModelParentID ( const UUID & parent)

Filters the combo box to only show children of the specified parent model.

Parameters
[in]parentThe UUID of the parent model.

◆ setModels()

void ModelChooserCombo::setModels ( const Buffer< Model > & models)

Replaces the combo box contents with the given models.

Parameters
[in]modelsThe models to populate the combo box with.

Referenced by setIDs().

◆ setModelType()

void ModelChooserCombo::setModelType ( const StringView & type)

Sets a single model type filter, replacing any existing type filters.

Parameters
[in]typeThe model type name to filter by.

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