Skip to content

Commit de9e98b

Browse files
author
timlinux
committedOct 2, 2009
Field Calculator: HIG compliance and use user friendly names for data types
git-svn-id: http://svn.osgeo.org/qgis/trunk@11743 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 27bc704 commit de9e98b

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed
 

‎src/app/qgsfieldcalculator.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl ): QDialog(), mVectorLayer( vl )
2323
{
2424
setupUi( this );
25-
mOutputFieldTypeComboBox->addItem( tr( "Double" ) );
26-
mOutputFieldTypeComboBox->addItem( tr( "Integer" ) );
27-
mOutputFieldTypeComboBox->addItem( tr( "String" ) );
25+
mOutputFieldTypeComboBox->addItem( tr( "Whole number (integer)" ), "Integer" );
26+
mOutputFieldTypeComboBox->addItem( tr( "Decimal number (double)" ), "Double" );
27+
mOutputFieldTypeComboBox->addItem( tr( "Text (string)" ), "String" );
2828

2929
populateFields();
3030

@@ -83,15 +83,16 @@ void QgsFieldCalculator::accept()
8383
{
8484
//create new field
8585
QgsField newField( mOutputFieldNameLineEdit->text() );
86-
if ( mOutputFieldTypeComboBox->currentText() == tr( "Double" ) )
86+
int index = mOutputFieldTypeComboBox->currentIndex();
87+
if ( mOutputFieldTypeComboBox->itemData( index, Qt::UserRole ) == "Double" )
8788
{
8889
newField.setType( QVariant::Double );
8990
}
90-
else if ( mOutputFieldTypeComboBox->currentText() == tr( "Integer" ) )
91+
else if ( mOutputFieldTypeComboBox->itemData( index, Qt::UserRole ) == "Integer" )
9192
{
9293
newField.setType( QVariant::Int );
9394
}
94-
else if ( mOutputFieldTypeComboBox->currentText() == tr( "String" ) )
95+
else if ( mOutputFieldTypeComboBox->itemData( index, Qt::UserRole ) == "String" )
9596
{
9697
newField.setType( QVariant::String );
9798
}

‎src/ui/qgsfieldcalculatorbase.ui

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<property name="windowTitle" >
1313
<string>Field calculator</string>
1414
</property>
15-
<layout class="QGridLayout" name="gridLayout_5" >
15+
<layout class="QGridLayout" >
1616
<item row="0" column="0" >
1717
<widget class="QCheckBox" name="mUpdateExistingFieldCheckBox" >
1818
<property name="text" >
@@ -35,11 +35,14 @@
3535
<property name="title" >
3636
<string>New field</string>
3737
</property>
38-
<layout class="QGridLayout" name="gridLayout_3" >
38+
<layout class="QGridLayout" >
3939
<item row="0" column="0" >
4040
<widget class="QLabel" name="mFieldNameLabel" >
4141
<property name="text" >
42-
<string>Output field name:</string>
42+
<string>Output field name</string>
43+
</property>
44+
<property name="buddy" >
45+
<cstring>mOutputFieldNameLineEdit</cstring>
4346
</property>
4447
</widget>
4548
</item>
@@ -49,7 +52,10 @@
4952
<item row="1" column="0" >
5053
<widget class="QLabel" name="mOutputFieldTypeLabel" >
5154
<property name="text" >
52-
<string>Output field type:</string>
55+
<string>Output field type</string>
56+
</property>
57+
<property name="buddy" >
58+
<cstring>mOutputFieldTypeComboBox</cstring>
5359
</property>
5460
</widget>
5561
</item>
@@ -59,7 +65,10 @@
5965
<item row="2" column="0" >
6066
<widget class="QLabel" name="mOutputFieldWidthLabel" >
6167
<property name="text" >
62-
<string>Output field width:</string>
68+
<string>Output field width</string>
69+
</property>
70+
<property name="buddy" >
71+
<cstring>mOuputFieldWidthSpinBox</cstring>
6372
</property>
6473
</widget>
6574
</item>
@@ -69,7 +78,10 @@
6978
<item row="2" column="2" >
7079
<widget class="QLabel" name="mOutputFieldPrecisionLabel" >
7180
<property name="text" >
72-
<string>Output field precision:</string>
81+
<string>Output field precision</string>
82+
</property>
83+
<property name="buddy" >
84+
<cstring>mOutputFieldPrecisionSpinBox</cstring>
7385
</property>
7486
</widget>
7587
</item>
@@ -84,7 +96,7 @@
8496
<property name="title" >
8597
<string>Fields</string>
8698
</property>
87-
<layout class="QGridLayout" name="gridLayout_4" >
99+
<layout class="QGridLayout" >
88100
<item row="0" column="0" >
89101
<widget class="QListWidget" name="mFieldsListWidget" />
90102
</item>
@@ -96,7 +108,7 @@
96108
<property name="title" >
97109
<string>Values</string>
98110
</property>
99-
<layout class="QGridLayout" name="gridLayout_2" >
111+
<layout class="QGridLayout" >
100112
<item row="0" column="0" colspan="2" >
101113
<widget class="QListWidget" name="mValueListWidget" />
102114
</item>
@@ -122,7 +134,7 @@
122134
<property name="title" >
123135
<string>Operators</string>
124136
</property>
125-
<layout class="QGridLayout" name="gridLayout" >
137+
<layout class="QGridLayout" >
126138
<item row="0" column="0" >
127139
<widget class="QPushButton" name="mPlusPushButton" >
128140
<property name="text" >
@@ -227,20 +239,23 @@
227239
<item row="5" column="0" colspan="2" >
228240
<widget class="QLabel" name="mFieldCalculatorExpressionLabel" >
229241
<property name="text" >
230-
<string>Field calculator expression:</string>
242+
<string>Field calculator expression</string>
243+
</property>
244+
<property name="buddy" >
245+
<cstring>mExpressionTextEdit</cstring>
231246
</property>
232247
</widget>
233248
</item>
234249
<item row="6" column="0" colspan="3" >
235250
<widget class="QTextEdit" name="mExpressionTextEdit" />
236251
</item>
237-
<item row="7" column="0" colspan="2" >
252+
<item row="7" column="0" colspan="3" >
238253
<widget class="QDialogButtonBox" name="mButtonBox" >
239254
<property name="orientation" >
240255
<enum>Qt::Horizontal</enum>
241256
</property>
242257
<property name="standardButtons" >
243-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
258+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
244259
</property>
245260
</widget>
246261
</item>

0 commit comments

Comments
 (0)