30 case QVariant::LongLong:
31 case QVariant::Double:
33 rangeStackedWidget->setCurrentIndex( vl->
fields().
at( fieldIdx ).
type() == QVariant::Double ? 1 : 0 );
36 rangeWidget->addItem(
tr(
"Editable" ),
"SpinBox" );
37 rangeWidget->addItem(
tr(
"Slider" ),
"Slider" );
38 rangeWidget->addItem(
tr(
"Dial" ),
"Dial" );
43 text =
tr(
"Current minimum for this value is %1 and current maximum is %2." ).
arg( min.
toString(), max.
toString() );
48 text =
tr(
"Attribute has no integer or real type, therefore range is not usable." );
52 valuesLabel->setText( text );
61 switch (
layer()->fields().at(
field() ).type() )
64 case QVariant::LongLong:
65 cfg.
insert(
"Min", minimumSpinBox->value() );
66 cfg.
insert(
"Max", maximumSpinBox->value() );
67 cfg.
insert(
"Step", stepSpinBox->value() );
70 case QVariant::Double:
71 cfg.
insert(
"Min", minimumDoubleSpinBox->value() );
72 cfg.
insert(
"Max", maximumDoubleSpinBox->value() );
73 cfg.
insert(
"Step", stepDoubleSpinBox->value() );
80 cfg.
insert(
"Style", rangeWidget->itemData( rangeWidget->currentIndex() ).toString() );
81 cfg.
insert(
"AllowNull", allowNullCheckBox->isChecked() );
83 if ( suffixLineEdit->text() !=
"" )
85 cfg.
insert(
"Suffix", suffixLineEdit->text() );
93 minimumDoubleSpinBox->setValue( config.
value(
"Min", 0.0 ).toDouble() );
94 maximumDoubleSpinBox->setValue( config.
value(
"Max", 5.0 ).toDouble() );
95 stepDoubleSpinBox->setValue( config.
value(
"Step", 1.0 ).toDouble() );
97 minimumSpinBox->setValue( config.
value(
"Min", 0 ).toInt() );
98 maximumSpinBox->setValue( config.
value(
"Max", 5 ).toInt() );
99 stepSpinBox->setValue( config.
value(
"Step", 1 ).toInt() );
101 rangeWidget->setCurrentIndex( rangeWidget->findData( config.
value(
"Style",
"SpinBox" ) ) );
103 suffixLineEdit->setText( config.
value(
"Suffix" ).toString() );
105 allowNullCheckBox->setChecked( config.
value(
"AllowNull",
true ).toBool() );
110 QString style = rangeWidget->itemData( index ).toString();
111 allowNullCheckBox->setEnabled( style ==
"SpinBox" );
void rangeWidgetChanged(int index)
QVariant maximumValue(int index)
Returns maximum value for an attribute column or invalid variant in case of error.
QgsFields fields() const
Returns the list of fields of this layer.
QVariant minimumValue(int index)
Returns minimum value for an attribute column or invalid variant in case of error.
QString tr(const char *sourceText, const char *disambiguation, int n)
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
virtual void setConfig(const QgsEditorWidgetConfig &config) override
Update the configuration widget to represent the given configuration.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
QgsRangeConfigDlg(QgsVectorLayer *vl, int fieldIdx, QWidget *parent)
iterator insert(const Key &key, const T &value)
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual QgsEditorWidgetConfig config() override
Create a configuration from the current GUI state.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
const T value(const Key &key) const