Skip to content
Permalink
Browse files

[FEATURE] Add suffix support for range widget

  • Loading branch information
m-kuhn committed Sep 22, 2014
1 parent c1c81ea commit f351195d94fe786f059c0849a83f1bedee78fecf
@@ -93,6 +93,11 @@ QgsEditorWidgetConfig QgsRangeConfigDlg::config()

cfg.insert( "Style", rangeWidget->itemData( rangeWidget->currentIndex() ).toString() );

if ( suffixLineEdit->text() != "" )
{
cfg.insert( "Suffix", suffixLineEdit->text() );
}

return cfg;
}

@@ -107,4 +112,6 @@ void QgsRangeConfigDlg::setConfig( const QgsEditorWidgetConfig& config )
stepSpinBox->setValue( config.value( "Step", 1 ).toInt() );

rangeWidget->setCurrentIndex( rangeWidget->findData( config.value( "Style", "SpinBox" ) ) );

suffixLineEdit->setText( config.value( "Suffix" ).toString() );
}
@@ -45,6 +45,11 @@ QgsEditorWidgetConfig QgsRangeWidgetFactory::readConfig( const QDomElement& conf
cfg.insert( "Max", configElement.attribute( "Max" ).toInt() );
cfg.insert( "Step", configElement.attribute( "Step" ).toInt() );

if ( configElement.hasAttribute( "Suffix" ) )
{
cfg.insert( "Suffix", configElement.attribute( "Suffix" ) );
}

return cfg;
}

@@ -58,6 +63,10 @@ void QgsRangeWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QD
configElement.setAttribute( "Min", config["Min"].toInt() );
configElement.setAttribute( "Max", config["Max"].toInt() );
configElement.setAttribute( "Step", config["Step"].toInt() );
if ( config.contains( "Suffix" ) )
{
configElement.setAttribute( "Suffix", config["Suffix"].toString() );
}
}

bool QgsRangeWidgetFactory::isFieldSupported( QgsVectorLayer* vl, int fieldIdx )
@@ -78,6 +78,10 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
mDoubleSpinBox->setMinimum( config( "Min" ).toDouble() );
mDoubleSpinBox->setMaximum( config( "Max" ).toDouble() );
mDoubleSpinBox->setSingleStep( config( "Step" ).toDouble() );
if ( config( "Suffix" ).isValid() )
{
mDoubleSpinBox->setSuffix( config( "Suffix" ).toString() );
}
connect( mDoubleSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( valueChanged( double ) ) );
}

@@ -86,6 +90,10 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
mIntSpinBox->setMinimum( config( "Min" ).toInt() );
mIntSpinBox->setMaximum( config( "Max" ).toInt() );
mIntSpinBox->setSingleStep( config( "Step" ).toInt() );
if ( config( "Suffix" ).isValid() )
{
mIntSpinBox->setSuffix( config( "Suffix" ).toString() );
}
connect( mIntSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( valueChanged( int ) ) );
}

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>549</width>
<height>318</height>
<height>333</height>
</rect>
</property>
<property name="windowTitle">
@@ -24,11 +24,21 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="valuesLabel">
<property name="text">
<string>Local minimum/maximum = 0/0</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QComboBox" name="rangeWidget"/>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_13">
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@@ -41,123 +51,161 @@
</spacer>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridRangeLayout">
<item row="0" column="1" rowspan="3">
<widget class="QStackedWidget" name="rangeStackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="intPage">
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QSpinBox" name="minimumSpinBox">
<property name="minimum">
<number>-999999999</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="maximumSpinBox">
<property name="minimum">
<number>-999999999</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="stepSpinBox">
<property name="maximum">
<number>999999999</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="doublePage">
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QDoubleSpinBox" name="minimumDoubleSpinBox">
<property name="minimum">
<double>-999999999.990000009536743</double>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="maximumDoubleSpinBox">
<property name="minimum">
<double>-999999999.990000009536743</double>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
<property name="value">
<double>5.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="stepDoubleSpinBox">
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="stepLabel">
<property name="text">
<string>Step</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="maximumLabel">
<property name="text">
<string>Maximum</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="minimumLabel">
<property name="text">
<string>Minimum</string>
</property>
</widget>
</item>
</layout>
<widget class="QStackedWidget" name="rangeStackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="intPage">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="minimumLabel">
<property name="text">
<string>Minimum</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="minimumSpinBox">
<property name="minimum">
<number>-999999999</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="maximumLabel">
<property name="text">
<string>Maximum</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="maximumSpinBox">
<property name="minimum">
<number>-999999999</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="stepLabel">
<property name="text">
<string>Step</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="stepSpinBox">
<property name="maximum">
<number>999999999</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="doublePage">
<layout class="QFormLayout" name="formLayout_2">
<item row="2" column="0">
<widget class="QLabel" name="stepLabel_2">
<property name="text">
<string>Step</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="maximumLabel_2">
<property name="text">
<string>Maximum</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="minimumLabel_2">
<property name="text">
<string>Minimum</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="minimumDoubleSpinBox">
<property name="minimum">
<double>-999999999.990000009536743</double>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="maximumDoubleSpinBox">
<property name="minimum">
<double>-999999999.990000009536743</double>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
<property name="value">
<double>5.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="stepDoubleSpinBox">
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="valuesLabel">
<property name="text">
<string>Local minimum/maximum = 0/0</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<widget class="QgsCollapsibleGroupBox" name="groupBox">
<property name="title">
<string>Advanced options</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="suffixLabel">
<property name="text">
<string>Suffix</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="suffixLineEdit">
<property name="placeholderText">
<string>Inactive</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

0 comments on commit f351195

Please sign in to comment.
You can’t perform that action at this time.