25 minimumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
26 minimumSpinBox->setMaximum( std::numeric_limits<int>::max() );
27 minimumSpinBox->setValue( std::numeric_limits<int>::lowest() );
29 maximumSpinBox->setMinimum( std::numeric_limits<int>::lowest() );
30 maximumSpinBox->setMaximum( std::numeric_limits<int>::max() );
31 maximumSpinBox->setValue( std::numeric_limits<int>::max() );
33 stepSpinBox->setMaximum( std::numeric_limits<int>::max() );
34 stepSpinBox->setValue( 1 );
36 minimumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
37 minimumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
38 minimumDoubleSpinBox->setValue( std::numeric_limits<double>::min() );
40 maximumDoubleSpinBox->setMinimum( std::numeric_limits<double>::lowest() );
41 maximumDoubleSpinBox->setMaximum( std::numeric_limits<double>::max() );
42 maximumDoubleSpinBox->setValue( std::numeric_limits<double>::max() );
45 stepDoubleSpinBox->setMaximum( std::numeric_limits<int>::max() );
46 stepDoubleSpinBox->setValue( 1 );
51 QVariant::Type fieldType( vl->
fields().
at( fieldIdx ).
type() );
56 case QVariant::LongLong:
57 case QVariant::Double:
59 rangeStackedWidget->setCurrentIndex( vl->
fields().
at( fieldIdx ).
type() == QVariant::Double ? 1 : 0 );
62 rangeWidget->addItem( tr(
"Editable" ), QStringLiteral(
"SpinBox" ) );
63 rangeWidget->addItem( tr(
"Slider" ), QStringLiteral(
"Slider" ) );
64 rangeWidget->addItem( tr(
"Dial" ), QStringLiteral(
"Dial" ) );
69 text = tr(
"Current minimum for this value is %1 and current maximum is %2." ).arg( min.toString(), max.toString() );
74 text = tr(
"Attribute has no integer or real type, therefore range is not usable." );
79 if ( fieldType != QVariant::Double )
81 precisionSpinBox->hide();
82 precisionLabel->hide();
85 valuesLabel->setText( text );
91 connect( minimumDoubleSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
92 connect( maximumDoubleSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
93 connect( stepDoubleSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &
QgsEditorConfigWidget::changed );
103 switch (
layer()->fields().at(
field() ).type() )
106 case QVariant::LongLong:
107 cfg.insert( QStringLiteral(
"Min" ), minimumSpinBox->value() );
108 cfg.insert( QStringLiteral(
"Max" ), maximumSpinBox->value() );
109 cfg.insert( QStringLiteral(
"Step" ), stepSpinBox->value() );
112 case QVariant::Double:
113 cfg.insert( QStringLiteral(
"Min" ), minimumDoubleSpinBox->value() );
114 cfg.insert( QStringLiteral(
"Max" ), maximumDoubleSpinBox->value() );
115 cfg.insert( QStringLiteral(
"Step" ), stepDoubleSpinBox->value() );
122 cfg.insert( QStringLiteral(
"Style" ), rangeWidget->currentData().toString() );
123 cfg.insert( QStringLiteral(
"AllowNull" ), allowNullCheckBox->isChecked() );
124 cfg.insert( QStringLiteral(
"Precision" ), precisionSpinBox->value() );
126 if ( !suffixLineEdit->text().isEmpty() )
128 cfg.insert( QStringLiteral(
"Suffix" ), suffixLineEdit->text() );
136 minimumDoubleSpinBox->setValue( config.value( QStringLiteral(
"Min" ), std::numeric_limits<double>::lowest() ).toDouble( ) );
137 maximumDoubleSpinBox->setValue( config.value( QStringLiteral(
"Max" ), std::numeric_limits<double>::max() ).toDouble( ) );
138 stepDoubleSpinBox->setValue( config.value( QStringLiteral(
"Step" ), 1.0 ).toDouble() );
139 minimumSpinBox->setValue( config.value( QStringLiteral(
"Min" ), std::numeric_limits<int>::lowest() ).toInt() );
140 maximumSpinBox->setValue( config.value( QStringLiteral(
"Max" ), std::numeric_limits<int>::max() ).toInt() );
141 stepSpinBox->setValue( config.value( QStringLiteral(
"Step" ), 1 ).toInt() );
142 rangeWidget->setCurrentIndex( rangeWidget->findData( config.value( QStringLiteral(
"Style" ),
"SpinBox" ) ) );
143 suffixLineEdit->setText( config.value( QStringLiteral(
"Suffix" ) ).toString() );
144 allowNullCheckBox->setChecked( config.value( QStringLiteral(
"AllowNull" ),
true ).toBool() );
145 precisionSpinBox->setValue( config.value( QStringLiteral(
"Precision" ),
layer()->fields().at(
field() ).precision() ).toInt( ) );
150 QString style = rangeWidget->itemData( index ).toString();
151 allowNullCheckBox->setEnabled( style == QLatin1String(
"SpinBox" ) );
void rangeWidgetChanged(int index)
QVariantMap config() override
Create a configuration from the current GUI state.
QVariant minimumValue(int index) const override
Returns the minimum value for an attribute column or an invalid variant in case of error...
QgsField at(int i) const
Get field at particular index (must be in range 0..N-1)
QgsFields fields() const override
Returns the list of fields of this layer.
QgsRangeConfigDlg(QgsVectorLayer *vl, int fieldIdx, QWidget *parent)
QVariant maximumValue(int index) const override
Returns the maximum value for an attribute column or an invalid variant in case of error...
Represents a vector layer which manages a vector based data sets.
void setConfig(const QVariantMap &config) override
Update the configuration widget to represent the given configuration.