Skip to content

Commit f351195

Browse files
committed
[FEATURE] Add suffix support for range widget
1 parent c1c81ea commit f351195

File tree

4 files changed

+185
-113
lines changed

4 files changed

+185
-113
lines changed

src/gui/editorwidgets/qgsrangeconfigdlg.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ QgsEditorWidgetConfig QgsRangeConfigDlg::config()
9393

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

96+
if ( suffixLineEdit->text() != "" )
97+
{
98+
cfg.insert( "Suffix", suffixLineEdit->text() );
99+
}
100+
96101
return cfg;
97102
}
98103

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

109114
rangeWidget->setCurrentIndex( rangeWidget->findData( config.value( "Style", "SpinBox" ) ) );
115+
116+
suffixLineEdit->setText( config.value( "Suffix" ).toString() );
110117
}

src/gui/editorwidgets/qgsrangewidgetfactory.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ QgsEditorWidgetConfig QgsRangeWidgetFactory::readConfig( const QDomElement& conf
4545
cfg.insert( "Max", configElement.attribute( "Max" ).toInt() );
4646
cfg.insert( "Step", configElement.attribute( "Step" ).toInt() );
4747

48+
if ( configElement.hasAttribute( "Suffix" ) )
49+
{
50+
cfg.insert( "Suffix", configElement.attribute( "Suffix" ) );
51+
}
52+
4853
return cfg;
4954
}
5055

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

6372
bool QgsRangeWidgetFactory::isFieldSupported( QgsVectorLayer* vl, int fieldIdx )

src/gui/editorwidgets/qgsrangewidgetwrapper.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
7878
mDoubleSpinBox->setMinimum( config( "Min" ).toDouble() );
7979
mDoubleSpinBox->setMaximum( config( "Max" ).toDouble() );
8080
mDoubleSpinBox->setSingleStep( config( "Step" ).toDouble() );
81+
if ( config( "Suffix" ).isValid() )
82+
{
83+
mDoubleSpinBox->setSuffix( config( "Suffix" ).toString() );
84+
}
8185
connect( mDoubleSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( valueChanged( double ) ) );
8286
}
8387

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

src/ui/editorwidgets/qgsrangeconfigdlgbase.ui

+161-113
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>549</width>
10-
<height>318</height>
10+
<height>333</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -24,11 +24,21 @@
2424
</property>
2525
</widget>
2626
</item>
27+
<item row="4" column="0">
28+
<widget class="QLabel" name="valuesLabel">
29+
<property name="text">
30+
<string>Local minimum/maximum = 0/0</string>
31+
</property>
32+
<property name="wordWrap">
33+
<bool>true</bool>
34+
</property>
35+
</widget>
36+
</item>
2737
<item row="1" column="0" colspan="2">
2838
<widget class="QComboBox" name="rangeWidget"/>
2939
</item>
30-
<item row="4" column="0">
31-
<spacer name="verticalSpacer_13">
40+
<item row="5" column="0">
41+
<spacer name="verticalSpacer">
3242
<property name="orientation">
3343
<enum>Qt::Vertical</enum>
3444
</property>
@@ -41,123 +51,161 @@
4151
</spacer>
4252
</item>
4353
<item row="2" column="0">
44-
<layout class="QGridLayout" name="gridRangeLayout">
45-
<item row="0" column="1" rowspan="3">
46-
<widget class="QStackedWidget" name="rangeStackedWidget">
47-
<property name="currentIndex">
48-
<number>0</number>
49-
</property>
50-
<widget class="QWidget" name="intPage">
51-
<layout class="QVBoxLayout" name="verticalLayout_11">
52-
<item>
53-
<widget class="QSpinBox" name="minimumSpinBox">
54-
<property name="minimum">
55-
<number>-999999999</number>
56-
</property>
57-
<property name="maximum">
58-
<number>999999999</number>
59-
</property>
60-
</widget>
61-
</item>
62-
<item>
63-
<widget class="QSpinBox" name="maximumSpinBox">
64-
<property name="minimum">
65-
<number>-999999999</number>
66-
</property>
67-
<property name="maximum">
68-
<number>999999999</number>
69-
</property>
70-
<property name="value">
71-
<number>5</number>
72-
</property>
73-
</widget>
74-
</item>
75-
<item>
76-
<widget class="QSpinBox" name="stepSpinBox">
77-
<property name="maximum">
78-
<number>999999999</number>
79-
</property>
80-
<property name="value">
81-
<number>1</number>
82-
</property>
83-
</widget>
84-
</item>
85-
</layout>
86-
</widget>
87-
<widget class="QWidget" name="doublePage">
88-
<layout class="QVBoxLayout" name="verticalLayout_12">
89-
<item>
90-
<widget class="QDoubleSpinBox" name="minimumDoubleSpinBox">
91-
<property name="minimum">
92-
<double>-999999999.990000009536743</double>
93-
</property>
94-
<property name="maximum">
95-
<double>999999999.990000009536743</double>
96-
</property>
97-
</widget>
98-
</item>
99-
<item>
100-
<widget class="QDoubleSpinBox" name="maximumDoubleSpinBox">
101-
<property name="minimum">
102-
<double>-999999999.990000009536743</double>
103-
</property>
104-
<property name="maximum">
105-
<double>999999999.990000009536743</double>
106-
</property>
107-
<property name="value">
108-
<double>5.000000000000000</double>
109-
</property>
110-
</widget>
111-
</item>
112-
<item>
113-
<widget class="QDoubleSpinBox" name="stepDoubleSpinBox">
114-
<property name="maximum">
115-
<double>999999999.990000009536743</double>
116-
</property>
117-
<property name="value">
118-
<double>1.000000000000000</double>
119-
</property>
120-
</widget>
121-
</item>
122-
</layout>
123-
</widget>
124-
</widget>
125-
</item>
126-
<item row="2" column="0">
127-
<widget class="QLabel" name="stepLabel">
128-
<property name="text">
129-
<string>Step</string>
130-
</property>
131-
</widget>
132-
</item>
133-
<item row="1" column="0">
134-
<widget class="QLabel" name="maximumLabel">
135-
<property name="text">
136-
<string>Maximum</string>
137-
</property>
138-
</widget>
139-
</item>
140-
<item row="0" column="0">
141-
<widget class="QLabel" name="minimumLabel">
142-
<property name="text">
143-
<string>Minimum</string>
144-
</property>
145-
</widget>
146-
</item>
147-
</layout>
54+
<widget class="QStackedWidget" name="rangeStackedWidget">
55+
<property name="currentIndex">
56+
<number>0</number>
57+
</property>
58+
<widget class="QWidget" name="intPage">
59+
<layout class="QFormLayout" name="formLayout">
60+
<item row="0" column="0">
61+
<widget class="QLabel" name="minimumLabel">
62+
<property name="text">
63+
<string>Minimum</string>
64+
</property>
65+
</widget>
66+
</item>
67+
<item row="0" column="1">
68+
<widget class="QSpinBox" name="minimumSpinBox">
69+
<property name="minimum">
70+
<number>-999999999</number>
71+
</property>
72+
<property name="maximum">
73+
<number>999999999</number>
74+
</property>
75+
</widget>
76+
</item>
77+
<item row="1" column="0">
78+
<widget class="QLabel" name="maximumLabel">
79+
<property name="text">
80+
<string>Maximum</string>
81+
</property>
82+
</widget>
83+
</item>
84+
<item row="1" column="1">
85+
<widget class="QSpinBox" name="maximumSpinBox">
86+
<property name="minimum">
87+
<number>-999999999</number>
88+
</property>
89+
<property name="maximum">
90+
<number>999999999</number>
91+
</property>
92+
<property name="value">
93+
<number>5</number>
94+
</property>
95+
</widget>
96+
</item>
97+
<item row="2" column="0">
98+
<widget class="QLabel" name="stepLabel">
99+
<property name="text">
100+
<string>Step</string>
101+
</property>
102+
</widget>
103+
</item>
104+
<item row="2" column="1">
105+
<widget class="QSpinBox" name="stepSpinBox">
106+
<property name="maximum">
107+
<number>999999999</number>
108+
</property>
109+
<property name="value">
110+
<number>1</number>
111+
</property>
112+
</widget>
113+
</item>
114+
</layout>
115+
</widget>
116+
<widget class="QWidget" name="doublePage">
117+
<layout class="QFormLayout" name="formLayout_2">
118+
<item row="2" column="0">
119+
<widget class="QLabel" name="stepLabel_2">
120+
<property name="text">
121+
<string>Step</string>
122+
</property>
123+
</widget>
124+
</item>
125+
<item row="1" column="0">
126+
<widget class="QLabel" name="maximumLabel_2">
127+
<property name="text">
128+
<string>Maximum</string>
129+
</property>
130+
</widget>
131+
</item>
132+
<item row="0" column="0">
133+
<widget class="QLabel" name="minimumLabel_2">
134+
<property name="text">
135+
<string>Minimum</string>
136+
</property>
137+
</widget>
138+
</item>
139+
<item row="0" column="1">
140+
<widget class="QDoubleSpinBox" name="minimumDoubleSpinBox">
141+
<property name="minimum">
142+
<double>-999999999.990000009536743</double>
143+
</property>
144+
<property name="maximum">
145+
<double>999999999.990000009536743</double>
146+
</property>
147+
</widget>
148+
</item>
149+
<item row="1" column="1">
150+
<widget class="QDoubleSpinBox" name="maximumDoubleSpinBox">
151+
<property name="minimum">
152+
<double>-999999999.990000009536743</double>
153+
</property>
154+
<property name="maximum">
155+
<double>999999999.990000009536743</double>
156+
</property>
157+
<property name="value">
158+
<double>5.000000000000000</double>
159+
</property>
160+
</widget>
161+
</item>
162+
<item row="2" column="1">
163+
<widget class="QDoubleSpinBox" name="stepDoubleSpinBox">
164+
<property name="maximum">
165+
<double>999999999.990000009536743</double>
166+
</property>
167+
<property name="value">
168+
<double>1.000000000000000</double>
169+
</property>
170+
</widget>
171+
</item>
172+
</layout>
173+
</widget>
174+
</widget>
148175
</item>
149176
<item row="3" column="0">
150-
<widget class="QLabel" name="valuesLabel">
151-
<property name="text">
152-
<string>Local minimum/maximum = 0/0</string>
153-
</property>
154-
<property name="wordWrap">
155-
<bool>true</bool>
177+
<widget class="QgsCollapsibleGroupBox" name="groupBox">
178+
<property name="title">
179+
<string>Advanced options</string>
156180
</property>
181+
<layout class="QFormLayout" name="formLayout_3">
182+
<item row="0" column="0">
183+
<widget class="QLabel" name="suffixLabel">
184+
<property name="text">
185+
<string>Suffix</string>
186+
</property>
187+
</widget>
188+
</item>
189+
<item row="0" column="1">
190+
<widget class="QLineEdit" name="suffixLineEdit">
191+
<property name="placeholderText">
192+
<string>Inactive</string>
193+
</property>
194+
</widget>
195+
</item>
196+
</layout>
157197
</widget>
158198
</item>
159199
</layout>
160200
</widget>
201+
<customwidgets>
202+
<customwidget>
203+
<class>QgsCollapsibleGroupBox</class>
204+
<extends>QGroupBox</extends>
205+
<header>qgscollapsiblegroupbox.h</header>
206+
<container>1</container>
207+
</customwidget>
208+
</customwidgets>
161209
<resources/>
162210
<connections/>
163211
</ui>

0 commit comments

Comments
 (0)