NDEVR
API Documentation
LayerCombo

A combo box that displays and allows selection of layers from the scene. More...

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

Public Member Functions

 LayerCombo (QTModelManager *manager, QWidget *parent=nullptr)
 Constructs a LayerCombo with a model manager and optional parent widget.
 LayerCombo (QWidget *parent=nullptr)
 Constructs a LayerCombo with an optional parent widget.
void clearSelected ()
 Clears the current selection so no layer is selected.
UUID currentSelection () const
 Returns the UUID of the currently selected layer.
QTModelManagermanager () const
 Returns the model manager backing this combo box.
void setManager (QTModelManager *manager)
 Sets the model manager used to populate the layer list.
void setSelected (UUID id)
 Sets the currently selected layer by UUID.
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 Attributes

LayerModelm_model = nullptr
 The layer data model driving the combo box.
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.

Additional Inherited Members

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.
virtual void onSorted (const Buffer< uint04 > &swap_indices)
 Called after sorting to allow subclasses to react to reordered indices.
void refreshWidget ()
 Rebuilds the widget contents from the internal value and display buffers.

Detailed Description

A combo box that displays and allows selection of layers from the scene.


Definition at line 117 of file LayerCombo.h.

Constructor & Destructor Documentation

◆ LayerCombo() [1/2]

LayerCombo::LayerCombo ( QWidget * parent = nullptr)

Constructs a LayerCombo with an optional parent widget.

Parameters
[in]parentThe parent widget, or nullptr if no parent.

◆ LayerCombo() [2/2]

LayerCombo::LayerCombo ( QTModelManager * manager,
QWidget * parent = nullptr )

Constructs a LayerCombo with a model manager and optional parent widget.

Parameters
[in]managerThe model manager providing layer data.
[in]parentThe parent widget, or nullptr if no parent.

References manager().

Member Function Documentation

◆ currentSelection()

UUID LayerCombo::currentSelection ( ) const

Returns the UUID of the currently selected layer.

Returns
The UUID of the selected layer, or an invalid UUID if none is selected.

◆ manager()

QTModelManager * LayerCombo::manager ( ) const

Returns the model manager backing this combo box.

Returns
A pointer to the QTModelManager.

Referenced by LayerCombo(), and setManager().

◆ setManager()

void LayerCombo::setManager ( QTModelManager * manager)

Sets the model manager used to populate the layer list.

Parameters
[in]managerThe model manager providing layer data.

References manager().

◆ setSelected()

void LayerCombo::setSelected ( UUID id)

Sets the currently selected layer by UUID.

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

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