DuxReiNummariae 1.0.0-alpha.23
Simple and powerful budgeting application
 
Loading...
Searching...
No Matches
drn::desktop_ui::CurrencyComboBox Class Referencefinal

A GUI item providing a selectable list of currencies. More...

#include <CurrencyCodeWidget.h>

Inheritance diagram for drn::desktop_ui::CurrencyComboBox:
Collaboration diagram for drn::desktop_ui::CurrencyComboBox:

Public Slots

void setCurrentCode (const pecunia::Currency &code)
 Updates the currently selected currency in the GUI item.
 

Public Member Functions

 CurrencyComboBox (const foundation::QtPtr<::QWidget > &parent)
 Constructs a specialized GUI item for selecting currencies.
 
std::set< pecunia::Currency > currencies () const
 Retrieves the set of currencies currently displayed in the GUI item.
 
pecunia::Currency currentCode () const
 Retrieves the currently selected currency code from the GUI item.
 
void populateUsableCurrencies (const std::set< pecunia::Currency > &usableCodes, const navigation::CurrencyDisplayOptions &displayAs)
 Populates the GUI item with a list of usable currencies.
 

Detailed Description

A GUI item providing a selectable list of currencies.

This class represents a specialized GUI element that allows users to select from a predefined set of currencies. It supports dynamic updates to its list of options and emits signals when the selection changes, enabling seamless integration with other components in the application.

Constructor & Destructor Documentation

◆ CurrencyComboBox()

drn::desktop_ui::CurrencyComboBox::CurrencyComboBox ( const foundation::QtPtr<::QWidget > & parent)
explicit

Constructs a specialized GUI item for selecting currencies.

This constructor initializes a GUI element that provides users with the ability to select currencies from a list. The list is displayed and managed in an alphabetically sorted order to ensure usability and clarity. The widget is created within the given parent GUI container, if specified.

Parameters
parentThe GUI element acting as the container for this widget.

Member Function Documentation

◆ currencies()

std::set< pecunia::Currency > drn::desktop_ui::CurrencyComboBox::currencies ( ) const
nodiscard

Retrieves the set of currencies currently displayed in the GUI item.

This method should be used to get a snapshot of the selectable currency options at any given point in time.

Returns
A collection of all valid currencies displayed by the GUI item. The returned collection reflects the current state of the GUI item and excludes any invalid or empty entries.

◆ currentCode()

pecunia::Currency drn::desktop_ui::CurrencyComboBox::currentCode ( ) const
nodiscard

Retrieves the currently selected currency code from the GUI item.

This function returns the currency code corresponding to the user's current selection in the GUI element. It ensures that the value aligns with predefined and usable currency codes.

Exceptions
DataEntryErrorThrows this exception if the selected country code is not supported or recognized. The error will indicate the problematic input and provide additional context.
Returns
The currency code corresponding to the user's current selection in the GUI item.

◆ populateUsableCurrencies()

void drn::desktop_ui::CurrencyComboBox::populateUsableCurrencies ( const std::set< pecunia::Currency > & usableCodes,
const navigation::CurrencyDisplayOptions & displayAs )

Populates the GUI item with a list of usable currencies.

This function updates the selectable options within the GUI element to reflect a given set of usable currencies. The GUI item's contents are kept consistent with the provided data, ensuring accurate and usable output for end-users.

Parameters
usableCodesA collection of currency codes that are considered valid and should be added to the list.
displayAsThe specific manner in which each currency should be displayed within the GUI element.
Postcondition
All preexisting selectable options in the GUI item are cleared.
The GUI item is populated with new options corresponding to the usableCodes collection.
The default selection in the GUI item is updated based on the provided data. If only one currency exists, it is selected.

◆ setCurrentCode

void drn::desktop_ui::CurrencyComboBox::setCurrentCode ( const pecunia::Currency & code)
slot

Updates the currently selected currency in the GUI item.

This function sets the current selection of a GUI element representing a selectable list of currencies. It ensures logical display behavior for a specific currency, adjusting the display text or index based on predefined conditions. It integrates seamlessly with other parts of the application for real-time updates.

Parameters
codeThe currency to be set as the currently selected value.
Postcondition
The selected currency in the GUI item is updated.