mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
selections persist when sorting a table
git-svn-id: http://svn.osgeo.org/qgis/trunk@256 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
c769c29956
commit
66135f841f
2
Makefile
2
Makefile
@ -27,6 +27,8 @@ plugins/$(MAKEFILE):
|
|||||||
sub-plugins: plugins/$(MAKEFILE) FORCE
|
sub-plugins: plugins/$(MAKEFILE) FORCE
|
||||||
cd plugins && $(MAKE) -f $(MAKEFILE)
|
cd plugins && $(MAKE) -f $(MAKEFILE)
|
||||||
|
|
||||||
|
Makefile: qgis.pro /usr/lib/qt3/mkspecs/linux-g++/qmake.conf
|
||||||
|
|
||||||
Makefile: qgis.pro $(QTDIR)/mkspecs/default/qmake.conf
|
Makefile: qgis.pro $(QTDIR)/mkspecs/default/qmake.conf
|
||||||
$(QMAKE) -o Makefile qgis.pro
|
$(QMAKE) -o Makefile qgis.pro
|
||||||
qmake: qmake_all
|
qmake: qmake_all
|
||||||
|
@ -40,7 +40,19 @@ QgsAttributeTable::~QgsAttributeTable()
|
|||||||
void QgsAttributeTable::columnClicked(int col)
|
void QgsAttributeTable::columnClicked(int col)
|
||||||
{
|
{
|
||||||
QApplication::setOverrideCursor(Qt::waitCursor);
|
QApplication::setOverrideCursor(Qt::waitCursor);
|
||||||
|
|
||||||
|
//store the ids of the selected rows in a list
|
||||||
|
QValueList<int> idsOfSelected;
|
||||||
|
for(int i=0;i<numSelections();i++)
|
||||||
|
{
|
||||||
|
for(int j=selection(i).topRow();j<=selection(i).bottomRow();j++)
|
||||||
|
{
|
||||||
|
idsOfSelected.append(text(j,0).toInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sortColumn(col, true, true);
|
sortColumn(col, true, true);
|
||||||
|
|
||||||
//clear and rebuild rowIdMap. Overwrite sortColumn later and sort rowIdMap there
|
//clear and rebuild rowIdMap. Overwrite sortColumn later and sort rowIdMap there
|
||||||
rowIdMap.clear();
|
rowIdMap.clear();
|
||||||
int id;
|
int id;
|
||||||
@ -49,9 +61,19 @@ void QgsAttributeTable::columnClicked(int col)
|
|||||||
id=text(i,0).toInt();
|
id=text(i,0).toInt();
|
||||||
rowIdMap.insert(id,i);
|
rowIdMap.insert(id,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject::disconnect(this,SIGNAL(selectionChanged()),this,SLOT(handleChangedSelections()));
|
||||||
clearSelection(true);
|
clearSelection(true);
|
||||||
emit selectionRemoved();
|
|
||||||
emit repaintRequested();
|
//select the rows again after sorting
|
||||||
|
|
||||||
|
QValueList<int>::iterator it;
|
||||||
|
for(it=idsOfSelected.begin();it!=idsOfSelected.end();++it)
|
||||||
|
{
|
||||||
|
selectRowWithId((*it));
|
||||||
|
}
|
||||||
|
QObject::connect(this,SIGNAL(selectionChanged()),this,SLOT(handleChangedSelections()));
|
||||||
|
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,15 +127,6 @@ void QgsAttributeTable::insertFeatureId(int id)
|
|||||||
|
|
||||||
void QgsAttributeTable::selectRowWithId(int id)
|
void QgsAttributeTable::selectRowWithId(int id)
|
||||||
{
|
{
|
||||||
//brute force approach, add a solution with a hash table or a search tree later (and rebuild this structure every time the table is sorted)
|
|
||||||
/*for(int i=0;i<numRows();i++)
|
|
||||||
{
|
|
||||||
if(text(i,0).toInt()==id)
|
|
||||||
{
|
|
||||||
selectRow(i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
QMap<int,int>::iterator it=rowIdMap.find(id);
|
QMap<int,int>::iterator it=rowIdMap.find(id);
|
||||||
selectRow(it.data());
|
selectRow(it.data());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user