![]() |
NDEVR
API Documentation
|
A compact way to present a list of options to the user. More...
Public Member Functions | |
| 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 | 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. | |
Protected Attributes | |
| 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 compact way to present a list of options to the user.
A combobox is a selection widget that shows the current item, and pops up a list of selectable items when clicked. Comboboxes can contain lists of translated data alongside of their program-values.
Definition at line 54 of file QCustomCombobox.h.
| QCustomComboBox::QCustomComboBox | ( | QWidget * | parent = nullptr | ) |
Constructs a QCustomComboBox with the given parent widget.
| [in] | parent | The parent widget. |
Referenced by DesignObjectComboWidget::DesignObjectComboWidget().
|
inline |
Adds a value and its display string to the combo box.
| [in] | value | The internal value to add. |
| [in] | display_value | The translated string shown to the user. |
| [in] | refresh_widget | Whether to refresh the widget immediately after adding. |
Definition at line 231 of file QCustomCombobox.h.
References m_display_values, m_values, and refresh().
| TranslatedString QCustomComboBox::currentDisplayValue | ( | ) | const |
Returns the currently displayed translated string.
| QCustomValidator & QCustomComboBox::customValidator | ( | ) |
Returns a mutable reference to the custom validator used for input validation.
| const QCustomValidator & QCustomComboBox::customValidator | ( | ) | const |
Returns a const reference to the custom validator used for input validation.
Referenced by DesignObjectComboWidget::setNDPO(), setup(), and setupResource().
|
inline |
Returns the translated display values of the combo box.
Definition at line 461 of file QCustomCombobox.h.
References m_display_values.
|
override |
Handles generic events for the combo box, including tooltip and theme updates.
| [in] | event | The event to handle. |
References event().
Referenced by event(), and resizeEvent().
|
override |
Handles focus-in events for the combo box.
| [in] | e | The focus event. |
|
inline |
Returns the current value converted to the requested type.
Definition at line 313 of file QCustomCombobox.h.
References cast(), getAs(), m_current_custom, m_using_custom, and m_values.
Referenced by getAs(), getAs(), ModelChooserCombo::isNewSelected(), ModelChooserCombo::selectedID(), DesignObjectComboWidget::sendCommand(), DesignObjectComboWidget::setNDPO(), DesignObjectComboWidget::setTitle(), and setupResource().
|
inline |
Returns the value at the given index converted to the requested type.
| [in] | index | The index of the value to retrieve. |
Definition at line 325 of file QCustomCombobox.h.
Returns the current value as an Angle in internal representation.
| fltp08 QCustomComboBox::getUnitValue | ( | ) | const |
Returns the current value as a floating-point number in user-facing units.
Referenced by setupResource().
|
inline |
Returns whether the combo box is currently using a custom (user-entered) value.
Definition at line 95 of file QCustomCombobox.h.
References m_using_custom.
Referenced by setValue().
|
override |
Returns the minimum size hint for layout purposes.
Called after sorting to allow subclasses to react to reordered indices.
| [in] | swap_indices | A mapping from old indices to new indices after sorting. |
Reimplemented in ModelChooserCombo.
|
override |
Custom paint event for rendering the combo box.
| [in] | event | The paint event. |
|
inline |
Removes a value and its corresponding display string from the combo box.
| [in] | value | The internal value to remove. |
| [in] | refresh_widget | Whether to refresh the widget immediately after removal. |
Definition at line 244 of file QCustomCombobox.h.
References IsValid(), m_display_values, m_values, and refresh().
|
override |
|
inline |
Sets the current selection to the given enum value.
| [in] | value | The enum value to select. |
Definition at line 304 of file QCustomCombobox.h.
References cast(), and enum_to_index.
|
inline |
Sets whether the user can enter a custom value not in the predefined list.
| [in] | allow_custom | Whether to allow custom values. |
Definition at line 420 of file QCustomCombobox.h.
References m_allow_custom, and refreshWidget().
|
inline |
Sets whether the combo box should automatically format display values.
| [in] | auto_format | Whether to enable auto-formatting. |
Definition at line 298 of file QCustomCombobox.h.
References m_auto_format.
| void QCustomComboBox::setConstantUnit | ( | const ConstPointer< Unit > & | unit, |
| uint01 | dimension = Constant< uint01 >::Invalid ) |
Sets a constant unit for value formatting and conversion.
| [in] | unit | The constant unit pointer to use. |
| [in] | dimension | The specific unit dimension, or Invalid for default. |
| void QCustomComboBox::setCustomUnit | ( | const StringView & | unit, |
| UnitCategory | fallback_unit, | ||
| uint01 | dimension = Constant< uint01 >::Invalid ) |
Sets a custom unit string with a fallback unit category.
| [in] | unit | The custom unit string. |
| [in] | fallback_unit | The fallback unit category if the custom unit is not recognized. |
| [in] | dimension | The specific unit dimension, or Invalid for default. |
| void QCustomComboBox::setCustomValidator | ( | const QCustomValidator & | validator | ) |
Sets the custom validator used for input validation and formatting.
| [in] | validator | The validator to apply. |
Referenced by DesignObjectComboWidget::setNDPO().
|
inline |
Sets a suffix appended to each display value.
| [in] | suffix | The suffix text to append. |
Definition at line 425 of file QCustomCombobox.h.
References m_suffix, refreshWidget(), and suffix().
| void QCustomComboBox::setTitle | ( | const TranslatedString & | title | ) |
Sets the display title for the combo box.
| [in] | title | The title to display. |
Referenced by setup(), setup(), and setupResource().
| void QCustomComboBox::setToolTip | ( | const TranslatedString & | tooltip | ) |
Sets the tooltip text for the combo box.
| [in] | tooltip | The tooltip text to display. |
| void QCustomComboBox::setUnitType | ( | UnitCategory | unit, |
| uint01 | dimension = Constant< uint01 >::Invalid ) |
Sets the unit type used for value formatting and conversion.
| [in] | unit | The unit category to use. |
| [in] | dimension | The specific unit dimension, or Invalid for default. |
Sets the value as a floating-point number in user-facing units.
| [in] | value | The unit value to set. |
| [in] | unit_dimension | The unit dimension index. |
Referenced by setupResource().
|
inline |
Sets up the combo box from a buffer of String/value pairs.
| [in] | title | The display title for the combo box. |
| [in] | items | A buffer of pairs mapping string labels to their values. |
Definition at line 120 of file QCustomCombobox.h.
References Buffer< t_type, t_memory_manager >::add(), TranslatedString::DirectString(), setup(), and values().
|
inline |
Sets up the combo box from a buffer of TranslatedString/value pairs.
| [in] | title | The display title for the combo box. |
| [in] | items | A buffer of pairs mapping translated display strings to their values. |
Definition at line 103 of file QCustomCombobox.h.
References Buffer< t_type, t_memory_manager >::add(), setup(), and values().
| void QCustomComboBox::setup | ( | const TranslatedString & | title, |
| const Buffer< String > & | values, | ||
| const Buffer< TranslatedString > & | display_values ) |
|
inline |
Sets up the combo box from a buffer of non-enum, non-number values using display strings.
| [in] | title | The display title for the combo box. |
| [in] | items | A buffer of values. |
Definition at line 193 of file QCustomCombobox.h.
References Buffer< t_type, t_memory_manager >::add(), String::DisplayString(), setup(), and values().
|
inline |
Sets up the combo box from a buffer of numeric values, formatting each with the validator.
| [in] | title | The display title for the combo box. |
| [in] | items | A buffer of numeric values. |
Definition at line 154 of file QCustomCombobox.h.
References Buffer< t_type, t_memory_manager >::add(), customValidator(), setup(), and values().
|
inline |
Sets up the combo box from a buffer of enum values, using display strings for each.
| [in] | title | The display title for the combo box. |
| [in] | items | A buffer of enum values. |
Definition at line 137 of file QCustomCombobox.h.
References Buffer< t_type, t_memory_manager >::add(), String::DisplayString(), setup(), and values().
| void QCustomComboBox::setup | ( | const TranslatedString & | title, |
| const Buffer< TranslatedString > & | values ) |
|
inline |
Sets up the combo box with a range of enum values from first to last (inclusive).
| [in] | title | The display title for the combo box. |
| [in] | first | The first enum value in the range. |
| [in] | last | The last enum value in the range. |
Definition at line 211 of file QCustomCombobox.h.
References cast(), String::DisplayString(), enum_to_index, index_to_enum, m_display_values, m_values, refreshWidget(), and setTitle().
|
inline |
Sets up the combo box with all values of an enum type, given the total count.
| [in] | title | The display title for the combo box. |
| [in] | size | The number of enum values to populate. |
Definition at line 173 of file QCustomCombobox.h.
References cast(), String::DisplayString(), enum_to_index, index_to_enum, m_display_values, m_values, refreshWidget(), and setTitle().
|
inline |
Sets up two-way binding between this combo box and a Resource.
When the combo box value changes, the resource is updated. When the resource changes externally, the combo box display is updated.
| [in] | title | The display title for the combo box. |
| [in] | resource | The resource to bind to. |
Definition at line 272 of file QCustomCombobox.h.
References ResourceBase::addListener(), customValidator(), edited(), Resource< T >::get(), getAs(), getUnitValue(), m_resource_changed_listener, Resource< T >::set(), setTitle(), setUnitValue(), and setValue().
| void QCustomComboBox::setValue | ( | const String & | value | ) |
Sets the current value from a raw String.
| [in] | value | The string value to set. |
|
inline |
Sets the current value of the combo box.
| [in] | t_value | The value to set. |
Definition at line 334 of file QCustomCombobox.h.
References setValue().
Referenced by DesignObjectComboWidget::onObjectUpdatedSlot(), ModelChooserCombo::setToNew(), setupResource(), setValue(), and setValue().
|
inline |
Sets the current value from a TranslatedString.
| [in] | t_value | The translated string value to set. |
Definition at line 342 of file QCustomCombobox.h.
References isUsingCustom(), and setValue().
|
override |
Returns the recommended size for layout purposes.
| void QCustomComboBox::sortAlphabetically | ( | uint04 | start = 0, |
| uint04 | size = Constant< uint04 >::Invalid ) |
Sorts the combo box entries alphabetically by display value.
| [in] | start | The starting index for the sort range. |
| [in] | size | The number of items to sort, or Invalid for all remaining items. |
|
inline |
Returns the current suffix appended to display values.
Definition at line 430 of file QCustomCombobox.h.
References m_suffix.
Referenced by setSuffix().
|
override |
Handles mouse wheel events, typically to scroll through values.
| [in] | e | The wheel event. |