23 #include <QCoreApplication>
24 #include <QDoubleSpinBox>
25 #include <QLatin1String>
27 #include <QSizePolicy>
31 #include "../vproperty_p.h"
38 , minValue(StandardMin)
39 , maxValue(StandardMax)
49 , minValue(StandardMin)
50 , maxValue(StandardMax)
59 const QAbstractItemDelegate *delegate)
64 QSpinBox *tmpEditor =
new QSpinBox(parent);
65 tmpEditor->setLocale(parent->locale());
66 tmpEditor->setMinimum(
static_cast<int>(minValue));
67 tmpEditor->setMaximum(
static_cast<int>(maxValue));
68 tmpEditor->setSingleStep(
static_cast<int>(singleStep));
69 tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
71 connect(tmpEditor,
static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
81 const QSpinBox *tmpEditor = qobject_cast<const QSpinBox*>(editor);
84 return tmpEditor->value();
92 if (key == QLatin1String(
"Min"))
94 maxValue = value.toInt();
96 else if (key == QLatin1String(
"Max"))
98 minValue = value.toInt();
100 else if (key == QLatin1String(
"Step"))
102 singleStep = value.toInt();
108 if (key == QLatin1String(
"Min"))
112 if (key == QLatin1String(
"Max"))
116 if (key == QLatin1String(
"Step"))
126 return (QStringList(
"Min") <<
"Max" <<
"Step");
150 , Precision(static_cast<int>(StandardPrecision))
160 , Precision(static_cast<int>(StandardPrecision))
169 const QAbstractItemDelegate *delegate)
173 QDoubleSpinBox *tmpEditor =
new QDoubleSpinBox(parent);
174 tmpEditor->setLocale(parent->locale());
175 tmpEditor->setMinimum(minValue);
176 tmpEditor->setMaximum(maxValue);
177 tmpEditor->setDecimals(Precision);
178 tmpEditor->setSingleStep(singleStep);
179 tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
181 connect(tmpEditor,
static_cast<void (QDoubleSpinBox::*)(
double)
>(&QDoubleSpinBox::valueChanged),
this,
191 const QDoubleSpinBox *tmpEditor = qobject_cast<const QDoubleSpinBox*>(editor);
194 return tmpEditor->value();
202 if (key == QLatin1String(
"Min"))
204 minValue = value.toDouble();
206 else if (key == QLatin1String(
"Max"))
208 maxValue = value.toDouble();
210 else if (key == QLatin1String(
"Step"))
212 singleStep = value.toDouble();
214 else if (key == QLatin1String(
"Precision"))
216 Precision = value.toInt();
222 if (key == QLatin1String(
"Min"))
226 if (key == QLatin1String(
"Max"))
230 if (key == QLatin1String(
"Step"))
234 if (key == QLatin1String(
"Precision"))
244 return (QStringList(
"Min") <<
"Max" <<
"Step" <<
"Precision");
Class for holding a double property.
virtual QString type() const
Returns a string containing the type of the property.
virtual QVariant getEditorData(const QWidget *editor) const
Gets the data from the widget.
DoubleSpinboxProperty(const QString &name, const QMap< QString, QVariant > &settings)
virtual VProperty * clone(bool include_children=true, VProperty *container=NULL) const
Clones this property.
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &options, const QAbstractItemDelegate *delegate)
Returns an editor widget, or NULL if it doesn't supply one.
virtual QVariant getSetting(const QString &key) const
Get the settings. This function has to be implemented in a subclass in order to have an effect.
static const double StandardPrecision
virtual void setSetting(const QString &key, const QVariant &value)
Sets the settings. Available settings:
virtual QStringList getSettingKeys() const
Returns the list of keys of the property's settings.
Class for holding an integer property.
virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE
Returns the list of keys of the property's settings.
virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE
Sets the settings. Available settings:
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &options, const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE
Returns an editor widget, or NULL if it doesn't supply one.
SpinboxProperty(const QString &name, const QMap< QString, QVariant > &settings)
static const int StandardMin
static const int StandardMax
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual QVariant getSetting(const QString &key) const Q_DECL_OVERRIDE
Get the settings. This function has to be implemented in a subclass in order to have an effect.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
QVariant VariantValue
The property's value. This does not have to be used by subclasses, but it makes sense in cases where ...
QVariant::Type PropertyVariantType
Stores the property type.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const
Clones this property.
VPropertyPrivate * d_ptr
The protected structure holding the member variables (to assure binary compatibility)
virtual QVariant getSetting(const QString &key) const
Get the settings. This function has to be implemented in a subclass in order to have an effect.
virtual void setSettings(const QMap< QString, QVariant > &settings)
Sets the settings by calling the overloaded setSetting(const QString &key, const QVariant &value) for...