| 74 | } |
| 75 | |
| 76 | SortingProxyModel::InternalMapIterator |
| 77 | SortingProxyModel::buildMapping( const ModelIndex& sourceParent ) { |
| 78 | auto it = mMappings.find( sourceParent ); |
| 79 | if ( it != mMappings.end() ) |
| 80 | return it; |
| 81 | |
| 82 | auto mapping = std::make_shared<Mapping>(); |
| 83 | |
| 84 | mapping->sourceParent = sourceParent; |
| 85 | |
| 86 | int rowCount = source().rowCount( sourceParent ); |
| 87 | mapping->sourceRows.resize( rowCount ); |
| 88 | mapping->proxyRows.resize( rowCount ); |
| 89 | |
| 90 | sortMapping( *mapping, mKeyColumn, mSortOrder ); |
| 91 | |
| 92 | if ( sourceParent.isValid() ) { |
| 93 | auto sourceGrandParent = sourceParent.parent(); |
| 94 | buildMapping( sourceGrandParent ); |
| 95 | } |
| 96 | mMappings.insert( { sourceParent, mapping } ); |
| 97 | return mMappings.find( sourceParent ); |
| 98 | } |
| 99 | |
| 100 | ModelIndex SortingProxyModel::mapToProxy( const ModelIndex& sourceIndex ) const { |
| 101 | if ( !sourceIndex.isValid() ) |