Skip to content

Commit

Permalink
Use sortValue for sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and nyalldawson committed Feb 1, 2022
1 parent b8d4419 commit 2f2d980
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Expand Up @@ -236,13 +236,7 @@ void QgsAttributeTableModel::featureAdded( QgsFeatureId fid )
QgsFieldFormatter *fieldFormatter = mFieldFormatters.at( cache.sortFieldIndex );
const QVariant &widgetCache = mAttributeWidgetCaches.at( cache.sortFieldIndex );
const QVariantMap &widgetConfig = mWidgetConfigs.at( cache.sortFieldIndex );
// If using the default formatter use the raw value for sorting
// (keep the correct QVariant type and do not convert to a possibly localized string)
// See: https://github.com/qgis/QGIS/issues/34935
const bool isFallbackFormatter { fieldFormatter->id().isEmpty() };
const QVariant sortValue = isFallbackFormatter ?
mFeat.attribute( cache.sortFieldIndex ) :
fieldFormatter->representValue( mLayer, cache.sortFieldIndex, widgetConfig, widgetCache, mFeat.attribute( cache.sortFieldIndex ) );
const QVariant sortValue = fieldFormatter->sortValue( mLayer, cache.sortFieldIndex, widgetConfig, widgetCache, mFeat.attribute( cache.sortFieldIndex ) );
cache.sortCache.insert( mFeat.id(), sortValue );
}
else if ( cache.sortCacheExpression.isValid() )
Expand Down

0 comments on commit 2f2d980

Please sign in to comment.