25 precisionSpinBox->setClearValue( 4 );
28 minimumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
29 minimumSpinBox->setMaximum( std::numeric_limits<int>::max() );
30 minimumSpinBox->setValue( std::numeric_limits<int>::lowest() );
32 maximumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
33 maximumSpinBox->setMaximum( std::numeric_limits<int>::max() );
34 maximumSpinBox->setValue( std::numeric_limits<int>::max() );
36 stepSpinBox->setMaximum( std::numeric_limits<int>::max() );
37 stepSpinBox->setValue( 1 );
38 stepSpinBox->setClearValue( 1 );
40 minimumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
41 minimumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
42 minimumDoubleSpinBox->setValue( std::numeric_limits<double>::min() );
44 maximumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
45 maximumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
46 maximumDoubleSpinBox->setValue( std::numeric_limits<double>::max() );
49 stepDoubleSpinBox->setMaximum( std::numeric_limits<int>::max() );
50 stepDoubleSpinBox->setValue( 1 );
51 stepDoubleSpinBox->setClearValue( 1 );
56 const QMetaType::Type fieldType( vl->
fields().
at( fieldIdx ).
type() );
60 case QMetaType::Type::Int:
61 case QMetaType::Type::LongLong:
62 case QMetaType::Type::Double:
66 rangeStackedWidget->setCurrentIndex( fieldType == QMetaType::Type::Int ? 0 : 1 );
67 if ( fieldType == QMetaType::Type::LongLong )
69 minimumDoubleSpinBox->setDecimals( 0 );
70 maximumDoubleSpinBox->setDecimals( 0 );
71 stepDoubleSpinBox->setDecimals( 0 );
75 rangeWidget->addItem( tr(
"Editable" ), QStringLiteral(
"SpinBox" ) );
76 rangeWidget->addItem( tr(
"Slider" ), QStringLiteral(
"Slider" ) );
77 rangeWidget->addItem( tr(
"Dial" ), QStringLiteral(
"Dial" ) );
83 text = tr(
"Current minimum for this value is %1 and current maximum is %2." ).arg( min.toString(), max.toString() );
88 text = tr(
"Attribute has no integer or real type, therefore range is not usable." );
93 if ( fieldType != QMetaType::Type::Double )
95 precisionSpinBox->hide();
96 precisionLabel->hide();
99 valuesLabel->setText( text );
105 connect( minimumDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
106 connect( maximumDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
107 connect( stepDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
118 switch (
layer()->fields().at(
field() ).type() )
120 case QMetaType::Type::Int:
121 cfg.insert( QStringLiteral(
"Min" ), minimumSpinBox->value() );
122 cfg.insert( QStringLiteral(
"Max" ), maximumSpinBox->value() );
123 cfg.insert( QStringLiteral(
"Step" ), stepSpinBox->value() );
128 case QMetaType::Type::Double:
129 case QMetaType::Type::LongLong:
130 cfg.insert( QStringLiteral(
"Min" ), minimumDoubleSpinBox->value() );
131 cfg.insert( QStringLiteral(
"Max" ), maximumDoubleSpinBox->value() );
132 cfg.insert( QStringLiteral(
"Step" ), stepDoubleSpinBox->value() );
139 cfg.insert( QStringLiteral(
"Style" ), rangeWidget->currentData().toString() );
140 cfg.insert( QStringLiteral(
"AllowNull" ), allowNullCheckBox->isChecked() );
141 cfg.insert( QStringLiteral(
"Precision" ), precisionSpinBox->value() );
143 if ( !suffixLineEdit->text().isEmpty() )
145 cfg.insert( QStringLiteral(
"Suffix" ), suffixLineEdit->text() );
153 minimumDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Min" ), std::numeric_limits<double>::lowest() ).toDouble( ) );
154 maximumDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Max" ), std::numeric_limits<double>::max() ).toDouble( ) );
155 stepDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Step" ), 1.0 ).toDouble() );
156 minimumSpinBox->setValue(
config.value( QStringLiteral(
"Min" ), std::numeric_limits<int>::lowest() ).toInt() );
157 maximumSpinBox->setValue(
config.value( QStringLiteral(
"Max" ), std::numeric_limits<int>::max() ).toInt() );
158 stepSpinBox->setValue(
config.value( QStringLiteral(
"Step" ), 1 ).toInt() );
159 rangeWidget->setCurrentIndex( rangeWidget->findData(
config.value( QStringLiteral(
"Style" ),
"SpinBox" ) ) );
160 suffixLineEdit->setText(
config.value( QStringLiteral(
"Suffix" ) ).toString() );
161 allowNullCheckBox->setChecked(
config.value( QStringLiteral(
"AllowNull" ),
true ).toBool() );
162 precisionSpinBox->setValue(
config.value( QStringLiteral(
"Precision" ),
layer()->fields().at(
field() ).
precision() ).toInt( ) );