![]() |
NDEVR
API Documentation
|
A combo box that allows the user to select from a filtered list of Models in the scene. More...
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. | |
| QTModelManager * | manager () 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. | |
| QCustomValidator & | customValidator () |
| Returns a mutable reference to the custom validator used for input validation. | |
| const QCustomValidator & | customValidator () 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< fltp08 > | getUnitAngle () 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 TranslatedString & | suffix () 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< UUID > | m_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. | |
| QTModelManager * | m_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< String > | m_model_types |
| Model type names used for filtering. | |
| Dictionary< UUID, uint04 > | m_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, uint04 > | enum_to_index |
| Maps enum numeric values to combo box indices. | |
| Dictionary< uint04, uint04 > | index_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< TranslatedString > | m_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. | |
| QCustomLineEdit * | m_line_edit |
| The embedded line edit for custom value entry. | |
| QTResourceListener * | m_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< String > | m_values |
| The internal string values for each option. | |
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.
| ModelChooserCombo::ModelChooserCombo | ( | QWidget * | parent = nullptr | ) |
Constructs the model chooser combo box.
| [in] | parent | The optional parent widget. |
| void ModelChooserCombo::addID | ( | const UUID & | id | ) |
|
inlineprotected |
Adds a model to the combo box if it passes the current filters.
| [in] | m | The model to add. |
Definition at line 247 of file ModelChooserCombo.h.
References canAddModel(), and QCustomComboBox::refreshWidget().
Adds multiple models to the combo box.
| [in] | models | The models to add. |
| void ModelChooserCombo::addModelType | ( | const StringView & | type | ) |
Adds an additional model type to the type filter list.
| [in] | type | The model type name to add. |
|
inline |
Checks whether a model can be added to the combo box.
| [in] | model | The model to check. |
Definition at line 78 of file ModelChooserCombo.h.
References DesignObject::get(), guid, isModelAllowed(), and m_models.
Referenced by addModel().
| TranslatedString ModelChooserCombo::displayName | ( | const Model & | m | ) |
Returns the translated display name for the given model.
| [in] | m | The model whose display name is requested. |
| bool ModelChooserCombo::isModelAllowed | ( | const Model & | model | ) |
Checks whether the model passes the current type and custom filters.
| [in] | model | The model to check. |
Referenced by canAddModel().
|
inline |
Checks whether the "New Model" entry is currently selected.
Definition at line 180 of file ModelChooserCombo.h.
References UUID::CreateUUID(), and QCustomComboBox::getAs().
|
inline |
Returns the model manager associated with this combo box.
Definition at line 72 of file ModelChooserCombo.h.
References m_manager.
Referenced by setManager().
| void ModelChooserCombo::modelSelectedSignal | ( | UUID | id | ) |
Emitted when a model is selected in the combo box.
| [in] | id | The UUID of the selected model. |
Slot called when objects are added to the scene, potentially adding them to the combo box.
| [in] | ids | The UUIDs of the newly added objects. |
Slot called when objects are updated, refreshing their display names.
| [in] | ids | The UUIDs of the updated objects. |
Called when the combo box items are sorted, to update internal state.
| [in] | sorted_indices | The new sort order indices. |
Reimplemented from QCustomComboBox.
|
inline |
Refreshes the combo box contents from the model manager.
Currently a no-op placeholder.
Definition at line 153 of file ModelChooserCombo.h.
|
inline |
Removes a model identified by UUID from the combo box.
| [in] | id | The UUID of the model to remove. |
Definition at line 126 of file ModelChooserCombo.h.
References m_models, and QCustomComboBox::refreshWidget().
|
inline |
Returns the UUID of the currently selected model, or Invalid if "New Model" is selected.
Definition at line 198 of file ModelChooserCombo.h.
References UUID::CreateUUID(), and QCustomComboBox::getAs().
| void ModelChooserCombo::setAllowNew | ( | bool | allow_new, |
| const TranslatedString & | new_title ) |
Enables or disables a "New Model" entry in the combo box.
| [in] | allow_new | Whether to show the new model option. |
| [in] | new_title | The display title for the new model entry. |
| void ModelChooserCombo::setCurrentSelection | ( | UUID | id | ) |
|
inline |
Sets a custom callback for generating model display names.
| [in] | callback | The display name callback function. |
Definition at line 214 of file ModelChooserCombo.h.
References m_display_name_callback.
Sets a list of model UUIDs to exclude from the combo box.
| [in] | exclusion_list | The UUIDs to exclude. |
Definition at line 188 of file ModelChooserCombo.h.
References m_exclusion_list.
Populates the combo box with models identified by the given UUIDs.
| [in] | ids | The UUIDs of models to include. |
Definition at line 111 of file ModelChooserCombo.h.
References m_manager, and setModels().
| void ModelChooserCombo::setIncludeParentName | ( | bool | include_parent_name, |
| const StringView & | parent_type = String() ) |
Configures whether the parent model name is shown in display labels.
| [in] | include_parent_name | Whether to include the parent name. |
| [in] | parent_type | Optional type filter for the parent name lookup. |
| void ModelChooserCombo::setIncludePath | ( | bool | include_parent_name, |
| const StringView & | parent_type = String() ) |
Configures whether the full model path is shown in display labels.
| [in] | include_parent_name | Whether to include the full path. |
| [in] | parent_type | Optional type filter for path construction. |
| void ModelChooserCombo::setManager | ( | QTModelManager * | manager | ) |
|
inline |
Sets a custom filter function for determining which models to include.
| [in] | model_filter | The filter predicate returning true for allowed models. |
Definition at line 92 of file ModelChooserCombo.h.
References m_model_filter, and m_model_types.
| void ModelChooserCombo::setModelParentID | ( | const UUID & | parent | ) |
Filters the combo box to only show children of the specified parent model.
| [in] | parent | The UUID of the parent model. |
Replaces the combo box contents with the given models.
| [in] | models | The models to populate the combo box with. |
Referenced by setIDs().
| void ModelChooserCombo::setModelType | ( | const StringView & | type | ) |
Sets a single model type filter, replacing any existing type filters.
| [in] | type | The model type name to filter by. |