Skip to content

Commit 1bdef80

Browse files
committed
QgsVectorLayer::uniqueValues() also returns uncommitted values
1 parent 482fa44 commit 1bdef80

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/core/qgsvectorlayer.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2819,7 +2819,29 @@ void QgsVectorLayer::uniqueValues( int index, QList<QVariant> &uniqueValues, int
28192819

28202820
if ( origin == QgsFields::OriginProvider ) //a provider field
28212821
{
2822-
return mDataProvider->uniqueValues( index, uniqueValues, limit );
2822+
mDataProvider->uniqueValues( index, uniqueValues, limit );
2823+
2824+
QSet<QString> vals;
2825+
Q_FOREACH( const QVariant& v, uniqueValues )
2826+
vals << v.toString();
2827+
2828+
QMapIterator< QgsFeatureId, QgsAttributeMap > it ( mEditBuffer->changedAttributeValues() );
2829+
while ( it.hasNext() && ( limit < 0 || uniqueValues.count() < limit ) )
2830+
{
2831+
it.next();
2832+
QVariant v = it.value().value( index );
2833+
if ( v.isValid() )
2834+
{
2835+
QString vs = v.toString();
2836+
if ( !vals.contains( vs ) )
2837+
{
2838+
vals << vs;
2839+
uniqueValues << v;
2840+
}
2841+
}
2842+
}
2843+
2844+
return;
28232845
}
28242846
else if ( origin == QgsFields::OriginJoin )
28252847
{

0 commit comments

Comments
 (0)