Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. void MDBReleasesModel::sort( int column, Qt::SortOrder order )
  2. {
  3. QHash<int, int> mapping;
  4. MDBModelSorter sorter( mReleases, mapping, column, Qt::DisplayRole );
  5. sorter.sort( order );
  6.  
  7. const QModelIndexList oldList = persistentIndexList();
  8. QModelIndexList newList;
  9.  
  10. emit layoutAboutToBeChanged();
  11.  
  12. foreach ( const QModelIndex& index, oldList ) {
  13. const int nativeRow = mSortMapping.value( index.row(), index.row() );
  14. newList << createIndex( mapping.key( nativeRow ), index.column() );
  15. }
  16.  
  17. mSortMapping = mapping;
  18. changePersistentIndexList( oldList, newList );
  19.  
  20. emit layoutChanged();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement