24 precisionSpinBox->setClearValue( 4 );
26 minimumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
27 minimumSpinBox->setMaximum( std::numeric_limits<int>::max() );
28 minimumSpinBox->setValue( std::numeric_limits<int>::lowest() );
30 maximumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
31 maximumSpinBox->setMaximum( std::numeric_limits<int>::max() );
32 maximumSpinBox->setValue( std::numeric_limits<int>::max() );
34 stepSpinBox->setMaximum( std::numeric_limits<int>::max() );
35 stepSpinBox->setValue( 1 );
36 stepSpinBox->setClearValue( 1 );
38 minimumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
39 minimumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
40 minimumDoubleSpinBox->setValue( std::numeric_limits<double>::min() );
42 maximumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
43 maximumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
44 maximumDoubleSpinBox->setValue( std::numeric_limits<double>::max() );
47 stepDoubleSpinBox->setMaximum( std::numeric_limits<int>::max() );
48 stepDoubleSpinBox->setValue( 1 );
49 stepDoubleSpinBox->setClearValue( 1 );
54 QVariant::Type fieldType( vl->
fields().
at( fieldIdx ).
type() );
59 case QVariant::LongLong:
60 case QVariant::Double:
62 rangeStackedWidget->setCurrentIndex( vl->
fields().
at( fieldIdx ).
type() == QVariant::Double ? 1 : 0 );
65 rangeWidget->addItem( tr(
"Editable" ), QStringLiteral(
"SpinBox" ) );
66 rangeWidget->addItem( tr(
"Slider" ), QStringLiteral(
"Slider" ) );
67 rangeWidget->addItem( tr(
"Dial" ), QStringLiteral(
"Dial" ) );
72 text = tr(
"Current minimum for this value is %1 and current maximum is %2." ).arg( min.toString(), max.toString() );
77 text = tr(
"Attribute has no integer or real type, therefore range is not usable." );
82 if ( fieldType != QVariant::Double )
84 precisionSpinBox->hide();
85 precisionLabel->hide();
88 valuesLabel->setText( text );
94 connect( minimumDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
95 connect( maximumDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
96 connect( stepDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
106 switch (
layer()->fields().at(
field() ).type() )
109 case QVariant::LongLong:
110 cfg.insert( QStringLiteral(
"Min" ), minimumSpinBox->value() );
111 cfg.insert( QStringLiteral(
"Max" ), maximumSpinBox->value() );
112 cfg.insert( QStringLiteral(
"Step" ), stepSpinBox->value() );
115 case QVariant::Double:
116 cfg.insert( QStringLiteral(
"Min" ), minimumDoubleSpinBox->value() );
117 cfg.insert( QStringLiteral(
"Max" ), maximumDoubleSpinBox->value() );
118 cfg.insert( QStringLiteral(
"Step" ), stepDoubleSpinBox->value() );
125 cfg.insert( QStringLiteral(
"Style" ), rangeWidget->currentData().toString() );
126 cfg.insert( QStringLiteral(
"AllowNull" ), allowNullCheckBox->isChecked() );
127 cfg.insert( QStringLiteral(
"Precision" ), precisionSpinBox->value() );
129 if ( !suffixLineEdit->text().isEmpty() )
131 cfg.insert( QStringLiteral(
"Suffix" ), suffixLineEdit->text() );
139 minimumDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Min" ), std::numeric_limits<double>::lowest() ).toDouble( ) );
140 maximumDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Max" ), std::numeric_limits<double>::max() ).toDouble( ) );
141 stepDoubleSpinBox->setValue(
config.value( QStringLiteral(
"Step" ), 1.0 ).toDouble() );
142 minimumSpinBox->setValue(
config.value( QStringLiteral(
"Min" ), std::numeric_limits<int>::lowest() ).toInt() );
143 maximumSpinBox->setValue(
config.value( QStringLiteral(
"Max" ), std::numeric_limits<int>::max() ).toInt() );
144 stepSpinBox->setValue(
config.value( QStringLiteral(
"Step" ), 1 ).toInt() );
145 rangeWidget->setCurrentIndex( rangeWidget->findData(
config.value( QStringLiteral(
"Style" ),
"SpinBox" ) ) );
146 suffixLineEdit->setText(
config.value( QStringLiteral(
"Suffix" ) ).toString() );
147 allowNullCheckBox->setChecked(
config.value( QStringLiteral(
"AllowNull" ),
true ).toBool() );
148 precisionSpinBox->setValue(
config.value( QStringLiteral(
"Precision" ),
layer()->fields().at(
field() ).
precision() ).toInt( ) );
153 QString style = rangeWidget->itemData( index ).toString();
154 allowNullCheckBox->setEnabled( style == QLatin1String(
"SpinBox" ) );