[QGIS Commit] r12555 - trunk/qgis/src/app/attributetable

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Dec 20 18:20:26 EST 2009


Author: jef
Date: 2009-12-20 18:20:25 -0500 (Sun, 20 Dec 2009)
New Revision: 12555

Modified:
   trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
Log:
fix #1773

Modified: trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp	2009-12-20 22:18:34 UTC (rev 12554)
+++ trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp	2009-12-20 23:20:25 UTC (rev 12555)
@@ -62,30 +62,6 @@
   QgsDebugMsg( fid );
 #endif
 
-#if 0
-  --mFeatureCount;
-  mIdRowMap.remove( fid );
-  mRowIdMap.remove( idx );
-
-  // fill the hole in the view
-  if ( idx != mFeatureCount )
-  {
-    QgsDebugMsg( "jo" );
-    //mRowIdMap[idx] = mRowIdMap[mFeatureCount];
-    //mIdRowMap[mRowIdMap[idx]] = idx;
-    int movedId = mRowIdMap[mFeatureCount];
-    mRowIdMap.remove( mFeatureCount );
-    mRowIdMap.insert( idx, movedId );
-    mIdRowMap[movedId] = idx;
-    //mIdRowMap.remove(mRowIdMap[idx]);
-    //mIdRowMap.insert(mRowIdMap[idx], idx);
-  }
-
-  QgsDebugMsg( QString( "map sizes:%1, %2" ).arg( mRowIdMap.size() ).arg( mIdRowMap.size() ) );
-  emit layoutChanged();
-  //reload(index(0,0), index(rowCount(), columnCount()));
-#endif
-
   QgsDebugMsg( "id->row" );
   QHash<int, int>::iterator it;
   for ( it = mIdRowMap.begin(); it != mIdRowMap.end(); ++it )
@@ -259,18 +235,6 @@
     endRemoveRows();
     QgsDebugMsg( "end rm" );
   }
-
-#if 0
-  QgsDebugMsg( "id->row" );
-  QHash<int, int>::iterator it;
-  for ( it = mIdRowMap.begin(); it != mIdRowMap.end(); ++it )
-    QgsDebugMsg( QString( "%1->%2" ).arg( it.key() ).arg( *it ) );
-
-  QgsDebugMsg( "row->id" );
-
-  for ( it = mRowIdMap.begin(); it != mRowIdMap.end(); ++it )
-    QgsDebugMsg( QString( "%1->%2" ).arg( it.key() ).arg( *it ) );
-#endif
 }
 
 void QgsAttributeTableModel::swapRows( int a, int b )
@@ -454,14 +418,6 @@
     return mValueMaps[ index.column()]->key( val.toString(), QString( "(%1)" ).arg( val.toString() ) );
   }
 
-  // force also numeric data for EditRole to be strings
-  // otherwise it creates spinboxes instead of line edits
-  // (probably not what we do want)
-  if ( fldNumeric && role == Qt::EditRole )
-    return val.toString();
-
-  // convert to QString from some other representation
-  // this prevents displaying greater numbers in exponential format
   return val.toString();
 }
 
@@ -480,9 +436,15 @@
     mLastRowId = rowToId( index.row() );
     mLastRow = ( QgsAttributeMap * ) & mFeat.attributeMap();
 
+    disconnect( mLayer, SIGNAL( layerModified( bool ) ), this, SLOT( layerModified( bool ) ) );
+
     mLayer->beginEditCommand( tr( "Attribute changed" ) );
     mLayer->changeAttributeValue( rowToId( index.row() ), mAttributes[ index.column()], value, true );
     mLayer->endEditCommand();
+
+    ( *mLastRow )[ mAttributes[index.column()] ] = value;
+
+    connect( mLayer, SIGNAL( layerModified( bool ) ), this, SLOT( layerModified( bool ) ) );
   }
 
   if ( !mLayer->isModified() )



More information about the QGIS-commit mailing list