diff --git a/src/qgsattributetable.cpp b/src/qgsattributetable.cpp index 9c0e870d8e6..49174f84560 100644 --- a/src/qgsattributetable.cpp +++ b/src/qgsattributetable.cpp @@ -40,6 +40,14 @@ void QgsAttributeTable::columnClicked(int col) { QApplication::setOverrideCursor(Qt::waitCursor); sortColumn(col, true, true); + //clear and rebuild rowIdMap. Overwrite sortColumn later and sort rowIdMap there + rowIdMap.clear(); + int id; + for(int i=0;i::iterator it=rowIdMap.find(id); + selectRow(it.data()); } diff --git a/src/qgsattributetable.h b/src/qgsattributetable.h index 0795c581906..3ef3ddc48dd 100644 --- a/src/qgsattributetable.h +++ b/src/qgsattributetable.h @@ -20,6 +20,7 @@ #define QGSATTRIBUTETABLE_H #include +#include /** *@author Gary E.Sherman @@ -33,6 +34,8 @@ class QgsAttributeTable:public QTable QgsAttributeTable(QWidget * parent = 0, const char *name = 0); ~QgsAttributeTable(); + /**Inserts the feature with the specified id into rowIdMap. This function has to be called (e.g. from QgsShapeFileLayer) when a row is inserted into the table*/ + void insertFeatureId(int id); /**Selects the row which belongs to the feature with the specified id*/ void selectRowWithId(int id); @@ -43,6 +46,8 @@ class QgsAttributeTable:public QTable protected: /**Flag telling if the ctrl-button or the shift-button is pressed*/ bool lockKeyPressed; + /**Search tree to find a row corresponding to a feature id*/ + QMap rowIdMap; void keyPressEvent(QKeyEvent* ev); void keyReleaseEvent(QKeyEvent* ev); signals: diff --git a/src/qgsshapefilelayer.cpp b/src/qgsshapefilelayer.cpp index 2d1265cd0f4..01430ac68df 100644 --- a/src/qgsshapefilelayer.cpp +++ b/src/qgsshapefilelayer.cpp @@ -410,6 +410,7 @@ void QgsShapeFileLayer::table() //id-field tabledisplay->table()->setText(row,0,QString::number(fet->GetFID())); + tabledisplay->table()->insertFeatureId(fet->GetFID());//insert the id into the search tree of qgsattributetable for (int i = 1; i < numFields+1; i++) { // get the field values QString val;