27 precisionSpinBox->setClearValue( 4 );
30 minimumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
31 minimumSpinBox->setMaximum( std::numeric_limits<int>::max() );
32 minimumSpinBox->setValue( std::numeric_limits<int>::lowest() );
34 maximumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
35 maximumSpinBox->setMaximum( std::numeric_limits<int>::max() );
36 maximumSpinBox->setValue( std::numeric_limits<int>::max() );
38 stepSpinBox->setMaximum( std::numeric_limits<int>::max() );
39 stepSpinBox->setValue( 1 );
40 stepSpinBox->setClearValue( 1 );
42 minimumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
43 minimumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
44 minimumDoubleSpinBox->setValue( std::numeric_limits<double>::min() );
46 maximumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
47 maximumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
48 maximumDoubleSpinBox->setValue( std::numeric_limits<double>::max() );
51 stepDoubleSpinBox->setMaximum( std::numeric_limits<int>::max() );
52 stepDoubleSpinBox->setValue( 1 );
53 stepDoubleSpinBox->setClearValue( 1 );
58 const QMetaType::Type fieldType( vl->
fields().
at( fieldIdx ).
type() );
62 case QMetaType::Type::Int:
63 case QMetaType::Type::LongLong:
64 case QMetaType::Type::Double:
68 rangeStackedWidget->setCurrentIndex( fieldType == QMetaType::Type::Int ? 0 : 1 );
69 if ( fieldType == QMetaType::Type::LongLong )
71 minimumDoubleSpinBox->setDecimals( 0 );
72 maximumDoubleSpinBox->setDecimals( 0 );
73 stepDoubleSpinBox->setDecimals( 0 );
77 rangeWidget->addItem( tr(
"Editable" ), QStringLiteral(
"SpinBox" ) );
78 rangeWidget->addItem( tr(
"Slider" ), QStringLiteral(
"Slider" ) );
79 rangeWidget->addItem( tr(
"Dial" ), QStringLiteral(
"Dial" ) );
85 text = tr(
"Current minimum for this value is %1 and current maximum is %2." ).arg( min.toString(), max.toString() );
90 text = tr(
"Attribute has no integer or real type, therefore range is not usable." );
95 if ( fieldType != QMetaType::Type::Double )
97 precisionSpinBox->hide();
98 precisionLabel->hide();
101 valuesLabel->setText( text );
107 connect( minimumDoubleSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
108 connect( maximumDoubleSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
109 connect( stepDoubleSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
120 switch (
layer()->fields().at(
field() ).type() )
122 case QMetaType::Type::Int:
123 cfg.insert( QStringLiteral(
"Min" ), minimumSpinBox->value() );
124 cfg.insert( QStringLiteral(
"Max" ), maximumSpinBox->value() );
125 cfg.insert( QStringLiteral(
"Step" ), stepSpinBox->value() );
130 case QMetaType::Type::Double:
131 case QMetaType::Type::LongLong:
132 cfg.insert( QStringLiteral(
"Min" ), minimumDoubleSpinBox->value() );
133 cfg.insert( QStringLiteral(
"Max" ), maximumDoubleSpinBox->value() );
134 cfg.insert( QStringLiteral(
"Step" ), stepDoubleSpinBox->value() );
141 cfg.insert( QStringLiteral(
"Style" ), rangeWidget->currentData().toString() );
142 cfg.insert( QStringLiteral(
"AllowNull" ), allowNullCheckBox->isChecked() );
143 cfg.insert( QStringLiteral(
"Precision" ), precisionSpinBox->value() );
145 if ( !suffixLineEdit->text().isEmpty() )
147 cfg.insert( QStringLiteral(
"Suffix" ), suffixLineEdit->text() );
155 minimumDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Min" ), std::numeric_limits<double>::lowest() ).toDouble() );
156 maximumDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Max" ), std::numeric_limits<double>::max() ).toDouble() );
157 stepDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Step" ), 1.0 ).toDouble() );
158 minimumSpinBox->setValue(
config.value( QStringLiteral(
"Min" ), std::numeric_limits<int>::lowest() ).toInt() );
159 maximumSpinBox->setValue(
config.value( QStringLiteral(
"Max" ), std::numeric_limits<int>::max() ).toInt() );
160 stepSpinBox->setValue(
config.value( QStringLiteral(
"Step" ), 1 ).toInt() );
161 rangeWidget->setCurrentIndex( rangeWidget->findData(
config.value( QStringLiteral(
"Style" ),
"SpinBox" ) ) );
162 suffixLineEdit->setText(
config.value( QStringLiteral(
"Suffix" ) ).toString() );
163 allowNullCheckBox->setChecked(
config.value( QStringLiteral(
"AllowNull" ),
true ).toBool() );
167 precisionSpinBox->setValue(
config.value( QStringLiteral(
"Precision" ), fieldPrecision ).toInt() );