[QGIS Commit] r9180 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Aug 27 03:30:30 EDT 2008


Author: jef
Date: 2008-08-27 03:30:30 -0400 (Wed, 27 Aug 2008)
New Revision: 9180

Modified:
   trunk/qgis/src/app/qgsattributetable.cpp
Log:
fix handling of null value updates in attribute table

Modified: trunk/qgis/src/app/qgsattributetable.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributetable.cpp	2008-08-27 07:28:12 UTC (rev 9179)
+++ trunk/qgis/src/app/qgsattributetable.cpp	2008-08-27 07:30:30 UTC (rev 9180)
@@ -700,7 +700,31 @@
   if ( !mAttrIdxMap.contains( idx ) )
     return;
 
-  item( rowIdMap[fid], mAttrIdxMap[idx] )->setText( value.toString() );
+  QTableWidgetItem *twi = horizontalHeaderItem( mAttrIdxMap[ idx ] );
+  if ( !twi )
+  {
+    QgsDebugMsg( "header item not found." );
+    return;
+  }
+
+  int type = twi->data( AttributeType ).toInt();
+  bool isNum = ( type == QVariant::Double || type == QVariant::Int );
+
+  QString v;
+  // get the field values
+  if ( value.isNull() )
+  {
+    if ( isNum )
+      v = "";
+    else
+      v = "NULL";
+  }
+  else
+  {
+    v = value.toString();
+  }
+
+  item( rowIdMap[fid], mAttrIdxMap[idx] )->setText( v );
 }
 
 void QgsAttributeTable::featureDeleted( int fid )



More information about the QGIS-commit mailing list