1#ifndef IV_SRC_UI_GUI_SHEETMODELENTRYFACTORY_HPP_
2#define IV_SRC_UI_GUI_SHEETMODELENTRYFACTORY_HPP_
5#include "third_party/magic_enum/magic_enum.hpp"
38 template<iv::concepts::IntegerType T>
48 cellDefinition.m_component = editNum;
50 editNum->setShouldDisplayPopOverIfError(
true);
54 return cellDefinition;
65 template<iv::concepts::IntegerType T>
67 std::optional<T> &valueRef,
68 unsigned short numMaxChar)
72 auto sharedValue = std::make_shared<T>(valueRef.value_or(0));
77 auto checkButton =
new CCheckButton(valueRef.has_value());
82 layout->addStart(checkButton,
false,
false, 0);
83 layout->addEnd(editNum,
true,
true, 0);
85 layout->emplaceListenerAccept(
86 [checkButton, sharedValue, &valueRef]()
88 if (checkButton->getValue())
90 valueRef = *sharedValue;
94 valueRef = std::nullopt;
98 cellDefinition.m_component = layout;
100 editNum->setShouldDisplayPopOverIfError(
true);
104 return cellDefinition;
116 auto sharedValue = std::make_shared<std::string>(valueRef.value_or(
""));
117 if (
CEdit *edit =
new CEdit(sharedValue.get()))
121 auto checkButton =
new CCheckButton(valueRef.has_value());
126 layout->addStart(checkButton,
false,
false, 0);
127 layout->addEnd(edit,
true,
true, 0);
129 layout->emplaceListenerAccept(
130 [checkButton, sharedValue, &valueRef]()
132 if (checkButton->getValue())
134 valueRef = *sharedValue;
138 valueRef = std::nullopt;
142 cellDefinition.m_component = layout;
144 edit->setShouldDisplayPopOverIfError(
true);
148 return cellDefinition;
161 template<iv::concepts::IntegerType T>
164 T maxValue,
unsigned short numMaxChar)
173 cellDefinition.m_component = editNum;
175 editNum->setShouldDisplayPopOverIfError(
true);
179 return cellDefinition;
191 template<iv::concepts::FloatingPo
intType T>
193 T &valueRef, uint16_t numMaxChar,
194 uint16_t numMaxDecimals)
202 cellDefinition.m_component = editNum;
204 editNum->setShouldDisplayPopOverIfError(
true);
208 return cellDefinition;
222 template<iv::concepts::FloatingPo
intType T>
225 T maxValue, uint16_t numMaxChar, uint16_t numMaxDecimals)
230 numMaxDecimals, numMaxChar))
234 cellDefinition.m_component = editNum;
236 editNum->setShouldDisplayPopOverIfError(
true);
240 return cellDefinition;
249 template<iv::concepts::EnumType T>
252 auto options = magic_enum::enum_values<T>();
262 template<iv::concepts::EnumType T>
272 for (T comboBoxValue: options)
274 comboBoxEnum->addOption(comboBoxValue, magic_enum::enum_name(comboBoxValue));
277 comboBoxEnum->setOption(
static_cast<uint32_t
>(option));
279 comboBoxEnum->emplaceListenerChange(
284 tComboBoxEnum->setTooltip(
285 magic_enum::enum_name(
static_cast<T
>(tComboBoxEnum->getIdOptionSelection())));
289 cellDefinition.m_component = comboBoxEnum;
291 return cellDefinition;
295 std::map<uint32_t, std::string> options);
298 const std::string &text =
"");
306 const std::weak_ptr<iv::units::Unit> &unit);
309 const std::optional<std::function<
bool(std::shared_ptr<iv::channels::AbstractChannel>)>> &filterCallback =
311 const std::function<
void(
const std::weak_ptr<iv::channels::AbstractChannel> &)> &selectionCallback =
312 [](
const auto &) {});
#define IV_ASSERT_NULL_POINTER(ptr)
Definition assert.hpp:128
Definition AbstractComponentGUI.hpp:30
Definition CComboBox.hpp:111
Definition CDialog.hpp:21
Definition CEditNum.hpp:15
static CEditNum * createInteger(const std::string &nameField, T &valueRef, const uint16_t numMaxChar)
Definition CEditNum.hpp:65
static CEditNum * createFloatingPoint(const std::string &nameField, T &valueRef, uint8_t numMaxDecimals, uint8_t numMaxChar)
Definition CEditNum.hpp:153
static CEditNum * createFloatingPointWithInterval(const std::string &nameField, T &valueRef, T minValue, T maxValue, uint8_t numMaxDecimals, uint8_t numMaxChar)
Definition CEditNum.hpp:169
static CEditNum * createIntegerWithInterval(const std::string &nameField, T &valueRef, R1 minValue, R2 maxValue, uint16_t numMaxChar)
Definition CEditNum.hpp:101
static const int32_t kDefaultSizeString
Definition CEdit.hpp:42
Definition CLayoutHorizontal.hpp:7
static void linkCheckWithComponent(CCheckButton *checkButton, AbstractComponentGUI *panel, bool inverted=false)
Definition CPanelsTools.cpp:157
Definition IListenerClick.hpp:7
Definition IListenerIsAccept.hpp:7
The SheetModelEntryFactory class. It contains the methods to create cell widgets for the sheet model.
Definition SheetModelEntryFactory.hpp:28
static iv::gui::sheets::CellDefinition createButtonCellDefinition(std::string_view text, IListenerClick *listener)
Definition SheetModelEntryFactory.cpp:345
static iv::gui::sheets::CellDefinition createEntryNumberIntegerCellDefinition(const std::string &nameField, T &valueRef, unsigned short numMaxChar)
Create a cell definition for an integer number.
Definition SheetModelEntryFactory.hpp:40
static iv::gui::sheets::CellDefinition createComboBoxEnumCellDefinition(T &option)
Create a cell definition for a combo box with enum values.
Definition SheetModelEntryFactory.hpp:250
static void prvSetEntryChangeListener(AbstractComponentGUI *entryComponent)
Definition SheetModelEntryFactory.cpp:337
static iv::gui::sheets::CellDefinition createCheckButtonCellDefinition(bool &activated, const std::string &text="")
Definition SheetModelEntryFactory.cpp:178
static iv::gui::sheets::CellDefinition createEntryOptionalStringCellDefinition(std::optional< std::string > &valueRef)
Create a cell definition for an optional string.
Definition SheetModelEntryFactory.hpp:112
static iv::gui::sheets::CellDefinition createEntryNumberIntegerCellDefinitionWithInterval(const std::string &nameField, T &valueRef, T minValue, T maxValue, unsigned short numMaxChar)
Create a cell definition for an integer number with interval.
Definition SheetModelEntryFactory.hpp:163
static iv::gui::sheets::CellDefinition createEntryNumberDecimalCellDefinitionWithInterval(const std::string &nameField, T &valueRef, T minValue, T maxValue, uint16_t numMaxChar, uint16_t numMaxDecimals)
Create a cell definition for a decimal number with interval.
Definition SheetModelEntryFactory.hpp:224
static iv::gui::sheets::CellDefinition createEntryCellDefinition(std::string &value)
Definition SheetModelEntryFactory.cpp:200
static iv::gui::sheets::CellDefinition createEntryCellDefinitionForTag(const std::shared_ptr< iv::channels::AbstractChannel > &channel, const std::weak_ptr< iv::units::Unit > &unit)
Definition SheetModelEntryFactory.cpp:241
static iv::gui::sheets::CellDefinition createButtonSelectChannelCellDefinition(iv::types::channelId &channelIdOut, const std::optional< std::function< bool(std::shared_ptr< iv::channels::AbstractChannel >)> > &filterCallback=std::nullopt, const std::function< void(const std::weak_ptr< iv::channels::AbstractChannel > &)> &selectionCallback=[](const auto &) {})
Definition SheetModelEntryFactory.cpp:275
static iv::gui::sheets::CellDefinition createComboBoxCellDefinition(uint32_t &option, std::map< uint32_t, std::string > options)
Definition SheetModelEntryFactory.cpp:155
static iv::gui::sheets::CellDefinition createEntryCellDefinitionStatic(std::string_view value="")
Definition SheetModelEntryFactory.cpp:321
static iv::gui::sheets::CellDefinition createComboBoxEnumCellDefinitionLimitedOptions(T &option, std::set< T > options)
Create a cell definition for a combo box with enum values.
Definition SheetModelEntryFactory.hpp:263
static iv::gui::sheets::CellDefinition createEntryNumberDecimalCellDefinition(const std::string &nameField, T &valueRef, uint16_t numMaxChar, uint16_t numMaxDecimals)
Create a cell definition for a decimal number.
Definition SheetModelEntryFactory.hpp:192
static iv::gui::sheets::CellDefinition createEntryOptionalNumberIntegerCellDefinition(const std::string &nameField, std::optional< T > &valueRef, unsigned short numMaxChar)
Create a cell definition for an integer number.
Definition SheetModelEntryFactory.hpp:66
Definition SheetModelCabinetsFactory.cpp:9
std::string channelId
Definition types.hpp:66
Definition structs.hpp:18