Creates editors for SessionItem's values.
More...
Creates editors for SessionItem's values.
◆ CreateEditor()
QWidget * PropertyEditorFactory::CreateEditor |
( |
const SessionItem & |
item, |
|
|
QWidget * |
parent = nullptr |
|
) |
| |
Creates an editor suitable for editing of item.value()
Definition at line 101 of file PropertyEditorFactory.cpp.
103 QWidget* result(
nullptr);
105 if (isDoubleProperty(item.
value())) {
106 if (item.
editorType() ==
"ScientificDouble") {
108 auto limits = item.
limits();
111 }
else if (item.
editorType() ==
"ScientificSpinBox") {
113 auto limits = item.
limits();
115 editor->setDecimals(item.
decimals());
116 editor->setSingleStep(getStep(item.
roleProperty(Qt::EditRole).toDouble()));
121 editor->setDecimals(item.
decimals());
124 }
else if (isIntProperty(item.
value())) {
128 }
else if (isBoolProperty(item.
value())) {
131 }
else if (isStringProperty(item.
value())) {
132 result = createCustomStringEditor(item);
133 }
else if (isExternalProperty(item.
value())) {
138 }
else if (isComboProperty(item.
value())) {
142 }
else if (item.
editorType() ==
"MultiSelectionComboEditor") {
147 if (parent && result)
148 result->setParent(parent);
Editor for ComboProperty variant.
Editor for Double variant.
void setLimits(const RealLimits &limits)
Editor for ExternalProperty variant.
void setExternalDialogType(const QString &dialogType)
void setLimits(const RealLimits &limits)
Provides custom editor for ComboProperty with multi-select option.
void setLimits(double xmin, double xmax)
Sets lower and upper limits.
Editor for ScientificDoubleProperty variant.
Editor for Double variant using ScientificSpinBox.
QVariant value() const
Get value.
QString editorType() const
QVariant roleProperty(int role) const
Returns corresponding variant under given role, invalid variant when role is not present.
RealLimits limits() const
References SessionItem::decimals(), SessionItem::editorType(), SessionItem::limits(), SessionItem::roleProperty(), ExternalPropertyEditor::setExternalDialogType(), DoubleEditor::setLimits(), IntEditor::setLimits(), RealLimits::setLimits(), and SessionItem::value().
Referenced by ComponentFlatView::createWidget().
◆ hasStringRepresentation()
bool PropertyEditorFactory::hasStringRepresentation |
( |
const QModelIndex & |
index | ) |
|
Returns true if the index data has known (custom) convertion to string.
Definition at line 64 of file PropertyEditorFactory.cpp.
66 auto variant = index.data();
67 if (isExternalProperty(variant))
69 if (isComboProperty(variant))
71 if (isBoolProperty(variant))
73 if (isDoubleProperty(variant) && index.internalPointer())
Referenced by SessionModelDelegate::paint().
◆ toString()
QString PropertyEditorFactory::toString |
( |
const QModelIndex & |
index | ) |
|
Provides string representation of index data.
Definition at line 79 of file PropertyEditorFactory.cpp.
81 auto variant = index.data();
82 if (isExternalProperty(variant))
84 if (isComboProperty(variant))
86 if (isBoolProperty(variant))
87 return variant.toBool() ?
"True" :
"False";
89 if (isDoubleProperty(variant) && index.internalPointer()) {
90 auto item =
static_cast<SessionItem*
>(index.internalPointer());
91 return item->
editorType() ==
"ScientificDouble"
92 ? QString::number(item->value().toDouble(),
'g')
93 : item->editorType() ==
"ScientificSpinBox"
95 : QString::number(item->value().toDouble(),
'f', item->decimals());
Custom property to define list of string values with multiple selections.
The ExternalProperty class defines custom QVariant property to carry the text, color and an identifie...
std::string toString(PyObject *obj)
Converts PyObject into string, if possible, or throws exception.
References SessionItem::editorType(), and ScientificSpinBox::toString().
Referenced by SessionModelDelegate::paint().