Skip to content

Commit 203f0e5

Browse files
author
jef
committed
fix handling of null value updates in attribute table
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9180 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5a0c4cf commit 203f0e5

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/app/qgsattributetable.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,31 @@ void QgsAttributeTable::attributeValueChanged( int fid, int idx, const QVariant
700700
if ( !mAttrIdxMap.contains( idx ) )
701701
return;
702702

703-
item( rowIdMap[fid], mAttrIdxMap[idx] )->setText( value.toString() );
703+
QTableWidgetItem *twi = horizontalHeaderItem( mAttrIdxMap[ idx ] );
704+
if ( !twi )
705+
{
706+
QgsDebugMsg( "header item not found." );
707+
return;
708+
}
709+
710+
int type = twi->data( AttributeType ).toInt();
711+
bool isNum = ( type == QVariant::Double || type == QVariant::Int );
712+
713+
QString v;
714+
// get the field values
715+
if ( value.isNull() )
716+
{
717+
if ( isNum )
718+
v = "";
719+
else
720+
v = "NULL";
721+
}
722+
else
723+
{
724+
v = value.toString();
725+
}
726+
727+
item( rowIdMap[fid], mAttrIdxMap[idx] )->setText( v );
704728
}
705729

706730
void QgsAttributeTable::featureDeleted( int fid )

0 commit comments

Comments
 (0)