Skip to content
Permalink
Browse files
fix #3606
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15706 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 15, 2011
1 parent cbe4ee9 commit 9fec25bcae34b01cc74aa5b09b6e75ce38fe90e5
Showing with 19 additions and 1 deletion.
  1. +19 −1 src/app/qgsfieldcalculator.cpp
@@ -18,6 +18,7 @@
#include "qgssearchstring.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"

#include <QMessageBox>

QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl )
@@ -192,7 +193,24 @@ void QgsFieldCalculator::accept()
}
else if ( value.isNumeric() )
{
mVectorLayer->changeAttributeValue( feature.id(), mAttributeId, value.number(), false );
const QgsField &f = mVectorLayer->pendingFields()[ mAttributeId ];
QVariant v;

if ( f.type() == QVariant::Double && f.precision() > 0 )
{
v = QString::number( value.number(), 'g', f.precision() );
}
else if ( f.type() == QVariant::Double && f.precision() > 0 && f.precision() == 0 )
{
v = QString::number( qRound( value.number() ) );
}
else
{
v = value.number();
}

v.convert( f.type() );
mVectorLayer->changeAttributeValue( feature.id(), mAttributeId, v, false );
}
else if ( value.isNull() )
{

0 comments on commit 9fec25b

Please sign in to comment.