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 );
56 connect( minimumSpinBox, SIGNAL( valueChanged(
int ) ),
this, SIGNAL(
changed() ) );
57 connect( maximumSpinBox, SIGNAL( valueChanged(
int ) ),
this, SIGNAL(
changed() ) );
58 connect( stepSpinBox, SIGNAL( valueChanged(
int ) ),
this, SIGNAL(
changed() ) );
59 connect( minimumDoubleSpinBox, SIGNAL( valueChanged(
double ) ),
this, SIGNAL(
changed() ) );
60 connect( maximumDoubleSpinBox, SIGNAL( valueChanged(
double ) ),
this, SIGNAL(
changed() ) );
61 connect( stepDoubleSpinBox, SIGNAL( valueChanged(
double ) ),
this, SIGNAL(
changed() ) );
62 connect( rangeWidget, SIGNAL( currentIndexChanged(
int ) ),
this, SIGNAL(
changed() ) );
63 connect( allowNullCheckBox, SIGNAL( toggled(
bool ) ),
this, SIGNAL(
changed() ) );
71 switch (
layer()->fields().at(
field() ).type() )
74 case QVariant::LongLong:
75 cfg.insert(
"Min", minimumSpinBox->value() );
76 cfg.insert(
"Max", maximumSpinBox->value() );
77 cfg.insert(
"Step", stepSpinBox->value() );
80 case QVariant::Double:
81 cfg.insert(
"Min", minimumDoubleSpinBox->value() );
82 cfg.insert(
"Max", maximumDoubleSpinBox->value() );
83 cfg.insert(
"Step", stepDoubleSpinBox->value() );
90 cfg.insert(
"Style", rangeWidget->itemData( rangeWidget->currentIndex() ).toString() );
91 cfg.insert(
"AllowNull", allowNullCheckBox->isChecked() );
93 if ( suffixLineEdit->text() !=
"" )
95 cfg.insert(
"Suffix", suffixLineEdit->text() );
103 minimumDoubleSpinBox->setValue( config.value(
"Min", 0.0 ).toDouble() );
104 maximumDoubleSpinBox->setValue( config.value(
"Max", 5.0 ).toDouble() );
105 stepDoubleSpinBox->setValue( config.value(
"Step", 1.0 ).toDouble() );
107 minimumSpinBox->setValue( config.value(
"Min", 0 ).toInt() );
108 maximumSpinBox->setValue( config.value(
"Max", 5 ).toInt() );
109 stepSpinBox->setValue( config.value(
"Step", 1 ).toInt() );
111 rangeWidget->setCurrentIndex( rangeWidget->findData( config.value(
"Style",
"SpinBox" ) ) );
113 suffixLineEdit->setText( config.value(
"Suffix" ).toString() );
115 allowNullCheckBox->setChecked( config.value(
"AllowNull",
true ).toBool() );
120 QString style = rangeWidget->itemData( index ).toString();
121 allowNullCheckBox->setEnabled( style ==
"SpinBox" );
void rangeWidgetChanged(int index)
QVariant maximumValue(int index)
Returns the maximum value for an attribute column or an invalid variant in case of error...
QVariant minimumValue(int index)
Returns the minimum value for an attribute column or an invalid variant in case of error...
QString tr(const char *sourceText, const char *disambiguation, int n)
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
QgsFields fields() const
Returns the list of fields of this layer.
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.
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
QgsRangeConfigDlg(QgsVectorLayer *vl, int fieldIdx, QWidget *parent)
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.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual QgsEditorWidgetConfig config() override
Create a configuration from the current GUI state.