Skip to content

Commit

Permalink
Field Calculator: HIG compliance and use user friendly names for data…
Browse files Browse the repository at this point in the history
… types

git-svn-id: http://svn.osgeo.org/qgis/trunk@11743 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 2, 2009
1 parent 27bc704 commit de9e98b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
13 changes: 7 additions & 6 deletions src/app/qgsfieldcalculator.cpp
Expand Up @@ -22,9 +22,9 @@
QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl ): QDialog(), mVectorLayer( vl )
{
setupUi( this );
mOutputFieldTypeComboBox->addItem( tr( "Double" ) );
mOutputFieldTypeComboBox->addItem( tr( "Integer" ) );
mOutputFieldTypeComboBox->addItem( tr( "String" ) );
mOutputFieldTypeComboBox->addItem( tr( "Whole number (integer)" ), "Integer" );
mOutputFieldTypeComboBox->addItem( tr( "Decimal number (double)" ), "Double" );
mOutputFieldTypeComboBox->addItem( tr( "Text (string)" ), "String" );

populateFields();

Expand Down Expand Up @@ -83,15 +83,16 @@ void QgsFieldCalculator::accept()
{
//create new field
QgsField newField( mOutputFieldNameLineEdit->text() );
if ( mOutputFieldTypeComboBox->currentText() == tr( "Double" ) )
int index = mOutputFieldTypeComboBox->currentIndex();
if ( mOutputFieldTypeComboBox->itemData( index, Qt::UserRole ) == "Double" )
{
newField.setType( QVariant::Double );
}
else if ( mOutputFieldTypeComboBox->currentText() == tr( "Integer" ) )
else if ( mOutputFieldTypeComboBox->itemData( index, Qt::UserRole ) == "Integer" )
{
newField.setType( QVariant::Int );
}
else if ( mOutputFieldTypeComboBox->currentText() == tr( "String" ) )
else if ( mOutputFieldTypeComboBox->itemData( index, Qt::UserRole ) == "String" )
{
newField.setType( QVariant::String );
}
Expand Down
39 changes: 27 additions & 12 deletions src/ui/qgsfieldcalculatorbase.ui
Expand Up @@ -12,7 +12,7 @@
<property name="windowTitle" >
<string>Field calculator</string>
</property>
<layout class="QGridLayout" name="gridLayout_5" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QCheckBox" name="mUpdateExistingFieldCheckBox" >
<property name="text" >
Expand All @@ -35,11 +35,14 @@
<property name="title" >
<string>New field</string>
</property>
<layout class="QGridLayout" name="gridLayout_3" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="mFieldNameLabel" >
<property name="text" >
<string>Output field name:</string>
<string>Output field name</string>
</property>
<property name="buddy" >
<cstring>mOutputFieldNameLineEdit</cstring>
</property>
</widget>
</item>
Expand All @@ -49,7 +52,10 @@
<item row="1" column="0" >
<widget class="QLabel" name="mOutputFieldTypeLabel" >
<property name="text" >
<string>Output field type:</string>
<string>Output field type</string>
</property>
<property name="buddy" >
<cstring>mOutputFieldTypeComboBox</cstring>
</property>
</widget>
</item>
Expand All @@ -59,7 +65,10 @@
<item row="2" column="0" >
<widget class="QLabel" name="mOutputFieldWidthLabel" >
<property name="text" >
<string>Output field width:</string>
<string>Output field width</string>
</property>
<property name="buddy" >
<cstring>mOuputFieldWidthSpinBox</cstring>
</property>
</widget>
</item>
Expand All @@ -69,7 +78,10 @@
<item row="2" column="2" >
<widget class="QLabel" name="mOutputFieldPrecisionLabel" >
<property name="text" >
<string>Output field precision:</string>
<string>Output field precision</string>
</property>
<property name="buddy" >
<cstring>mOutputFieldPrecisionSpinBox</cstring>
</property>
</widget>
</item>
Expand All @@ -84,7 +96,7 @@
<property name="title" >
<string>Fields</string>
</property>
<layout class="QGridLayout" name="gridLayout_4" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QListWidget" name="mFieldsListWidget" />
</item>
Expand All @@ -96,7 +108,7 @@
<property name="title" >
<string>Values</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<layout class="QGridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QListWidget" name="mValueListWidget" />
</item>
Expand All @@ -122,7 +134,7 @@
<property name="title" >
<string>Operators</string>
</property>
<layout class="QGridLayout" name="gridLayout" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QPushButton" name="mPlusPushButton" >
<property name="text" >
Expand Down Expand Up @@ -227,20 +239,23 @@
<item row="5" column="0" colspan="2" >
<widget class="QLabel" name="mFieldCalculatorExpressionLabel" >
<property name="text" >
<string>Field calculator expression:</string>
<string>Field calculator expression</string>
</property>
<property name="buddy" >
<cstring>mExpressionTextEdit</cstring>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3" >
<widget class="QTextEdit" name="mExpressionTextEdit" />
</item>
<item row="7" column="0" colspan="2" >
<item row="7" column="0" colspan="3" >
<widget class="QDialogButtonBox" name="mButtonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
Expand Down

0 comments on commit de9e98b

Please sign in to comment.