Skip to content

Commit

Permalink
[FEATURE] Add suffix support for range widget
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 22, 2014
1 parent c1c81ea commit f351195
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 113 deletions.
7 changes: 7 additions & 0 deletions src/gui/editorwidgets/qgsrangeconfigdlg.cpp
Expand Up @@ -93,6 +93,11 @@ QgsEditorWidgetConfig QgsRangeConfigDlg::config()


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


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

return cfg; return cfg;
} }


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


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

suffixLineEdit->setText( config.value( "Suffix" ).toString() );
} }
9 changes: 9 additions & 0 deletions src/gui/editorwidgets/qgsrangewidgetfactory.cpp
Expand Up @@ -45,6 +45,11 @@ QgsEditorWidgetConfig QgsRangeWidgetFactory::readConfig( const QDomElement& conf
cfg.insert( "Max", configElement.attribute( "Max" ).toInt() ); cfg.insert( "Max", configElement.attribute( "Max" ).toInt() );
cfg.insert( "Step", configElement.attribute( "Step" ).toInt() ); cfg.insert( "Step", configElement.attribute( "Step" ).toInt() );


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

return cfg; return cfg;
} }


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


bool QgsRangeWidgetFactory::isFieldSupported( QgsVectorLayer* vl, int fieldIdx ) bool QgsRangeWidgetFactory::isFieldSupported( QgsVectorLayer* vl, int fieldIdx )
Expand Down
8 changes: 8 additions & 0 deletions src/gui/editorwidgets/qgsrangewidgetwrapper.cpp
Expand Up @@ -78,6 +78,10 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
mDoubleSpinBox->setMinimum( config( "Min" ).toDouble() ); mDoubleSpinBox->setMinimum( config( "Min" ).toDouble() );
mDoubleSpinBox->setMaximum( config( "Max" ).toDouble() ); mDoubleSpinBox->setMaximum( config( "Max" ).toDouble() );
mDoubleSpinBox->setSingleStep( config( "Step" ).toDouble() ); mDoubleSpinBox->setSingleStep( config( "Step" ).toDouble() );
if ( config( "Suffix" ).isValid() )
{
mDoubleSpinBox->setSuffix( config( "Suffix" ).toString() );
}
connect( mDoubleSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( valueChanged( double ) ) ); connect( mDoubleSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( valueChanged( double ) ) );
} }


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


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

0 comments on commit f351195

Please sign in to comment.