15 #ifndef BORNAGAIN_GUI_MODEL_DESCRIPTOR_SELECTIONDESCRIPTOR_H
16 #define BORNAGAIN_GUI_MODEL_DESCRIPTOR_SELECTIONDESCRIPTOR_H
21 #include <QStringList>
88 if (comboProperty.currentIndex() != index) {
90 item->
setValue(QVariant::fromValue<ComboProperty>(comboProperty));
95 if constexpr (std::is_pointer<T>::value) {
96 if (
auto* groupItem =
dynamic_cast<GroupItem*
>(item))
97 currentItem = [=] {
return dynamic_cast<T
>(groupItem->currentItem()); };
98 }
else if constexpr (std::is_same<T, QString>::value)
Defines class ComboProperty.
Abstract base class for SelectionDescriptor to ease referencing.
virtual ~AbstractSelectionDescriptor()=default
virtual int currentIndex() const =0
Get currently selected option.
virtual void setCurrentIndex(int newIndex) const =0
Set currently selected option.
Custom property to define list of string values with multiple selections. Intended for QVariant.
void setCurrentIndex(int index)
Describes a selection (various possibilities and the current one).
int currentIndex() const override
Get currently selected option.
SelectionDescriptor()=default
function< int()> currentIndexGetter
Function to get currently selected option.
QString label
A label text (short, no trailing colon)
function< T()> currentItem
Function to get currently selected item.
function< void(int)> currentIndexSetter
Function to set currently selected option.
QStringList options
List of options, usually presented as combo entries.
void setCurrentIndex(int newIndex) const override
Set currently selected option.
SelectionDescriptor(SessionItem *item)
Initialize the members by means of a SessionItem containing a ComboProperty. This can be a GroupItem ...
QString tooltip
Tooltip text.
Base class for a GUI data item.
QString displayName() const
Get display name of item, append index if ambigue.
QVariant value() const
Get value.
bool setValue(QVariant value)
Set value, ensure that variant types match.