Hello! After the sorting of my model (derived from the abstract table model, my own file model) the selection on my table view remains on the (now false) place. The problem: my selection is on the view and my sorting is in the model.
I thought it should work automatically in the view to keep the selection of indexes and not of cells by sorting my model.
What can You recommend?
void FileModel::sort ( int column, Qt::SortOrder order )
{
bool (*compare_funk)(const BUFileInfo &a,const BUFileInfo &b)=0; //point to the compare-function
switch (column)
{
case 0:
compare_funk=(order)?BUFileInfo::biggerName:BUFileInfo::lessName;
break;
case 1:
compare_funk=(order)?BUFileInfo::biggerSize:BUFileInfo::lessSize;
break;
case 2:
compare_funk=(order)?BUFileInfo::biggerExt:BUFileInfo::lessExt;
break;
case 3:
compare_funk=(order)?BUFileInfo::biggerDate:BUFileInfo::lessDate;
break;
case 4:
compare_funk=(order)?BUFileInfo::biggerState:BUFileInfo::lessState;
break;
}
if(compare_funk)
{
//std::list<BUFileInfo>::sort(fileList.begin(),fileList.end(),compare_funk);
qSort(fileList.begin(),fileList.end(),compare_funk);
emit layoutChanged();
}
}
void FileModel::sort ( int column, Qt::SortOrder order )
{
bool (*compare_funk)(const BUFileInfo &a,const BUFileInfo &b)=0; //point to the compare-function
switch (column)
{
case 0:
compare_funk=(order)?BUFileInfo::biggerName:BUFileInfo::lessName;
break;
case 1:
compare_funk=(order)?BUFileInfo::biggerSize:BUFileInfo::lessSize;
break;
case 2:
compare_funk=(order)?BUFileInfo::biggerExt:BUFileInfo::lessExt;
break;
case 3:
compare_funk=(order)?BUFileInfo::biggerDate:BUFileInfo::lessDate;
break;
case 4:
compare_funk=(order)?BUFileInfo::biggerState:BUFileInfo::lessState;
break;
}
if(compare_funk)
{
//std::list<BUFileInfo>::sort(fileList.begin(),fileList.end(),compare_funk);
qSort(fileList.begin(),fileList.end(),compare_funk);
emit layoutChanged();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks