Skip to content
Permalink
Browse files

fix deprecated QList::toSet in Qt 5.14+ (#36459)

add an helper in qgis.h to avoid overwhelming the code
  • Loading branch information
3nids committed May 15, 2020
1 parent 0df50ca commit 8b7a17b2936f95a3446dddbd70d6311acff962f2
@@ -457,6 +457,16 @@ namespace qgis
return pmf;
}
};

template<class T>
QSet<T> listToSet( const QList<T> &list )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
return list.toSet();
#else
return QSet<T>( list.begin(), list.end() );
#endif
}
}
///@endcond
#endif
@@ -67,11 +67,7 @@ void QgsFeatureFilterModel::requestToReloadCurrentFeature( QgsFeatureRequest &re

QSet<QString> QgsFeatureFilterModel::requestedAttributes() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
return mIdentifierFields.toSet();
#else
return QSet<QString>( mIdentifierFields.begin(), mIdentifierFields.end() );
#endif
return qgis::listToSet( mIdentifierFields );
}

QVariant QgsFeatureFilterModel::entryIdentifier( const QgsFeatureExpressionValuesGatherer::Entry &entry ) const
@@ -20,6 +20,7 @@
#include <QVariantList>

#include "qgis_core.h"
#include "qgis.h"

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
@@ -164,7 +165,7 @@ class CORE_EXPORT QgsStringStatisticalSummary
* Returns the set of distinct string values.
* \see countDistinct()
*/
QSet< QString > distinctValues() const { return QSet<QString>::fromList( mValues.keys() ); }
QSet< QString > distinctValues() const { return qgis::listToSet( mValues.keys() ); }

/**
* Returns the number of missing (null) string values.
@@ -76,7 +76,7 @@ class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink
public:
SetOption( const QString &docString, const QStringList &values, const QString &defaultValue, bool allowNone = false )
: Option( docString, Set )
, values( values.toSet() )
, values( qgis::listToSet( values ) )
, defaultValue( defaultValue )
, allowNone( allowNone )
{}
@@ -231,7 +231,7 @@ class CORE_EXPORT QgsVectorLayerCache : public QObject
* \see isFidCached()
* \since QGIS 3.0
*/
QgsFeatureIds cachedFeatureIds() const { return mCache.keys().toSet(); }
QgsFeatureIds cachedFeatureIds() const { return qgis::listToSet( mCache.keys() ); }

/**
* Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features

0 comments on commit 8b7a17b

Please sign in to comment.
You can’t perform that action at this time.