UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
ComboBoxUi Class Reference

#include <combobox_ui.hpp>

Inheritance diagram for ComboBoxUi:
Inheritance graph
Collaboration diagram for ComboBoxUi:
Collaboration graph

Public Member Functions

 ComboBoxUi (QComboBox *box, Settings *settings, const std::string &opt, std::function< std::vector< SettingItem >()> itemBuilder)
 
void refresh () override
 
- Public Member Functions inherited from WidgetUi
 WidgetUi (const WidgetUi &)=delete
 
 WidgetUi (Settings *settings, const std::string &opt)
 
 WidgetUi (WidgetUi &&)=delete
 
virtual ~WidgetUi ()
 
WidgetUi & operator= (const WidgetUi &)=delete
 
WidgetUi & operator= (WidgetUi &&)=delete
 
void registerCallback (const std::string &option)
 
void registerCustomCallback (const std::string &option, Option::Callback callback, std::unique_ptr< ExtraCallbackData > &&extraDataPtr=nullptr)
 
void setOpt (const std::string &opt)
 

Private Slots

void itemSelected (int index)
 

Private Member Functions

void connectSignals () override
 
void optChangeCallback (Option &opt, bool suboption) override
 
void selectOption ()
 
void updateUiItems ()
 
void updateUiState () override
 

Private Attributes

QComboBox * box
 
bool ignoreCallback
 
std::function< std::vector< SettingItem >()> itemBuilder
 
std::vector< SettingItem > items
 

Additional Inherited Members

- Signals inherited from WidgetUi
void changed ()
 
- Protected Member Functions inherited from WidgetUi
void registerCallback ()
 
- Static Protected Member Functions inherited from WidgetUi
static void optChangeCallbackStatic (Option &, bool, void *)
 
- Protected Attributes inherited from WidgetUi
std::vector< std::unique_ptr< ExtraCallbackData > > extraData
 
std::string opt
 
std::vector< std::pair< std::string, Option::Callback > > registeredCallbacks
 
Settings * settings
 

Detailed Description

Definition at line 28 of file combobox_ui.hpp.

Constructor & Destructor Documentation

◆ ComboBoxUi()

ComboBoxUi::ComboBoxUi ( QComboBox * box,
Settings * settings,
const std::string & opt,
std::function< std::vector< SettingItem >()> itemBuilder )

Definition at line 4 of file combobox_ui.cpp.

7 :
9 box(box),
10 itemBuilder(std::move(itemBuilder)),
11 ignoreCallback(false)
12{
13 refresh();
16}
QComboBox * box
bool ignoreCallback
void refresh() override
std::function< std::vector< SettingItem >()> itemBuilder
void connectSignals() override
WidgetUi(Settings *settings, const std::string &opt)
Definition widget_ui.cpp:3
std::string opt
Definition widget_ui.hpp:34
void registerCallback()
Definition widget_ui.cpp:57
Settings * settings
Definition widget_ui.hpp:33

References connectSignals(), refresh(), and WidgetUi::registerCallback().

Here is the call graph for this function:

Member Function Documentation

◆ connectSignals()

void ComboBoxUi::connectSignals ( )
overrideprivatevirtual

Implements WidgetUi.

Definition at line 18 of file combobox_ui.cpp.

18 {
19 connect(box, Overload<int>::of(&QComboBox::activated),
21}
void itemSelected(int index)
QOverload< Args... > Overload
Definition overload.hpp:9

References box, and itemSelected().

Referenced by ComboBoxUi().

Here is the call graph for this function:

◆ itemSelected

void ComboBoxUi::itemSelected ( int index)
privateslot

Definition at line 116 of file combobox_ui.cpp.

116 {
117 const SettingItem &item = box->itemData(index).value<SettingItem>();
118
119 ignoreCallback = true;
120 for(const auto &option : item.opts){
121 settings->getOption(option.opt).setValue(option.val);
122 }
123 ignoreCallback = false;
124
125 emit changed();
126}
virtual void setValue(const std::string &val, bool suppressCallback=false)
Definition settings.cpp:73
const Option & getOption(const std::string &opt) const
Definition settings.cpp:384
void changed()
Definition hd-rum.c:27

References box, WidgetUi::changed(), Settings::getOption(), ignoreCallback, WidgetUi::settings, and Option::setValue().

Referenced by connectSignals(), and selectOption().

Here is the call graph for this function:

◆ optChangeCallback()

void ComboBoxUi::optChangeCallback ( Option & opt,
bool suboption )
overrideprivatevirtual

Implements WidgetUi.

Definition at line 91 of file combobox_ui.cpp.

91 {
92 if(suboption || ignoreCallback)
93 return;
94
95 if(opt.getName() != this->opt)
97
99}
void selectOption()
void updateUiItems()

References ignoreCallback, WidgetUi::opt, selectOption(), and updateUiItems().

Here is the call graph for this function:

◆ refresh()

void ComboBoxUi::refresh ( )
overridevirtual

Reimplemented from WidgetUi.

Definition at line 23 of file combobox_ui.cpp.

23 {
25
26 for(const auto &item : items){
27 for(const auto &opt : item.opts){
29 }
30 for(const auto &condClause : item.conditions){
31 for(const auto &condItem : condClause){
32 registerCallback(condItem.value.opt);
33 }
34 }
35 }
36
39}
std::vector< SettingItem > items

References itemBuilder, items, WidgetUi::opt, WidgetUi::registerCallback(), selectOption(), and updateUiItems().

Referenced by ComboBoxUi().

Here is the call graph for this function:

◆ selectOption()

void ComboBoxUi::selectOption ( )
private

Definition at line 66 of file combobox_ui.cpp.

66 {
67 int i;
68 bool found = false;
69 for(i = 0; i < box->count(); i++){
70 const SettingItem &item = box->itemData(i).value<SettingItem>();
71
72 found = true;
73 for(const auto &itemOpt : item.opts){
74 if(itemOpt.val != settings->getOption(itemOpt.opt).getValue()){
75 found = false;
76 break;
77 }
78 }
79
80 if(found)
81 break;
82 }
83
84 if(found){
85 box->setCurrentIndex(i);
86 } else {
87 itemSelected(0);
88 }
89}
std::string getValue() const
Definition settings.cpp:26

References box, Settings::getOption(), Option::getValue(), itemSelected(), and WidgetUi::settings.

Referenced by optChangeCallback(), refresh(), and updateUiState().

Here is the call graph for this function:

◆ updateUiItems()

void ComboBoxUi::updateUiItems ( )
private

Definition at line 105 of file combobox_ui.cpp.

105 {
106 box->clear();
107
108 for(const auto &i : items){
109 if(conditionsSatisfied(i.conditions, settings)){
110 box->addItem(QString::fromStdString(i.name),
111 QVariant::fromValue(i));
112 }
113 }
114}
static bool conditionsSatisfied(const std::vector< std::vector< ConditionItem > > &conds, Settings *settings)

References box, conditionsSatisfied(), items, and WidgetUi::settings.

Referenced by optChangeCallback(), and refresh().

Here is the call graph for this function:

◆ updateUiState()

void ComboBoxUi::updateUiState ( )
overrideprivatevirtual

Implements WidgetUi.

Definition at line 101 of file combobox_ui.cpp.

101 {
102 selectOption();
103}

References selectOption().

Here is the call graph for this function:

Member Data Documentation

◆ box

QComboBox* ComboBoxUi::box
private

Definition at line 40 of file combobox_ui.hpp.

Referenced by connectSignals(), itemSelected(), selectOption(), and updateUiItems().

◆ ignoreCallback

bool ComboBoxUi::ignoreCallback
private

Definition at line 42 of file combobox_ui.hpp.

Referenced by itemSelected(), and optChangeCallback().

◆ itemBuilder

std::function<std::vector<SettingItem>()> ComboBoxUi::itemBuilder
private

Definition at line 41 of file combobox_ui.hpp.

Referenced by refresh().

◆ items

std::vector<SettingItem> ComboBoxUi::items
private

Definition at line 44 of file combobox_ui.hpp.

Referenced by refresh(), and updateUiItems().


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