20 #include <QModelIndex>
25 double getStep(
double val)
27 return val == 0.0 ? 1.0 : val / 100.;
30 bool isDoubleProperty(
const QVariant& variant)
32 return variant.type() == QVariant::Double;
35 bool isComboProperty(
const QVariant& variant)
45 auto variant = index.data();
46 if (isComboProperty(variant))
48 if (isDoubleProperty(variant) && index.internalPointer())
56 auto variant = index.data();
57 if (isComboProperty(variant))
60 if (isDoubleProperty(variant) && index.internalPointer()) {
61 auto* item =
static_cast<SessionItem*
>(index.internalPointer());
71 QWidget* result(
nullptr);
73 if (isDoubleProperty(item.
value())) {
77 editor->setDecimals(item.
decimals());
78 editor->setSingleStep(getStep(item.
roleProperty(Qt::EditRole).toDouble()));
80 }
else if (isComboProperty(item.
value()))
84 result->setParent(parent);
Defines class ComboProperty.
Defines CustomEditors classes.
Defines namespace GUI::View::PropertyEditorFactory.
Defines class ScientificSpinBox.
Defines class SessionItem.
Editor for ComboProperty variant.
Custom property to define list of string values with multiple selections. Intended for QVariant.
Editor for Double variant using ScientificSpinBox.
void setLimits(const RealLimits &limits)
static QString toString(double val, int decimal_points)
Base class for a GUI data item.
QVariant value() const
Get value.
QVariant roleProperty(int role) const
Returns corresponding variant under given role, invalid variant when role is not present.
RealLimits limits() const
QWidget * CreateEditor(const SessionItem &item, QWidget *parent=nullptr)
Creates an editor suitable for editing of item.value()
QString toString(const QModelIndex &index)
Provides string representation of index data.
bool hasStringRepresentation(const QModelIndex &index)
Returns true if the index data has known (custom) conversion to string.