24 precisionSpinBox->setClearValue( 4 );
27 minimumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
28 minimumSpinBox->setMaximum( std::numeric_limits<int>::max() );
29 minimumSpinBox->setValue( std::numeric_limits<int>::lowest() );
31 maximumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
32 maximumSpinBox->setMaximum( std::numeric_limits<int>::max() );
33 maximumSpinBox->setValue( std::numeric_limits<int>::max() );
35 stepSpinBox->setMaximum( std::numeric_limits<int>::max() );
36 stepSpinBox->setValue( 1 );
37 stepSpinBox->setClearValue( 1 );
39 minimumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
40 minimumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
41 minimumDoubleSpinBox->setValue( std::numeric_limits<double>::min() );
43 maximumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
44 maximumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
45 maximumDoubleSpinBox->setValue( std::numeric_limits<double>::max() );
48 stepDoubleSpinBox->setMaximum( std::numeric_limits<int>::max() );
49 stepDoubleSpinBox->setValue( 1 );
50 stepDoubleSpinBox->setClearValue( 1 );
55 const QMetaType::Type fieldType( vl->
fields().
at( fieldIdx ).
type() );
59 case QMetaType::Type::Int:
60 case QMetaType::Type::LongLong:
61 case QMetaType::Type::Double:
65 rangeStackedWidget->setCurrentIndex( fieldType == QMetaType::Type::Int ? 0 : 1 );
66 if ( fieldType == QMetaType::Type::LongLong )
68 minimumDoubleSpinBox->setDecimals( 0 );
69 maximumDoubleSpinBox->setDecimals( 0 );
70 stepDoubleSpinBox->setDecimals( 0 );
74 rangeWidget->addItem( tr(
"Editable" ), QStringLiteral(
"SpinBox" ) );
75 rangeWidget->addItem( tr(
"Slider" ), QStringLiteral(
"Slider" ) );
76 rangeWidget->addItem( tr(
"Dial" ), QStringLiteral(
"Dial" ) );
82 text = tr(
"Current minimum for this value is %1 and current maximum is %2." ).arg( min.toString(), max.toString() );
87 text = tr(
"Attribute has no integer or real type, therefore range is not usable." );
92 if ( fieldType != QMetaType::Type::Double )
94 precisionSpinBox->hide();
95 precisionLabel->hide();
98 valuesLabel->setText( text );
104 connect( minimumDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
105 connect( maximumDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
106 connect( stepDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
117 switch (
layer()->fields().at(
field() ).type() )
119 case QMetaType::Type::Int:
120 cfg.insert( QStringLiteral(
"Min" ), minimumSpinBox->value() );
121 cfg.insert( QStringLiteral(
"Max" ), maximumSpinBox->value() );
122 cfg.insert( QStringLiteral(
"Step" ), stepSpinBox->value() );
127 case QMetaType::Type::Double:
128 case QMetaType::Type::LongLong:
129 cfg.insert( QStringLiteral(
"Min" ), minimumDoubleSpinBox->value() );
130 cfg.insert( QStringLiteral(
"Max" ), maximumDoubleSpinBox->value() );
131 cfg.insert( QStringLiteral(
"Step" ), stepDoubleSpinBox->value() );
138 cfg.insert( QStringLiteral(
"Style" ), rangeWidget->currentData().toString() );
139 cfg.insert( QStringLiteral(
"AllowNull" ), allowNullCheckBox->isChecked() );
140 cfg.insert( QStringLiteral(
"Precision" ), precisionSpinBox->value() );
142 if ( !suffixLineEdit->text().isEmpty() )
144 cfg.insert( QStringLiteral(
"Suffix" ), suffixLineEdit->text() );
152 minimumDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Min" ), std::numeric_limits<double>::lowest() ).toDouble( ) );
153 maximumDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Max" ), std::numeric_limits<double>::max() ).toDouble( ) );
154 stepDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Step" ), 1.0 ).toDouble() );
155 minimumSpinBox->setValue(
config.value( QStringLiteral(
"Min" ), std::numeric_limits<int>::lowest() ).toInt() );
156 maximumSpinBox->setValue(
config.value( QStringLiteral(
"Max" ), std::numeric_limits<int>::max() ).toInt() );
157 stepSpinBox->setValue(
config.value( QStringLiteral(
"Step" ), 1 ).toInt() );
158 rangeWidget->setCurrentIndex( rangeWidget->findData(
config.value( QStringLiteral(
"Style" ),
"SpinBox" ) ) );
159 suffixLineEdit->setText(
config.value( QStringLiteral(
"Suffix" ) ).toString() );
160 allowNullCheckBox->setChecked(
config.value( QStringLiteral(
"AllowNull" ),
true ).toBool() );
161 precisionSpinBox->setValue(
config.value( QStringLiteral(
"Precision" ),
layer()->fields().at(
field() ).
precision() ).toInt( ) );