38 if (
config(
"Style" ).toString() ==
"Dial" )
42 else if (
config(
"Style" ).toString() ==
"Slider" )
44 editor =
new QgsSlider( Qt::Horizontal, parent );
51 case QVariant::Double:
57 case QVariant::LongLong:
69 mDoubleSpinBox = qobject_cast<QDoubleSpinBox*>( editor );
70 mIntSpinBox = qobject_cast<QSpinBox*>( editor );
71 mDial = qobject_cast<QDial*>( editor );
72 mSlider = qobject_cast<QSlider*>( editor );
73 mQgsDial = qobject_cast<
QgsDial*>( editor );
74 mQgsSlider = qobject_cast<
QgsSlider*>( editor );
76 bool allowNull =
config(
"AllowNull" ).toBool();
84 mDoubleSpinBox->setDecimals(
layer()->pendingFields()[
fieldIdx()].precision() );
88 double step =
config(
"Step" ).toDouble();
96 min -= 10 ^ -precision;
102 mDoubleSpinBox->setValue( min );
103 mDoubleSpinBox->setSpecialValueText( QSettings().
value(
"qgis/nullValue",
"NULL" ).toString() );
105 mDoubleSpinBox->setMinimum( min );
106 mDoubleSpinBox->setMaximum(
config(
"Max" ).toDouble() );
107 mDoubleSpinBox->setSingleStep( step );
108 if (
config(
"Suffix" ).isValid() )
110 mDoubleSpinBox->setSuffix(
config(
"Suffix" ).toString() );
118 int step =
config(
"Step" ).toInt();
125 mIntSpinBox->setValue( min );
126 mIntSpinBox->setSpecialValueText( QSettings().
value(
"qgis/nullValue",
"NULL" ).toString() );
128 mIntSpinBox->setMinimum( min );
129 mIntSpinBox->setMaximum(
config(
"Max" ).toInt() );
130 mIntSpinBox->setSingleStep( step );
131 if (
config(
"Suffix" ).isValid() )
133 mIntSpinBox->setSuffix(
config(
"Suffix" ).toString() );
138 if ( mQgsDial || mQgsSlider )
142 QVariant step(
config(
"Step" ) );
150 mQgsSlider->setMinimum( min );
151 mQgsSlider->setMaximum( max );
152 mQgsSlider->setSingleStep( step );
157 mQgsDial->setMinimum( min );
158 mQgsDial->setMaximum( max );
159 mQgsDial->setSingleStep( step );
166 mDial->setMinimum(
config(
"Min" ).toInt() );
167 mDial->setMaximum(
config(
"Max" ).toInt() );
168 mDial->setSingleStep(
config(
"Step" ).toInt() );
173 mSlider->setMinimum(
config(
"Min" ).toInt() );
174 mSlider->setMaximum(
config(
"Max" ).toInt() );
175 mSlider->setSingleStep(
config(
"Step" ).toInt() );
182 if ( v.type() == QVariant::Int )
184 if ( v.type() == QVariant::Double )
192 if ( mDoubleSpinBox )
194 value = mDoubleSpinBox->value();
195 if ( value == mDoubleSpinBox->minimum() &&
config(
"AllowNull" ).toBool() )
197 value = QVariant(
field().type() );
200 else if ( mIntSpinBox )
202 value = mIntSpinBox->value();
203 if ( value == mIntSpinBox->minimum() &&
config(
"AllowNull" ).toBool() )
205 value = QVariant(
field().type() );
212 else if ( mQgsSlider )
218 value = mDial->value();
222 value = mSlider->value();
230 if ( mDoubleSpinBox )
232 if ( value.isNull() &&
config(
"AllowNull" ).toBool() )
234 mDoubleSpinBox->setValue( mDoubleSpinBox->minimum() );
238 mDoubleSpinBox->setValue( value.toDouble() );
244 if ( value.isNull() &&
config(
"AllowNull" ).toBool() )
246 mIntSpinBox->setValue( mIntSpinBox->minimum() );
250 mIntSpinBox->setValue( value.toInt() );
258 else if ( mQgsSlider )
264 mDial->setValue( value.toInt() );
268 mSlider->setValue( value.toInt() );
void setValue(const QVariant &value)
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
void setShowClearButton(const bool showClearButton)
determines if the widget will show a clear button
void setShowClearButton(const bool showClearButton)
determines if the widget will show a clear button
QVariant variantValue() const
QVariant variantValue() const
void setValue(const QVariant &value)
bool convertCompatible(QVariant &v) const
Converts the provided variant to a compatible format.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
Represents a vector layer which manages a vector based data sets.