36 if (
config(
"Style" ).toString() ==
"Dial" )
40 else if (
config(
"Style" ).toString() ==
"Slider" )
42 editor =
new QgsSlider( Qt::Horizontal, parent );
49 case QVariant::Double:
55 case QVariant::LongLong:
67 mDoubleSpinBox = qobject_cast<QDoubleSpinBox*>( editor );
68 mIntSpinBox = qobject_cast<QSpinBox*>( editor );
69 mDial = qobject_cast<QDial*>( editor );
70 mSlider = qobject_cast<QSlider*>( editor );
72 bool allowNull =
config(
"AllowNull" ).toBool();
80 mDoubleSpinBox->setDecimals(
layer()->pendingFields()[
fieldIdx()].precision() );
84 double step =
config(
"Step" ).toDouble();
92 min -= 10 ^ -precision;
98 mDoubleSpinBox->setValue( min );
99 mDoubleSpinBox->setSpecialValueText( QSettings().
value(
"qgis/nullValue",
"NULL" ).toString() );
101 mDoubleSpinBox->setMinimum( min );
102 mDoubleSpinBox->setMaximum(
config(
"Max" ).toDouble() );
103 mDoubleSpinBox->setSingleStep( step );
104 if (
config(
"Suffix" ).isValid() )
106 mDoubleSpinBox->setSuffix(
config(
"Suffix" ).toString() );
114 int step =
config(
"Step" ).toInt();
121 mIntSpinBox->setValue( min );
122 mIntSpinBox->setSpecialValueText( QSettings().
value(
"qgis/nullValue",
"NULL" ).toString() );
124 mIntSpinBox->setMinimum( min );
125 mIntSpinBox->setMaximum(
config(
"Max" ).toInt() );
126 mIntSpinBox->setSingleStep( step );
127 if (
config(
"Suffix" ).isValid() )
129 mIntSpinBox->setSuffix(
config(
"Suffix" ).toString() );
136 mDial->setMinimum(
config(
"Min" ).toInt() );
137 mDial->setMaximum(
config(
"Max" ).toInt() );
138 mDial->setSingleStep(
config(
"Step" ).toInt() );
144 mSlider->setMinimum(
config(
"Min" ).toInt() );
145 mSlider->setMaximum(
config(
"Max" ).toInt() );
146 mSlider->setSingleStep(
config(
"Step" ).toInt() );
155 if ( mDoubleSpinBox )
157 value = mDoubleSpinBox->value();
158 if ( value == mDoubleSpinBox->minimum() &&
config(
"AllowNull" ).toBool() )
160 value = QVariant(
field().type() );
163 else if ( mIntSpinBox )
165 value = mIntSpinBox->value();
166 if ( value == mIntSpinBox->minimum() &&
config(
"AllowNull" ).toBool() )
168 value = QVariant(
field().type() );
173 value = mDial->value();
177 value = mSlider->value();
185 if ( mDoubleSpinBox )
187 if ( value.isNull() &&
config(
"AllowNull" ).toBool() )
189 mDoubleSpinBox->setValue( mDoubleSpinBox->minimum() );
193 mDoubleSpinBox->setValue( value.toDouble() );
199 if ( value.isNull() &&
config(
"AllowNull" ).toBool() )
201 mIntSpinBox->setValue( mIntSpinBox->minimum() );
205 mIntSpinBox->setValue( value.toInt() );
210 mDial->setValue( value.toInt() );
214 mSlider->setValue( value.toInt() );