From 7c65f3d628055286ccec07981da50d4908f76e05 Mon Sep 17 00:00:00 2001 From: Julien Cabieces Date: Wed, 27 Nov 2024 11:34:47 +0100 Subject: [PATCH] convert QVariant::Type to QMetaType::Type --- .../actions/qgsactionscope.sip.in | 1 + .../qgsabstractprofilegenerator.sip.in | 2 +- .../expression/qgsexpression.sip.in | 4 +- .../qgsdatetimefieldformatter.sip.in | 16 +- .../auto_generated/geometry/qgsbox3d.sip.in | 2 +- .../geometry/qgsquadrilateral.sip.in | 1 + .../auto_generated/geometry/qgswkbptr.sip.in | 4 - .../pointcloud/qgspointcloudattribute.sip.in | 2 +- .../arcgis/qgsarcgisrestutils.sip.in | 4 +- .../qgsaggregatecalculator.sip.in | 2 +- .../core/auto_generated/qgsapplication.sip.in | 2 +- .../core/auto_generated/qgsattributes.sip.in | 2 +- python/core/auto_generated/qgsfeature.sip.in | 8 +- python/core/auto_generated/qgsfield.sip.in | 20 +- python/core/auto_generated/qgsfields.sip.in | 2 +- .../core/auto_generated/qgsjsonutils.sip.in | 2 +- .../auto_generated/qgsvariantutils.sip.in | 2 +- python/core/auto_generated/qgsxmlutils.sip.in | 8 +- .../raster/qgsrasterattributetable.sip.in | 12 +- .../textrenderer/qgstextfragment.sip.in | 2 + .../qgstiledsceneboundingvolume.sip.in | 2 +- .../vector/qgsfielddomain.sip.in | 12 +- .../vector/qgsvectordataprovider.sip.in | 8 +- src/core/actions/qgsactionscope.h | 1 + src/core/callouts/qgscallout.cpp | 2 +- .../elevation/qgsabstractprofilegenerator.cpp | 2 +- .../elevation/qgsabstractprofilegenerator.h | 2 +- src/core/elevation/qgsprofileexporter.cpp | 8 +- src/core/expression/qgsexpression.cpp | 50 +- src/core/expression/qgsexpression.h | 4 +- src/core/expression/qgsexpressionfunction.cpp | 62 +-- src/core/expression/qgsexpressionnodeimpl.cpp | 52 +-- src/core/expression/qgsexpressionutils.cpp | 6 +- src/core/expression/qgsexpressionutils.h | 50 +- .../qgscheckboxfieldformatter.cpp | 4 +- .../qgsdatetimefieldformatter.cpp | 12 +- .../qgsdatetimefieldformatter.h | 16 +- .../fieldformatter/qgsrangefieldformatter.cpp | 6 +- .../qgsvaluerelationfieldformatter.cpp | 8 +- src/core/geocoding/qgsgooglemapsgeocoder.cpp | 20 +- src/core/geocoding/qgsnominatimgeocoder.cpp | 26 +- src/core/geometry/qgsbox3d.h | 2 +- src/core/geometry/qgsquadrilateral.h | 1 + src/core/geometry/qgswkbptr.h | 2 +- src/core/gps/qgsvectorlayergpslogger.cpp | 4 +- src/core/labeling/qgspallabeling.cpp | 2 +- src/core/layout/qgslayoutitempicture.cpp | 4 +- .../pointcloud/qgspointcloudattribute.cpp | 10 +- src/core/pointcloud/qgspointcloudattribute.h | 2 +- .../qgsprocessingmodelchildalgorithm.cpp | 2 +- .../models/qgsprocessingmodeloutput.cpp | 2 +- .../qgsprocessingparameteraggregate.cpp | 4 +- .../qgsprocessingparameterdxflayers.cpp | 20 +- .../qgsprocessingparameterfieldmap.cpp | 4 +- .../qgsprocessingparametermeshdataset.cpp | 12 +- .../processing/qgsprocessingparameters.cpp | 210 ++++----- .../qgsprocessingparametertininputlayers.cpp | 4 +- ...cessingparametervectortilewriterlayers.cpp | 4 +- src/core/processing/qgsprocessingutils.cpp | 26 +- src/core/project/qgsproject.cpp | 10 +- src/core/project/qgsprojectproperty.cpp | 102 ++--- .../providers/arcgis/qgsarcgisrestutils.cpp | 63 ++- .../providers/arcgis/qgsarcgisrestutils.h | 4 +- src/core/providers/gdal/qgsgdalprovider.cpp | 28 +- .../providers/memory/qgsmemoryprovider.cpp | 82 ++-- .../memory/qgsmemoryproviderutils.cpp | 28 +- .../ogr/qgsgeopackageproviderconnection.cpp | 4 +- .../ogr/qgsogrexpressioncompiler.cpp | 2 +- src/core/providers/ogr/qgsogrprovider.cpp | 98 ++-- .../providers/ogr/qgsogrprovidermetadata.cpp | 4 +- .../providers/ogr/qgsogrproviderutils.cpp | 12 +- src/core/qgis.cpp | 63 ++- src/core/qgsaggregatecalculator.cpp | 271 ++++++----- src/core/qgsaggregatecalculator.h | 4 +- src/core/qgsapplication.h | 2 +- src/core/qgsattributes.h | 2 +- src/core/qgsauxiliarystorage.cpp | 14 +- src/core/qgsdatetimestatisticalsummary.cpp | 6 +- src/core/qgsexpressionfieldbuffer.cpp | 4 +- src/core/qgsexpressionsorter_p.h | 20 +- src/core/qgsfeature.cpp | 6 +- src/core/qgsfeature.h | 8 +- src/core/qgsfeaturefiltermodel.cpp | 3 +- src/core/qgsfield.cpp | 86 ++-- src/core/qgsfield.h | 22 +- src/core/qgsfield_p.h | 8 +- src/core/qgsfieldproxymodel.cpp | 18 +- src/core/qgsfields.cpp | 44 +- src/core/qgsfields.h | 2 +- src/core/qgsgml.cpp | 8 +- src/core/qgsgmlschema.cpp | 16 +- src/core/qgsjsonutils.cpp | 32 +- src/core/qgsjsonutils.h | 2 +- src/core/qgsobjectcustomproperties.cpp | 2 +- src/core/qgsofflineediting.cpp | 58 +-- src/core/qgsogcutils.cpp | 34 +- src/core/qgsogrutils.cpp | 182 ++++---- src/core/qgsogrutils.h | 6 +- src/core/qgspostgresstringutils.cpp | 6 +- src/core/qgsproperty.cpp | 4 +- src/core/qgsrelation.cpp | 4 +- src/core/qgssqlexpressioncompiler.cpp | 14 +- src/core/qgssqliteutils.cpp | 10 +- src/core/qgssqlstatement.cpp | 10 +- src/core/qgsstringstatisticalsummary.cpp | 4 +- src/core/qgsvariantutils.cpp | 241 +++++----- src/core/qgsvariantutils.h | 2 +- src/core/qgsvectorfilewriter.cpp | 90 ++-- src/core/qgsvectorfilewriter.h | 2 +- src/core/qgsvirtuallayerdefinition.cpp | 18 +- src/core/qgsxmlutils.cpp | 36 +- src/core/qgsxmlutils.h | 8 +- src/core/raster/qgsexiftools.cpp | 16 +- src/core/raster/qgsrasterattributetable.cpp | 154 +++---- src/core/raster/qgsrasterattributetable.h | 12 +- src/core/settings/qgssettings.cpp | 2 +- .../qgscategorizedsymbolrenderer.cpp | 47 +- .../symbology/qgsgraduatedsymbolrenderer.cpp | 4 +- .../symbology/qgsinterpolatedlinerenderer.cpp | 6 +- src/core/symbology/qgslinesymbollayer.cpp | 2 +- src/core/symbology/qgsmarkersymbollayer.cpp | 2 +- src/core/symbology/qgsrulebasedrenderer.cpp | 10 +- src/core/symbology/qgssymbollayerutils.cpp | 6 +- src/core/textrenderer/qgstextfragment.h | 4 + .../tiledscene/qgstiledsceneboundingvolume.h | 2 +- src/core/vector/qgsfielddomain.cpp | 8 +- src/core/vector/qgsfielddomain.h | 14 +- src/core/vector/qgsvectordataprovider.cpp | 26 +- src/core/vector/qgsvectordataprovider.h | 8 +- .../vector/qgsvectorlayerfeatureiterator.cpp | 8 +- .../qgsvectorlayertemporalproperties.cpp | 6 +- src/core/vector/qgsvectorlayerutils.cpp | 10 +- .../vectortile/qgsmapboxglstyleconverter.cpp | 426 +++++++++--------- src/core/vectortile/qgsvectortilelayer.cpp | 4 +- .../vectortile/qgsvectortilematrixset.cpp | 2 +- .../vectortile/qgsvectortilemvtencoder.cpp | 6 +- src/core/vectortile/qgsvectortileutils.cpp | 2 +- src/core/vectortile/qgsvectortilewriter.cpp | 4 +- 138 files changed, 1682 insertions(+), 1684 deletions(-) diff --git a/python/core/auto_generated/actions/qgsactionscope.sip.in b/python/core/auto_generated/actions/qgsactionscope.sip.in index 68de870d89e8..8d123ecf6b8d 100644 --- a/python/core/auto_generated/actions/qgsactionscope.sip.in +++ b/python/core/auto_generated/actions/qgsactionscope.sip.in @@ -114,6 +114,7 @@ Returns if this scope is valid. .. versionadded:: 3.0 %End + long __hash__(); %MethodCode sipRes = qHash( *sipCpp ); diff --git a/python/core/auto_generated/elevation/qgsabstractprofilegenerator.sip.in b/python/core/auto_generated/elevation/qgsabstractprofilegenerator.sip.in index 5ce2fe476b44..6d5cae816dea 100644 --- a/python/core/auto_generated/elevation/qgsabstractprofilegenerator.sip.in +++ b/python/core/auto_generated/elevation/qgsabstractprofilegenerator.sip.in @@ -24,7 +24,7 @@ Abstract base class for storage of elevation profiles. %End public: - QgsProfileRenderContext( QgsRenderContext &context ); + QgsProfileRenderContext( const QgsRenderContext &context ); %Docstring Constructor for QgsProfileRenderContext, with the specified embedded render ``context``. %End diff --git a/python/core/auto_generated/expression/qgsexpression.sip.in b/python/core/auto_generated/expression/qgsexpression.sip.in index 8e7ea464dc08..2b26dcb186a5 100644 --- a/python/core/auto_generated/expression/qgsexpression.sip.in +++ b/python/core/auto_generated/expression/qgsexpression.sip.in @@ -588,7 +588,7 @@ quotations where required. .. versionadded:: 2.14 %End - static QString quotedValue( const QVariant &value, QVariant::Type type ); + static QString quotedValue( const QVariant &value, QMetaType::Type type ); %Docstring Returns a string representation of a literal value, including appropriate quotations where required. @@ -691,7 +691,7 @@ length, and presents text representations of non numeric/text types (e.g., geome .. versionadded:: 2.14 %End - static QString createFieldEqualityExpression( const QString &fieldName, const QVariant &value, QVariant::Type fieldType = QVariant::Type::Invalid ); + static QString createFieldEqualityExpression( const QString &fieldName, const QVariant &value, QMetaType::Type fieldType = QMetaType::UnknownType ); %Docstring Create an expression allowing to evaluate if a field is equal to a value. The value may be null. diff --git a/python/core/auto_generated/fieldformatter/qgsdatetimefieldformatter.sip.in b/python/core/auto_generated/fieldformatter/qgsdatetimefieldformatter.sip.in index 1500a367e898..ba88298d18a7 100644 --- a/python/core/auto_generated/fieldformatter/qgsdatetimefieldformatter.sip.in +++ b/python/core/auto_generated/fieldformatter/qgsdatetimefieldformatter.sip.in @@ -41,24 +41,24 @@ Default constructor of field formatter for a date time field. virtual QString representValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const; - static QString defaultFormat( QVariant::Type type ); + static QString defaultFormat( QMetaType::Type type ); %Docstring Gets the default format in function of the type. The type is expected to be one of -- QVariant.DateTime -- QVariant.Date -- QVariant.Time +- QMetaType.QDateTime +- QMetaType.QDate +- QMetaType.QTime %End - static QString defaultDisplayFormat( QVariant::Type type ); + static QString defaultDisplayFormat( QMetaType::Type type ); %Docstring Gets the default display format in function of the type. The type is expected to be one of -- QVariant.DateTime -- QVariant.Date -- QVariant.Time +- QMetaType.QDateTime +- QMetaType.QDate +- QMetaType.QTime .. versionadded:: 3.30 %End diff --git a/python/core/auto_generated/geometry/qgsbox3d.sip.in b/python/core/auto_generated/geometry/qgsbox3d.sip.in index 4ab507f5272d..9929ab51b64c 100644 --- a/python/core/auto_generated/geometry/qgsbox3d.sip.in +++ b/python/core/auto_generated/geometry/qgsbox3d.sip.in @@ -351,7 +351,7 @@ Returns the smallest distance between the box and the point ``point`` bool operator==( const QgsBox3D &other ) const /HoldGIL/; - void scale( double scaleFactor, const QgsPoint ¢er = QgsPoint() ) /HoldGIL/; + void scale( double scaleFactor, const QgsPoint ¢er = {} ) /HoldGIL/; %Docstring Scale the rectangle around a ``center`` :py:class:`QgsPoint`. diff --git a/python/core/auto_generated/geometry/qgsquadrilateral.sip.in b/python/core/auto_generated/geometry/qgsquadrilateral.sip.in index 4d9237937a42..91301a9f38a6 100644 --- a/python/core/auto_generated/geometry/qgsquadrilateral.sip.in +++ b/python/core/auto_generated/geometry/qgsquadrilateral.sip.in @@ -195,6 +195,7 @@ Returns the area of the quadrilateral, or 0 if the quadrilateral is empty. %Docstring Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty. %End + SIP_PYOBJECT __repr__(); %MethodCode QString str = QStringLiteral( "" ).arg( sipCpp->toString() ); diff --git a/python/core/auto_generated/geometry/qgswkbptr.sip.in b/python/core/auto_generated/geometry/qgswkbptr.sip.in index 41a2da707704..d712e575007c 100644 --- a/python/core/auto_generated/geometry/qgswkbptr.sip.in +++ b/python/core/auto_generated/geometry/qgswkbptr.sip.in @@ -40,10 +40,6 @@ A const WKB pointer. %TypeHeaderCode #include "qgswkbptr.h" %End - protected: - - - public: QgsConstWkbPtr( const unsigned char *p /Array/, int size /ArraySize/ ); diff --git a/python/core/auto_generated/pointcloud/qgspointcloudattribute.sip.in b/python/core/auto_generated/pointcloud/qgspointcloudattribute.sip.in index fc9ad6c3930f..7d87314df9e2 100644 --- a/python/core/auto_generated/pointcloud/qgspointcloudattribute.sip.in +++ b/python/core/auto_generated/pointcloud/qgspointcloudattribute.sip.in @@ -65,7 +65,7 @@ Returns the data type .. seealso:: :py:func:`variantType` %End - QVariant::Type variantType() const; + QMetaType::Type variantType() const; %Docstring Returns the most suitable equivalent QVariant data type to this attribute type. diff --git a/python/core/auto_generated/providers/arcgis/qgsarcgisrestutils.sip.in b/python/core/auto_generated/providers/arcgis/qgsarcgisrestutils.sip.in index d433184ba84f..1bbfccd79bce 100644 --- a/python/core/auto_generated/providers/arcgis/qgsarcgisrestutils.sip.in +++ b/python/core/auto_generated/providers/arcgis/qgsarcgisrestutils.sip.in @@ -74,7 +74,7 @@ Utility functions for working with ArcGIS REST services. public: - static QVariant::Type convertFieldType( const QString &type ); + static QMetaType::Type convertFieldType( const QString &type ); %Docstring Converts an ESRI REST field ``type`` to a QVariant type. %End @@ -187,7 +187,7 @@ Converts a ``feature`` to an ArcGIS REST JSON representation. .. versionadded:: 3.28 %End - static QVariant variantToAttributeValue( const QVariant &variant, QVariant::Type expectedType, const QgsArcGisRestContext &context ); + static QVariant variantToAttributeValue( const QVariant &variant, QMetaType::Type expectedType, const QgsArcGisRestContext &context ); %Docstring Converts a variant to a REST attribute value. diff --git a/python/core/auto_generated/qgsaggregatecalculator.sip.in b/python/core/auto_generated/qgsaggregatecalculator.sip.in index b04fdb16b3c9..946fe4440087 100644 --- a/python/core/auto_generated/qgsaggregatecalculator.sip.in +++ b/python/core/auto_generated/qgsaggregatecalculator.sip.in @@ -31,7 +31,7 @@ to a data provider for remote calculation. { QString function; QString name; - QSet supportedTypes; + QSet supportedTypes; }; enum Aggregate diff --git a/python/core/auto_generated/qgsapplication.sip.in b/python/core/auto_generated/qgsapplication.sip.in index ba69766bdca0..0e25817dd2b6 100644 --- a/python/core/auto_generated/qgsapplication.sip.in +++ b/python/core/auto_generated/qgsapplication.sip.in @@ -1038,7 +1038,7 @@ differently across work stations. This string is used to represent the value `NULL` throughout QGIS. In general, when passing values around, prefer to use a null QVariant -`QVariant( field.type() )` or `QVariant( QVariant.Int )`. This value +`QVariant( field.type() )` or `QVariant( QMetaType.Int )`. This value should only be used in the final presentation step when showing values in a widget or sending it to a web browser. %End diff --git a/python/core/auto_generated/qgsattributes.sip.in b/python/core/auto_generated/qgsattributes.sip.in index 7b1665627cc9..0415e1038008 100644 --- a/python/core/auto_generated/qgsattributes.sip.in +++ b/python/core/auto_generated/qgsattributes.sip.in @@ -79,7 +79,7 @@ typedef QVector QgsAttributes; PyObject *obj = PyList_GET_ITEM( sipPy, i ); if ( obj == Py_None ) { - qv->append( QVariant( QVariant::Int ) ); + qv->append( QVariant( QMetaType::Int ) ); } else { diff --git a/python/core/auto_generated/qgsfeature.sip.in b/python/core/auto_generated/qgsfeature.sip.in index e7ae9e155db1..b8bbbd19a111 100644 --- a/python/core/auto_generated/qgsfeature.sip.in +++ b/python/core/auto_generated/qgsfeature.sip.in @@ -77,7 +77,7 @@ geometry and a list of field/values attributes. if ( a1Wrapper == Py_None ) { - rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) ); + rv = sipCpp->setAttribute( a0, QVariant( QMetaType::Int ) ); } else { @@ -103,7 +103,7 @@ geometry and a list of field/values attributes. { if ( a1Wrapper == Py_None ) { - sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) ); + sipCpp->setAttribute( *a0, QVariant( QMetaType::Int ) ); } else { @@ -310,7 +310,7 @@ Alternatively, in Python it is possible to directly set a field's value via the if ( a1Wrapper == Py_None ) { - rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) ); + rv = sipCpp->setAttribute( a0, QVariant( QMetaType::Int ) ); } else { @@ -565,7 +565,7 @@ Alternatively, in Python it is possible to directly set a field's value via the { if ( a1Wrapper == Py_None ) { - sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) ); + sipCpp->setAttribute( *a0, QVariant( QMetaType::Int ) ); } else { diff --git a/python/core/auto_generated/qgsfield.sip.in b/python/core/auto_generated/qgsfield.sip.in index ad205b675185..f62c6b458997 100644 --- a/python/core/auto_generated/qgsfield.sip.in +++ b/python/core/auto_generated/qgsfield.sip.in @@ -36,12 +36,12 @@ length, and if applicable, precision. QgsField( const QString &name = QString(), - QVariant::Type type = QVariant::Invalid, + QMetaType::Type type = QMetaType::UnknownType, const QString &typeName = QString(), int len = 0, int prec = 0, const QString &comment = QString(), - QVariant::Type subType = QVariant::Invalid ); + QMetaType::Type subType = QMetaType::UnknownType ); %Docstring Constructor. Constructs a new QgsField object. @@ -56,7 +56,7 @@ Constructor. Constructs a new QgsField object. :param comment: Comment for the field :param subType: If the field is a collection, its element's type. When all the elements don't need to have the same type, leave - this to QVariant.Invalid. + this to QMetaType.UnknownType. %End QgsField( const QgsField &other ); @@ -64,6 +64,8 @@ Constructor. Constructs a new QgsField object. Copy constructor %End + QVariant testVariant( QMetaType::Type type ); + virtual ~QgsField(); @@ -133,16 +135,16 @@ length, precision or constraint information. .. versionadded:: 3.14 %End - QVariant::Type type() const; + QMetaType::Type type() const; %Docstring Gets variant type of the field as it will be retrieved from data source %End - QVariant::Type subType() const; + QMetaType::Type subType() const; %Docstring If the field is a collection, gets its element's type. When all the elements don't need to have the same type, this returns -QVariant.Invalid. +QMetaType.UnknownType. .. versionadded:: 3.0 %End @@ -239,16 +241,16 @@ Set the field name. :param name: Name of the field %End - void setType( QVariant::Type type ); + void setType( QMetaType::Type type ); %Docstring Set variant type. %End - void setSubType( QVariant::Type subType ); + void setSubType( QMetaType::Type subType ); %Docstring If the field is a collection, set its element's type. When all the elements don't need to have the same type, set this to -QVariant.Invalid. +QMetaType.UnknownType. .. versionadded:: 3.0 %End diff --git a/python/core/auto_generated/qgsfields.sip.in b/python/core/auto_generated/qgsfields.sip.in index cd2f46fce80c..8b5ec029a5ef 100644 --- a/python/core/auto_generated/qgsfields.sip.in +++ b/python/core/auto_generated/qgsfields.sip.in @@ -350,7 +350,7 @@ Returns an icon corresponding to a field index, based on the field's type and so } %End - static QIcon iconForFieldType( QVariant::Type type, QVariant::Type subType = QVariant::Type::Invalid, const QString &typeString = QString() ); + static QIcon iconForFieldType( QMetaType::Type type, QMetaType::Type subType = QMetaType::UnknownType, const QString &typeString = QString() ); %Docstring Returns an icon corresponding to a field ``type`` diff --git a/python/core/auto_generated/qgsjsonutils.sip.in b/python/core/auto_generated/qgsjsonutils.sip.in index 664b85eedc70..40ec49f204ea 100644 --- a/python/core/auto_generated/qgsjsonutils.sip.in +++ b/python/core/auto_generated/qgsjsonutils.sip.in @@ -341,7 +341,7 @@ Exports all attributes from a :py:class:`QgsFeature` as a JSON map type. %End - static QVariantList parseArray( const QString &json, QVariant::Type type = QVariant::Invalid ); + static QVariantList parseArray( const QString &json, QMetaType::Type type = QMetaType::UnknownType ); %Docstring Parse a simple array (depth=1) diff --git a/python/core/auto_generated/qgsvariantutils.sip.in b/python/core/auto_generated/qgsvariantutils.sip.in index 1b4429529a2d..537602149f10 100644 --- a/python/core/auto_generated/qgsvariantutils.sip.in +++ b/python/core/auto_generated/qgsvariantutils.sip.in @@ -22,7 +22,7 @@ Contains utility functions for working with QVariants and QVariant types. %End public: - static QString typeToDisplayString( QVariant::Type type, QVariant::Type subType = QVariant::Type::Invalid ); + static QString typeToDisplayString( QMetaType::Type type, QMetaType::Type subType = QMetaType::UnknownType ); %Docstring Returns a user-friendly translated string representing a QVariant ``type``. diff --git a/python/core/auto_generated/qgsxmlutils.sip.in b/python/core/auto_generated/qgsxmlutils.sip.in index 77cd94f79738..17035c0ea981 100644 --- a/python/core/auto_generated/qgsxmlutils.sip.in +++ b/python/core/auto_generated/qgsxmlutils.sip.in @@ -67,10 +67,10 @@ Write a QVariant to a QDomElement. Supported types are -- QVariant.Map -- QVariant.Int -- QVariant.Double -- QVariant.String +- QMetaType.QVariantMap +- QMetaType.Int +- QMetaType.Double +- QMetaType.QString - :py:class:`QgsProperty` (since QGIS 3.4) - :py:class:`QgsCoordinateReferenceSystem` (since QGIS 3.4) %End diff --git a/python/core/auto_generated/raster/qgsrasterattributetable.sip.in b/python/core/auto_generated/raster/qgsrasterattributetable.sip.in index b195d0e4ffca..9dd492e02585 100644 --- a/python/core/auto_generated/raster/qgsrasterattributetable.sip.in +++ b/python/core/auto_generated/raster/qgsrasterattributetable.sip.in @@ -52,7 +52,7 @@ The UsageInformation class represents information about a field usage. bool maybeClass; - QList allowedTypes; + QList allowedTypes; }; class Field @@ -68,7 +68,7 @@ The Field class represents a Raster Attribute Table field, including its name, u %End public: - Field( const QString &name, const Qgis::RasterAttributeTableFieldUsage &usage, const QVariant::Type type ); + Field( const QString &name, const Qgis::RasterAttributeTableFieldUsage &usage, const QMetaType::Type type ); %Docstring Creates a new Field with ``name``, ``type`` and ``usage``. %End @@ -85,7 +85,7 @@ Returns ``True`` if the field carries a color ramp component information (RedMin QString name; Qgis::RasterAttributeTableFieldUsage usage; - QVariant::Type type; + QMetaType::Type type; }; class MinMaxClass @@ -250,7 +250,7 @@ Inserts a new ``field`` at ``position``, optionally reporting any error in ``err Out of range position is automatically clamped to a valid value. %End - bool insertField( int position, const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QVariant::Type type, QString *errorMessage /Out/ = 0 ); + bool insertField( int position, const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QMetaType::Type type, QString *errorMessage /Out/ = 0 ); %Docstring Creates a new field from ``name``, ``usage`` and ``type`` and inserts it at ``position``, optionally reporting any error in ``errorMessage``, returns ``True`` on success. %End @@ -272,7 +272,7 @@ Change the usage of the field at index ``fieldIndex`` to ``usage`` with checks f Create RGBA minimum and maximum fields and inserts them at ``position``, optionally reporting any error in ``errorMessage``, returns ``True`` on success. %End - bool appendField( const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QVariant::Type type, QString *errorMessage /Out/ = 0 ); + bool appendField( const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QMetaType::Type type, QString *errorMessage /Out/ = 0 ); %Docstring Creates a new field from ``name``, ``usage`` and ``type`` and appends it to the fields, optionally reporting any error in ``errorMessage``, returns ``True`` on success. %End @@ -408,7 +408,7 @@ If the attribute table does not have any value field (and hence is not valid), the current data are returned without any change. %End - static Qgis::RasterAttributeTableFieldUsage guessFieldUsage( const QString &name, const QVariant::Type type ); + static Qgis::RasterAttributeTableFieldUsage guessFieldUsage( const QString &name, const QMetaType::Type type ); %Docstring Try to determine the field usage from its ``name`` and ``type``. %End diff --git a/python/core/auto_generated/textrenderer/qgstextfragment.sip.in b/python/core/auto_generated/textrenderer/qgstextfragment.sip.in index 1b5ecaaba217..924a99ba89d5 100644 --- a/python/core/auto_generated/textrenderer/qgstextfragment.sip.in +++ b/python/core/auto_generated/textrenderer/qgstextfragment.sip.in @@ -9,6 +9,8 @@ + + class QgsTextFragment { %Docstring(signature="appended") diff --git a/python/core/auto_generated/tiledscene/qgstiledsceneboundingvolume.sip.in b/python/core/auto_generated/tiledscene/qgstiledsceneboundingvolume.sip.in index 551d9a26d1a3..28265f4b1aa2 100644 --- a/python/core/auto_generated/tiledscene/qgstiledsceneboundingvolume.sip.in +++ b/python/core/auto_generated/tiledscene/qgstiledsceneboundingvolume.sip.in @@ -38,7 +38,7 @@ Abstract base class for bounding volumes for tiled scene nodes. default: sipType = 0; break; - }; + } %End virtual ~QgsAbstractTiledSceneBoundingVolume(); diff --git a/python/core/auto_generated/vector/qgsfielddomain.sip.in b/python/core/auto_generated/vector/qgsfielddomain.sip.in index 9de95b822bef..d7c7157b9135 100644 --- a/python/core/auto_generated/vector/qgsfielddomain.sip.in +++ b/python/core/auto_generated/vector/qgsfielddomain.sip.in @@ -44,7 +44,7 @@ A field domain is a set of constraints that apply to one or several fields. QgsFieldDomain( const QString &name, const QString &description, - QVariant::Type fieldType ); + QMetaType::Type fieldType ); %Docstring Constructor for QgsFieldDomain, with the specified ``name``, ``description`` and ``fieldType``. %End @@ -94,14 +94,14 @@ Sets the ``description`` of the field domain. .. seealso:: :py:func:`description` %End - QVariant::Type fieldType() const; + QMetaType::Type fieldType() const; %Docstring Returns the associated field type. .. seealso:: :py:func:`setFieldType` %End - void setFieldType( QVariant::Type type ); + void setFieldType( QMetaType::Type type ); %Docstring Sets the associated field ``type``. @@ -206,7 +206,7 @@ The type of the code should be the one of the field domain. QgsCodedFieldDomain( const QString &name, const QString &description, - QVariant::Type fieldType, + QMetaType::Type fieldType, const QList &values ); %Docstring Constructor for QgsCodedFieldDomain, with the associated ``name``, ``description`` and ``fieldType``. @@ -263,7 +263,7 @@ Definition of a numeric field domain with a range of validity for values. QgsRangeFieldDomain( const QString &name, const QString &description, - QVariant::Type fieldType, + QMetaType::Type fieldType, const QVariant &minimum, bool minimumIsInclusive, const QVariant &maximum, @@ -394,7 +394,7 @@ Globs are matching expression like "*[a-z][0-1]?" QgsGlobFieldDomain( const QString &name, const QString &description, - QVariant::Type fieldType, + QMetaType::Type fieldType, const QString &glob ); %Docstring Constructor for QgsGlobFieldDomain, with the specified ``name``, ``description`` and ``fieldType``. diff --git a/python/core/auto_generated/vector/qgsvectordataprovider.sip.in b/python/core/auto_generated/vector/qgsvectordataprovider.sip.in index c0f06e3156bb..9bd6b94cdf9f 100644 --- a/python/core/auto_generated/vector/qgsvectordataprovider.sip.in +++ b/python/core/auto_generated/vector/qgsvectordataprovider.sip.in @@ -500,16 +500,16 @@ check if provider supports type of field struct NativeType { - NativeType( const QString &typeDesc, const QString &typeName, QVariant::Type type, int minLen = 0, int maxLen = 0, int minPrec = 0, int maxPrec = 0, QVariant::Type subType = QVariant::Invalid ); + NativeType( const QString &typeDesc, const QString &typeName, QMetaType::Type type, int minLen = 0, int maxLen = 0, int minPrec = 0, int maxPrec = 0, QMetaType::Type subType = QMetaType::UnknownType ); QString mTypeDesc; QString mTypeName; - QVariant::Type mType; + QMetaType::Type mType; int mMinLen; int mMaxLen; int mMinPrec; int mMaxPrec; - QVariant::Type mSubType; + QMetaType::Type mSubType; }; QList< QgsVectorDataProvider::NativeType > nativeTypes() const; @@ -589,7 +589,7 @@ providers will return ``None``. .. versionadded:: 3.6 %End - static QVariant convertValue( QVariant::Type type, const QString &value ); + static QVariant convertValue( QMetaType::Type type, const QString &value ); virtual QgsTransaction *transaction() const; %Docstring diff --git a/src/core/actions/qgsactionscope.h b/src/core/actions/qgsactionscope.h index 38d5c6e2da3c..44f81e8306b8 100644 --- a/src/core/actions/qgsactionscope.h +++ b/src/core/actions/qgsactionscope.h @@ -123,6 +123,7 @@ class CORE_EXPORT QgsActionScope * \since QGIS 3.0 */ bool isValid() const; + #ifdef SIP_RUN long __hash__(); % MethodCode diff --git a/src/core/callouts/qgscallout.cpp b/src/core/callouts/qgscallout.cpp index e2db4ea28f43..bd8f4025b5ba 100644 --- a/src/core/callouts/qgscallout.cpp +++ b/src/core/callouts/qgscallout.cpp @@ -1239,7 +1239,7 @@ QPolygonF QgsBalloonCallout::getPoints( QgsRenderContext &context, QgsPointXY or const QVariant value = dataDefinedProperties().value( QgsCallout::Margins, context.expressionContext() ); if ( !QgsVariantUtils::isNull( value ) ) { - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { const QVariantList list = value.toList(); if ( list.size() == 4 ) diff --git a/src/core/elevation/qgsabstractprofilegenerator.cpp b/src/core/elevation/qgsabstractprofilegenerator.cpp index 986683e1c4d4..5446b6ace85f 100644 --- a/src/core/elevation/qgsabstractprofilegenerator.cpp +++ b/src/core/elevation/qgsabstractprofilegenerator.cpp @@ -18,7 +18,7 @@ #include "qgsprofilesnapping.h" -QgsProfileRenderContext::QgsProfileRenderContext( QgsRenderContext &context ) +QgsProfileRenderContext::QgsProfileRenderContext( const QgsRenderContext &context ) : mRenderContext( context ) { diff --git a/src/core/elevation/qgsabstractprofilegenerator.h b/src/core/elevation/qgsabstractprofilegenerator.h index ae9ac68406a2..ef172e46d81a 100644 --- a/src/core/elevation/qgsabstractprofilegenerator.h +++ b/src/core/elevation/qgsabstractprofilegenerator.h @@ -43,7 +43,7 @@ class CORE_EXPORT QgsProfileRenderContext /** * Constructor for QgsProfileRenderContext, with the specified embedded render \a context. */ - QgsProfileRenderContext( QgsRenderContext &context ); + QgsProfileRenderContext( const QgsRenderContext &context ); /** * Returns a reference to the component QgsRenderContext. diff --git a/src/core/elevation/qgsprofileexporter.cpp b/src/core/elevation/qgsprofileexporter.cpp index 13f0ca042560..a775180933c2 100644 --- a/src/core/elevation/qgsprofileexporter.cpp +++ b/src/core/elevation/qgsprofileexporter.cpp @@ -72,7 +72,7 @@ QList< QgsVectorLayer *> QgsProfileExporter::toLayers() { // first collate a master list of fields for this geometry type QgsFields outputFields; - outputFields.append( QgsField( QStringLiteral( "layer" ), QVariant::String ) ); + outputFields.append( QgsField( QStringLiteral( "layer" ), QMetaType::QString ) ); for ( const QgsAbstractProfileResults::Feature &feature : std::as_const( wkbTypeIt.value() ) ) { @@ -81,14 +81,14 @@ QList< QgsVectorLayer *> QgsProfileExporter::toLayers() const int existingFieldIndex = outputFields.lookupField( attributeIt.key() ); if ( existingFieldIndex < 0 ) { - outputFields.append( QgsField( attributeIt.key(), attributeIt.value().type() ) ); + outputFields.append( QgsField( attributeIt.key(), static_cast( attributeIt.value().userType() ) ) ); } else { - if ( outputFields.at( existingFieldIndex ).type() != QVariant::String && outputFields.at( existingFieldIndex ).type() != attributeIt.value().type() ) + if ( outputFields.at( existingFieldIndex ).type() != QMetaType::QString && outputFields.at( existingFieldIndex ).type() != attributeIt.value().userType() ) { // attribute type mismatch across fields, just promote to string types to be flexible - outputFields[ existingFieldIndex ].setType( QVariant::String ); + outputFields[ existingFieldIndex ].setType( QMetaType::QString ); } } } diff --git a/src/core/expression/qgsexpression.cpp b/src/core/expression/qgsexpression.cpp index 47af47859af2..54a12def49f6 100644 --- a/src/core/expression/qgsexpression.cpp +++ b/src/core/expression/qgsexpression.cpp @@ -87,26 +87,26 @@ QString QgsExpression::quotedString( QString text ) QString QgsExpression::quotedValue( const QVariant &value ) { - return quotedValue( value, value.type() ); + return quotedValue( value, static_cast( value.userType() ) ); } -QString QgsExpression::quotedValue( const QVariant &value, QVariant::Type type ) +QString QgsExpression::quotedValue( const QVariant &value, QMetaType::Type type ) { if ( QgsVariantUtils::isNull( value ) ) return QStringLiteral( "NULL" ); switch ( type ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: return value.toString(); - case QVariant::Bool: + case QMetaType::Bool: return value.toBool() ? QStringLiteral( "TRUE" ) : QStringLiteral( "FALSE" ); - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: { QStringList quotedValues; const QVariantList values = value.toList(); @@ -119,7 +119,7 @@ QString QgsExpression::quotedValue( const QVariant &value, QVariant::Type type ) } default: - case QVariant::String: + case QMetaType::QString: return quotedString( value.toString() ); } @@ -1058,22 +1058,22 @@ QString QgsExpression::formatPreviewString( const QVariant &value, const bool ht { return startToken + tr( "gradient ramp" ) + endToken; } - else if ( value.type() == QVariant::Date ) + else if ( value.typeId() == QMetaType::QDate ) { const QDate dt = value.toDate(); return startToken + tr( "date: %1" ).arg( dt.toString( QStringLiteral( "yyyy-MM-dd" ) ) ) + endToken; } - else if ( value.type() == QVariant::Time ) + else if ( value.typeId() == QMetaType::QTime ) { const QTime tm = value.toTime(); return startToken + tr( "time: %1" ).arg( tm.toString( QStringLiteral( "hh:mm:ss" ) ) ) + endToken; } - else if ( value.type() == QVariant::DateTime ) + else if ( value.typeId() == QMetaType::QDateTime ) { const QDateTime dt = value.toDateTime(); return startToken + tr( "datetime: %1 (%2)" ).arg( dt.toString( QStringLiteral( "yyyy-MM-dd hh:mm:ss" ) ), dt.timeZoneAbbreviation() ) + endToken; } - else if ( value.type() == QVariant::String ) + else if ( value.typeId() == QMetaType::QString ) { const QString previewString = value.toString(); if ( previewString.length() > maximumPreviewLength + 3 ) @@ -1085,7 +1085,7 @@ QString QgsExpression::formatPreviewString( const QVariant &value, const bool ht return '\'' + previewString + '\''; } } - else if ( value.type() == QVariant::Map ) + else if ( value.typeId() == QMetaType::QVariantMap ) { QString mapStr = QStringLiteral( "{" ); const QVariantMap map = value.toMap(); @@ -1108,7 +1108,7 @@ QString QgsExpression::formatPreviewString( const QVariant &value, const bool ht mapStr += QLatin1Char( '}' ); return mapStr; } - else if ( value.type() == QVariant::List || value.type() == QVariant::StringList ) + else if ( value.typeId() == QMetaType::QVariantList || value.typeId() == QMetaType::QStringList ) { QString listStr = QStringLiteral( "[" ); const QVariantList list = value.toList(); @@ -1132,13 +1132,12 @@ QString QgsExpression::formatPreviewString( const QVariant &value, const bool ht listStr += QLatin1Char( ']' ); return listStr; } - else if ( value.type() == QVariant::Int || - value.type() == QVariant::UInt || - value.type() == QVariant::LongLong || - value.type() == QVariant::ULongLong || - value.type() == QVariant::Double || - // Qt madness with QMetaType::Float :/ - value.type() == static_cast( QMetaType::Float ) ) + else if ( value.typeId() == QMetaType::Int || + value.typeId() == QMetaType::UInt || + value.typeId() == QMetaType::LongLong || + value.typeId() == QMetaType::ULongLong || + value.typeId() == QMetaType::Double || + value.typeId() == QMetaType::Float ) { return QgsExpressionUtils::toLocalizedString( value ); } @@ -1153,13 +1152,13 @@ QString QgsExpression::formatPreviewString( const QVariant &value, const bool ht } } -QString QgsExpression::createFieldEqualityExpression( const QString &fieldName, const QVariant &value, QVariant::Type fieldType ) +QString QgsExpression::createFieldEqualityExpression( const QString &fieldName, const QVariant &value, QMetaType::Type fieldType ) { QString expr; if ( QgsVariantUtils::isNull( value ) ) expr = QStringLiteral( "%1 IS NULL" ).arg( quotedColumnRef( fieldName ) ); - else if ( fieldType == QVariant::Type::Invalid ) + else if ( fieldType == QMetaType::UnknownType ) expr = QStringLiteral( "%1 = %2" ).arg( quotedColumnRef( fieldName ), quotedValue( value ) ); else expr = QStringLiteral( "%1 = %2" ).arg( quotedColumnRef( fieldName ), quotedValue( value, fieldType ) ); @@ -1436,6 +1435,3 @@ QList QgsExpression::nodes() const return d->mRootNode->nodes(); } - - - diff --git a/src/core/expression/qgsexpression.h b/src/core/expression/qgsexpression.h index eeebde680a9d..22a54f22e71d 100644 --- a/src/core/expression/qgsexpression.h +++ b/src/core/expression/qgsexpression.h @@ -685,7 +685,7 @@ class CORE_EXPORT QgsExpression * \see quotedColumnRef() * \since QGIS 2.14 */ - static QString quotedValue( const QVariant &value, QVariant::Type type ); + static QString quotedValue( const QVariant &value, QMetaType::Type type ); ////// @@ -770,7 +770,7 @@ class CORE_EXPORT QgsExpression * \returns the expression to evaluate field equality * \since QGIS 3.0 */ - static QString createFieldEqualityExpression( const QString &fieldName, const QVariant &value, QVariant::Type fieldType = QVariant::Type::Invalid ); + static QString createFieldEqualityExpression( const QString &fieldName, const QVariant &value, QMetaType::Type fieldType = QMetaType::UnknownType ); /** * Returns TRUE if the given \a expression is a simple "field=value" type expression. diff --git a/src/core/expression/qgsexpressionfunction.cpp b/src/core/expression/qgsexpressionfunction.cpp index 0c102fa5d35c..f7249b9bd411 100644 --- a/src/core/expression/qgsexpressionfunction.cpp +++ b/src/core/expression/qgsexpressionfunction.cpp @@ -587,7 +587,7 @@ static QVariant fcnExponentialScale( const QVariantList &values, const QgsExpres static QVariant fcnMax( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) { - QVariant result( QVariant::Double ); + QVariant result { QMetaType( QMetaType::Double ) }; double maxVal = std::numeric_limits::quiet_NaN(); for ( const QVariant &val : values ) { @@ -611,7 +611,7 @@ static QVariant fcnMax( const QVariantList &values, const QgsExpressionContext * static QVariant fcnMin( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) { - QVariant result( QVariant::Double ); + QVariant result{ QMetaType( QMetaType::Double ) }; double minVal = std::numeric_limits::quiet_NaN(); for ( const QVariant &val : values ) { @@ -1505,7 +1505,7 @@ static QVariant fcnLength3D( const QVariantList &values, const QgsExpressionCont static QVariant fcnReplace( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) { - if ( values.count() == 2 && values.at( 1 ).type() == QVariant::Map ) + if ( values.count() == 2 && values.at( 1 ).typeId() == QMetaType::QVariantMap ) { QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent ); QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent ); @@ -1539,7 +1539,7 @@ static QVariant fcnReplace( const QVariantList &values, const QgsExpressionConte QVariantList after; bool isSingleReplacement = false; - if ( !QgsExpressionUtils::isList( values.at( 1 ) ) && values.at( 2 ).type() != QVariant::StringList ) + if ( !QgsExpressionUtils::isList( values.at( 1 ) ) && values.at( 2 ).typeId() != QMetaType::QStringList ) { before = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 1 ), parent ); } @@ -2323,13 +2323,13 @@ static QVariant fcnIsSelected( const QVariantList &values, const QgsExpressionCo QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer ); if ( !layer || !feature.isValid() ) { - return QVariant( QVariant::Bool ); + return QVariant( QMetaType( QMetaType::Bool ) ); } return layer->selectedFeatureIds().contains( feature.id() ); }, foundLayer ); if ( !foundLayer ) - return QVariant( QVariant::Bool ); + return QVariant( QMetaType( QMetaType::Bool ) ); else return res; } @@ -2354,13 +2354,13 @@ static QVariant fcnNumSelected( const QVariantList &values, const QgsExpressionC QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer ); if ( !layer ) { - return QVariant( QVariant::LongLong ); + return QVariant( QMetaType( QMetaType::LongLong ) ); } return layer->selectedFeatureCount(); }, foundLayer ); if ( !foundLayer ) - return QVariant( QVariant::LongLong ); + return QVariant( QMetaType( QMetaType::LongLong ) ); else return res; } @@ -3743,7 +3743,7 @@ static QVariant fcnMakeLine( const QVariantList &values, const QgsExpressionCont for ( const QVariant &value : values ) { - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { const QVariantList list = value.toList(); for ( const QVariant &v : list ) @@ -4477,7 +4477,7 @@ static QVariant fcnZMax( const QVariantList &values, const QgsExpressionContext } if ( max == std::numeric_limits< double >::lowest() ) - return QVariant( QVariant::Double ); + return QVariant( QMetaType( QMetaType::Double ) ); return QVariant( max ); } @@ -4503,7 +4503,7 @@ static QVariant fcnZMin( const QVariantList &values, const QgsExpressionContext } if ( min == std::numeric_limits< double >::max() ) - return QVariant( QVariant::Double ); + return QVariant( QMetaType( QMetaType::Double ) ); return QVariant( min ); } @@ -4529,7 +4529,7 @@ static QVariant fcnMMin( const QVariantList &values, const QgsExpressionContext } if ( min == std::numeric_limits< double >::max() ) - return QVariant( QVariant::Double ); + return QVariant( QMetaType( QMetaType::Double ) ); return QVariant( min ); } @@ -4555,7 +4555,7 @@ static QVariant fcnMMax( const QVariantList &values, const QgsExpressionContext } if ( max == std::numeric_limits< double >::lowest() ) - return QVariant( QVariant::Double ); + return QVariant( QMetaType( QMetaType::Double ) ); return QVariant( max ); } @@ -6237,7 +6237,7 @@ static QVariant fcnGetFeature( const QVariantList &values, const QgsExpressionCo } QgsFeatureRequest req; QString cacheValueKey; - if ( values.at( 1 ).type() == QVariant::Map ) + if ( values.at( 1 ).typeId() == QMetaType::QVariantMap ) { QVariantMap attributeMap = QgsExpressionUtils::getMapValue( values.at( 1 ), parent ); @@ -6754,7 +6754,7 @@ static QVariant fcnArraySum( const QVariantList &values, const QgsExpressionCont return i == 0 ? QVariant() : total; } -static QVariant convertToSameType( const QVariant &value, QVariant::Type type ) +static QVariant convertToSameType( const QVariant &value, QMetaType::Type type ) { QVariant result = value; result.convert( static_cast( type ) ); @@ -6778,7 +6778,7 @@ static QVariant fcnArrayMajority( const QVariantList &values, const QgsExpressio const QString option = values.at( 1 ).toString(); if ( option.compare( QLatin1String( "all" ), Qt::CaseInsensitive ) == 0 ) { - return convertToSameType( hash.keys( maxValue ), values.at( 0 ).type() ); + return convertToSameType( hash.keys( maxValue ), static_cast( values.at( 0 ).userType() ) ); } else if ( option.compare( QLatin1String( "any" ), Qt::CaseInsensitive ) == 0 ) { @@ -6789,7 +6789,7 @@ static QVariant fcnArrayMajority( const QVariantList &values, const QgsExpressio } else if ( option.compare( QLatin1String( "median" ), Qt::CaseInsensitive ) == 0 ) { - return fcnArrayMedian( QVariantList() << convertToSameType( hash.keys( maxValue ), values.at( 0 ).type() ), context, parent, node ); + return fcnArrayMedian( QVariantList() << convertToSameType( hash.keys( maxValue ), static_cast( values.at( 0 ).userType() ) ), context, parent, node ); } else if ( option.compare( QLatin1String( "real_majority" ), Qt::CaseInsensitive ) == 0 ) { @@ -6822,7 +6822,7 @@ static QVariant fcnArrayMinority( const QVariantList &values, const QgsExpressio const QString option = values.at( 1 ).toString(); if ( option.compare( QLatin1String( "all" ), Qt::CaseInsensitive ) == 0 ) { - return convertToSameType( hash.keys( minValue ), values.at( 0 ).type() ); + return convertToSameType( hash.keys( minValue ), static_cast( values.at( 0 ).userType() ) ); } else if ( option.compare( QLatin1String( "any" ), Qt::CaseInsensitive ) == 0 ) { @@ -6833,7 +6833,7 @@ static QVariant fcnArrayMinority( const QVariantList &values, const QgsExpressio } else if ( option.compare( QLatin1String( "median" ), Qt::CaseInsensitive ) == 0 ) { - return fcnArrayMedian( QVariantList() << convertToSameType( hash.keys( minValue ), values.at( 0 ).type() ), context, parent, node ); + return fcnArrayMedian( QVariantList() << convertToSameType( hash.keys( minValue ), static_cast( values.at( 0 ).userType() ) ), context, parent, node ); } else if ( option.compare( QLatin1String( "real_minority" ), Qt::CaseInsensitive ) == 0 ) { @@ -6845,7 +6845,7 @@ static QVariant fcnArrayMinority( const QVariantList &values, const QgsExpressio if ( maxValue * 2 > list.size() ) hash.remove( hash.key( maxValue ) ); - return convertToSameType( hash.keys(), values.at( 0 ).type() ); + return convertToSameType( hash.keys(), static_cast( values.at( 0 ).userType() ) ); } else { @@ -6858,21 +6858,21 @@ static QVariant fcnArrayAppend( const QVariantList &values, const QgsExpressionC { QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent ); list.append( values.at( 1 ) ); - return convertToSameType( list, values.at( 0 ).type() ); + return convertToSameType( list, static_cast( values.at( 0 ).userType() ) ); } static QVariant fcnArrayPrepend( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) { QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent ); list.prepend( values.at( 1 ) ); - return convertToSameType( list, values.at( 0 ).type() ); + return convertToSameType( list, static_cast( values.at( 0 ).userType() ) ); } static QVariant fcnArrayInsert( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) { QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent ); list.insert( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), values.at( 2 ) ); - return convertToSameType( list, values.at( 0 ).type() ); + return convertToSameType( list, static_cast( values.at( 0 ).userType() ) ); } static QVariant fcnArrayRemoveAt( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) @@ -6883,7 +6883,7 @@ static QVariant fcnArrayRemoveAt( const QVariantList &values, const QgsExpressio position = position + list.length(); if ( position >= 0 && position < list.length() ) list.removeAt( position ); - return convertToSameType( list, values.at( 0 ).type() ); + return convertToSameType( list, static_cast( values.at( 0 ).userType() ) ); } static QVariant fcnArrayRemoveAll( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) @@ -6905,12 +6905,12 @@ static QVariant fcnArrayRemoveAll( const QVariantList &values, const QgsExpressi { list.removeAll( toRemove ); } - return convertToSameType( list, values.at( 0 ).type() ); + return convertToSameType( list, static_cast( values.at( 0 ).userType() ) ); } static QVariant fcnArrayReplace( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) { - if ( values.count() == 2 && values.at( 1 ).type() == QVariant::Map ) + if ( values.count() == 2 && values.at( 1 ).typeId() == QMetaType::QVariantMap ) { QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent ); @@ -6925,7 +6925,7 @@ static QVariant fcnArrayReplace( const QVariantList &values, const QgsExpression } } - return convertToSameType( list, values.at( 0 ).type() ); + return convertToSameType( list, static_cast( values.at( 0 ).userType() ) ); } else if ( values.count() == 3 ) { @@ -6933,7 +6933,7 @@ static QVariant fcnArrayReplace( const QVariantList &values, const QgsExpression QVariantList after; bool isSingleReplacement = false; - if ( !QgsExpressionUtils::isList( values.at( 1 ) ) && values.at( 2 ).type() != QVariant::StringList ) + if ( !QgsExpressionUtils::isList( values.at( 1 ) ) && values.at( 2 ).typeId() != QMetaType::QStringList ) { before = QVariantList() << values.at( 1 ); } @@ -6969,7 +6969,7 @@ static QVariant fcnArrayReplace( const QVariantList &values, const QgsExpression } } - return convertToSameType( list, values.at( 0 ).type() ); + return convertToSameType( list, static_cast( values.at( 0 ).userType() ) ); } else { @@ -6993,7 +6993,7 @@ static QVariant fcnArrayPrioritize( const QVariantList &values, const QgsExpress list_new.append( list ); - return convertToSameType( list_new, values.at( 0 ).type() ); + return convertToSameType( list_new, static_cast( values.at( 0 ).userType() ) ); } static QVariant fcnArrayCat( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) @@ -7003,7 +7003,7 @@ static QVariant fcnArrayCat( const QVariantList &values, const QgsExpressionCont { list += QgsExpressionUtils::getListValue( cur, parent ); } - return convertToSameType( list, values.at( 0 ).type() ); + return convertToSameType( list, static_cast( values.at( 0 ).userType() ) ); } static QVariant fcnArraySlice( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * ) diff --git a/src/core/expression/qgsexpressionnodeimpl.cpp b/src/core/expression/qgsexpressionnodeimpl.cpp index 45b38d9d203d..62b08b1b2236 100644 --- a/src/core/expression/qgsexpressionnodeimpl.cpp +++ b/src/core/expression/qgsexpressionnodeimpl.cpp @@ -223,7 +223,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const switch ( mOp ) { case boPlus: - if ( vL.type() == QVariant::String && vR.type() == QVariant::String ) + if ( vL.typeId() == QMetaType::QString && vR.typeId() == QMetaType::QString ) { QString sL = QgsExpressionUtils::isNull( vL ) ? QString() : QgsExpressionUtils::getStringValue( vL, parent ); ENSURE_NO_EVAL_ERROR @@ -266,17 +266,17 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const } return QVariant( computeDateTimeFromInterval( dL, &iL ) ); } - else if ( mOp == boPlus && ( ( vL.type() == QVariant::Date && vR.type() == QVariant::Time ) || - ( vR.type() == QVariant::Date && vL.type() == QVariant::Time ) ) ) + else if ( mOp == boPlus && ( ( vL.typeId() == QMetaType::QDate && vR.typeId() == QMetaType::QTime ) || + ( vR.typeId() == QMetaType::QDate && vL.typeId() == QMetaType::QTime ) ) ) { - QDate date = QgsExpressionUtils::getDateValue( vL.type() == QVariant::Date ? vL : vR, parent ); + QDate date = QgsExpressionUtils::getDateValue( vL.typeId() == QMetaType::QDate ? vL : vR, parent ); ENSURE_NO_EVAL_ERROR - QTime time = QgsExpressionUtils::getTimeValue( vR.type() == QVariant::Time ? vR : vL, parent ); + QTime time = QgsExpressionUtils::getTimeValue( vR.typeId() == QMetaType::QTime ? vR : vL, parent ); ENSURE_NO_EVAL_ERROR QDateTime dt = QDateTime( date, time ); return QVariant( dt ); } - else if ( mOp == boMinus && vL.type() == QVariant::Date && vR.type() == QVariant::Date ) + else if ( mOp == boMinus && vL.typeId() == QMetaType::QDate && vR.typeId() == QMetaType::QDate ) { QDate date1 = QgsExpressionUtils::getDateValue( vL, parent ); ENSURE_NO_EVAL_ERROR @@ -284,7 +284,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const ENSURE_NO_EVAL_ERROR return date1 - date2; } - else if ( mOp == boMinus && vL.type() == QVariant::Time && vR.type() == QVariant::Time ) + else if ( mOp == boMinus && vL.typeId() == QMetaType::QTime && vR.typeId() == QMetaType::QTime ) { QTime time1 = QgsExpressionUtils::getTimeValue( vL, parent ); ENSURE_NO_EVAL_ERROR @@ -292,7 +292,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const ENSURE_NO_EVAL_ERROR return time1 - time2; } - else if ( mOp == boMinus && vL.type() == QVariant::DateTime && vR.type() == QVariant::DateTime ) + else if ( mOp == boMinus && vL.typeId() == QMetaType::QDateTime && vR.typeId() == QMetaType::QDateTime ) { QDateTime datetime1 = QgsExpressionUtils::getDateTimeValue( vL, parent ); ENSURE_NO_EVAL_ERROR @@ -428,7 +428,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const return TVL_Unknown; } } - else if ( ( vL.type() == QVariant::DateTime && vR.type() == QVariant::DateTime ) ) + else if ( ( vL.typeId() == QMetaType::QDateTime && vR.typeId() == QMetaType::QDateTime ) ) { QDateTime dL = QgsExpressionUtils::getDateTimeValue( vL, parent ); ENSURE_NO_EVAL_ERROR @@ -444,7 +444,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const return compare( dR.msecsTo( dL ) ) ? TVL_True : TVL_False; } - else if ( ( vL.type() == QVariant::Date && vR.type() == QVariant::Date ) ) + else if ( ( vL.typeId() == QMetaType::QDate && vR.typeId() == QMetaType::QDate ) ) { const QDate dL = QgsExpressionUtils::getDateValue( vL, parent ); ENSURE_NO_EVAL_ERROR @@ -452,7 +452,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const ENSURE_NO_EVAL_ERROR return compare( dR.daysTo( dL ) ) ? TVL_True : TVL_False; } - else if ( ( vL.type() == QVariant::Time && vR.type() == QVariant::Time ) ) + else if ( ( vL.typeId() == QMetaType::QTime && vR.typeId() == QMetaType::QTime ) ) { const QTime dL = QgsExpressionUtils::getTimeValue( vL, parent ); ENSURE_NO_EVAL_ERROR @@ -460,7 +460,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const ENSURE_NO_EVAL_ERROR return compare( dR.msecsTo( dL ) ) ? TVL_True : TVL_False; } - else if ( ( vL.type() != QVariant::String || vR.type() != QVariant::String ) && + else if ( ( vL.typeId() != QMetaType::QString || vR.typeId() != QMetaType::QString ) && QgsExpressionUtils::isDoubleSafe( vL ) && QgsExpressionUtils::isDoubleSafe( vR ) ) { // do numeric comparison if both operators can be converted to numbers, @@ -501,7 +501,7 @@ QVariant QgsExpressionNodeBinaryOperator::evalNode( QgsExpression *parent, const { bool equal = false; if ( QgsExpressionUtils::isDoubleSafe( vL ) && QgsExpressionUtils::isDoubleSafe( vR ) && - ( vL.type() != QVariant::String || vR.type() != QVariant::String ) ) + ( vL.typeId() != QMetaType::QString || vR.typeId() != QMetaType::QString ) ) { double fL = QgsExpressionUtils::getDoubleValue( vL, parent ); ENSURE_NO_EVAL_ERROR @@ -972,7 +972,7 @@ QVariant QgsExpressionNodeInOperator::evalNode( QgsExpression *parent, const Qgs { bool equal = false; // check whether they are equal - if ( ( v1.type() != QVariant::String || v2.type() != QVariant::String ) && + if ( ( v1.typeId() != QMetaType::QString || v2.typeId() != QMetaType::QString ) && QgsExpressionUtils::isDoubleSafe( v1 ) && QgsExpressionUtils::isDoubleSafe( v2 ) ) { // do numeric comparison if both operators can be converted to numbers, @@ -1379,23 +1379,23 @@ QString QgsExpressionNodeLiteral::valueAsString() const if ( QgsVariantUtils::isNull( mValue ) ) return QStringLiteral( "NULL" ); - switch ( mValue.type() ) + switch ( mValue.typeId() ) { - case QVariant::Int: + case QMetaType::Int: return QString::number( mValue.toInt() ); - case QVariant::Double: + case QMetaType::Double: return QString::number( mValue.toDouble() ); - case QVariant::LongLong: + case QMetaType::LongLong: return QString::number( mValue.toLongLong() ); - case QVariant::String: + case QMetaType::QString: return QgsExpression::quotedString( mValue.toString() ); - case QVariant::Time: + case QMetaType::QTime: return QgsExpression::quotedString( mValue.toTime().toString( Qt::ISODate ) ); - case QVariant::Date: + case QMetaType::QDate: return QgsExpression::quotedString( mValue.toDate().toString( Qt::ISODate ) ); - case QVariant::DateTime: + case QMetaType::QDateTime: return QgsExpression::quotedString( mValue.toDateTime().toString( Qt::ISODate ) ); - case QVariant::Bool: + case QMetaType::Bool: return mValue.toBool() ? QStringLiteral( "TRUE" ) : QStringLiteral( "FALSE" ); default: return tr( "[unsupported type: %1; value: %2]" ).arg( mValue.typeName(), mValue.toString() ); @@ -2010,11 +2010,11 @@ QVariant QgsExpressionNodeIndexOperator::evalNode( QgsExpression *parent, const switch ( container.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: return QgsExpressionUtils::getMapValue( container, parent ).value( index.toString() ); - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: { const QVariantList list = QgsExpressionUtils::getListValue( container, parent ); qlonglong pos = QgsExpressionUtils::getIntValue( index, parent ); diff --git a/src/core/expression/qgsexpressionutils.cpp b/src/core/expression/qgsexpressionutils.cpp index 9b65480a707d..e0f986967d42 100644 --- a/src/core/expression/qgsexpressionutils.cpp +++ b/src/core/expression/qgsexpressionutils.cpp @@ -336,7 +336,7 @@ QString QgsExpressionUtils::getFilePathValue( const QVariant &value, const QgsEx ///@endcond -std::tuple QgsExpressionUtils::determineResultType( const QString &expression, const QgsVectorLayer *layer, QgsFeatureRequest request, QgsExpressionContext context, bool *foundFeatures ) +std::tuple QgsExpressionUtils::determineResultType( const QString &expression, const QgsVectorLayer *layer, QgsFeatureRequest request, QgsExpressionContext context, bool *foundFeatures ) { QgsExpression exp( expression ); request.setFlags( ( exp.needsGeometry() ) ? @@ -368,10 +368,10 @@ std::tuple QgsExpressionUtils::determineResultType( const Q const QVariant value = exp.evaluate( &context ); if ( !QgsVariantUtils::isNull( value ) ) { - return std::make_tuple( value.type(), value.userType() ); + return std::make_tuple( static_cast( value.userType() ), value.userType() ); } hasFeature = it.nextFeature( f ); } value = QVariant(); - return std::make_tuple( value.type(), value.userType() ); + return std::make_tuple( static_cast( value.type() ), value.userType() ); } diff --git a/src/core/expression/qgsexpressionutils.h b/src/core/expression/qgsexpressionutils.h index d26b1455145c..9fb2f6a2ef13 100644 --- a/src/core/expression/qgsexpressionutils.h +++ b/src/core/expression/qgsexpressionutils.h @@ -107,7 +107,7 @@ class CORE_EXPORT QgsExpressionUtils return feat.isValid() ? True : False; } - if ( value.type() == QVariant::Int ) + if ( value.typeId() == QMetaType::Int ) return value.toInt() != 0 ? True : False; bool ok; @@ -123,17 +123,17 @@ class CORE_EXPORT QgsExpressionUtils static inline bool isIntSafe( const QVariant &v ) { - if ( v.type() == QVariant::Int ) + if ( v.typeId() == QMetaType::Int ) return true; - if ( v.type() == QVariant::UInt ) + if ( v.typeId() == QMetaType::UInt ) return true; - if ( v.type() == QVariant::LongLong ) + if ( v.typeId() == QMetaType::LongLong ) return true; - if ( v.type() == QVariant::ULongLong ) + if ( v.typeId() == QMetaType::ULongLong ) return true; - if ( v.type() == QVariant::Double ) + if ( v.typeId() == QMetaType::Double ) return false; - if ( v.type() == QVariant::String ) + if ( v.typeId() == QMetaType::QString ) { bool ok; v.toString().toInt( &ok ); @@ -144,17 +144,17 @@ class CORE_EXPORT QgsExpressionUtils static inline bool isDoubleSafe( const QVariant &v ) { - if ( v.type() == QVariant::Double ) + if ( v.typeId() == QMetaType::Double ) return true; - if ( v.type() == QVariant::Int ) + if ( v.typeId() == QMetaType::Int ) return true; - if ( v.type() == QVariant::UInt ) + if ( v.typeId() == QMetaType::UInt ) return true; - if ( v.type() == QVariant::LongLong ) + if ( v.typeId() == QMetaType::LongLong ) return true; - if ( v.type() == QVariant::ULongLong ) + if ( v.typeId() == QMetaType::ULongLong ) return true; - if ( v.type() == QVariant::String ) + if ( v.typeId() == QMetaType::QString ) { bool ok; const double val = v.toString().toDouble( &ok ); @@ -166,9 +166,9 @@ class CORE_EXPORT QgsExpressionUtils static inline bool isDateTimeSafe( const QVariant &v ) { - return v.type() == QVariant::DateTime - || v.type() == QVariant::Date - || v.type() == QVariant::Time; + return v.typeId() == QMetaType::QDateTime + || v.typeId() == QMetaType::QDate + || v.typeId() == QMetaType::QTime; } static inline bool isIntervalSafe( const QVariant &v ) @@ -178,7 +178,7 @@ class CORE_EXPORT QgsExpressionUtils return true; } - if ( v.type() == QVariant::String ) + if ( v.typeId() == QMetaType::QString ) { return QgsInterval::fromString( v.toString() ).isValid(); } @@ -192,7 +192,7 @@ class CORE_EXPORT QgsExpressionUtils static inline bool isList( const QVariant &v ) { - return v.type() == QVariant::List || v.type() == QVariant::StringList; + return v.typeId() == QMetaType::QVariantList || v.typeId() == QMetaType::QStringList; } // implicit conversion to string @@ -210,7 +210,7 @@ class CORE_EXPORT QgsExpressionUtils */ static QByteArray getBinaryValue( const QVariant &value, QgsExpression *parent ) { - if ( value.type() != QVariant::ByteArray ) + if ( value.typeId() != QMetaType::QByteArray ) { parent->setEvalErrorString( QObject::tr( "Value is not a binary value" ) ); return QByteArray(); @@ -392,7 +392,7 @@ class CORE_EXPORT QgsExpressionUtils static QVariantList getListValue( const QVariant &value, QgsExpression *parent ) { - if ( value.type() == QVariant::List || value.type() == QVariant::StringList ) + if ( value.typeId() == QMetaType::QVariantList || value.typeId() == QMetaType::QStringList ) { return value.toList(); } @@ -405,7 +405,7 @@ class CORE_EXPORT QgsExpressionUtils static QVariantMap getMapValue( const QVariant &value, QgsExpression *parent ) { - if ( value.type() == QVariant::Map ) + if ( value.typeId() == QMetaType::QVariantMap ) { return value.toMap(); } @@ -424,12 +424,12 @@ class CORE_EXPORT QgsExpressionUtils */ static QString toLocalizedString( const QVariant &value ) { - if ( value.type() == QVariant::Int || value.type() == QVariant::UInt || value.type() == QVariant::LongLong || value.type() == QVariant::ULongLong ) + if ( value.typeId() == QMetaType::Int || value.typeId() == QMetaType::UInt || value.typeId() == QMetaType::LongLong || value.typeId() == QMetaType::ULongLong ) { bool ok; QString res; - if ( value.type() == QVariant::ULongLong ) + if ( value.typeId() == QMetaType::ULongLong ) { res = QLocale().toString( value.toULongLong( &ok ) ); } @@ -448,7 +448,7 @@ class CORE_EXPORT QgsExpressionUtils } } // Qt madness with QMetaType::Float :/ - else if ( value.type() == QVariant::Double || value.type() == static_cast( QMetaType::Float ) ) + else if ( value.typeId() == QMetaType::Double || value.typeId() == QMetaType::Float ) { bool ok; const QString strVal = value.toString(); @@ -481,7 +481,7 @@ class CORE_EXPORT QgsExpressionUtils * \param foundFeatures An optional boolean parameter that will be set when features are found. * \since QGIS 3.22 */ - static std::tuple determineResultType( const QString &expression, const QgsVectorLayer *layer, QgsFeatureRequest request = QgsFeatureRequest(), QgsExpressionContext context = QgsExpressionContext(), bool *foundFeatures = nullptr ); + static std::tuple determineResultType( const QString &expression, const QgsVectorLayer *layer, QgsFeatureRequest request = QgsFeatureRequest(), QgsExpressionContext context = QgsExpressionContext(), bool *foundFeatures = nullptr ); private: diff --git a/src/core/fieldformatter/qgscheckboxfieldformatter.cpp b/src/core/fieldformatter/qgscheckboxfieldformatter.cpp index 36e48b69ce04..ac21395d69a3 100644 --- a/src/core/fieldformatter/qgscheckboxfieldformatter.cpp +++ b/src/core/fieldformatter/qgscheckboxfieldformatter.cpp @@ -48,8 +48,8 @@ QString QgsCheckBoxFieldFormatter::representValue( QgsVectorLayer *layer, int fi bool boolValue = false; QString textValue = QgsApplication::nullRepresentation(); - const QVariant::Type fieldType = layer->fields().at( fieldIndex ).type(); - if ( fieldType == QVariant::Bool ) + const QMetaType::Type fieldType = layer->fields().at( fieldIndex ).type(); + if ( fieldType == QMetaType::Bool ) { boolValue = value.toBool(); textValue = boolValue ? QObject::tr( "true" ) : QObject::tr( "false" ); diff --git a/src/core/fieldformatter/qgsdatetimefieldformatter.cpp b/src/core/fieldformatter/qgsdatetimefieldformatter.cpp index c353e7dbcdd1..eca29a45b5b6 100644 --- a/src/core/fieldformatter/qgsdatetimefieldformatter.cpp +++ b/src/core/fieldformatter/qgsdatetimefieldformatter.cpp @@ -106,26 +106,26 @@ QString QgsDateTimeFieldFormatter::representValue( QgsVectorLayer *layer, int fi return result; } -QString QgsDateTimeFieldFormatter::defaultFormat( QVariant::Type type ) +QString QgsDateTimeFieldFormatter::defaultFormat( QMetaType::Type type ) { switch ( type ) { - case QVariant::DateTime: + case QMetaType::QDateTime: return QgsDateTimeFieldFormatter::DATETIME_FORMAT; - case QVariant::Time: + case QMetaType::QTime: return QgsDateTimeFieldFormatter::TIME_FORMAT; default: return QgsDateTimeFieldFormatter::DATE_FORMAT; } } -QString QgsDateTimeFieldFormatter::defaultDisplayFormat( QVariant::Type type ) +QString QgsDateTimeFieldFormatter::defaultDisplayFormat( QMetaType::Type type ) { switch ( type ) { - case QVariant::DateTime: + case QMetaType::QDateTime: return QgsDateTimeFieldFormatter::DATETIME_DISPLAY_FORMAT; - case QVariant::Time: + case QMetaType::QTime: return QgsDateTimeFieldFormatter::TIME_FORMAT; default: return QgsDateTimeFieldFormatter::DATE_DISPLAY_FORMAT; diff --git a/src/core/fieldformatter/qgsdatetimefieldformatter.h b/src/core/fieldformatter/qgsdatetimefieldformatter.h index 4fb8e73f944f..fd50902a81d6 100644 --- a/src/core/fieldformatter/qgsdatetimefieldformatter.h +++ b/src/core/fieldformatter/qgsdatetimefieldformatter.h @@ -52,23 +52,23 @@ class CORE_EXPORT QgsDateTimeFieldFormatter : public QgsFieldFormatter * Gets the default format in function of the type. * The type is expected to be one of * - * - QVariant::DateTime - * - QVariant::Date - * - QVariant::Time + * - QMetaType::QDateTime + * - QMetaType::QDate + * - QMetaType::QTime */ - static QString defaultFormat( QVariant::Type type ); + static QString defaultFormat( QMetaType::Type type ); /** * Gets the default display format in function of the type. * The type is expected to be one of * - * - QVariant::DateTime - * - QVariant::Date - * - QVariant::Time + * - QMetaType::QDateTime + * - QMetaType::QDate + * - QMetaType::QTime * * \since QGIS 3.30 */ - static QString defaultDisplayFormat( QVariant::Type type ); + static QString defaultDisplayFormat( QMetaType::Type type ); /** * Adjusts the date time display formats according to locale. diff --git a/src/core/fieldformatter/qgsrangefieldformatter.cpp b/src/core/fieldformatter/qgsrangefieldformatter.cpp index 4a6f9b1f1d2f..a13604bc2d3b 100644 --- a/src/core/fieldformatter/qgsrangefieldformatter.cpp +++ b/src/core/fieldformatter/qgsrangefieldformatter.cpp @@ -43,7 +43,7 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field const QgsField field = layer->fields().at( fieldIndex ); - if ( field.type() == QVariant::Double && + if ( field.type() == QMetaType::Double && config.contains( QStringLiteral( "Precision" ) ) && value.isValid( ) ) { @@ -59,7 +59,7 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field } } } - else if ( ( field.type() == QVariant::Int ) && + else if ( ( field.type() == QMetaType::Int ) && value.isValid( ) ) { bool ok; @@ -69,7 +69,7 @@ QString QgsRangeFieldFormatter::representValue( QgsVectorLayer *layer, int field result = QLocale().toString( val, 'f', 0 ); } } - else if ( ( field.type() == QVariant::LongLong ) && + else if ( ( field.type() == QMetaType::LongLong ) && value.isValid( ) ) { bool ok; diff --git a/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp b/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp index 3f014ebd0f13..5726482c0aad 100644 --- a/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp +++ b/src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp @@ -68,7 +68,7 @@ QString QgsValueRelationFieldFormatter::representValue( QgsVectorLayer *layer, i { QStringList keyList; - if ( layer->fields().at( fieldIndex ).type() == QVariant::Map ) + if ( layer->fields().at( fieldIndex ).type() == QMetaType::QVariantMap ) { //because of json it's stored as QVariantList keyList = value.toStringList(); @@ -229,14 +229,14 @@ QVariantList QgsValueRelationFieldFormatter::availableValues( const QVariantMap QStringList QgsValueRelationFieldFormatter::valueToStringList( const QVariant &value ) { QStringList checkList; - if ( value.type() == QVariant::StringList ) + if ( value.typeId() == QMetaType::QStringList ) { checkList = value.toStringList(); } else { QVariantList valuesList; - if ( value.type() == QVariant::String ) + if ( value.typeId() == QMetaType::QString ) { // This must be an array representation auto newVal { value }; @@ -272,7 +272,7 @@ QStringList QgsValueRelationFieldFormatter::valueToStringList( const QVariant &v } } } - else if ( value.type() == QVariant::List ) + else if ( value.typeId() == QMetaType::QVariantList ) { valuesList = value.toList( ); } diff --git a/src/core/geocoding/qgsgooglemapsgeocoder.cpp b/src/core/geocoding/qgsgooglemapsgeocoder.cpp index 262f871c2b14..26d1a9a45f1d 100644 --- a/src/core/geocoding/qgsgooglemapsgeocoder.cpp +++ b/src/core/geocoding/qgsgooglemapsgeocoder.cpp @@ -49,18 +49,18 @@ QgsGeocoderInterface::Flags QgsGoogleMapsGeocoder::flags() const QgsFields QgsGoogleMapsGeocoder::appendedFields() const { QgsFields fields; - fields.append( QgsField( QStringLiteral( "location_type" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "formatted_address" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "place_id" ), QVariant::String ) ); + fields.append( QgsField( QStringLiteral( "location_type" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "formatted_address" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "place_id" ), QMetaType::QString ) ); // add more? - fields.append( QgsField( QStringLiteral( "street_number" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "route" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "locality" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "administrative_area_level_2" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "administrative_area_level_1" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "country" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "postal_code" ), QVariant::String ) ); + fields.append( QgsField( QStringLiteral( "street_number" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "route" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "locality" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "administrative_area_level_2" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "administrative_area_level_1" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "country" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "postal_code" ), QMetaType::QString ) ); return fields; } diff --git a/src/core/geocoding/qgsnominatimgeocoder.cpp b/src/core/geocoding/qgsnominatimgeocoder.cpp index 445544419037..a235d25805da 100644 --- a/src/core/geocoding/qgsnominatimgeocoder.cpp +++ b/src/core/geocoding/qgsnominatimgeocoder.cpp @@ -49,19 +49,19 @@ QgsGeocoderInterface::Flags QgsNominatimGeocoder::flags() const QgsFields QgsNominatimGeocoder::appendedFields() const { QgsFields fields; - fields.append( QgsField( QStringLiteral( "osm_type" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "display_name" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "place_id" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "class" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "type" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "road" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "village" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "city_district" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "town" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "city" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "state" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "country" ), QVariant::String ) ); - fields.append( QgsField( QStringLiteral( "postcode" ), QVariant::String ) ); + fields.append( QgsField( QStringLiteral( "osm_type" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "display_name" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "place_id" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "class" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "type" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "road" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "village" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "city_district" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "town" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "city" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "state" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "country" ), QMetaType::QString ) ); + fields.append( QgsField( QStringLiteral( "postcode" ), QMetaType::QString ) ); return fields; } diff --git a/src/core/geometry/qgsbox3d.h b/src/core/geometry/qgsbox3d.h index 2615ffb707c8..dbea03f58f18 100644 --- a/src/core/geometry/qgsbox3d.h +++ b/src/core/geometry/qgsbox3d.h @@ -357,7 +357,7 @@ class CORE_EXPORT QgsBox3D * * \since QGIS 3.26 */ - void scale( double scaleFactor, const QgsPoint ¢er = QgsPoint() ) SIP_HOLDGIL; + void scale( double scaleFactor, const QgsPoint ¢er = {} ) SIP_HOLDGIL; /** * Scale the rectangle around a center coordinates. diff --git a/src/core/geometry/qgsquadrilateral.h b/src/core/geometry/qgsquadrilateral.h index 5b171736648a..19b46a06f362 100644 --- a/src/core/geometry/qgsquadrilateral.h +++ b/src/core/geometry/qgsquadrilateral.h @@ -210,6 +210,7 @@ class CORE_EXPORT QgsQuadrilateral * Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty. */ double perimeter() const SIP_HOLDGIL; + #ifdef SIP_RUN SIP_PYOBJECT __repr__(); % MethodCode diff --git a/src/core/geometry/qgswkbptr.h b/src/core/geometry/qgswkbptr.h index 1ee87a2a687d..5b1a80b9fda7 100644 --- a/src/core/geometry/qgswkbptr.h +++ b/src/core/geometry/qgswkbptr.h @@ -136,7 +136,7 @@ class CORE_EXPORT QgsWkbPtr class CORE_EXPORT QgsConstWkbPtr { - protected: + private: mutable unsigned char *mP; unsigned char *mEnd; mutable bool mEndianSwap; diff --git a/src/core/gps/qgsvectorlayergpslogger.cpp b/src/core/gps/qgsvectorlayergpslogger.cpp index ed611fb9d944..073a7dd1e9bc 100644 --- a/src/core/gps/qgsvectorlayergpslogger.cpp +++ b/src/core/gps/qgsvectorlayergpslogger.cpp @@ -295,10 +295,10 @@ QVariant QgsVectorLayerGpsLogger::timestamp( QgsVectorLayer *vlayer, int idx, co // Only string and datetime fields are supported switch ( vlayer->fields().at( idx ).type() ) { - case QVariant::String: + case QMetaType::QString: value = time.toString( Qt::DateFormat::ISODate ); break; - case QVariant::DateTime: + case QMetaType::QDateTime: value = time; break; default: diff --git a/src/core/labeling/qgspallabeling.cpp b/src/core/labeling/qgspallabeling.cpp index 630b7580b0bf..18697d8d4b90 100644 --- a/src/core/labeling/qgspallabeling.cpp +++ b/src/core/labeling/qgspallabeling.cpp @@ -2204,7 +2204,7 @@ std::unique_ptr QgsPalLayerSettings::registerFeatureWithDetails const QVariant dataDefinedOutside = mDataDefinedProperties.value( QgsPalLayerSettings::PolygonLabelOutside, context.expressionContext() ); if ( !QgsVariantUtils::isNull( dataDefinedOutside ) ) { - if ( dataDefinedOutside.type() == QVariant::String ) + if ( dataDefinedOutside.typeId() == QMetaType::QString ) { const QString value = dataDefinedOutside.toString().trimmed(); if ( value.compare( QLatin1String( "force" ), Qt::CaseInsensitive ) == 0 ) diff --git a/src/core/layout/qgslayoutitempicture.cpp b/src/core/layout/qgslayoutitempicture.cpp index 8a03dfde61f2..cc866b2516ae 100644 --- a/src/core/layout/qgslayoutitempicture.cpp +++ b/src/core/layout/qgslayoutitempicture.cpp @@ -360,7 +360,7 @@ void QgsLayoutItemPicture::refreshPicture( const QgsExpressionContext *context ) QgsMessageLog::logMessage( QStringLiteral( "%1: %2" ).arg( tr( "Picture expression eval error" ), sourceProperty.asExpression() ) ); } } - else if ( source.type() != QVariant::ByteArray ) + else if ( source.typeId() != QMetaType::QByteArray ) { source = source.toString().trimmed(); QgsDebugMsgLevel( QStringLiteral( "exprVal PictureSource:%1" ).arg( source.toString() ), 2 ); @@ -551,7 +551,7 @@ void QgsLayoutItemPicture::loadPicture( const QVariant &data ) imageData = QByteArray::fromBase64( base64, QByteArray::OmitTrailingEquals ); } - if ( imageData.type() == QVariant::ByteArray ) + if ( imageData.typeId() == QMetaType::QByteArray ) { if ( mImage.loadFromData( imageData.toByteArray() ) ) { diff --git a/src/core/pointcloud/qgspointcloudattribute.cpp b/src/core/pointcloud/qgspointcloudattribute.cpp index 8dd9d55749c5..fea364ad7f27 100644 --- a/src/core/pointcloud/qgspointcloudattribute.cpp +++ b/src/core/pointcloud/qgspointcloudattribute.cpp @@ -27,7 +27,7 @@ QgsPointCloudAttribute::QgsPointCloudAttribute( const QString &name, DataType ty updateSize(); } -QVariant::Type QgsPointCloudAttribute::variantType() const +QMetaType::Type QgsPointCloudAttribute::variantType() const { switch ( mType ) { @@ -37,16 +37,16 @@ QVariant::Type QgsPointCloudAttribute::variantType() const case DataType::UShort: case DataType::UInt32: case DataType::Int32: - return QVariant::Int; + return QMetaType::Int; case DataType::UInt64: case DataType::Int64: - return QVariant::LongLong; + return QMetaType::LongLong; case DataType::Float: case DataType::Double: - return QVariant::Double; + return QMetaType::Double; } - return QVariant::Invalid; + return QMetaType::UnknownType; } QString QgsPointCloudAttribute::displayType() const diff --git a/src/core/pointcloud/qgspointcloudattribute.h b/src/core/pointcloud/qgspointcloudattribute.h index bd38152052d7..2e15b627b768 100644 --- a/src/core/pointcloud/qgspointcloudattribute.h +++ b/src/core/pointcloud/qgspointcloudattribute.h @@ -78,7 +78,7 @@ class CORE_EXPORT QgsPointCloudAttribute * * \see type() */ - QVariant::Type variantType() const; + QMetaType::Type variantType() const; /** * Returns the type to use when displaying this field. diff --git a/src/core/processing/models/qgsprocessingmodelchildalgorithm.cpp b/src/core/processing/models/qgsprocessingmodelchildalgorithm.cpp index 4557fedc70a9..f562896f5c49 100644 --- a/src/core/processing/models/qgsprocessingmodelchildalgorithm.cpp +++ b/src/core/processing/models/qgsprocessingmodelchildalgorithm.cpp @@ -175,7 +175,7 @@ bool QgsProcessingModelChildAlgorithm::loadVariant( const QVariant &child ) mActive = map.value( QStringLiteral( "active" ) ).toBool(); mDependencies.clear(); - if ( map.value( QStringLiteral( "dependencies" ) ).type() == QVariant::StringList ) + if ( map.value( QStringLiteral( "dependencies" ) ).typeId() == QMetaType::QStringList ) { const QStringList dependencies = map.value( QStringLiteral( "dependencies" ) ).toStringList(); for ( const QString &dependency : dependencies ) diff --git a/src/core/processing/models/qgsprocessingmodeloutput.cpp b/src/core/processing/models/qgsprocessingmodeloutput.cpp index 291ba6050a48..9986827628aa 100644 --- a/src/core/processing/models/qgsprocessingmodeloutput.cpp +++ b/src/core/processing/models/qgsprocessingmodeloutput.cpp @@ -57,7 +57,7 @@ bool QgsProcessingModelOutput::loadVariant( const QVariantMap &map ) mName = map.value( QStringLiteral( "name" ) ).toString(); const QVariant defaultValue = map.value( QStringLiteral( "default_value" ) ); - if ( defaultValue.type() == QVariant::Map ) + if ( defaultValue.typeId() == QMetaType::QVariantMap ) { QVariantMap defaultMap = defaultValue.toMap(); if ( defaultMap["class"] == QLatin1String( "QgsProcessingOutputLayerDefinition" ) ) diff --git a/src/core/processing/qgsprocessingparameteraggregate.cpp b/src/core/processing/qgsprocessingparameteraggregate.cpp index 2fcf865151a2..f292ce9d7064 100644 --- a/src/core/processing/qgsprocessingparameteraggregate.cpp +++ b/src/core/processing/qgsprocessingparameteraggregate.cpp @@ -39,13 +39,13 @@ bool QgsProcessingParameterAggregate::checkValueIsAcceptable( const QVariant &in if ( !input.isValid() ) return mFlags & FlagOptional; - if ( input.type() != QVariant::List ) + if ( input.typeId() != QMetaType::QVariantList ) return false; const QVariantList inputList = input.toList(); for ( const QVariant &inputItem : inputList ) { - if ( inputItem.type() != QVariant::Map ) + if ( inputItem.typeId() != QMetaType::QVariantMap ) return false; const QVariantMap inputItemMap = inputItem.toMap(); diff --git a/src/core/processing/qgsprocessingparameterdxflayers.cpp b/src/core/processing/qgsprocessingparameterdxflayers.cpp index 0bacb0591f34..460a2a67cb46 100644 --- a/src/core/processing/qgsprocessingparameterdxflayers.cpp +++ b/src/core/processing/qgsprocessingparameterdxflayers.cpp @@ -42,7 +42,7 @@ bool QgsProcessingParameterDxfLayers::checkValueIsAcceptable( const QVariant &in return true; } - if ( input.type() == QVariant::String ) + if ( input.typeId() == QMetaType::QString ) { if ( input.toString().isEmpty() ) return mFlags & FlagOptional; @@ -53,7 +53,7 @@ bool QgsProcessingParameterDxfLayers::checkValueIsAcceptable( const QVariant &in QgsMapLayer *mapLayer = QgsProcessingUtils::mapLayerFromString( input.toString(), *context ); return mapLayer && ( mapLayer->type() == Qgis::LayerType::Vector ); } - else if ( input.type() == QVariant::List ) + else if ( input.typeId() == QMetaType::QVariantList ) { if ( input.toList().isEmpty() ) return mFlags & FlagOptional;; @@ -64,7 +64,7 @@ bool QgsProcessingParameterDxfLayers::checkValueIsAcceptable( const QVariant &in if ( qobject_cast< QgsVectorLayer * >( qvariant_cast( variantLayer ) ) ) continue; - if ( variantLayer.type() == QVariant::String ) + if ( variantLayer.typeId() == QMetaType::QString ) { if ( !context ) return true; @@ -73,7 +73,7 @@ bool QgsProcessingParameterDxfLayers::checkValueIsAcceptable( const QVariant &in if ( !mapLayer || mapLayer->type() != Qgis::LayerType::Vector ) return false; } - else if ( variantLayer.type() == QVariant::Map ) + else if ( variantLayer.typeId() == QMetaType::QVariantMap ) { const QVariantMap layerMap = variantLayer.toMap(); @@ -102,7 +102,7 @@ bool QgsProcessingParameterDxfLayers::checkValueIsAcceptable( const QVariant &in } return true; } - else if ( input.type() == QVariant::StringList ) + else if ( input.typeId() == QMetaType::QStringList ) { const auto constToStringList = input.toStringList(); if ( constToStringList.isEmpty() ) @@ -172,29 +172,29 @@ QList QgsProcessingParameterDxfLayers::parameterAsLayers layers << QgsDxfExport::DxfLayer( layer ); } - if ( layersVariant.type() == QVariant::String ) + if ( layersVariant.typeId() == QMetaType::QString ) { QgsMapLayer *mapLayer = QgsProcessingUtils::mapLayerFromString( layersVariant.toString(), context ); layers << QgsDxfExport::DxfLayer( static_cast( mapLayer ) ); } - else if ( layersVariant.type() == QVariant::List ) + else if ( layersVariant.typeId() == QMetaType::QVariantList ) { const QVariantList layersVariantList = layersVariant.toList(); for ( const QVariant &layerItem : layersVariantList ) { - if ( layerItem.type() == QVariant::Map ) + if ( layerItem.typeId() == QMetaType::QVariantMap ) { const QVariantMap layerVariantMap = layerItem.toMap(); layers << variantMapAsLayer( layerVariantMap, context ); } - else if ( layerItem.type() == QVariant::String ) + else if ( layerItem.typeId() == QMetaType::QString ) { QgsMapLayer *mapLayer = QgsProcessingUtils::mapLayerFromString( layerItem.toString(), context ); layers << QgsDxfExport::DxfLayer( static_cast( mapLayer ) ); } } } - else if ( layersVariant.type() == QVariant::StringList ) + else if ( layersVariant.typeId() == QMetaType::QStringList ) { const auto layersStringList = layersVariant.toStringList(); for ( const QString &layerItem : layersStringList ) diff --git a/src/core/processing/qgsprocessingparameterfieldmap.cpp b/src/core/processing/qgsprocessingparameterfieldmap.cpp index d6f34430c971..7c8e6a13d94c 100644 --- a/src/core/processing/qgsprocessingparameterfieldmap.cpp +++ b/src/core/processing/qgsprocessingparameterfieldmap.cpp @@ -39,13 +39,13 @@ bool QgsProcessingParameterFieldMapping::checkValueIsAcceptable( const QVariant if ( !input.isValid() ) return mFlags & FlagOptional; - if ( input.type() != QVariant::List ) + if ( input.typeId() != QMetaType::QVariantList ) return false; const QVariantList inputList = input.toList(); for ( const QVariant &inputItem : inputList ) { - if ( inputItem.type() != QVariant::Map ) + if ( inputItem.typeId() != QMetaType::QVariantMap ) return false; const QVariantMap inputItemMap = inputItem.toMap(); diff --git a/src/core/processing/qgsprocessingparametermeshdataset.cpp b/src/core/processing/qgsprocessingparametermeshdataset.cpp index aab8435f0cde..31d45bcabef7 100644 --- a/src/core/processing/qgsprocessingparametermeshdataset.cpp +++ b/src/core/processing/qgsprocessingparametermeshdataset.cpp @@ -118,7 +118,7 @@ QList QgsProcessingParameterMeshDatasetGroups::valueAsDatasetGroup( const Q if ( value.isValid() ) { - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { const QVariantList varList = value.toList(); for ( const QVariant &v : varList ) @@ -160,7 +160,7 @@ bool QgsProcessingParameterMeshDatasetGroups::valueIsAcceptable( const QVariant if ( !input.isValid() ) return allowEmpty; - if ( input.type() != QVariant::List ) + if ( input.typeId() != QMetaType::QVariantList ) { bool ok = false; input.toInt( &ok ); @@ -343,7 +343,7 @@ bool QgsProcessingParameterMeshDatasetTime::valueIsAcceptable( const QVariant &i if ( input.toDateTime().isValid() ) return true; - if ( input.type() != QVariant::Map ) + if ( input.typeId() != QMetaType::QVariantMap ) return false; const QVariantMap map = input.toMap(); @@ -362,17 +362,17 @@ bool QgsProcessingParameterMeshDatasetTime::valueIsAcceptable( const QVariant &i if ( type == QLatin1String( "dataset-time-step" ) ) { - if ( value.type() != QVariant::List ) + if ( value.typeId() != QMetaType::QVariantList ) return false; const QVariantList list = value.toList(); if ( value.toList().count() != 2 ) return false; - if ( list.at( 0 ).type() != QVariant::Int || list.at( 1 ).type() != QVariant::Int ) + if ( list.at( 0 ).typeId() != QMetaType::Int || list.at( 1 ).typeId() != QMetaType::Int ) return false; } else if ( type == QLatin1String( "defined-date-time" ) ) { - if ( value.type() != QVariant::DateTime ) + if ( value.typeId() != QMetaType::QDateTime ) return false; } else diff --git a/src/core/processing/qgsprocessingparameters.cpp b/src/core/processing/qgsprocessingparameters.cpp index 17b764dd57cd..7ee55fa812f8 100644 --- a/src/core/processing/qgsprocessingparameters.cpp +++ b/src/core/processing/qgsprocessingparameters.cpp @@ -269,7 +269,7 @@ QList< int > QgsProcessingParameters::parameterAsInts( const QgsProcessingParame { if ( val.userType() == QMetaType::type( "QgsProperty" ) ) resultList << val.value< QgsProperty >().valueAsInt( context.expressionContext(), definition->defaultValue().toInt() ); - else if ( val.type() == QVariant::List ) + else if ( val.typeId() == QMetaType::QVariantList ) { const QVariantList list = val.toList(); for ( auto it = list.constBegin(); it != list.constEnd(); ++it ) @@ -288,7 +288,7 @@ QList< int > QgsProcessingParameters::parameterAsInts( const QgsProcessingParame // check default if ( definition->defaultValue().isValid() ) { - if ( definition->defaultValue().type() == QVariant::List ) + if ( definition->defaultValue().typeId() == QMetaType::QVariantList ) { const QVariantList list = definition->defaultValue().toList(); for ( auto it = list.constBegin(); it != list.constEnd(); ++it ) @@ -324,7 +324,7 @@ QDateTime QgsProcessingParameters::parameterAsDateTime( const QgsProcessingParam val = val.value< QgsProperty >().value( context.expressionContext(), definition->defaultValue() ); QDateTime d = val.toDateTime(); - if ( !d.isValid() && val.type() == QVariant::String ) + if ( !d.isValid() && val.typeId() == QMetaType::QString ) { d = QDateTime::fromString( val.toString() ); } @@ -335,7 +335,7 @@ QDateTime QgsProcessingParameters::parameterAsDateTime( const QgsProcessingParam val = definition->defaultValue(); d = val.toDateTime(); } - if ( !d.isValid() && val.type() == QVariant::String ) + if ( !d.isValid() && val.typeId() == QMetaType::QString ) { d = QDateTime::fromString( val.toString() ); } @@ -361,7 +361,7 @@ QDate QgsProcessingParameters::parameterAsDate( const QgsProcessingParameterDefi val = val.value< QgsProperty >().value( context.expressionContext(), definition->defaultValue() ); QDate d = val.toDate(); - if ( !d.isValid() && val.type() == QVariant::String ) + if ( !d.isValid() && val.typeId() == QMetaType::QString ) { d = QDate::fromString( val.toString() ); } @@ -372,7 +372,7 @@ QDate QgsProcessingParameters::parameterAsDate( const QgsProcessingParameterDefi val = definition->defaultValue(); d = val.toDate(); } - if ( !d.isValid() && val.type() == QVariant::String ) + if ( !d.isValid() && val.typeId() == QMetaType::QString ) { d = QDate::fromString( val.toString() ); } @@ -399,12 +399,12 @@ QTime QgsProcessingParameters::parameterAsTime( const QgsProcessingParameterDefi QTime d; - if ( val.type() == QVariant::DateTime ) + if ( val.typeId() == QMetaType::QDateTime ) d = val.toDateTime().time(); else d = val.toTime(); - if ( !d.isValid() && val.type() == QVariant::String ) + if ( !d.isValid() && val.typeId() == QMetaType::QString ) { d = QTime::fromString( val.toString() ); } @@ -415,7 +415,7 @@ QTime QgsProcessingParameters::parameterAsTime( const QgsProcessingParameterDefi val = definition->defaultValue(); d = val.toTime(); } - if ( !d.isValid() && val.type() == QVariant::String ) + if ( !d.isValid() && val.typeId() == QMetaType::QString ) { d = QTime::fromString( val.toString() ); } @@ -462,13 +462,13 @@ QList QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet const QVariant val = value; if ( val.userType() == QMetaType::type( "QgsProperty" ) ) resultList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() ); - else if ( val.type() == QVariant::List ) + else if ( val.typeId() == QMetaType::QVariantList ) { const auto constToList = val.toList(); for ( const QVariant &var : constToList ) resultList << var; } - else if ( val.type() == QVariant::String ) + else if ( val.typeId() == QMetaType::QString ) { const auto constSplit = val.toString().split( ',' ); for ( const QString &var : constSplit ) @@ -484,13 +484,13 @@ QList QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet { resultList.clear(); // check default - if ( definition->defaultValue().type() == QVariant::List ) + if ( definition->defaultValue().typeId() == QMetaType::QVariantList ) { const auto constToList = definition->defaultValue().toList(); for ( const QVariant &var : constToList ) resultList << var; } - else if ( definition->defaultValue().type() == QVariant::String ) + else if ( definition->defaultValue().typeId() == QMetaType::QString ) { const auto constSplit = definition->defaultValue().toString().split( ',' ); for ( const QString &var : constSplit ) @@ -555,7 +555,7 @@ QStringList QgsProcessingParameters::parameterAsEnumStrings( const QgsProcessing std::function< void( const QVariant &var ) > processVariant; processVariant = [ &enumValues, &context, &definition, &processVariant ]( const QVariant & var ) { - if ( var.type() == QVariant::List ) + if ( var.typeId() == QMetaType::QVariantList ) { const auto constToList = var.toList(); for ( const QVariant &listVar : constToList ) @@ -563,7 +563,7 @@ QStringList QgsProcessingParameters::parameterAsEnumStrings( const QgsProcessing processVariant( listVar ); } } - else if ( var.type() == QVariant::StringList ) + else if ( var.typeId() == QMetaType::QStringList ) { const auto constToStringList = var.toStringList(); for ( const QString &s : constToStringList ) @@ -1728,7 +1728,7 @@ QVariantList QgsProcessingParameters::parameterAsMatrix( const QgsProcessingPara const QVariant val = value; if ( val.userType() == QMetaType::type( "QgsProperty" ) ) resultString = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() ); - else if ( val.type() == QVariant::List ) + else if ( val.typeId() == QMetaType::QVariantList ) return val.toList(); else resultString = val.toString(); @@ -1736,7 +1736,7 @@ QVariantList QgsProcessingParameters::parameterAsMatrix( const QgsProcessingPara if ( resultString.isEmpty() ) { // check default - if ( definition->defaultValue().type() == QVariant::List ) + if ( definition->defaultValue().typeId() == QMetaType::QVariantList ) return definition->defaultValue().toList(); else resultString = definition->defaultValue().toString(); @@ -1779,7 +1779,7 @@ QList QgsProcessingParameters::parameterAsLayerList( const QgsPro std::function< void( const QVariant &var ) > processVariant; processVariant = [ &layers, &context, &definition, flags, &processVariant]( const QVariant & var ) { - if ( var.type() == QVariant::List ) + if ( var.typeId() == QMetaType::QVariantList ) { const auto constToList = var.toList(); for ( const QVariant &listVar : constToList ) @@ -1787,7 +1787,7 @@ QList QgsProcessingParameters::parameterAsLayerList( const QgsPro processVariant( listVar ); } } - else if ( var.type() == QVariant::StringList ) + else if ( var.typeId() == QMetaType::QStringList ) { const auto constToStringList = var.toStringList(); for ( const QString &s : constToStringList ) @@ -1828,7 +1828,7 @@ QList QgsProcessingParameters::parameterAsLayerList( const QgsPro { layers << layer; } - else if ( definition->defaultValue().type() == QVariant::List ) + else if ( definition->defaultValue().typeId() == QMetaType::QVariantList ) { const auto constToList = definition->defaultValue().toList(); for ( const QVariant &var : constToList ) @@ -1862,7 +1862,7 @@ QStringList QgsProcessingParameters::parameterAsFileList( const QgsProcessingPar std::function< void( const QVariant &var ) > processVariant; processVariant = [ &files, &context, &definition, &processVariant ]( const QVariant & var ) { - if ( var.type() == QVariant::List ) + if ( var.typeId() == QMetaType::QVariantList ) { const auto constToList = var.toList(); for ( const QVariant &listVar : constToList ) @@ -1870,7 +1870,7 @@ QStringList QgsProcessingParameters::parameterAsFileList( const QgsProcessingPar processVariant( listVar ); } } - else if ( var.type() == QVariant::StringList ) + else if ( var.typeId() == QMetaType::QStringList ) { const auto constToStringList = var.toStringList(); for ( const QString &s : constToStringList ) @@ -1922,7 +1922,7 @@ QList QgsProcessingParameters::parameterAsRange( const QgsProcessingPara if ( val.userType() == QMetaType::type( "QgsProperty" ) ) resultStringList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() ); - else if ( val.type() == QVariant::List ) + else if ( val.typeId() == QMetaType::QVariantList ) { const auto constToList = val.toList(); for ( const QVariant &var : constToList ) @@ -1935,7 +1935,7 @@ QList QgsProcessingParameters::parameterAsRange( const QgsProcessingPara { resultStringList.clear(); // check default - if ( definition->defaultValue().type() == QVariant::List ) + if ( definition->defaultValue().typeId() == QMetaType::QVariantList ) { const auto constToList = definition->defaultValue().toList(); for ( const QVariant &var : constToList ) @@ -2002,13 +2002,13 @@ QStringList QgsProcessingParameters::parameterAsStrings( const QgsProcessingPara { if ( val.userType() == QMetaType::type( "QgsProperty" ) ) resultStringList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() ); - else if ( val.type() == QVariant::List ) + else if ( val.typeId() == QMetaType::QVariantList ) { const auto constToList = val.toList(); for ( const QVariant &var : constToList ) resultStringList << var.toString(); } - else if ( val.type() == QVariant::StringList ) + else if ( val.typeId() == QMetaType::QStringList ) { resultStringList = val.toStringList(); } @@ -2022,13 +2022,13 @@ QStringList QgsProcessingParameters::parameterAsStrings( const QgsProcessingPara // check default if ( definition->defaultValue().isValid() ) { - if ( definition->defaultValue().type() == QVariant::List ) + if ( definition->defaultValue().typeId() == QMetaType::QVariantList ) { const auto constToList = definition->defaultValue().toList(); for ( const QVariant &var : constToList ) resultStringList << var.toString(); } - else if ( definition->defaultValue().type() == QVariant::StringList ) + else if ( definition->defaultValue().typeId() == QMetaType::QStringList ) { resultStringList = definition->defaultValue().toStringList(); } @@ -2108,7 +2108,7 @@ QColor QgsProcessingParameters::parameterAsColor( const QgsProcessingParameterDe { val = val.value< QgsProperty >().value( context.expressionContext(), definition->defaultValue() ); } - if ( val.type() == QVariant::Color ) + if ( val.typeId() == QMetaType::QColor ) { QColor c = val.value< QColor >(); if ( const QgsProcessingParameterColor *colorParam = dynamic_cast< const QgsProcessingParameterColor * >( definition ) ) @@ -2120,7 +2120,7 @@ QColor QgsProcessingParameters::parameterAsColor( const QgsProcessingParameterDe QString colorText = parameterAsString( definition, value, context ); if ( colorText.isEmpty() && !( definition->flags() & QgsProcessingParameterDefinition::FlagOptional ) ) { - if ( definition->defaultValue().type() == QVariant::Color ) + if ( definition->defaultValue().typeId() == QMetaType::QColor ) return definition->defaultValue().value< QColor >(); else colorText = definition->defaultValue().toString(); @@ -2456,8 +2456,8 @@ bool QgsProcessingParameterDefinition::checkValueIsAcceptable( const QVariant &i if ( !input.isValid() && !mDefault.isValid() ) return mFlags & FlagOptional; - if ( ( input.type() == QVariant::String && input.toString().isEmpty() ) - || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) ) + if ( ( input.typeId() == QMetaType::QString && input.toString().isEmpty() ) + || ( !input.isValid() && mDefault.typeId() == QMetaType::QString && mDefault.toString().isEmpty() ) ) return mFlags & FlagOptional; return true; @@ -2485,7 +2485,7 @@ QVariant QgsProcessingParameterDefinition::valueAsJsonObjectPrivate( const QVari return value; // dive into map and list types and convert each value - if ( value.type() == QVariant::Type::Map ) + if ( value.typeId() == QMetaType::QVariantMap ) { const QVariantMap sourceMap = value.toMap(); QVariantMap resultMap; @@ -2495,7 +2495,7 @@ QVariant QgsProcessingParameterDefinition::valueAsJsonObjectPrivate( const QVari } return resultMap; } - else if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList ) + else if ( value.typeId() == QMetaType::QVariantList || value.typeId() == QMetaType::QStringList ) { const QVariantList sourceList = value.toList(); QVariantList resultList; @@ -2867,7 +2867,7 @@ QStringList QgsProcessingParameterDefinition::valueAsStringList( const QVariant if ( !value.isValid( ) ) return QStringList(); - if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList ) + if ( value.typeId() == QMetaType::QVariantList || value.typeId() == QMetaType::QStringList ) { const QVariantList sourceList = value.toList(); QStringList resultList; @@ -3045,7 +3045,7 @@ bool QgsProcessingParameterCrs::checkValueIsAcceptable( const QVariant &input, Q if ( qobject_cast< QgsMapLayer * >( qvariant_cast( input ) ) ) return true; - if ( input.type() != QVariant::String || input.toString().isEmpty() ) + if ( input.typeId() != QMetaType::QString || input.toString().isEmpty() ) return mFlags & FlagOptional; return true; @@ -3118,7 +3118,7 @@ bool QgsProcessingParameterMapLayer::checkValueIsAcceptable( const QVariant &inp return true; } - if ( input.type() != QVariant::String || input.toString().isEmpty() ) + if ( input.typeId() != QMetaType::QString || input.toString().isEmpty() ) return mFlags & FlagOptional; if ( !context ) @@ -3416,7 +3416,7 @@ bool QgsProcessingParameterExtent::checkValueIsAcceptable( const QVariant &input if ( qobject_cast< QgsMapLayer * >( qvariant_cast( input ) ) ) return true; - if ( input.type() != QVariant::String || input.toString().isEmpty() ) + if ( input.typeId() != QMetaType::QString || input.toString().isEmpty() ) return mFlags & FlagOptional; if ( !context ) @@ -3537,7 +3537,7 @@ bool QgsProcessingParameterPoint::checkValueIsAcceptable( const QVariant &input, return true; } - if ( input.type() == QVariant::String ) + if ( input.typeId() == QMetaType::QString ) { if ( input.toString().isEmpty() ) return mFlags & FlagOptional; @@ -3655,7 +3655,7 @@ bool QgsProcessingParameterGeometry::checkValueIsAcceptable( const QVariant &inp return anyTypeAllowed || mGeomTypes.contains( static_cast< int >( Qgis::GeometryType::Polygon ) ); } - if ( input.type() == QVariant::String ) + if ( input.typeId() == QMetaType::QString ) { if ( input.toString().isEmpty() ) return mFlags & FlagOptional; @@ -3888,7 +3888,7 @@ bool QgsProcessingParameterFile::checkValueIsAcceptable( const QVariant &input, const QString string = input.toString().trimmed(); - if ( input.type() != QVariant::String || string.isEmpty() ) + if ( input.typeId() != QMetaType::QString || string.isEmpty() ) return mFlags & FlagOptional; switch ( mBehavior ) @@ -4028,19 +4028,19 @@ bool QgsProcessingParameterMatrix::checkValueIsAcceptable( const QVariant &input if ( !input.isValid() ) return mFlags & FlagOptional; - if ( input.type() == QVariant::String ) + if ( input.typeId() == QMetaType::QString ) { if ( input.toString().isEmpty() ) return mFlags & FlagOptional; return true; } - else if ( input.type() == QVariant::List ) + else if ( input.typeId() == QMetaType::QVariantList ) { if ( input.toList().isEmpty() ) return mFlags & FlagOptional; return true; } - else if ( input.type() == QVariant::Double || input.type() == QVariant::Int ) + else if ( input.typeId() == QMetaType::Double || input.typeId() == QMetaType::Int ) { return true; } @@ -4168,7 +4168,7 @@ bool QgsProcessingParameterMultipleLayers::checkValueIsAcceptable( const QVarian } } - if ( input.type() == QVariant::String ) + if ( input.typeId() == QMetaType::QString ) { if ( input.toString().isEmpty() ) return mFlags & FlagOptional; @@ -4184,7 +4184,7 @@ bool QgsProcessingParameterMultipleLayers::checkValueIsAcceptable( const QVarian else return true; } - else if ( input.type() == QVariant::List ) + else if ( input.typeId() == QMetaType::QVariantList ) { if ( input.toList().count() < mMinimumNumberInputs ) return mFlags & FlagOptional; @@ -4209,7 +4209,7 @@ bool QgsProcessingParameterMultipleLayers::checkValueIsAcceptable( const QVarian } return true; } - else if ( input.type() == QVariant::StringList ) + else if ( input.typeId() == QMetaType::QStringList ) { if ( input.toStringList().count() < mMinimumNumberInputs ) return mFlags & FlagOptional; @@ -4245,14 +4245,14 @@ QString QgsProcessingParameterMultipleLayers::valueAsPythonString( const QVarian if ( mLayerType == QgsProcessing::TypeFile ) { QStringList parts; - if ( value.type() == QVariant::StringList ) + if ( value.typeId() == QMetaType::QStringList ) { const QStringList list = value.toStringList(); parts.reserve( list.count() ); for ( const QString &v : list ) parts << QgsProcessingUtils::stringToPythonLiteral( v ); } - else if ( value.type() == QVariant::List ) + else if ( value.typeId() == QMetaType::QVariantList ) { const QVariantList list = value.toList(); parts.reserve( list.count() ); @@ -4312,7 +4312,7 @@ QString QgsProcessingParameterMultipleLayers::asScriptCode() const break; } code += ' '; - if ( mDefault.type() == QVariant::List ) + if ( mDefault.typeId() == QMetaType::QVariantList ) { QStringList parts; const auto constToList = mDefault.toList(); @@ -4322,7 +4322,7 @@ QString QgsProcessingParameterMultipleLayers::asScriptCode() const } code += parts.join( ',' ); } - else if ( mDefault.type() == QVariant::StringList ) + else if ( mDefault.typeId() == QMetaType::QStringList ) { code += mDefault.toStringList().join( ',' ); } @@ -4614,7 +4614,7 @@ bool QgsProcessingParameterRange::checkValueIsAcceptable( const QVariant &input, return true; } - if ( input.type() == QVariant::String ) + if ( input.typeId() == QMetaType::QString ) { const QStringList list = input.toString().split( ',' ); if ( list.count() != 2 ) @@ -4627,7 +4627,7 @@ bool QgsProcessingParameterRange::checkValueIsAcceptable( const QVariant &input, return mFlags & FlagOptional; return true; } - else if ( input.type() == QVariant::List ) + else if ( input.typeId() == QMetaType::QVariantList ) { if ( input.toList().count() != 2 ) return mFlags & FlagOptional; @@ -4740,7 +4740,7 @@ bool QgsProcessingParameterRasterLayer::checkValueIsAcceptable( const QVariant & if ( qobject_cast< QgsRasterLayer * >( qvariant_cast( input ) ) ) return true; - if ( input.type() != QVariant::String || input.toString().isEmpty() ) + if ( input.typeId() != QMetaType::QString || input.toString().isEmpty() ) return mFlags & FlagOptional; if ( !context ) @@ -4823,7 +4823,7 @@ bool QgsProcessingParameterEnum::checkValueIsAcceptable( const QVariant &value, if ( mUsesStaticStrings ) { - if ( input.type() == QVariant::List ) + if ( input.typeId() == QMetaType::QVariantList ) { if ( !mAllowMultiple ) return false; @@ -4840,7 +4840,7 @@ bool QgsProcessingParameterEnum::checkValueIsAcceptable( const QVariant &value, return true; } - else if ( input.type() == QVariant::StringList ) + else if ( input.typeId() == QMetaType::QStringList ) { if ( !mAllowMultiple ) return false; @@ -4860,7 +4860,7 @@ bool QgsProcessingParameterEnum::checkValueIsAcceptable( const QVariant &value, } return true; } - else if ( input.type() == QVariant::String ) + else if ( input.typeId() == QMetaType::QString ) { const QStringList parts = input.toString().split( ',' ); if ( parts.count() > 1 && !mAllowMultiple ) @@ -4877,7 +4877,7 @@ bool QgsProcessingParameterEnum::checkValueIsAcceptable( const QVariant &value, } else { - if ( input.type() == QVariant::List ) + if ( input.typeId() == QMetaType::QVariantList ) { if ( !mAllowMultiple ) return false; @@ -4898,7 +4898,7 @@ bool QgsProcessingParameterEnum::checkValueIsAcceptable( const QVariant &value, return true; } - else if ( input.type() == QVariant::String ) + else if ( input.typeId() == QMetaType::QString ) { const QStringList parts = input.toString().split( ',' ); if ( parts.count() > 1 && !mAllowMultiple ) @@ -4916,7 +4916,7 @@ bool QgsProcessingParameterEnum::checkValueIsAcceptable( const QVariant &value, } return true; } - else if ( input.type() == QVariant::Int || input.type() == QVariant::Double ) + else if ( input.typeId() == QMetaType::Int || input.typeId() == QMetaType::Double ) { bool ok = false; const int res = input.toInt( &ok ); @@ -4940,7 +4940,7 @@ QString QgsProcessingParameterEnum::valueAsPythonString( const QVariant &value, if ( mUsesStaticStrings ) { - if ( value.type() == QVariant::List || value.type() == QVariant::StringList ) + if ( value.typeId() == QMetaType::QVariantList || value.typeId() == QMetaType::QStringList ) { QStringList parts; const QStringList constList = value.toStringList(); @@ -4950,7 +4950,7 @@ QString QgsProcessingParameterEnum::valueAsPythonString( const QVariant &value, } return parts.join( ',' ).prepend( '[' ).append( ']' ); } - else if ( value.type() == QVariant::String ) + else if ( value.typeId() == QMetaType::QString ) { QStringList parts; const QStringList constList = value.toString().split( ',' ); @@ -4968,7 +4968,7 @@ QString QgsProcessingParameterEnum::valueAsPythonString( const QVariant &value, } else { - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { QStringList parts; const auto constToList = value.toList(); @@ -4978,7 +4978,7 @@ QString QgsProcessingParameterEnum::valueAsPythonString( const QVariant &value, } return parts.join( ',' ).prepend( '[' ).append( ']' ); } - else if ( value.type() == QVariant::String ) + else if ( value.typeId() == QMetaType::QString ) { const QStringList parts = value.toString().split( ',' ); if ( parts.count() > 1 ) @@ -5005,7 +5005,7 @@ QString QgsProcessingParameterEnum::valueAsPythonComment( const QVariant &value, } else { - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { QStringList parts; const QVariantList toList = value.toList(); @@ -5016,7 +5016,7 @@ QString QgsProcessingParameterEnum::valueAsPythonComment( const QVariant &value, } return parts.join( ',' ); } - else if ( value.type() == QVariant::String ) + else if ( value.typeId() == QMetaType::QString ) { const QStringList parts = value.toString().split( ',' ); QStringList comments; @@ -5465,7 +5465,7 @@ bool QgsProcessingParameterVectorLayer::checkValueIsAcceptable( const QVariant & if ( qobject_cast< QgsVectorLayer * >( qvariant_cast( var ) ) ) return true; - if ( var.type() != QVariant::String || var.toString().isEmpty() ) + if ( var.typeId() != QMetaType::QString || var.toString().isEmpty() ) return mFlags & FlagOptional; if ( !context ) @@ -5612,7 +5612,7 @@ bool QgsProcessingParameterMeshLayer::checkValueIsAcceptable( const QVariant &v, if ( qobject_cast< QgsMeshLayer * >( qvariant_cast( var ) ) ) return true; - if ( var.type() != QVariant::String || var.toString().isEmpty() ) + if ( var.typeId() != QMetaType::QString || var.toString().isEmpty() ) return mFlags & FlagOptional; if ( !context ) @@ -5689,7 +5689,7 @@ bool QgsProcessingParameterField::checkValueIsAcceptable( const QVariant &input, return true; } - if ( input.type() == QVariant::List || input.type() == QVariant::StringList ) + if ( input.typeId() == QMetaType::QVariantList || input.typeId() == QMetaType::QStringList ) { if ( !mAllowMultiple ) return false; @@ -5697,7 +5697,7 @@ bool QgsProcessingParameterField::checkValueIsAcceptable( const QVariant &input, if ( input.toList().isEmpty() && !( mFlags & FlagOptional ) ) return false; } - else if ( input.type() == QVariant::String ) + else if ( input.typeId() == QMetaType::QString ) { if ( input.toString().isEmpty() ) return mFlags & FlagOptional; @@ -5722,7 +5722,7 @@ QString QgsProcessingParameterField::valueAsPythonString( const QVariant &value, if ( value.userType() == QMetaType::type( "QgsProperty" ) ) return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() ); - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { QStringList parts; const auto constToList = value.toList(); @@ -5732,7 +5732,7 @@ QString QgsProcessingParameterField::valueAsPythonString( const QVariant &value, } return parts.join( ',' ).prepend( '[' ).append( ']' ); } - else if ( value.type() == QVariant::StringList ) + else if ( value.typeId() == QMetaType::QStringList ) { QStringList parts; const auto constToStringList = value.toStringList(); @@ -5998,7 +5998,7 @@ bool QgsProcessingParameterFeatureSource::checkValueIsAcceptable( const QVariant return true; } - if ( var.type() != QVariant::String || var.toString().isEmpty() ) + if ( var.typeId() != QMetaType::QString || var.toString().isEmpty() ) return mFlags & FlagOptional; if ( !context ) @@ -6273,7 +6273,7 @@ bool QgsProcessingParameterFeatureSink::checkValueIsAcceptable( const QVariant & } } - if ( var.type() != QVariant::String ) + if ( var.typeId() != QMetaType::QString ) return false; if ( var.toString().isEmpty() ) @@ -6557,7 +6557,7 @@ bool QgsProcessingParameterRasterDestination::checkValueIsAcceptable( const QVar } } - if ( var.type() != QVariant::String ) + if ( var.typeId() != QMetaType::QString ) return false; if ( var.toString().isEmpty() ) @@ -6681,7 +6681,7 @@ bool QgsProcessingParameterFileDestination::checkValueIsAcceptable( const QVaria } } - if ( var.type() != QVariant::String ) + if ( var.typeId() != QMetaType::QString ) return false; if ( var.toString().isEmpty() ) @@ -6828,7 +6828,7 @@ bool QgsProcessingParameterFolderDestination::checkValueIsAcceptable( const QVar } } - if ( var.type() != QVariant::String ) + if ( var.typeId() != QMetaType::QString ) return false; if ( var.toString().isEmpty() ) @@ -6982,7 +6982,7 @@ bool QgsProcessingParameterVectorDestination::checkValueIsAcceptable( const QVar } } - if ( var.type() != QVariant::String ) + if ( var.typeId() != QMetaType::QString ) return false; if ( var.toString().isEmpty() ) @@ -7222,7 +7222,7 @@ bool QgsProcessingParameterBand::checkValueIsAcceptable( const QVariant &input, return true; } - if ( input.type() == QVariant::List || input.type() == QVariant::StringList ) + if ( input.typeId() == QMetaType::QVariantList || input.typeId() == QMetaType::QStringList ) { if ( !mAllowMultiple ) return false; @@ -7259,7 +7259,7 @@ QString QgsProcessingParameterBand::valueAsPythonString( const QVariant &value, if ( value.userType() == QMetaType::type( "QgsProperty" ) ) return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() ); - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { QStringList parts; const QVariantList values = value.toList(); @@ -7269,7 +7269,7 @@ QString QgsProcessingParameterBand::valueAsPythonString( const QVariant &value, } return parts.join( ',' ).prepend( '[' ).append( ']' ); } - else if ( value.type() == QVariant::StringList ) + else if ( value.typeId() == QMetaType::QStringList ) { QStringList parts; const QStringList values = value.toStringList(); @@ -7854,7 +7854,7 @@ bool QgsProcessingParameterColor::checkValueIsAcceptable( const QVariant &input, if ( !input.isValid() ) return mFlags & FlagOptional; - if ( input.type() == QVariant::Color ) + if ( input.typeId() == QMetaType::QColor ) { return true; } @@ -7863,7 +7863,7 @@ bool QgsProcessingParameterColor::checkValueIsAcceptable( const QVariant &input, return true; } - if ( input.type() != QVariant::String || input.toString().isEmpty() ) + if ( input.typeId() != QMetaType::QString || input.toString().isEmpty() ) return mFlags & FlagOptional; bool containsAlpha = false; @@ -8068,8 +8068,8 @@ bool QgsProcessingParameterMapTheme::checkValueIsAcceptable( const QVariant &inp if ( !input.isValid() && !mDefault.isValid() ) return mFlags & FlagOptional; - if ( ( input.type() == QVariant::String && input.toString().isEmpty() ) - || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) ) + if ( ( input.typeId() == QMetaType::QString && input.toString().isEmpty() ) + || ( !input.isValid() && mDefault.typeId() == QMetaType::QString && mDefault.toString().isEmpty() ) ) return mFlags & FlagOptional; return true; @@ -8183,13 +8183,13 @@ bool QgsProcessingParameterDateTime::checkValueIsAcceptable( const QVariant &val return true; } - if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String ) + if ( input.typeId() != QMetaType::QDateTime && input.typeId() != QMetaType::QDate && input.typeId() != QMetaType::QTime && input.typeId() != QMetaType::QString ) return false; - if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType == Time ) + if ( ( input.typeId() == QMetaType::QDateTime || input.typeId() == QMetaType::QDate ) && mDataType == Time ) return false; - if ( input.type() == QVariant::String ) + if ( input.typeId() == QMetaType::QString ) { const QString s = input.toString(); if ( s.isEmpty() ) @@ -8225,7 +8225,7 @@ QString QgsProcessingParameterDateTime::valueAsPythonString( const QVariant &val if ( value.userType() == QMetaType::type( "QgsProperty" ) ) return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() ); - if ( value.type() == QVariant::DateTime ) + if ( value.typeId() == QMetaType::QDateTime ) { const QDateTime dt = value.toDateTime(); if ( !dt.isValid() ) @@ -8238,7 +8238,7 @@ QString QgsProcessingParameterDateTime::valueAsPythonString( const QVariant &val .arg( dt.time().minute() ) .arg( dt.time().second() ); } - else if ( value.type() == QVariant::Date ) + else if ( value.typeId() == QMetaType::QDate ) { const QDate dt = value.toDate(); if ( !dt.isValid() ) @@ -8248,7 +8248,7 @@ QString QgsProcessingParameterDateTime::valueAsPythonString( const QVariant &val .arg( dt.month() ) .arg( dt.day() ); } - else if ( value.type() == QVariant::Time ) + else if ( value.typeId() == QMetaType::QTime ) { const QTime dt = value.toTime(); if ( !dt.isValid() ) @@ -8384,8 +8384,8 @@ bool QgsProcessingParameterProviderConnection::checkValueIsAcceptable( const QVa if ( !input.isValid() && !mDefault.isValid() ) return mFlags & FlagOptional; - if ( ( input.type() == QVariant::String && input.toString().isEmpty() ) - || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) ) + if ( ( input.typeId() == QMetaType::QString && input.toString().isEmpty() ) + || ( !input.isValid() && mDefault.typeId() == QMetaType::QString && mDefault.toString().isEmpty() ) ) return mFlags & FlagOptional; return true; @@ -8499,8 +8499,8 @@ bool QgsProcessingParameterDatabaseSchema::checkValueIsAcceptable( const QVarian if ( !input.isValid() && !mDefault.isValid() ) return mFlags & FlagOptional; - if ( ( input.type() == QVariant::String && input.toString().isEmpty() ) - || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) ) + if ( ( input.typeId() == QMetaType::QString && input.toString().isEmpty() ) + || ( !input.isValid() && mDefault.typeId() == QMetaType::QString && mDefault.toString().isEmpty() ) ) return mFlags & FlagOptional; return true; @@ -8633,8 +8633,8 @@ bool QgsProcessingParameterDatabaseTable::checkValueIsAcceptable( const QVariant if ( !input.isValid() && !mDefault.isValid() ) return mFlags & FlagOptional; - if ( ( input.type() == QVariant::String && input.toString().isEmpty() ) - || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) ) + if ( ( input.typeId() == QMetaType::QString && input.toString().isEmpty() ) + || ( !input.isValid() && mDefault.typeId() == QMetaType::QString && mDefault.toString().isEmpty() ) ) return mFlags & FlagOptional; return true; @@ -8810,7 +8810,7 @@ bool QgsProcessingParameterPointCloudLayer::checkValueIsAcceptable( const QVaria if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast( var ) ) ) return true; - if ( var.type() != QVariant::String || var.toString().isEmpty() ) + if ( var.typeId() != QMetaType::QString || var.toString().isEmpty() ) return mFlags & FlagOptional; if ( !context ) @@ -8899,7 +8899,7 @@ bool QgsProcessingParameterAnnotationLayer::checkValueIsAcceptable( const QVaria if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast( var ) ) ) return true; - if ( var.type() != QVariant::String || var.toString().isEmpty() ) + if ( var.typeId() != QMetaType::QString || var.toString().isEmpty() ) return mFlags & FlagOptional; if ( !context ) @@ -8980,7 +8980,7 @@ bool QgsProcessingParameterPointCloudDestination::checkValueIsAcceptable( const } } - if ( var.type() != QVariant::String ) + if ( var.typeId() != QMetaType::QString ) return false; if ( var.toString().isEmpty() ) @@ -9094,7 +9094,7 @@ bool QgsProcessingParameterPointCloudAttribute::checkValueIsAcceptable( const QV return true; } - if ( input.type() == QVariant::List || input.type() == QVariant::StringList ) + if ( input.typeId() == QMetaType::QVariantList || input.typeId() == QMetaType::QStringList ) { if ( !mAllowMultiple ) return false; @@ -9102,7 +9102,7 @@ bool QgsProcessingParameterPointCloudAttribute::checkValueIsAcceptable( const QV if ( input.toList().isEmpty() && !( mFlags & FlagOptional ) ) return false; } - else if ( input.type() == QVariant::String ) + else if ( input.typeId() == QMetaType::QString ) { if ( input.toString().isEmpty() ) return mFlags & FlagOptional; @@ -9127,7 +9127,7 @@ QString QgsProcessingParameterPointCloudAttribute::valueAsPythonString( const QV if ( value.userType() == QMetaType::type( "QgsProperty" ) ) return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() ); - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { QStringList parts; const auto constToList = value.toList(); @@ -9137,7 +9137,7 @@ QString QgsProcessingParameterPointCloudAttribute::valueAsPythonString( const QV } return parts.join( ',' ).prepend( '[' ).append( ']' ); } - else if ( value.type() == QVariant::StringList ) + else if ( value.typeId() == QMetaType::QStringList ) { QStringList parts; const auto constToStringList = value.toStringList(); @@ -9327,7 +9327,7 @@ bool QgsProcessingParameterVectorTileDestination::checkValueIsAcceptable( const } } - if ( var.type() != QVariant::String ) + if ( var.typeId() != QMetaType::QString ) return false; if ( var.toString().isEmpty() ) diff --git a/src/core/processing/qgsprocessingparametertininputlayers.cpp b/src/core/processing/qgsprocessingparametertininputlayers.cpp index ba951cd98cc3..dea6c971b982 100644 --- a/src/core/processing/qgsprocessingparametertininputlayers.cpp +++ b/src/core/processing/qgsprocessingparametertininputlayers.cpp @@ -32,7 +32,7 @@ QString QgsProcessingParameterTinInputLayers::type() const bool QgsProcessingParameterTinInputLayers::checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context ) const { - if ( input.type() != QVariant::List ) + if ( input.typeId() != QMetaType::QVariantList ) return false; const QVariantList variantLayers = input.toList(); @@ -42,7 +42,7 @@ bool QgsProcessingParameterTinInputLayers::checkValueIsAcceptable( const QVarian for ( const QVariant &variantLayer : variantLayers ) { - if ( variantLayer.type() != QVariant::Map ) + if ( variantLayer.typeId() != QMetaType::QVariantMap ) return false; const QVariantMap layerMap = variantLayer.toMap(); diff --git a/src/core/processing/qgsprocessingparametervectortilewriterlayers.cpp b/src/core/processing/qgsprocessingparametervectortilewriterlayers.cpp index 9a27e485db7b..a91962a4ca45 100644 --- a/src/core/processing/qgsprocessingparametervectortilewriterlayers.cpp +++ b/src/core/processing/qgsprocessingparametervectortilewriterlayers.cpp @@ -38,13 +38,13 @@ bool QgsProcessingParameterVectorTileWriterLayers::checkValueIsAcceptable( const if ( !input.isValid() ) return mFlags & FlagOptional; - if ( input.type() != QVariant::List ) + if ( input.typeId() != QMetaType::QVariantList ) return false; const QVariantList inputList = input.toList(); for ( const QVariant &inputItem : inputList ) { - if ( inputItem.type() != QVariant::Map ) + if ( inputItem.typeId() != QMetaType::QVariantMap ) return false; QVariantMap inputItemMap = inputItem.toMap(); diff --git a/src/core/processing/qgsprocessingutils.cpp b/src/core/processing/qgsprocessingutils.cpp index f00301f15f60..6413418c11da 100644 --- a/src/core/processing/qgsprocessingutils.cpp +++ b/src/core/processing/qgsprocessingutils.cpp @@ -722,21 +722,21 @@ QString QgsProcessingUtils::variantToPythonLiteral( const QVariant &value ) switch ( value.type() ) { - case QVariant::Bool: + case QMetaType::Bool: return value.toBool() ? QStringLiteral( "True" ) : QStringLiteral( "False" ); - case QVariant::Double: + case QMetaType::Double: return QString::number( value.toDouble() ); - case QVariant::Int: - case QVariant::UInt: + case QMetaType::Int: + case QMetaType::UInt: return QString::number( value.toInt() ); - case QVariant::LongLong: - case QVariant::ULongLong: + case QMetaType::LongLong: + case QMetaType::ULongLong: return QString::number( value.toLongLong() ); - case QVariant::List: + case QMetaType::QVariantList: { QStringList parts; const QVariantList vl = value.toList(); @@ -747,7 +747,7 @@ QString QgsProcessingUtils::variantToPythonLiteral( const QVariant &value ) return parts.join( ',' ).prepend( '[' ).append( ']' ); } - case QVariant::Map: + case QMetaType::QVariantMap: { const QVariantMap map = value.toMap(); QStringList parts; @@ -759,7 +759,7 @@ QString QgsProcessingUtils::variantToPythonLiteral( const QVariant &value ) return parts.join( ',' ).prepend( '{' ).append( '}' ); } - case QVariant::DateTime: + case QMetaType::QDateTime: { const QDateTime dateTime = value.toDateTime(); return QStringLiteral( "QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ) @@ -1494,11 +1494,11 @@ QVariantMap QgsProcessingUtils::removePointerValuesFromMap( const QVariantMap &m QVariantMap res; for ( auto it = map.constBegin(); it != map.constEnd(); ++it ) { - if ( it->type() == QVariant::Map ) + if ( it->typeId() == QMetaType::QVariantMap ) { res.insert( it.key(), removePointerValuesFromMap( it.value().toMap() ) ); } - else if ( it->type() == QVariant::List ) + else if ( it->typeId() == QMetaType::QVariantList ) { QVariantList dest; const QVariantList source = it.value().toList(); @@ -1523,7 +1523,7 @@ QVariantMap QgsProcessingUtils::preprocessQgisProcessParameters( const QVariantM ok = true; for ( auto it = parameters.constBegin(); it != parameters.constEnd(); ++it ) { - if ( it.value().type() == QVariant::Map ) + if ( it.value().typeId() == QMetaType::QVariantMap ) { const QVariantMap value = it.value().toMap(); if ( value.value( QStringLiteral( "type" ) ).toString() == QLatin1String( "data_defined" ) ) @@ -1549,7 +1549,7 @@ QVariantMap QgsProcessingUtils::preprocessQgisProcessParameters( const QVariantM output.insert( it.key(), it.value() ); } } - else if ( it.value().type() == QVariant::String ) + else if ( it.value().typeId() == QMetaType::QString ) { const QString stringValue = it.value().toString(); diff --git a/src/core/project/qgsproject.cpp b/src/core/project/qgsproject.cpp index 8914458dbfe0..365ad345392d 100644 --- a/src/core/project/qgsproject.cpp +++ b/src/core/project/qgsproject.cpp @@ -3341,7 +3341,7 @@ QStringList QgsProject::readListEntry( const QString &scope, { value = property->value(); - const bool valid = QVariant::StringList == value.type(); + const bool valid = QMetaType::QStringList == value.userType(); if ( ok ) *ok = valid; @@ -3372,7 +3372,7 @@ QString QgsProject::readEntry( const QString &scope, { value = property->value(); - const bool valid = value.canConvert( QVariant::String ); + const bool valid = value.canConvert( QMetaType::QString ); if ( ok ) *ok = valid; @@ -3399,7 +3399,7 @@ int QgsProject::readNumEntry( const QString &scope, const QString &key, int def, value = property->value(); } - const bool valid = value.canConvert( QVariant::Int ); + const bool valid = value.canConvert( QMetaType::Int ); if ( ok ) { @@ -3425,7 +3425,7 @@ double QgsProject::readDoubleEntry( const QString &scope, const QString &key, { const QVariant value = property->value(); - const bool valid = value.canConvert( QVariant::Double ); + const bool valid = value.canConvert( QMetaType::Double ); if ( ok ) *ok = valid; @@ -3449,7 +3449,7 @@ bool QgsProject::readBoolEntry( const QString &scope, const QString &key, bool d { const QVariant value = property->value(); - const bool valid = value.canConvert( QVariant::Bool ); + const bool valid = value.canConvert( QMetaType::Bool ); if ( ok ) *ok = valid; diff --git a/src/core/project/qgsprojectproperty.cpp b/src/core/project/qgsprojectproperty.cpp index aa5515d11927..75602980057d 100644 --- a/src/core/project/qgsprojectproperty.cpp +++ b/src/core/project/qgsprojectproperty.cpp @@ -35,7 +35,7 @@ void QgsProjectPropertyValue::dump( int tabs ) const QString tabString; tabString.fill( '\t', tabs ); - if ( QVariant::StringList == mValue.type() ) + if ( QMetaType::QStringList == mValue.userType() ) { const QStringList sl = mValue.toStringList(); @@ -71,7 +71,7 @@ bool QgsProjectPropertyValue::readXml( const QDomNode &keyNode ) mValue.clear(); // get the type associated with the value first - QVariant::Type type = QVariant::nameToType( typeString.toLocal8Bit().constData() ); + QMetaType::Type type = static_cast( QMetaType::fromName( typeString.toLocal8Bit().constData() ).id() ); // This huge switch is left-over from an earlier incarnation of // QgsProject where there was a fine level of granularity for value @@ -82,23 +82,23 @@ bool QgsProjectPropertyValue::readXml( const QDomNode &keyNode ) switch ( type ) { - case QVariant::Invalid: + case QMetaType::UnknownType: QgsDebugError( QStringLiteral( "invalid value type %1 .. " ).arg( typeString ) ); return false; - case QVariant::Map: - QgsDebugError( QStringLiteral( "no support for QVariant::Map" ) ); + case QMetaType::QVariantMap: + QgsDebugError( QStringLiteral( "no support for QMetaType::QVariantMap" ) ); return false; - case QVariant::List: - QgsDebugError( QStringLiteral( "no support for QVariant::List" ) ); + case QMetaType::QVariantList: + QgsDebugError( QStringLiteral( "no support for QMetaType::QVariantList" ) ); return false; - case QVariant::String: + case QMetaType::QString: mValue = subkeyElement.text(); // no translating necessary break; - case QVariant::StringList: + case QMetaType::QStringList: { int i = 0; QDomNodeList values = keyNode.childNodes(); @@ -125,96 +125,96 @@ bool QgsProjectPropertyValue::readXml( const QDomNode &keyNode ) break; } - case QVariant::Font: - QgsDebugError( QStringLiteral( "no support for QVariant::Font" ) ); + case QMetaType::QFont: + QgsDebugError( QStringLiteral( "no support for QMetaType::QFont" ) ); return false; - case QVariant::Pixmap: - QgsDebugError( QStringLiteral( "no support for QVariant::Pixmap" ) ); + case QMetaType::QPixmap: + QgsDebugError( QStringLiteral( "no support for QMetaType::QPixmap" ) ); return false; - case QVariant::Brush: - QgsDebugError( QStringLiteral( "no support for QVariant::Brush" ) ); + case QMetaType::QBrush: + QgsDebugError( QStringLiteral( "no support for QMetaType::QBrush" ) ); return false; - case QVariant::Rect: - QgsDebugError( QStringLiteral( "no support for QVariant::Rect" ) ); + case QMetaType::QRect: + QgsDebugError( QStringLiteral( "no support for QMetaType::QRect" ) ); return false; - case QVariant::Size: - QgsDebugError( QStringLiteral( "no support for QVariant::Size" ) ); + case QMetaType::QSize: + QgsDebugError( QStringLiteral( "no support for QMetaType::QSize" ) ); return false; - case QVariant::Color: - QgsDebugError( QStringLiteral( "no support for QVariant::Color" ) ); + case QMetaType::QColor: + QgsDebugError( QStringLiteral( "no support for QMetaType::QColor" ) ); return false; - case QVariant::Palette: - QgsDebugError( QStringLiteral( "no support for QVariant::Palette" ) ); + case QMetaType::QPalette: + QgsDebugError( QStringLiteral( "no support for QMetaType::QPalette" ) ); return false; - case QVariant::Point: - QgsDebugError( QStringLiteral( "no support for QVariant::Point" ) ); + case QMetaType::QPoint: + QgsDebugError( QStringLiteral( "no support for QMetaType::QPoint" ) ); return false; - case QVariant::Image: - QgsDebugError( QStringLiteral( "no support for QVariant::Image" ) ); + case QMetaType::QImage: + QgsDebugError( QStringLiteral( "no support for QMetaType::QImage" ) ); return false; - case QVariant::Int: + case QMetaType::Int: mValue = QVariant( subkeyElement.text() ).toInt(); break; - case QVariant::UInt: + case QMetaType::UInt: mValue = QVariant( subkeyElement.text() ).toUInt(); break; - case QVariant::Bool: + case QMetaType::Bool: mValue = QVariant( subkeyElement.text() ).toBool(); break; - case QVariant::Double: + case QMetaType::Double: mValue = QVariant( subkeyElement.text() ).toDouble(); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: mValue = QVariant( subkeyElement.text() ).toByteArray(); break; - case QVariant::Polygon: - QgsDebugError( QStringLiteral( "no support for QVariant::Polygon" ) ); + case QMetaType::QPolygon: + QgsDebugError( QStringLiteral( "no support for QMetaType::QPolygon" ) ); return false; - case QVariant::Region: - QgsDebugError( QStringLiteral( "no support for QVariant::Region" ) ); + case QMetaType::QRegion: + QgsDebugError( QStringLiteral( "no support for QMetaType::QRegion" ) ); return false; - case QVariant::Bitmap: - QgsDebugError( QStringLiteral( "no support for QVariant::Bitmap" ) ); + case QMetaType::QBitmap: + QgsDebugError( QStringLiteral( "no support for QMetaType::QBitmap" ) ); return false; - case QVariant::Cursor: - QgsDebugError( QStringLiteral( "no support for QVariant::Cursor" ) ); + case QMetaType::QCursor: + QgsDebugError( QStringLiteral( "no support for QMetaType::QCursor" ) ); return false; - case QVariant::BitArray : - QgsDebugError( QStringLiteral( "no support for QVariant::BitArray" ) ); + case QMetaType::QBitArray : + QgsDebugError( QStringLiteral( "no support for QMetaType::QBitArray" ) ); return false; - case QVariant::KeySequence : - QgsDebugError( QStringLiteral( "no support for QVariant::KeySequence" ) ); + case QMetaType::QKeySequence : + QgsDebugError( QStringLiteral( "no support for QMetaType::QKeySequence" ) ); return false; - case QVariant::Pen : - QgsDebugError( QStringLiteral( "no support for QVariant::Pen" ) ); + case QMetaType::QPen : + QgsDebugError( QStringLiteral( "no support for QMetaType::QPen" ) ); return false; #if 0 // Currently unsupported variant types - case QVariant::LongLong : + case QMetaType::LongLong : value_ = QVariant( subkeyElement.text() ).toLongLong(); break; - case QVariant::ULongLong : + case QMetaType::ULongLong : value_ = QVariant( subkeyElement.text() ).toULongLong(); break; #endif @@ -242,7 +242,7 @@ bool QgsProjectPropertyValue::writeXml( QString const &nodeName, // create a sequence of repeated elements to cover all the string list // members; each value will be in a tag. // XXX Not the most elegant way to handle string lists? - if ( QVariant::StringList == mValue.type() ) + if ( QMetaType::QStringList == mValue.userType() ) { QStringList sl = mValue.toStringList(); @@ -285,7 +285,7 @@ QVariant QgsProjectPropertyKey::value() const if ( !foundQgsProperty ) { QgsDebugError( QStringLiteral( "key has null child" ) ); - return QVariant(); // just return an QVariant::Invalid + return QVariant(); // just return an QMetaType::UnknownType } return foundQgsProperty->value(); @@ -312,7 +312,7 @@ void QgsProjectPropertyKey::dump( int tabs ) const { QgsProjectPropertyValue *propertyValue = static_cast( i.value() ); - if ( QVariant::StringList == propertyValue->value().type() ) + if ( QMetaType::QStringList == propertyValue->value().userType() ) { QgsDebugMsgLevel( QStringLiteral( "%1key: <%2> value:" ).arg( tabString, i.key() ), 4 ); propertyValue->dump( tabs + 1 ); diff --git a/src/core/providers/arcgis/qgsarcgisrestutils.cpp b/src/core/providers/arcgis/qgsarcgisrestutils.cpp index b227a8970783..98837e0d33b4 100644 --- a/src/core/providers/arcgis/qgsarcgisrestutils.cpp +++ b/src/core/providers/arcgis/qgsarcgisrestutils.cpp @@ -46,35 +46,35 @@ #include #include -QVariant::Type QgsArcGisRestUtils::convertFieldType( const QString &esriFieldType ) +QMetaType::Type QgsArcGisRestUtils::convertFieldType( const QString &esriFieldType ) { if ( esriFieldType == QLatin1String( "esriFieldTypeInteger" ) ) - return QVariant::LongLong; + return QMetaType::LongLong; if ( esriFieldType == QLatin1String( "esriFieldTypeSmallInteger" ) ) - return QVariant::Int; + return QMetaType::Int; if ( esriFieldType == QLatin1String( "esriFieldTypeDouble" ) ) - return QVariant::Double; + return QMetaType::Double; if ( esriFieldType == QLatin1String( "esriFieldTypeSingle" ) ) - return QVariant::Double; + return QMetaType::Double; if ( esriFieldType == QLatin1String( "esriFieldTypeString" ) ) - return QVariant::String; + return QMetaType::QString; if ( esriFieldType == QLatin1String( "esriFieldTypeDate" ) ) - return QVariant::DateTime; + return QMetaType::QDateTime; if ( esriFieldType == QLatin1String( "esriFieldTypeGeometry" ) ) - return QVariant::Invalid; // Geometry column should not appear as field + return QMetaType::UnknownType; // Geometry column should not appear as field if ( esriFieldType == QLatin1String( "esriFieldTypeOID" ) ) - return QVariant::LongLong; + return QMetaType::LongLong; if ( esriFieldType == QLatin1String( "esriFieldTypeBlob" ) ) - return QVariant::ByteArray; + return QMetaType::QByteArray; if ( esriFieldType == QLatin1String( "esriFieldTypeGlobalID" ) ) - return QVariant::String; + return QMetaType::QString; if ( esriFieldType == QLatin1String( "esriFieldTypeRaster" ) ) - return QVariant::ByteArray; + return QMetaType::QByteArray; if ( esriFieldType == QLatin1String( "esriFieldTypeGUID" ) ) - return QVariant::String; + return QMetaType::QString; if ( esriFieldType == QLatin1String( "esriFieldTypeXML" ) ) - return QVariant::String; - return QVariant::Invalid; + return QMetaType::QString; + return QMetaType::UnknownType; } Qgis::WkbType QgsArcGisRestUtils::convertGeometryType( const QString &esriGeometryType ) @@ -191,7 +191,7 @@ std::unique_ptr< QgsCompoundCurve > QgsArcGisRestUtils::convertCompoundCurve( co int curveListIndex = 0; for ( const QVariant &curveData : curvesList ) { - if ( curveData.type() == QVariant::List ) + if ( curveData.typeId() == QMetaType::QVariantList ) { const QVariantList coordList = curveData.toList(); const int nCoords = coordList.size(); @@ -217,7 +217,7 @@ std::unique_ptr< QgsCompoundCurve > QgsArcGisRestUtils::convertCompoundCurve( co *outLineM++ = ( ( hasZ && nCoords >= 4 ) || ( !hasZ && nCoords >= 3 ) ) ? coordList[ hasZ ? 3 : 2].toDouble() : std::numeric_limits< double >::quiet_NaN(); } } - else if ( curveData.type() == QVariant::Map ) + else if ( curveData.typeId() == QMetaType::QVariantMap ) { // The last point of the linestring is the start point of this circular string QgsPoint lastLineStringPoint; @@ -1571,25 +1571,25 @@ QVariantMap QgsArcGisRestUtils::featureToJson( const QgsFeature &feature, const return res; } -QVariant QgsArcGisRestUtils::variantToAttributeValue( const QVariant &variant, QVariant::Type expectedType, const QgsArcGisRestContext &context ) +QVariant QgsArcGisRestUtils::variantToAttributeValue( const QVariant &variant, QMetaType::Type expectedType, const QgsArcGisRestContext &context ) { if ( QgsVariantUtils::isNull( variant ) ) return QVariant(); switch ( expectedType ) { - case QVariant::String: + case QMetaType::QString: return QString( QUrl::toPercentEncoding( variant.toString() ) ); - case QVariant::DateTime: - case QVariant::Date: + case QMetaType::QDateTime: + case QMetaType::QDate: { - switch ( variant.type() ) + switch ( variant.userType() ) { - case QVariant::DateTime: + case QMetaType::QDateTime: return variant.toDateTime().toMSecsSinceEpoch(); - case QVariant::Date: + case QMetaType::QDate: // for date values, assume start of day -- the REST api requires datetime values only, not plain dates if ( context.timeZone().isValid() ) return QDateTime( variant.toDate(), QTime( 0, 0, 0 ), context.timeZone() ).toMSecsSinceEpoch(); @@ -1614,28 +1614,28 @@ QVariantMap QgsArcGisRestUtils::fieldDefinitionToJson( const QgsField &field ) QString fieldType; switch ( field.type() ) { - case QVariant::LongLong: + case QMetaType::LongLong: fieldType = QStringLiteral( "esriFieldTypeInteger" ); break; - case QVariant::Int: + case QMetaType::Int: fieldType = QStringLiteral( "esriFieldTypeSmallInteger" ); break; - case QVariant::Double: + case QMetaType::Double: fieldType = QStringLiteral( "esriFieldTypeDouble" ); break; - case QVariant::String: + case QMetaType::QString: fieldType = QStringLiteral( "esriFieldTypeString" ); break; - case QVariant::DateTime: - case QVariant::Date: + case QMetaType::QDateTime: + case QMetaType::QDate: fieldType = QStringLiteral( "esriFieldTypeDate" ); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: fieldType = QStringLiteral( "esriFieldTypeBlob" ); break; @@ -1676,4 +1676,3 @@ Qgis::ArcGisRestServiceType QgsArcGisRestUtils::serviceTypeFromString( const QSt return Qgis::ArcGisRestServiceType::Unknown; } - diff --git a/src/core/providers/arcgis/qgsarcgisrestutils.h b/src/core/providers/arcgis/qgsarcgisrestutils.h index 7d026cf6e2d8..e6392183f0e0 100644 --- a/src/core/providers/arcgis/qgsarcgisrestutils.h +++ b/src/core/providers/arcgis/qgsarcgisrestutils.h @@ -120,7 +120,7 @@ class CORE_EXPORT QgsArcGisRestUtils /** * Converts an ESRI REST field \a type to a QVariant type. */ - static QVariant::Type convertFieldType( const QString &type ); + static QMetaType::Type convertFieldType( const QString &type ); /** * Converts an ESRI REST geometry \a type to a WKB type. @@ -246,7 +246,7 @@ class CORE_EXPORT QgsArcGisRestUtils * * \since QGIS 3.28 */ - static QVariant variantToAttributeValue( const QVariant &variant, QVariant::Type expectedType, const QgsArcGisRestContext &context ); + static QVariant variantToAttributeValue( const QVariant &variant, QMetaType::Type expectedType, const QgsArcGisRestContext &context ); /** * Converts a \a field's definition to an ArcGIS REST JSON representation. diff --git a/src/core/providers/gdal/qgsgdalprovider.cpp b/src/core/providers/gdal/qgsgdalprovider.cpp index e7aeebe21407..48ed1fd72ed3 100644 --- a/src/core/providers/gdal/qgsgdalprovider.cpp +++ b/src/core/providers/gdal/qgsgdalprovider.cpp @@ -3308,22 +3308,22 @@ bool QgsGdalProvider::readNativeAttributeTable( QString *errorMessage ) for ( int columnNumber = 0; columnNumber < GDALRATGetColumnCount( hRat ); ++columnNumber ) { const Qgis::RasterAttributeTableFieldUsage usage { static_cast( GDALRATGetUsageOfCol( hRat, columnNumber ) ) }; - QVariant::Type type = QVariant::Int; + QMetaType::Type type = QMetaType::Int; switch ( GDALRATGetTypeOfCol( hRat, columnNumber ) ) { case GFT_Integer: { - type = QVariant::Int; + type = QMetaType::Int; break; } case GFT_Real: { - type = QVariant::Double; + type = QMetaType::Double; break; } case GFT_String: { - type = QVariant::String; + type = QMetaType::QString; break; } @@ -3355,15 +3355,15 @@ bool QgsGdalProvider::readNativeAttributeTable( QString *errorMessage ) { switch ( field.type ) { - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: { rowData.push_back( GDALRATGetValueAsInt( hRat, rowIdx, colIdx ) ); break; } - case QVariant::Double: + case QMetaType::Double: { rowData.push_back( GDALRATGetValueAsDouble( hRat, rowIdx, colIdx ) ); break; @@ -3464,15 +3464,15 @@ bool QgsGdalProvider::writeNativeAttributeTable( QString *errorMessage ) //#spel GDALRATFieldType fType { GFT_String }; switch ( field.type ) { - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: { fType = GFT_Integer; break; } - case QVariant::Double: + case QMetaType::Double: { fType = GFT_Real; break; diff --git a/src/core/providers/memory/qgsmemoryprovider.cpp b/src/core/providers/memory/qgsmemoryprovider.cpp index e1beab4bd0a4..bf059a91413e 100644 --- a/src/core/providers/memory/qgsmemoryprovider.cpp +++ b/src/core/providers/memory/qgsmemoryprovider.cpp @@ -76,50 +76,50 @@ QgsMemoryProvider::QgsMemoryProvider( const QString &uri, const ProviderOptions mNextFeatureId = 1; setNativeTypes( QList< NativeType >() - << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer)" ), QStringLiteral( "integer" ), QVariant::Int, 0, 10 ) + << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer)" ), QStringLiteral( "integer" ), QMetaType::Int, 0, 10 ) // Decimal number from OGR/Shapefile/dbf may come with length up to 32 and // precision up to length-2 = 30 (default, if width is not specified in dbf is length = 24 precision = 15) - // We know that double (QVariant::Double) has only 15-16 significant numbers, + // We know that double (QMetaType::Double) has only 15-16 significant numbers, // but setting that correct limits would disable the use of memory provider with // data from Shapefiles. In any case, the data are handled as doubles. // So the limits set here are not correct but enable use of data from Shapefiles. - << QgsVectorDataProvider::NativeType( tr( "Decimal Number (real)" ), QStringLiteral( "double" ), QVariant::Double, 0, 32, 0, 30 ) - << QgsVectorDataProvider::NativeType( tr( "Text (string)" ), QStringLiteral( "string" ), QVariant::String, 0, 255 ) + << QgsVectorDataProvider::NativeType( tr( "Decimal Number (real)" ), QStringLiteral( "double" ), QMetaType::Double, 0, 32, 0, 30 ) + << QgsVectorDataProvider::NativeType( tr( "Text (string)" ), QStringLiteral( "string" ), QMetaType::QString, 0, 255 ) // date type - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::Date ), QStringLiteral( "date" ), QVariant::Date, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::Time ), QStringLiteral( "time" ), QVariant::Time, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::DateTime ), QStringLiteral( "datetime" ), QVariant::DateTime, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QDate ), QStringLiteral( "date" ), QMetaType::QDate, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QTime ), QStringLiteral( "time" ), QMetaType::QTime, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QDateTime ), QStringLiteral( "datetime" ), QMetaType::QDateTime, -1, -1, -1, -1 ) // integer types - << QgsVectorDataProvider::NativeType( tr( "Whole Number (smallint - 16bit)" ), QStringLiteral( "int2" ), QVariant::Int, -1, -1, 0, 0 ) - << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer - 32bit)" ), QStringLiteral( "int4" ), QVariant::Int, -1, -1, 0, 0 ) - << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer - 64bit)" ), QStringLiteral( "int8" ), QVariant::LongLong, -1, -1, 0, 0 ) - << QgsVectorDataProvider::NativeType( tr( "Decimal Number (numeric)" ), QStringLiteral( "numeric" ), QVariant::Double, 1, 20, 0, 20 ) - << QgsVectorDataProvider::NativeType( tr( "Decimal Number (decimal)" ), QStringLiteral( "decimal" ), QVariant::Double, 1, 20, 0, 20 ) + << QgsVectorDataProvider::NativeType( tr( "Whole Number (smallint - 16bit)" ), QStringLiteral( "int2" ), QMetaType::Int, -1, -1, 0, 0 ) + << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer - 32bit)" ), QStringLiteral( "int4" ), QMetaType::Int, -1, -1, 0, 0 ) + << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer - 64bit)" ), QStringLiteral( "int8" ), QMetaType::LongLong, -1, -1, 0, 0 ) + << QgsVectorDataProvider::NativeType( tr( "Decimal Number (numeric)" ), QStringLiteral( "numeric" ), QMetaType::Double, 1, 20, 0, 20 ) + << QgsVectorDataProvider::NativeType( tr( "Decimal Number (decimal)" ), QStringLiteral( "decimal" ), QMetaType::Double, 1, 20, 0, 20 ) // floating point - << QgsVectorDataProvider::NativeType( tr( "Decimal Number (real)" ), QStringLiteral( "real" ), QVariant::Double, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( tr( "Decimal Number (double)" ), QStringLiteral( "double precision" ), QVariant::Double, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( tr( "Decimal Number (real)" ), QStringLiteral( "real" ), QMetaType::Double, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( tr( "Decimal Number (double)" ), QStringLiteral( "double precision" ), QMetaType::Double, -1, -1, -1, -1 ) // string types - << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QVariant::String, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QMetaType::QString, -1, -1, -1, -1 ) // boolean - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::Bool ), QStringLiteral( "boolean" ), QVariant::Bool ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Bool ), QStringLiteral( "boolean" ), QMetaType::Bool ) // blob - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::ByteArray ), QStringLiteral( "binary" ), QVariant::ByteArray ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QByteArray ), QStringLiteral( "binary" ), QMetaType::QByteArray ) // list types - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::StringList ), QStringLiteral( "stringlist" ), QVariant::StringList, 0, 0, 0, 0, QVariant::String ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::List, QVariant::Int ), QStringLiteral( "integerlist" ), QVariant::List, 0, 0, 0, 0, QVariant::Int ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::List, QVariant::Double ), QStringLiteral( "doublelist" ), QVariant::List, 0, 0, 0, 0, QVariant::Double ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::List, QVariant::LongLong ), QStringLiteral( "integer64list" ), QVariant::List, 0, 0, 0, 0, QVariant::LongLong ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QStringList ), QStringLiteral( "stringlist" ), QMetaType::QStringList, 0, 0, 0, 0, QMetaType::QString ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QVariantList, QMetaType::Int ), QStringLiteral( "integerlist" ), QMetaType::QVariantList, 0, 0, 0, 0, QMetaType::Int ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QVariantList, QMetaType::Double ), QStringLiteral( "doublelist" ), QMetaType::QVariantList, 0, 0, 0, 0, QMetaType::Double ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QVariantList, QMetaType::LongLong ), QStringLiteral( "integer64list" ), QMetaType::QVariantList, 0, 0, 0, 0, QMetaType::LongLong ) // complex types - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::Map ), QStringLiteral( "map" ), QVariant::Map, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( tr( "Geometry" ), QStringLiteral( "geometry" ), QVariant::UserType ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QVariantMap ), QStringLiteral( "map" ), QMetaType::QVariantMap, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( tr( "Geometry" ), QStringLiteral( "geometry" ), QMetaType::User ) ); if ( query.hasQueryItem( QStringLiteral( "field" ) ) ) @@ -139,8 +139,8 @@ QgsMemoryProvider::QgsMemoryProvider( const QString &uri, const ProviderOptions const QRegularExpressionMatch regularExpressionMatch = reFieldDef.match( name ); // If no match -> use string as type - QVariant::Type type = QVariant::String; - QVariant::Type subType = QVariant::Invalid; + QMetaType::Type type = QMetaType::QString; + QMetaType::Type subType = QMetaType::UnknownType; QString typeName( QStringLiteral( "string" ) ); int length = 255; int precision = 0; @@ -170,23 +170,23 @@ QgsMemoryProvider::QgsMemoryProvider( const QString &uri, const ProviderOptions { if ( typeName == QLatin1String( "int" ) ) { - type = QVariant::Int; + type = QMetaType::Int; typeName = QStringLiteral( "integer" ); } else if ( typeName == QLatin1String( "long" ) ) { - type = QVariant::LongLong; + type = QMetaType::LongLong; typeName = QStringLiteral( "int8" ); } else if ( typeName == QLatin1String( "bool" ) ) { - type = QVariant::Bool; + type = QMetaType::Bool; typeName = QStringLiteral( "boolean" ); } else { QgsLogger::warning( tr( "Unsupported typeName '%1'. Will be handled as string." ).arg( typeName ) ); - type = QVariant::String; + type = QMetaType::QString; typeName = QStringLiteral( "string" ); } } @@ -207,11 +207,11 @@ QgsMemoryProvider::QgsMemoryProvider( const QString &uri, const ProviderOptions // Array if ( !regularExpressionMatch.captured( 4 ).isEmpty() ) { - if ( subType == QVariant::Invalid ) + if ( subType == QMetaType::UnknownType ) subType = type; - if ( type != QVariant::List && type != QVariant::StringList ) - type = type == QVariant::String ? QVariant::StringList : QVariant::List; + if ( type != QMetaType::QVariantList && type != QMetaType::QStringList ) + type = type == QMetaType::QString ? QMetaType::QStringList : QMetaType::QVariantList; const QLatin1String listSuffix( "list" ); if ( !typeName.endsWith( listSuffix ) ) @@ -287,23 +287,23 @@ QString QgsMemoryProvider::dataSourceUri( bool expandAuthConfig ) const QString typeName = field.typeName(); bool isList = false; - if ( field.type() == QVariant::List || field.type() == QVariant::StringList ) + if ( field.type() == QMetaType::QVariantList || field.type() == QMetaType::QStringList ) { switch ( field.subType() ) { - case QVariant::Int: + case QMetaType::Int: typeName = QStringLiteral( "integer" ); break; - case QVariant::LongLong: + case QMetaType::LongLong: typeName = QStringLiteral( "long" ); break; - case QVariant::Double: + case QMetaType::Double: typeName = QStringLiteral( "double" ); break; - case QVariant::String: + case QMetaType::QString: typeName = QStringLiteral( "string" ); break; @@ -440,7 +440,7 @@ bool QgsMemoryProvider::addFeatures( QgsFeatureList &flist, Flags flags ) QgsAttributes attributes = it->attributes(); for ( int i = it->attributes().count(); i < mFields.count(); ++i ) { - attributes.append( QVariant( mFields.at( i ).type() ) ); + attributes.append( QVariant( QMetaType( mFields.at( i ).type() ) ) ); } it->setAttributes( attributes ); } @@ -569,7 +569,7 @@ bool QgsMemoryProvider::addAttributes( const QList &attributes ) // Make sure added attributes typeName correspond to a native type name bool isNativeTypeName = false; - NativeType nativeTypeCandidate( QString(), QString(), QVariant::Invalid ); + NativeType nativeTypeCandidate( QString(), QString(), QMetaType::UnknownType ); const QList nativeTypesList( nativeTypes() ); for ( const NativeType &nativeType : nativeTypesList ) { @@ -580,12 +580,12 @@ bool QgsMemoryProvider::addAttributes( const QList &attributes ) } if ( nativeType.mType == field.type() - && nativeTypeCandidate.mType == QVariant::Invalid ) + && nativeTypeCandidate.mType == QMetaType::UnknownType ) nativeTypeCandidate = nativeType; } if ( !isNativeTypeName ) { - if ( nativeTypeCandidate.mType == QVariant::Invalid ) + if ( nativeTypeCandidate.mType == QMetaType::UnknownType ) { QgsLogger::warning( "Field type not supported: " + field.typeName() ); continue; diff --git a/src/core/providers/memory/qgsmemoryproviderutils.cpp b/src/core/providers/memory/qgsmemoryproviderutils.cpp index 888e1c263550..66680470eec5 100644 --- a/src/core/providers/memory/qgsmemoryproviderutils.cpp +++ b/src/core/providers/memory/qgsmemoryproviderutils.cpp @@ -20,41 +20,41 @@ #include "qgsvectorlayer.h" #include -QString memoryLayerFieldType( QVariant::Type type, const QString &typeString ) +QString memoryLayerFieldType( QMetaType::Type type, const QString &typeString ) { switch ( type ) { - case QVariant::Int: + case QMetaType::Int: return QStringLiteral( "integer" ); - case QVariant::LongLong: + case QMetaType::LongLong: return QStringLiteral( "long" ); - case QVariant::Double: + case QMetaType::Double: return QStringLiteral( "double" ); - case QVariant::String: + case QMetaType::QString: return QStringLiteral( "string" ); - case QVariant::Date: + case QMetaType::QDate: return QStringLiteral( "date" ); - case QVariant::Time: + case QMetaType::QTime: return QStringLiteral( "time" ); - case QVariant::DateTime: + case QMetaType::QDateTime: return QStringLiteral( "datetime" ); - case QVariant::ByteArray: + case QMetaType::QByteArray: return QStringLiteral( "binary" ); - case QVariant::Bool: + case QMetaType::Bool: return QStringLiteral( "boolean" ); - case QVariant::Map: + case QMetaType::QVariantMap: return QStringLiteral( "map" ); - case QVariant::UserType: + case QMetaType::User: if ( typeString.compare( QLatin1String( "geometry" ), Qt::CaseInsensitive ) == 0 ) { return QStringLiteral( "geometry" ); @@ -89,9 +89,9 @@ QgsVectorLayer *QgsMemoryProviderUtils::createMemoryLayer( const QString &name, { const QString lengthPrecision = QStringLiteral( "(%1,%2)" ).arg( field.length() ).arg( field.precision() ); parts << QStringLiteral( "field=%1:%2%3%4" ).arg( QString( QUrl::toPercentEncoding( field.name() ) ), - memoryLayerFieldType( field.type() == QVariant::List || field.type() == QVariant::StringList ? field.subType() : field.type(), field.typeName() ), + memoryLayerFieldType( field.type() == QMetaType::QVariantList || field.type() == QMetaType::QStringList ? field.subType() : field.type(), field.typeName() ), lengthPrecision, - field.type() == QVariant::List || field.type() == QVariant::StringList ? QStringLiteral( "[]" ) : QString() ); + field.type() == QMetaType::QVariantList || field.type() == QMetaType::QStringList ? QStringLiteral( "[]" ) : QString() ); } const QString uri = geomType + '?' + parts.join( '&' ); diff --git a/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp b/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp index 9cf767cc9468..272182dd77e9 100644 --- a/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp +++ b/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp @@ -522,7 +522,7 @@ QgsFields QgsGeoPackageProviderConnection::fields( const QString &schema, const if ( ! pkname.isEmpty() ) { - fieldList.append( QgsField{ pkname, QVariant::LongLong } ); + fieldList.append( QgsField{ pkname, QMetaType::LongLong } ); } QgsVectorLayer::LayerOptions options { false, true }; @@ -544,7 +544,7 @@ QgsFields QgsGeoPackageProviderConnection::fields( const QString &schema, const const auto results = executeSql( sql ); if ( ! results.isEmpty() ) { - fieldList.append( QgsField{ results.first().first().toString(), QVariant::String, QStringLiteral( "geometry" ) } ); + fieldList.append( QgsField{ results.first().first().toString(), QMetaType::QString, QStringLiteral( "geometry" ) } ); } } catch ( QgsProviderConnectionException &ex ) diff --git a/src/core/providers/ogr/qgsogrexpressioncompiler.cpp b/src/core/providers/ogr/qgsogrexpressioncompiler.cpp index 6eef4003b292..4cc74d5b5d99 100644 --- a/src/core/providers/ogr/qgsogrexpressioncompiler.cpp +++ b/src/core/providers/ogr/qgsogrexpressioncompiler.cpp @@ -159,7 +159,7 @@ QString QgsOgrExpressionCompiler::quotedValue( const QVariant &value, bool &ok ) { ok = true; - if ( value.type() == QVariant::Bool ) + if ( value.typeId() == QMetaType::Bool ) { // No support for boolean literals, so fake them return value.toBool() ? "(1=1)" : "(1=0)"; diff --git a/src/core/providers/ogr/qgsogrprovider.cpp b/src/core/providers/ogr/qgsogrprovider.cpp index d2cac79987c4..0050238f526b 100644 --- a/src/core/providers/ogr/qgsogrprovider.cpp +++ b/src/core/providers/ogr/qgsogrprovider.cpp @@ -72,67 +72,67 @@ bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding ) ogrWidth += 1; switch ( field.type() ) { - case QVariant::LongLong: + case QMetaType::LongLong: ogrType = OFTInteger64; ogrPrecision = 0; ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21; break; - case QVariant::String: + case QMetaType::QString: ogrType = OFTString; if ( ogrWidth < 0 || ogrWidth > 255 ) ogrWidth = 255; break; - case QVariant::Int: + case QMetaType::Int: ogrType = OFTInteger; ogrWidth = ogrWidth > 0 && ogrWidth <= 10 ? ogrWidth : 10; ogrPrecision = 0; break; - case QVariant::Bool: + case QMetaType::Bool: ogrType = OFTInteger; ogrSubType = OFSTBoolean; ogrWidth = 1; ogrPrecision = 0; break; - case QVariant::Double: + case QMetaType::Double: ogrType = OFTReal; break; - case QVariant::Date: + case QMetaType::QDate: ogrType = OFTDate; break; - case QVariant::Time: + case QMetaType::QTime: ogrType = OFTTime; break; - case QVariant::DateTime: + case QMetaType::QDateTime: ogrType = OFTDateTime; break; - case QVariant::StringList: + case QMetaType::QStringList: { ogrType = OFTStringList; break; } - case QVariant::List: - if ( field.subType() == QVariant::String ) + case QMetaType::QVariantList: + if ( field.subType() == QMetaType::QString ) { ogrType = OFTStringList; } - else if ( field.subType() == QVariant::Int ) + else if ( field.subType() == QMetaType::Int ) { ogrType = OFTIntegerList; } - else if ( field.subType() == QVariant::LongLong ) + else if ( field.subType() == QMetaType::LongLong ) { ogrType = OFTInteger64List; } - else if ( field.subType() == QVariant::Double ) + else if ( field.subType() == QMetaType::Double ) { ogrType = OFTRealList; } @@ -143,7 +143,7 @@ bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding ) } break; - case QVariant::Map: + case QMetaType::QVariantMap: ogrType = OFTString; ogrSubType = OFSTJSON; break; @@ -736,7 +736,7 @@ void QgsOgrProvider::loadFields() { QgsField fidField( fidColumn, - QVariant::LongLong, + QMetaType::LongLong, QStringLiteral( "Integer64" ) ); // Set constraints for feature id @@ -765,8 +765,8 @@ void QgsOgrProvider::loadFields() const OGRFieldType ogrType = OGR_Fld_GetType( fldDef ); const OGRFieldSubType ogrSubType = OGR_Fld_GetSubType( fldDef ); - QVariant::Type varType = QVariant::Invalid; - QVariant::Type varSubType = QVariant::Invalid; + QMetaType::Type varType = QMetaType::UnknownType; + QMetaType::Type varSubType = QMetaType::UnknownType; QgsOgrUtils::ogrFieldTypeToQVariantType( ogrType, ogrSubType, varType, varSubType ); //TODO: fix this hack @@ -1008,7 +1008,7 @@ void QgsOgrProvider::loadMetadata() if ( f ) { bool ok = false; - QVariant res = QgsOgrUtils::getOgrFeatureAttribute( f.get(), QgsField( QString(), QVariant::String ), 0, nullptr, &ok ); + QVariant res = QgsOgrUtils::getOgrFeatureAttribute( f.get(), QgsField( QString(), QMetaType::QString ), 0, nullptr, &ok ); if ( ok ) { QDomDocument doc; @@ -1036,7 +1036,7 @@ void QgsOgrProvider::loadMetadata() if ( f ) { bool ok = false; - QVariant res = QgsOgrUtils::getOgrFeatureAttribute( f.get(), QgsField( QString(), QVariant::String ), 0, textEncoding(), &ok ); + QVariant res = QgsOgrUtils::getOgrFeatureAttribute( f.get(), QgsField( QString(), QMetaType::QString ), 0, textEncoding(), &ok ); if ( ok ) { QDomDocument metadataDoc; @@ -1477,7 +1477,7 @@ bool QgsOgrProvider::addFeaturePrivate( QgsFeature &f, Flags flags, QgsFeatureId { OGR_F_UnsetField( feature.get(), ogrAttributeId ); } - else if ( QgsVariantUtils::isNull( attrVal ) || ( type != OFTString && ( ( attrVal.type() != QVariant::List && attrVal.toString().isEmpty() && attrVal.type() != QVariant::StringList && attrVal.toStringList().isEmpty() ) || ( attrVal.type() == QVariant::List && attrVal.toList().empty() ) ) ) ) + else if ( QgsVariantUtils::isNull( attrVal ) || ( type != OFTString && ( ( attrVal.typeId() != QMetaType::QVariantList && attrVal.toString().isEmpty() && attrVal.typeId() != QMetaType::QStringList && attrVal.toStringList().isEmpty() ) || ( attrVal.typeId() == QMetaType::QVariantList && attrVal.toList().empty() ) ) ) ) { // Starting with GDAL 2.2, there are 2 concepts: unset fields and null fields // whereas previously there was only unset fields. For a GeoJSON output, @@ -1764,11 +1764,11 @@ bool QgsOgrProvider::addAttributeOGRLevel( const QgsField &field, bool &ignoreEr switch ( field.type() ) { - case QVariant::Int: - case QVariant::Bool: + case QMetaType::Int: + case QMetaType::Bool: type = OFTInteger; break; - case QVariant::LongLong: + case QMetaType::LongLong: { const char *pszDataTypes = GDALGetMetadataItem( mOgrLayer->driver(), GDAL_DMD_CREATIONFIELDDATATYPES, nullptr ); if ( pszDataTypes && strstr( pszDataTypes, "Integer64" ) ) @@ -1779,47 +1779,47 @@ bool QgsOgrProvider::addAttributeOGRLevel( const QgsField &field, bool &ignoreEr } break; } - case QVariant::Double: + case QMetaType::Double: type = OFTReal; break; - case QVariant::Date: + case QMetaType::QDate: type = OFTDate; break; - case QVariant::Time: + case QMetaType::QTime: type = OFTTime; break; - case QVariant::DateTime: + case QMetaType::QDateTime: type = OFTDateTime; break; - case QVariant::String: + case QMetaType::QString: type = OFTString; break; - case QVariant::ByteArray: + case QMetaType::QByteArray: type = OFTBinary; break; - case QVariant::Map: + case QMetaType::QVariantMap: type = OFTString; break; - case QVariant::StringList: + case QMetaType::QStringList: type = OFTStringList; break; - case QVariant::List: - if ( field.subType() == QVariant::String ) + case QMetaType::QVariantList: + if ( field.subType() == QMetaType::QString ) { type = OFTStringList; break; } - else if ( field.subType() == QVariant::Int ) + else if ( field.subType() == QMetaType::Int ) { type = OFTIntegerList; break; } - else if ( field.subType() == QVariant::LongLong ) + else if ( field.subType() == QMetaType::LongLong ) { type = OFTInteger64List; break; } - else if ( field.subType() == QVariant::Double ) + else if ( field.subType() == QMetaType::Double ) { type = OFTRealList; break; @@ -1845,10 +1845,10 @@ bool QgsOgrProvider::addAttributeOGRLevel( const QgsField &field, bool &ignoreEr switch ( field.type() ) { - case QVariant::Bool: + case QMetaType::Bool: OGR_Fld_SetSubType( fielddefn.get(), OFSTBoolean ); break; - case QVariant::Map: + case QMetaType::QVariantMap: OGR_Fld_SetSubType( fielddefn.get(), OFSTJSON ); break; default: @@ -1914,7 +1914,7 @@ bool QgsOgrProvider::addAttributes( const QList &attributes ) // real-world drivers that might only be able to satisfy request only partially. // So to avoid erroring out, patch field type, width and precision to match // what was requested. - // For example in case of Integer64->Real mapping so that QVariant::LongLong is + // For example in case of Integer64->Real mapping so that QMetaType::LongLong is // still returned to the caller // Or if a field width was specified but not strictly enforced by the driver (#15614) for ( QMap< QString, QgsField >::const_iterator it = mapFieldNameToOriginalField.constBegin(); @@ -2285,7 +2285,7 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_ } OGRFieldType type = OGR_Fld_GetType( fd ); - if ( QgsVariantUtils::isNull( *it2 ) || ( type != OFTString && ( ( it2->type() != QVariant::List && it2->type() != QVariant::StringList && it2->toString().isEmpty() ) || ( it2->type() == QVariant::List && it2->toList().empty() ) || ( it2->type() == QVariant::StringList && it2->toStringList().empty() ) ) ) ) + if ( QgsVariantUtils::isNull( *it2 ) || ( type != OFTString && ( ( it2->typeId() != QMetaType::QVariantList && it2->typeId() != QMetaType::QStringList && it2->toString().isEmpty() ) || ( it2->typeId() == QMetaType::QVariantList && it2->toList().empty() ) || ( it2->typeId() == QMetaType::QStringList && it2->toStringList().empty() ) ) ) ) { // Starting with GDAL 2.2, there are 2 concepts: unset fields and null fields // whereas previously there was only unset fields. For a GeoJSON output, @@ -3361,9 +3361,9 @@ QVariant QgsOgrProvider::minimumValue( int index ) const QgsField fld = originalField; // can't use native date/datetime types -- OGR converts these to string in the MAX return value - if ( fld.type() == QVariant::DateTime || fld.type() == QVariant::Date ) + if ( fld.type() == QMetaType::QDateTime || fld.type() == QMetaType::QDate ) { - fld.setType( QVariant::String ); + fld.setType( QMetaType::QString ); } // Don't quote column name (see https://trac.osgeo.org/gdal/ticket/5799#comment:9) @@ -3393,10 +3393,10 @@ QVariant QgsOgrProvider::minimumValue( int index ) const if ( !ok ) return QVariant(); - if ( res.type() != originalField.type() ) + if ( static_cast( res.userType() ) != originalField.type() ) res = convertValue( originalField.type(), res.toString() ); - if ( originalField.type() == QVariant::DateTime ) + if ( originalField.type() == QMetaType::QDateTime ) { // ensure that we treat times as local time, to match behavior when iterating features QDateTime temp = res.toDateTime(); @@ -3421,9 +3421,9 @@ QVariant QgsOgrProvider::maximumValue( int index ) const QgsField fld = originalField; // can't use native date/datetime types -- OGR converts these to string in the MAX return value - if ( fld.type() == QVariant::DateTime || fld.type() == QVariant::Date ) + if ( fld.type() == QMetaType::QDateTime || fld.type() == QMetaType::QDate ) { - fld.setType( QVariant::String ); + fld.setType( QMetaType::QString ); } // Don't quote column name (see https://trac.osgeo.org/gdal/ticket/5799#comment:9) @@ -3453,10 +3453,10 @@ QVariant QgsOgrProvider::maximumValue( int index ) const if ( !ok ) return QVariant(); - if ( res.type() != originalField.type() ) + if ( static_cast( res.userType() ) != originalField.type() ) res = convertValue( originalField.type(), res.toString() ); - if ( originalField.type() == QVariant::DateTime ) + if ( originalField.type() == QMetaType::QDateTime ) { // ensure that we treat times as local time, to match behavior when iterating features QDateTime temp = res.toDateTime(); diff --git a/src/core/providers/ogr/qgsogrprovidermetadata.cpp b/src/core/providers/ogr/qgsogrprovidermetadata.cpp index b6af1c640125..9647e217537c 100644 --- a/src/core/providers/ogr/qgsogrprovidermetadata.cpp +++ b/src/core/providers/ogr/qgsogrprovidermetadata.cpp @@ -985,7 +985,7 @@ bool QgsOgrProviderMetadata::saveLayerMetadata( const QString &uri, const QgsLay if ( f ) { bool ok = false; - QVariant res = QgsOgrUtils::getOgrFeatureAttribute( f.get(), QgsField( QString(), QVariant::String ), 0, nullptr, &ok ); + QVariant res = QgsOgrUtils::getOgrFeatureAttribute( f.get(), QgsField( QString(), QMetaType::QString ), 0, nullptr, &ok ); if ( ok ) { existingRowId = res.toInt( &ok ); @@ -1032,7 +1032,7 @@ bool QgsOgrProviderMetadata::saveLayerMetadata( const QString &uri, const QgsLay if ( f ) { bool ok = false; - QVariant res = QgsOgrUtils::getOgrFeatureAttribute( f.get(), QgsField( QString(), QVariant::String ), 0, nullptr, &ok ); + QVariant res = QgsOgrUtils::getOgrFeatureAttribute( f.get(), QgsField( QString(), QMetaType::QString ), 0, nullptr, &ok ); if ( !ok ) { return false; diff --git a/src/core/providers/ogr/qgsogrproviderutils.cpp b/src/core/providers/ogr/qgsogrproviderutils.cpp index 7b1c515a4643..e115a0be2660 100644 --- a/src/core/providers/ogr/qgsogrproviderutils.cpp +++ b/src/core/providers/ogr/qgsogrproviderutils.cpp @@ -1316,19 +1316,19 @@ QString QgsOgrProviderUtils::quotedValue( const QVariant &value ) if ( QgsVariantUtils::isNull( value ) ) return QStringLiteral( "NULL" ); - switch ( value.type() ) + switch ( value.typeId() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: return value.toString(); - case QVariant::Bool: + case QMetaType::Bool: //OGR does not support boolean literals return value.toBool() ? "1" : "0"; default: - case QVariant::String: + case QMetaType::QString: QString v = value.toString(); v.replace( '\'', QLatin1String( "''" ) ); if ( v.contains( '\\' ) ) diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp index 86885c515c41..8931fddd8ab3 100644 --- a/src/core/qgis.cpp +++ b/src/core/qgis.cpp @@ -127,30 +127,30 @@ bool qgsVariantLessThan( const QVariant &lhs, const QVariant &rhs ) else if ( !rhs.isValid() || rhs.isNull() ) return false; - switch ( lhs.type() ) + switch ( lhs.userType() ) { - case QVariant::Int: + case QMetaType::Int: return lhs.toInt() < rhs.toInt(); - case QVariant::UInt: + case QMetaType::UInt: return lhs.toUInt() < rhs.toUInt(); - case QVariant::LongLong: + case QMetaType::LongLong: return lhs.toLongLong() < rhs.toLongLong(); - case QVariant::ULongLong: + case QMetaType::ULongLong: return lhs.toULongLong() < rhs.toULongLong(); - case QVariant::Double: + case QMetaType::Double: return lhs.toDouble() < rhs.toDouble(); - case QVariant::Char: + case QMetaType::QChar: return lhs.toChar() < rhs.toChar(); - case QVariant::Date: + case QMetaType::QDate: return lhs.toDate() < rhs.toDate(); - case QVariant::Time: + case QMetaType::QTime: return lhs.toTime() < rhs.toTime(); - case QVariant::DateTime: + case QMetaType::QDateTime: return lhs.toDateTime() < rhs.toDateTime(); - case QVariant::Bool: + case QMetaType::Bool: return lhs.toBool() < rhs.toBool(); - case QVariant::List: + case QMetaType::QVariantList: { const QList &lhsl = lhs.toList(); const QList &rhsl = rhs.toList(); @@ -165,7 +165,7 @@ bool qgsVariantLessThan( const QVariant &lhs, const QVariant &rhs ) return qgsVariantLessThan( lhsl[i], rhsl[i] ); } - case QVariant::StringList: + case QMetaType::QStringList: { const QStringList &lhsl = lhs.toStringList(); const QStringList &rhsl = rhs.toStringList(); @@ -200,39 +200,39 @@ uint qHash( const QVariant &variant ) if ( !variant.isValid() || variant.isNull() ) return std::numeric_limits::max(); - switch ( variant.type() ) + switch ( variant.userType() ) { - case QVariant::Int: + case QMetaType::Int: return qHash( variant.toInt() ); - case QVariant::UInt: + case QMetaType::UInt: return qHash( variant.toUInt() ); - case QVariant::Bool: + case QMetaType::Bool: return qHash( variant.toBool() ); - case QVariant::Double: + case QMetaType::Double: return qHash( variant.toDouble() ); - case QVariant::LongLong: + case QMetaType::LongLong: return qHash( variant.toLongLong() ); - case QVariant::ULongLong: + case QMetaType::ULongLong: return qHash( variant.toULongLong() ); - case QVariant::String: + case QMetaType::QString: return qHash( variant.toString() ); - case QVariant::Char: + case QMetaType::QChar: return qHash( variant.toChar() ); - case QVariant::List: + case QMetaType::QVariantList: return qHash( variant.toList() ); - case QVariant::StringList: + case QMetaType::QStringList: return qHash( variant.toStringList() ); - case QVariant::ByteArray: + case QMetaType::QByteArray: return qHash( variant.toByteArray() ); - case QVariant::Date: + case QMetaType::QDate: return qHash( variant.toDate() ); - case QVariant::Time: + case QMetaType::QTime: return qHash( variant.toTime() ); - case QVariant::DateTime: + case QMetaType::QDateTime: return qHash( variant.toDateTime() ); - case QVariant::Url: - case QVariant::Locale: - case QVariant::RegularExpression: + case QMetaType::QUrl: + case QMetaType::QLocale: + case QMetaType::QRegularExpression: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) case QVariant::RegExp: #endif @@ -317,4 +317,3 @@ bool qMapLessThanKey( const QVariantList &key1, const QVariantList return qgsVariantGreaterThan( key1, key2 ) && key1 != key2; } #endif - diff --git a/src/core/qgsaggregatecalculator.cpp b/src/core/qgsaggregatecalculator.cpp index ac90faaf8239..d079de5c8449 100644 --- a/src/core/qgsaggregatecalculator.cpp +++ b/src/core/qgsaggregatecalculator.cpp @@ -106,20 +106,20 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag request.setFeedback( feedback ? feedback : ( context ? context->feedback() : nullptr ) ); //determine result type - QVariant::Type resultType = QVariant::Double; + QMetaType::Type resultType = QMetaType::Double; int userType = 0; if ( attrNum == -1 ) { if ( aggregate == GeometryCollect ) { // in this case we know the result should be a geometry value, so no need to sniff it out... - resultType = QVariant::UserType; + resultType = QMetaType::User; } else { // check expression result type bool foundFeatures = false; - std::tuple returnType = QgsExpressionUtils::determineResultType( fieldOrExpression, mLayer, request, *context, &foundFeatures ); + std::tuple returnType = QgsExpressionUtils::determineResultType( fieldOrExpression, mLayer, request, *context, &foundFeatures ); if ( !foundFeatures ) { if ( ok ) @@ -129,7 +129,7 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag resultType = std::get<0>( returnType ); userType = std::get<1>( returnType ); - if ( resultType == QVariant::Invalid ) + if ( resultType == QMetaType::UnknownType ) { QVariant v; switch ( aggregate ) @@ -173,7 +173,7 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag v = QString(); break; } - resultType = v.type(); + resultType = static_cast( v.userType() ); userType = v.userType(); } } @@ -303,229 +303,229 @@ QList QgsAggregateCalculator::aggregates( { QStringLiteral( "count" ), QCoreApplication::tr( "Count" ), - QSet() - << QVariant::DateTime - << QVariant::Date - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::String + QSet() + << QMetaType::QDateTime + << QMetaType::QDate + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::QString } << AggregateInfo { QStringLiteral( "count_distinct" ), QCoreApplication::tr( "Count Distinct" ), - QSet() - << QVariant::DateTime - << QVariant::Date - << QVariant::UInt - << QVariant::Int - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::String + QSet() + << QMetaType::QDateTime + << QMetaType::QDate + << QMetaType::UInt + << QMetaType::Int + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::QString } << AggregateInfo { QStringLiteral( "count_missing" ), QCoreApplication::tr( "Count Missing" ), - QSet() - << QVariant::DateTime - << QVariant::Date - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::String + QSet() + << QMetaType::QDateTime + << QMetaType::QDate + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::QString } << AggregateInfo { QStringLiteral( "min" ), QCoreApplication::tr( "Min" ), - QSet() - << QVariant::DateTime - << QVariant::Date - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double - << QVariant::String + QSet() + << QMetaType::QDateTime + << QMetaType::QDate + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double + << QMetaType::QString } << AggregateInfo { QStringLiteral( "max" ), QCoreApplication::tr( "Max" ), - QSet() - << QVariant::DateTime - << QVariant::Date - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double - << QVariant::String + QSet() + << QMetaType::QDateTime + << QMetaType::QDate + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double + << QMetaType::QString } << AggregateInfo { QStringLiteral( "sum" ), QCoreApplication::tr( "Sum" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double } << AggregateInfo { QStringLiteral( "mean" ), QCoreApplication::tr( "Mean" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double } << AggregateInfo { QStringLiteral( "median" ), QCoreApplication::tr( "Median" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::Double + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::Double } << AggregateInfo { QStringLiteral( "stdev" ), QCoreApplication::tr( "Stdev" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double } << AggregateInfo { QStringLiteral( "stdevsample" ), QCoreApplication::tr( "Stdev Sample" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double } << AggregateInfo { QStringLiteral( "range" ), QCoreApplication::tr( "Range" ), - QSet() - << QVariant::Date - << QVariant::DateTime - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double + QSet() + << QMetaType::QDate + << QMetaType::QDateTime + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double } << AggregateInfo { QStringLiteral( "minority" ), QCoreApplication::tr( "Minority" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double - << QVariant::String + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double + << QMetaType::QString } << AggregateInfo { QStringLiteral( "majority" ), QCoreApplication::tr( "Majority" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double - << QVariant::String + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double + << QMetaType::QString } << AggregateInfo { QStringLiteral( "q1" ), QCoreApplication::tr( "Q1" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double } << AggregateInfo { QStringLiteral( "q3" ), QCoreApplication::tr( "Q3" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double } << AggregateInfo { QStringLiteral( "iqr" ), QCoreApplication::tr( "InterQuartileRange" ), - QSet() - << QVariant::Int - << QVariant::UInt - << QVariant::LongLong - << QVariant::ULongLong - << QVariant::Double + QSet() + << QMetaType::Int + << QMetaType::UInt + << QMetaType::LongLong + << QMetaType::ULongLong + << QMetaType::Double } << AggregateInfo { QStringLiteral( "min_length" ), QCoreApplication::tr( "Min Length" ), - QSet() - << QVariant::String + QSet() + << QMetaType::QString } << AggregateInfo { QStringLiteral( "max_length" ), QCoreApplication::tr( "Max Length" ), - QSet() - << QVariant::String + QSet() + << QMetaType::QString } << AggregateInfo { QStringLiteral( "concatenate" ), QCoreApplication::tr( "Concatenate" ), - QSet() - << QVariant::String + QSet() + << QMetaType::QString } << AggregateInfo { QStringLiteral( "collect" ), QCoreApplication::tr( "Collect" ), - QSet() + QSet() } << AggregateInfo { QStringLiteral( "array_agg" ), QCoreApplication::tr( "Array Aggregate" ), - QSet() + QSet() }; return aggregates; } -QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate aggregate, QgsFeatureIterator &fit, QVariant::Type resultType, int userType, +QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate aggregate, QgsFeatureIterator &fit, QMetaType::Type resultType, int userType, int attr, QgsExpression *expression, const QString &delimiter, QgsExpressionContext *context, bool *ok, QString *error ) { if ( ok ) @@ -540,11 +540,11 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag switch ( resultType ) { - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::Double: { bool statOk = false; const QgsStatisticalSummary::Statistic stat = numericStatFromAggregate( aggregate, &statOk ); @@ -561,8 +561,8 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag return calculateNumericAggregate( fit, attr, expression, context, stat ); } - case QVariant::Date: - case QVariant::DateTime: + case QMetaType::QDate: + case QMetaType::QDateTime: { bool statOk = false; const QgsDateTimeStatisticalSummary::Statistic stat = dateTimeStatFromAggregate( aggregate, &statOk ); @@ -570,7 +570,7 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag { if ( error ) *error = ( expression ? QObject::tr( "Cannot calculate %1 on %2 values" ).arg( displayName( aggregate ) ) : - QObject::tr( "Cannot calculate %1 on %2 fields" ).arg( displayName( aggregate ) ) ).arg( resultType == QVariant::Date ? QObject::tr( "date" ) : QObject::tr( "datetime" ) ); + QObject::tr( "Cannot calculate %1 on %2 fields" ).arg( displayName( aggregate ) ) ).arg( resultType == QMetaType::QDate ? QObject::tr( "date" ) : QObject::tr( "datetime" ) ); return QVariant(); } @@ -579,7 +579,7 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag return calculateDateTimeAggregate( fit, attr, expression, context, stat ); } - case QVariant::UserType: + case QMetaType::User: { if ( aggregate == GeometryCollect ) { @@ -616,12 +616,12 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag if ( !statOk ) { QString typeString; - if ( resultType == QVariant::Invalid ) + if ( resultType == QMetaType::UnknownType ) typeString = QObject::tr( "null" ); - else if ( resultType == QVariant::UserType ) + else if ( resultType == QMetaType::User ) typeString = QMetaType::typeName( userType ); else - typeString = resultType == QVariant::String ? QObject::tr( "string" ) : QVariant::typeToName( resultType ); + typeString = resultType == QMetaType::QString ? QObject::tr( "string" ) : QVariant::typeToName( resultType ); if ( error ) *error = expression ? QObject::tr( "Cannot calculate %1 on %3 values" ).arg( displayName( aggregate ), typeString ) @@ -989,4 +989,3 @@ QVariant QgsAggregateCalculator::calculateArrayAggregate( QgsFeatureIterator &fi } return array; } - diff --git a/src/core/qgsaggregatecalculator.h b/src/core/qgsaggregatecalculator.h index 89c8d8cb6e3c..234158bf3701 100644 --- a/src/core/qgsaggregatecalculator.h +++ b/src/core/qgsaggregatecalculator.h @@ -57,7 +57,7 @@ class CORE_EXPORT QgsAggregateCalculator //! A translated, human readable name QString name; //! This aggregate function can only be used with these datatypes - QSet supportedTypes; + QSet supportedTypes; }; /** @@ -248,7 +248,7 @@ class CORE_EXPORT QgsAggregateCalculator static QVariant calculateArrayAggregate( QgsFeatureIterator &fit, int attr, QgsExpression *expression, QgsExpressionContext *context ); - static QVariant calculate( Aggregate aggregate, QgsFeatureIterator &fit, QVariant::Type resultType, int userType, + static QVariant calculate( Aggregate aggregate, QgsFeatureIterator &fit, QMetaType::Type resultType, int userType, int attr, QgsExpression *expression, const QString &delimiter, QgsExpressionContext *context, bool *ok = nullptr, QString *error = nullptr ); diff --git a/src/core/qgsapplication.h b/src/core/qgsapplication.h index 01adc6fb3276..856850cdb34a 100644 --- a/src/core/qgsapplication.h +++ b/src/core/qgsapplication.h @@ -990,7 +990,7 @@ class CORE_EXPORT QgsApplication : public QApplication * This string is used to represent the value `NULL` throughout QGIS. * * In general, when passing values around, prefer to use a null QVariant - * `QVariant( field.type() )` or `QVariant( QVariant::Int )`. This value + * `QVariant( field.type() )` or `QVariant( QMetaType::Int )`. This value * should only be used in the final presentation step when showing values * in a widget or sending it to a web browser. */ diff --git a/src/core/qgsattributes.h b/src/core/qgsattributes.h index a70897e00408..ee87e87ce31f 100644 --- a/src/core/qgsattributes.h +++ b/src/core/qgsattributes.h @@ -200,7 +200,7 @@ typedef QVector QgsAttributes; PyObject *obj = PyList_GET_ITEM( sipPy, i ); if ( obj == Py_None ) { - qv->append( QVariant( QVariant::Int ) ); + qv->append( QVariant( QMetaType::Int ) ); } else { diff --git a/src/core/qgsauxiliarystorage.cpp b/src/core/qgsauxiliarystorage.cpp index 4c57442d977c..caac05cb87fc 100644 --- a/src/core/qgsauxiliarystorage.cpp +++ b/src/core/qgsauxiliarystorage.cpp @@ -480,24 +480,24 @@ QgsField QgsAuxiliaryLayer::createAuxiliaryField( const QgsPropertyDefinition &d if ( !def.name().isEmpty() || !def.comment().isEmpty() ) { - QVariant::Type type = QVariant::Invalid; + QMetaType::Type type = QMetaType::UnknownType; QString typeName; int len( 0 ), precision( 0 ); switch ( def.dataType() ) { case QgsPropertyDefinition::DataTypeString: - type = QVariant::String; + type = QMetaType::QString; len = 50; typeName = QStringLiteral( "String" ); break; case QgsPropertyDefinition::DataTypeNumeric: - type = QVariant::Double; + type = QMetaType::Double; len = 0; precision = 0; typeName = QStringLiteral( "Real" ); break; case QgsPropertyDefinition::DataTypeBoolean: - type = QVariant::Int; // sqlite does not have a bool type + type = QMetaType::Int; // sqlite does not have a bool type typeName = QStringLiteral( "Integer" ); break; } @@ -571,15 +571,15 @@ QgsPropertyDefinition QgsAuxiliaryLayer::propertyDefinitionFromField( const QgsF def.setName( propertyName ); switch ( f.type() ) { - case QVariant::Double: + case QMetaType::Double: def.setDataType( QgsPropertyDefinition::DataTypeNumeric ); break; - case QVariant::Bool: + case QMetaType::Bool: def.setDataType( QgsPropertyDefinition::DataTypeBoolean ); break; - case QVariant::String: + case QMetaType::QString: default: def.setDataType( QgsPropertyDefinition::DataTypeString ); break; diff --git a/src/core/qgsdatetimestatisticalsummary.cpp b/src/core/qgsdatetimestatisticalsummary.cpp index 12e973967924..ae76649ea91c 100644 --- a/src/core/qgsdatetimestatisticalsummary.cpp +++ b/src/core/qgsdatetimestatisticalsummary.cpp @@ -60,17 +60,17 @@ void QgsDateTimeStatisticalSummary::calculate( const QVariantList &values ) void QgsDateTimeStatisticalSummary::addValue( const QVariant &value ) { - if ( value.type() == QVariant::DateTime ) + if ( value.typeId() == QMetaType::QDateTime ) { testDateTime( value.toDateTime(), QgsVariantUtils::isNull( value ) ); } - else if ( value.type() == QVariant::Date ) + else if ( value.typeId() == QMetaType::QDate ) { const QDate date = value.toDate(); testDateTime( date.isValid() ? QDateTime( date, QTime( 0, 0, 0 ) ) : QDateTime(), QgsVariantUtils::isNull( value ) ); } - else if ( value.type() == QVariant::Time ) + else if ( value.typeId() == QMetaType::QTime ) { mIsTimes = true; const QTime time = value.toTime(); diff --git a/src/core/qgsexpressionfieldbuffer.cpp b/src/core/qgsexpressionfieldbuffer.cpp index f79f8a3f8b8f..1d2665944415 100644 --- a/src/core/qgsexpressionfieldbuffer.cpp +++ b/src/core/qgsexpressionfieldbuffer.cpp @@ -81,8 +81,8 @@ void QgsExpressionFieldBuffer::readXml( const QDomNode &layerNode ) const QString comment = field.attribute( QStringLiteral( "comment" ) ); const int precision = field.attribute( QStringLiteral( "precision" ) ).toInt(); const int length = field.attribute( QStringLiteral( "length" ) ).toInt(); - const QVariant::Type type = static_cast< QVariant::Type >( field.attribute( QStringLiteral( "type" ) ).toInt() ); - const QVariant::Type subType = static_cast< QVariant::Type >( field.attribute( QStringLiteral( "subType" ), QStringLiteral( "0" ) ).toInt() ); + const QMetaType::Type type = static_cast< QMetaType::Type >( field.attribute( QStringLiteral( "type" ) ).toInt() ); + const QMetaType::Type subType = static_cast< QMetaType::Type >( field.attribute( QStringLiteral( "subType" ), QStringLiteral( "0" ) ).toInt() ); const QString typeName = field.attribute( QStringLiteral( "typeName" ) ); mExpressions.append( ExpressionField( exp, QgsField( name, type, typeName, length, precision, comment, subType ) ) ); diff --git a/src/core/qgsexpressionsorter_p.h b/src/core/qgsexpressionsorter_p.h index f8e2a5d8d9fe..44963b6890a5 100644 --- a/src/core/qgsexpressionsorter_p.h +++ b/src/core/qgsexpressionsorter_p.h @@ -56,12 +56,12 @@ class QgsExpressionSorter } // Both values are not NULL - switch ( v1.type() ) + switch ( v1.userType() ) { - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: if ( v1.toLongLong() == v2.toLongLong() ) continue; if ( orderBy.ascending() ) @@ -69,7 +69,7 @@ class QgsExpressionSorter else return v1.toLongLong() > v2.toLongLong(); - case QVariant::Double: + case QMetaType::Double: if ( qgsDoubleNear( v1.toDouble(), v2.toDouble() ) ) continue; if ( orderBy.ascending() ) @@ -77,7 +77,7 @@ class QgsExpressionSorter else return v1.toDouble() > v2.toDouble(); - case QVariant::Date: + case QMetaType::QDate: if ( v1.toDate() == v2.toDate() ) continue; if ( orderBy.ascending() ) @@ -85,7 +85,7 @@ class QgsExpressionSorter else return v1.toDate() > v2.toDate(); - case QVariant::Time: + case QMetaType::QTime: if ( v1.toTime() == v2.toTime() ) continue; if ( orderBy.ascending() ) @@ -93,7 +93,7 @@ class QgsExpressionSorter else return v1.toTime() > v2.toTime(); - case QVariant::DateTime: + case QMetaType::QDateTime: if ( v1.toDateTime() == v2.toDateTime() ) continue; if ( orderBy.ascending() ) @@ -101,7 +101,7 @@ class QgsExpressionSorter else return v1.toDateTime() > v2.toDateTime(); - case QVariant::Bool: + case QMetaType::Bool: if ( v1.toBool() == v2.toBool() ) continue; if ( orderBy.ascending() ) diff --git a/src/core/qgsfeature.cpp b/src/core/qgsfeature.cpp index db835c8dad50..11c204b35cfb 100644 --- a/src/core/qgsfeature.cpp +++ b/src/core/qgsfeature.cpp @@ -362,16 +362,16 @@ static size_t qgsQVariantApproximateMemoryUsage( const QVariant &v ) // A QVariant has a private structure that is a union of things whose larger // size if a long long, and a int size_t s = sizeof( QVariant ) + sizeof( long long ) + sizeof( int ); - if ( v.type() == QVariant::String ) + if ( v.typeId() == QMetaType::QString ) { s += qgsQStringApproximateMemoryUsage( v.toString() ); } - else if ( v.type() == QVariant::StringList ) + else if ( v.typeId() == QMetaType::QStringList ) { for ( const QString &str : v.toStringList() ) s += qgsQStringApproximateMemoryUsage( str ); } - else if ( v.type() == QVariant::List ) + else if ( v.typeId() == QMetaType::QVariantList ) { for ( const QVariant &subV : v.toList() ) s += qgsQVariantApproximateMemoryUsage( subV ); diff --git a/src/core/qgsfeature.h b/src/core/qgsfeature.h index 8e4739217c32..0169d42db114 100644 --- a/src/core/qgsfeature.h +++ b/src/core/qgsfeature.h @@ -112,7 +112,7 @@ class CORE_EXPORT QgsFeature if ( a1Wrapper == Py_None ) { - rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) ); + rv = sipCpp->setAttribute( a0, QVariant( QMetaType::Int ) ); } else { @@ -138,7 +138,7 @@ class CORE_EXPORT QgsFeature { if ( a1Wrapper == Py_None ) { - sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) ); + sipCpp->setAttribute( *a0, QVariant( QMetaType::Int ) ); } else { @@ -370,7 +370,7 @@ class CORE_EXPORT QgsFeature if ( a1Wrapper == Py_None ) { - rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) ); + rv = sipCpp->setAttribute( a0, QVariant( QMetaType::Int ) ); } else { @@ -633,7 +633,7 @@ class CORE_EXPORT QgsFeature { if ( a1Wrapper == Py_None ) { - sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) ); + sipCpp->setAttribute( *a0, QVariant( QMetaType::Int ) ); } else { diff --git a/src/core/qgsfeaturefiltermodel.cpp b/src/core/qgsfeaturefiltermodel.cpp index 73bbb37dd9fa..a0b516e98c71 100644 --- a/src/core/qgsfeaturefiltermodel.cpp +++ b/src/core/qgsfeaturefiltermodel.cpp @@ -106,7 +106,7 @@ QVariant QgsFeatureFilterModel::nullIdentifier() const { QVariantList nullValues; for ( int i = 0; i < mIdentifierFields.count(); i++ ) - nullValues << QVariant( QVariant::Int ); + nullValues << QVariant( QMetaType( QMetaType::Int ) ); return nullValues; } @@ -151,4 +151,3 @@ void QgsFeatureFilterModel::setExtraIdentifierValueToNull() { setExtraIdentifierValue( nullIdentifier() ); } - diff --git a/src/core/qgsfield.cpp b/src/core/qgsfield.cpp index c5249370e6a7..2a518ee8e257 100644 --- a/src/core/qgsfield.cpp +++ b/src/core/qgsfield.cpp @@ -44,8 +44,8 @@ QgsField::QgsField( QString nam, QString typ, int len, int prec, bool num, // names how they are now. } #endif -QgsField::QgsField( const QString &name, QVariant::Type type, - const QString &typeName, int len, int prec, const QString &comment, QVariant::Type subType ) +QgsField::QgsField( const QString &name, QMetaType::Type type, + const QString &typeName, int len, int prec, const QString &comment, QMetaType::Type subType ) { d = new QgsFieldPrivate( name, type, subType, typeName, len, prec, comment ); } @@ -127,7 +127,7 @@ QString QgsField::displayType( const bool showConstraints ) const QString QgsField::friendlyTypeString() const { - if ( d->type == QVariant::UserType ) + if ( d->type == QMetaType::User ) { if ( d->typeName.compare( QLatin1String( "geometry" ), Qt::CaseInsensitive ) == 0 ) { @@ -137,12 +137,12 @@ QString QgsField::friendlyTypeString() const return QgsVariantUtils::typeToDisplayString( d->type, d->subType ); } -QVariant::Type QgsField::type() const +QMetaType::Type QgsField::type() const { return d->type; } -QVariant::Type QgsField::subType() const +QMetaType::Type QgsField::subType() const { return d->subType; } @@ -199,12 +199,12 @@ void QgsField::setMetadata( int property, const QVariant &value ) bool QgsField::isNumeric() const { - return d->type == QVariant::Double || d->type == QVariant::Int || d->type == QVariant::UInt || d->type == QVariant::LongLong || d->type == QVariant::ULongLong; + return d->type == QMetaType::Double || d->type == QMetaType::Int || d->type == QMetaType::UInt || d->type == QMetaType::LongLong || d->type == QMetaType::ULongLong; } bool QgsField::isDateOrTime() const { - return d->type == QVariant::Date || d->type == QVariant::Time || d->type == QVariant::DateTime; + return d->type == QMetaType::QDate || d->type == QMetaType::QTime || d->type == QMetaType::QDateTime; } /*************************************************************************** @@ -218,12 +218,12 @@ void QgsField::setName( const QString &name ) d->name = name; } -void QgsField::setType( QVariant::Type type ) +void QgsField::setType( QMetaType::Type type ) { d->type = type; } -void QgsField::setSubType( QVariant::Type subType ) +void QgsField::setSubType( QMetaType::Type subType ) { d->subType = subType; } @@ -318,7 +318,7 @@ QString QgsField::displayString( const QVariant &v ) const } // Special treatment for numeric types if group separator is set or decimalPoint is not a dot - if ( d->type == QVariant::Double ) + if ( d->type == QMetaType::Double ) { // if value doesn't contain a double (a default value expression for instance), // apply no transformation @@ -406,11 +406,11 @@ QString QgsField::displayString( const QVariant &v ) const const QJsonDocument doc = QJsonDocument::fromVariant( v ); return QString::fromUtf8( doc.toJson().constData() ); } - else if ( d->type == QVariant::ByteArray ) + else if ( d->type == QMetaType::QByteArray ) { return QObject::tr( "BLOB" ); } - else if ( d->type == QVariant::StringList || d->type == QVariant::List ) + else if ( d->type == QMetaType::QStringList || d->type == QMetaType::QVariantList ) { QString result; const QVariantList list = v.toList(); @@ -461,9 +461,9 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const return true; } - if ( d->type == QVariant::Int && v.toInt() != v.toLongLong() ) + if ( d->type == QMetaType::Int && v.toInt() != v.toLongLong() ) { - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); if ( errorMessage ) *errorMessage = QObject::tr( "Value \"%1\" is too large for integer field" ).arg( original.toLongLong() ); return false; @@ -471,7 +471,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const // Give it a chance to convert to double since for not '.' locales // we accept both comma and dot as decimal point - if ( d->type == QVariant::Double && v.type() == QVariant::String ) + if ( d->type == QMetaType::Double && v.typeId() == QMetaType::QString ) { QVariant tmp( v ); if ( !tmp.convert( d->type ) ) @@ -498,7 +498,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const } // For string representation of an int we also might have thousand separator - if ( d->type == QVariant::Int && v.type() == QVariant::String ) + if ( d->type == QMetaType::Int && v.typeId() == QMetaType::QString ) { QVariant tmp( v ); if ( !tmp.convert( d->type ) ) @@ -515,7 +515,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const } // For string representation of a long we also might have thousand separator - if ( d->type == QVariant::LongLong && v.type() == QVariant::String ) + if ( d->type == QMetaType::LongLong && v.typeId() == QMetaType::QString ) { QVariant tmp( v ); if ( !tmp.convert( d->type ) ) @@ -531,16 +531,16 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const } } - //String representations of doubles in QVariant will return false to convert( QVariant::Int ) + //String representations of doubles in QVariant will return false to convert( QMetaType::Int ) //work around this by first converting to double, and then checking whether the double is convertible to int - if ( d->type == QVariant::Int && v.canConvert( QVariant::Double ) ) + if ( d->type == QMetaType::Int && v.canConvert( QMetaType::Double ) ) { bool ok = false; const double dbl = v.toDouble( &ok ); if ( !ok ) { //couldn't convert to number - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); if ( errorMessage ) *errorMessage = QObject::tr( "Value \"%1\" is not a number" ).arg( original.toString() ); @@ -552,7 +552,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const if ( round > std::numeric_limits::max() || round < -std::numeric_limits::max() ) { //double too large to fit in int - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); if ( errorMessage ) *errorMessage = QObject::tr( "Value \"%1\" is too large for integer field" ).arg( original.toDouble() ); @@ -563,9 +563,9 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const return true; } - //String representations of doubles in QVariant will return false to convert( QVariant::LongLong ) + //String representations of doubles in QVariant will return false to convert( QMetaType::LongLong ) //work around this by first converting to double, and then checking whether the double is convertible to longlong - if ( d->type == QVariant::LongLong && v.canConvert( QVariant::Double ) ) + if ( d->type == QMetaType::LongLong && v.canConvert( QMetaType::Double ) ) { //firstly test the conversion to longlong because conversion to double will rounded the value QVariant tmp( v ); @@ -576,7 +576,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const if ( !ok ) { //couldn't convert to number - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); if ( errorMessage ) *errorMessage = QObject::tr( "Value \"%1\" is not a number" ).arg( original.toString() ); @@ -588,7 +588,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const if ( round > static_cast( std::numeric_limits::max() ) || round < static_cast( -std::numeric_limits::max() ) ) { //double too large to fit in longlong - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); if ( errorMessage ) *errorMessage = QObject::tr( "Value \"%1\" is too large for long long field" ).arg( original.toDouble() ); @@ -602,7 +602,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const if ( d->typeName.compare( QLatin1String( "json" ), Qt::CaseInsensitive ) == 0 || d->typeName.compare( QLatin1String( "jsonb" ), Qt::CaseInsensitive ) == 0 ) { - if ( d->type == QVariant::String ) + if ( d->type == QMetaType::QString ) { const QJsonDocument doc = QJsonDocument::fromVariant( v ); if ( !doc.isNull() ) @@ -610,30 +610,30 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const v = QString::fromUtf8( doc.toJson( QJsonDocument::Compact ).constData() ); return true; } - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); return false; } - else if ( d->type == QVariant::Map ) + else if ( d->type == QMetaType::QVariantMap ) { - if ( v.type() == QVariant::StringList || v.type() == QVariant::List || v.type() == QVariant::Map ) + if ( v.typeId() == QMetaType::QStringList || v.typeId() == QMetaType::QVariantList || v.typeId() == QMetaType::QVariantMap ) { return true; } - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); return false; } } - if ( ( d->type == QVariant::StringList || ( d->type == QVariant::List && d->subType == QVariant::String ) ) - && ( v.type() == QVariant::String ) ) + if ( ( d->type == QMetaType::QStringList || ( d->type == QMetaType::QVariantList && d->subType == QMetaType::QString ) ) + && ( v.typeId() == QMetaType::QString ) ) { v = QStringList( { v.toString() } ); return true; } - if ( ( d->type == QVariant::StringList || d->type == QVariant::List ) && !( v.type() == QVariant::StringList || v.type() == QVariant::List ) ) + if ( ( d->type == QMetaType::QStringList || d->type == QMetaType::QVariantList ) && !( v.typeId() == QMetaType::QStringList || v.typeId() == QMetaType::QVariantList ) ) { - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); if ( errorMessage ) *errorMessage = QObject::tr( "Could not convert value \"%1\" to target list type" ).arg( original.toString() ); @@ -642,12 +642,12 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const } // Handle referenced geometries (e.g. from additional geometry fields) - if ( d->type == QVariant::String && v.userType() == QMetaType::type( "QgsReferencedGeometry" ) ) + if ( d->type == QMetaType::QString && v.userType() == QMetaType::type( "QgsReferencedGeometry" ) ) { const QgsReferencedGeometry geom { v.value( ) }; if ( geom.isNull() ) { - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); } else { @@ -655,13 +655,13 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const } return true; } - else if ( d->type == QVariant::UserType && d->typeName.compare( QLatin1String( "geometry" ), Qt::CaseInsensitive ) == 0 ) + else if ( d->type == QMetaType::User && d->typeName.compare( QLatin1String( "geometry" ), Qt::CaseInsensitive ) == 0 ) { if ( v.userType() == QMetaType::type( "QgsReferencedGeometry" ) || v.userType() == QMetaType::type( "QgsGeometry" ) ) { return true; } - else if ( v.type() == QVariant::String ) + else if ( v.typeId() == QMetaType::QString ) { const QgsGeometry geom = QgsGeometry::fromWkt( v.toString() ); if ( !geom.isNull() ) @@ -674,7 +674,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const } else if ( !v.convert( d->type ) ) { - v = QVariant( d->type ); + v = QVariant( QMetaType( d->type ) ); if ( errorMessage ) *errorMessage = QObject::tr( "Could not convert value \"%1\" to target type \"%2\"" ) @@ -684,7 +684,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const return false; } - if ( d->type == QVariant::Double && d->precision > 0 ) + if ( d->type == QMetaType::Double && d->precision > 0 ) { const double s = std::pow( 10, d->precision ); const double d = v.toDouble() * s; @@ -692,7 +692,7 @@ bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const return true; } - if ( d->type == QVariant::String && d->length > 0 && v.toString().length() > d->length ) + if ( d->type == QMetaType::QString && d->length > 0 && v.toString().length() > d->length ) { const int length = v.toString().length(); v = v.toString().left( d->length ); @@ -798,7 +798,7 @@ QDataStream &operator>>( QDataStream &in, QgsField &field ) >> defaultValueExpression >> applyOnUpdate >> constraints >> originNotNull >> originUnique >> originExpression >> strengthNotNull >> strengthUnique >> strengthExpression >> constraintExpression >> constraintDescription >> subType >> splitPolicy >> metadata; field.setName( name ); - field.setType( static_cast< QVariant::Type >( type ) ); + field.setType( static_cast< QMetaType::Type >( type ) ); field.setTypeName( typeName ); field.setLength( static_cast< int >( length ) ); field.setPrecision( static_cast< int >( precision ) ); @@ -830,7 +830,7 @@ QDataStream &operator>>( QDataStream &in, QgsField &field ) fieldConstraints.removeConstraint( QgsFieldConstraints::ConstraintExpression ); fieldConstraints.setConstraintExpression( constraintExpression, constraintDescription ); field.setConstraints( fieldConstraints ); - field.setSubType( static_cast< QVariant::Type >( subType ) ); + field.setSubType( static_cast< QMetaType::Type >( subType ) ); field.setMetadata( metadata ); return in; } diff --git a/src/core/qgsfield.h b/src/core/qgsfield.h index 4046f1d17974..e9c9e83da478 100644 --- a/src/core/qgsfield.h +++ b/src/core/qgsfield.h @@ -57,7 +57,7 @@ class CORE_EXPORT QgsField Q_PROPERTY( bool isDateOrTime READ isDateOrTime ) Q_PROPERTY( int length READ length WRITE setLength ) Q_PROPERTY( int precision READ precision WRITE setPrecision ) - Q_PROPERTY( QVariant::Type type READ type WRITE setType ) + Q_PROPERTY( QMetaType::Type type READ type WRITE setType ) Q_PROPERTY( QString comment READ comment WRITE setComment ) Q_PROPERTY( QString name READ name WRITE setName ) Q_PROPERTY( QString alias READ alias WRITE setAlias ) @@ -103,22 +103,22 @@ class CORE_EXPORT QgsField * \param comment Comment for the field * \param subType If the field is a collection, its element's type. When * all the elements don't need to have the same type, leave - * this to QVariant::Invalid. + * this to QMetaType::UnknownType. */ QgsField( const QString &name = QString(), - QVariant::Type type = QVariant::Invalid, + QMetaType::Type type = QMetaType::UnknownType, const QString &typeName = QString(), int len = 0, int prec = 0, const QString &comment = QString(), - QVariant::Type subType = QVariant::Invalid ); + QMetaType::Type subType = QMetaType::UnknownType ); /** * Copy constructor */ QgsField( const QgsField &other ); - QVariant testVariant( QVariant::Type type ){return QVariant(type);} + QVariant testVariant( QMetaType::Type type ) {return QVariant( QMetaType( type ) );} /** * Assignment operator @@ -184,15 +184,15 @@ class CORE_EXPORT QgsField QString friendlyTypeString() const; //! Gets variant type of the field as it will be retrieved from data source - QVariant::Type type() const; + QMetaType::Type type() const; /** * If the field is a collection, gets its element's type. * When all the elements don't need to have the same type, this returns - * QVariant::Invalid. + * QMetaType::UnknownType. * \since QGIS 3.0 */ - QVariant::Type subType() const; + QMetaType::Type subType() const; /** * Gets the field type. Field types vary depending on the data source. Examples @@ -295,15 +295,15 @@ class CORE_EXPORT QgsField /** * Set variant type. */ - void setType( QVariant::Type type ); + void setType( QMetaType::Type type ); /** * If the field is a collection, set its element's type. * When all the elements don't need to have the same type, set this to - * QVariant::Invalid. + * QMetaType::UnknownType. * \since QGIS 3.0 */ - void setSubType( QVariant::Type subType ); + void setSubType( QMetaType::Type subType ); /** * Set the field type. diff --git a/src/core/qgsfield_p.h b/src/core/qgsfield_p.h index 7ffc9ad0c094..277335636d4c 100644 --- a/src/core/qgsfield_p.h +++ b/src/core/qgsfield_p.h @@ -50,8 +50,8 @@ class QgsFieldPrivate : public QSharedData public: QgsFieldPrivate( const QString &name = QString(), - QVariant::Type type = QVariant::Invalid, - QVariant::Type subType = QVariant::Invalid, + QMetaType::Type type = QMetaType::UnknownType, + QMetaType::Type subType = QMetaType::UnknownType, const QString &typeName = QString(), int len = 0, int prec = 0, @@ -105,10 +105,10 @@ class QgsFieldPrivate : public QSharedData QString name; //! Variant type - QVariant::Type type; + QMetaType::Type type; //! If the variant is a collection, its element's type - QVariant::Type subType; + QMetaType::Type subType; //! Type name from provider QString typeName; diff --git a/src/core/qgsfieldproxymodel.cpp b/src/core/qgsfieldproxymodel.cpp index 3ad9720ff2f4..704c6e3cd509 100644 --- a/src/core/qgsfieldproxymodel.cpp +++ b/src/core/qgsfieldproxymodel.cpp @@ -95,18 +95,18 @@ bool QgsFieldProxyModel::filterAcceptsRow( int source_row, const QModelIndex &so return true; bool ok; - const QVariant::Type type = ( QVariant::Type )typeVar.toInt( &ok ); + const QMetaType::Type type = ( QMetaType::Type )typeVar.toInt( &ok ); if ( !ok ) return true; - if ( ( mFilters.testFlag( String ) && type == QVariant::String ) || - ( mFilters.testFlag( LongLong ) && type == QVariant::LongLong ) || - ( mFilters.testFlag( Int ) && type == QVariant::Int ) || - ( mFilters.testFlag( Double ) && type == QVariant::Double ) || - ( mFilters.testFlag( Date ) && type == QVariant::Date ) || - ( mFilters.testFlag( Date ) && type == QVariant::DateTime ) || - ( mFilters.testFlag( DateTime ) && type == QVariant::DateTime ) || - ( mFilters.testFlag( Time ) && type == QVariant::Time ) ) + if ( ( mFilters.testFlag( String ) && type == QMetaType::QString ) || + ( mFilters.testFlag( LongLong ) && type == QMetaType::LongLong ) || + ( mFilters.testFlag( Int ) && type == QMetaType::Int ) || + ( mFilters.testFlag( Double ) && type == QMetaType::Double ) || + ( mFilters.testFlag( Date ) && type == QMetaType::QDate ) || + ( mFilters.testFlag( Date ) && type == QMetaType::QDateTime ) || + ( mFilters.testFlag( DateTime ) && type == QMetaType::QDateTime ) || + ( mFilters.testFlag( Time ) && type == QMetaType::QTime ) ) return true; return false; diff --git a/src/core/qgsfields.cpp b/src/core/qgsfields.cpp index ff06a4308228..02bbf3548b2e 100644 --- a/src/core/qgsfields.cpp +++ b/src/core/qgsfields.cpp @@ -291,51 +291,51 @@ QIcon QgsFields::iconForField( int fieldIdx, bool considerOrigin ) const return iconForFieldType( d->fields.at( fieldIdx ).field.type(), d->fields.at( fieldIdx ).field.subType(), d->fields.at( fieldIdx ).field.typeName() ); } -QIcon QgsFields::iconForFieldType( QVariant::Type type, QVariant::Type subType, const QString &typeString ) +QIcon QgsFields::iconForFieldType( QMetaType::Type type, QMetaType::Type subType, const QString &typeString ) { switch ( type ) { - case QVariant::Bool: + case QMetaType::Bool: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldBool.svg" ) ); - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldInteger.svg" ) ); - case QVariant::Double: + case QMetaType::Double: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldFloat.svg" ) ); - case QVariant::String: + case QMetaType::QString: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldText.svg" ) ); - case QVariant::Date: + case QMetaType::QDate: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldDate.svg" ) ); - case QVariant::DateTime: + case QMetaType::QDateTime: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldDateTime.svg" ) ); - case QVariant::Time: + case QMetaType::QTime: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldTime.svg" ) ); - case QVariant::ByteArray: + case QMetaType::QByteArray: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldBinary.svg" ) ); - case QVariant::List: + case QMetaType::QVariantList: { switch ( subType ) { - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldArrayInteger.svg" ) ); - case QVariant::Double: + case QMetaType::Double: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldArrayFloat.svg" ) ); - case QVariant::String: + case QMetaType::QString: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldArrayString.svg" ) ); default: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldArray.svg" ) ); } } - case QVariant::StringList: + case QMetaType::QStringList: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldArrayString.svg" ) ); - case QVariant::Map: + case QMetaType::QVariantMap: return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldJson.svg" ) ); - case QVariant::UserType: + case QMetaType::User: if ( typeString.compare( QLatin1String( "geometry" ) ) == 0 ) { return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldGeometry.svg" ) ); diff --git a/src/core/qgsfields.h b/src/core/qgsfields.h index 8545614c1d59..0617a2d7a2e4 100644 --- a/src/core/qgsfields.h +++ b/src/core/qgsfields.h @@ -443,7 +443,7 @@ class CORE_EXPORT QgsFields * * \since QGIS 3.16 */ - static QIcon iconForFieldType( QVariant::Type type, QVariant::Type subType = QVariant::Type::Invalid, const QString &typeString = QString() ); + static QIcon iconForFieldType( QMetaType::Type type, QMetaType::Type subType = QMetaType::UnknownType, const QString &typeString = QString() ); //! Allows direct construction of QVariants from fields. operator QVariant() const diff --git a/src/core/qgsgml.cpp b/src/core/qgsgml.cpp index e8419648c803..b62e84e6afcd 100644 --- a/src/core/qgsgml.cpp +++ b/src/core/qgsgml.cpp @@ -1228,16 +1228,16 @@ void QgsGmlStreamingParser::setAttribute( const QString &name, const QString &va QVariant var; switch ( att_it.value().second.type() ) { - case QVariant::Double: + case QMetaType::Double: var = QVariant( value.toDouble( &conversionOk ) ); break; - case QVariant::Int: + case QMetaType::Int: var = QVariant( value.toInt( &conversionOk ) ); break; - case QVariant::LongLong: + case QMetaType::LongLong: var = QVariant( value.toLongLong( &conversionOk ) ); break; - case QVariant::DateTime: + case QMetaType::QDateTime: var = QVariant( QDateTime::fromString( value, Qt::ISODate ) ); break; default: //string type is default diff --git a/src/core/qgsgmlschema.cpp b/src/core/qgsgmlschema.cpp index a9f60d01a4ed..a3eafa90d5b8 100644 --- a/src/core/qgsgmlschema.cpp +++ b/src/core/qgsgmlschema.cpp @@ -202,7 +202,7 @@ bool QgsGmlSchema::xsdFeatureClass( const QDomElement &element, const QString &t fieldTypeName = stripNS( sequenceElementRestriction.attribute( QStringLiteral( "base" ) ) ); } - QVariant::Type fieldType = QVariant::String; + QMetaType::Type fieldType = QMetaType::QString; if ( fieldTypeName.isEmpty() ) { QgsDebugError( QStringLiteral( "Cannot get %1.%2 field type" ).arg( typeName, fieldName ) ); @@ -218,11 +218,11 @@ bool QgsGmlSchema::xsdFeatureClass( const QDomElement &element, const QString &t if ( fieldTypeName == QLatin1String( "decimal" ) ) { - fieldType = QVariant::Double; + fieldType = QMetaType::Double; } else if ( fieldTypeName == QLatin1String( "integer" ) ) { - fieldType = QVariant::Int; + fieldType = QMetaType::Int; } } @@ -515,17 +515,17 @@ void QgsGmlSchema::addAttribute( const QString &name, const QString &value ) // It is not geometry attribute -> analyze value bool ok; ( void ) value.toInt( &ok ); - QVariant::Type type = QVariant::String; + QMetaType::Type type = QMetaType::QString; if ( ok ) { - type = QVariant::Int; + type = QMetaType::Int; } else { ( void ) value.toDouble( &ok ); if ( ok ) { - type = QVariant::Double; + type = QMetaType::Double; } } //QgsDebugMsgLevel( "mStringCash = " + mStringCash + " type = " + QVariant::typeToName( type ),2 ); @@ -541,8 +541,8 @@ void QgsGmlSchema::addAttribute( const QString &name, const QString &value ) { QgsField &field = fields[fieldIndex]; // check if type is sufficient - if ( ( field.type() == QVariant::Int && ( type == QVariant::String || type == QVariant::Double ) ) || - ( field.type() == QVariant::Double && type == QVariant::String ) ) + if ( ( field.type() == QMetaType::Int && ( type == QMetaType::QString || type == QMetaType::Double ) ) || + ( field.type() == QMetaType::Double && type == QMetaType::QString ) ) { field.setType( type ); } diff --git a/src/core/qgsjsonutils.cpp b/src/core/qgsjsonutils.cpp index 7c29b2f9ecd6..8534a6356d93 100644 --- a/src/core/qgsjsonutils.cpp +++ b/src/core/qgsjsonutils.cpp @@ -278,25 +278,25 @@ QString QgsJsonUtils::encodeValue( const QVariant &value ) if ( QgsVariantUtils::isNull( value ) ) return QStringLiteral( "null" ); - switch ( value.type() ) + switch ( value.userType() ) { - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::Double: return value.toString(); - case QVariant::Bool: + case QMetaType::Bool: return value.toBool() ? "true" : "false"; - case QVariant::StringList: - case QVariant::List: - case QVariant::Map: + case QMetaType::QStringList: + case QMetaType::QVariantList: + case QMetaType::QVariantMap: return QString::fromUtf8( QJsonDocument::fromVariant( value ).toJson( QJsonDocument::Compact ) ); default: - case QVariant::String: + case QMetaType::QString: QString v = value.toString() .replace( '\\', QLatin1String( "\\\\" ) ) .replace( '"', QLatin1String( "\\\"" ) ) @@ -334,7 +334,7 @@ QString QgsJsonUtils::exportAttributes( const QgsFeature &feature, QgsVectorLaye return attrs.prepend( '{' ).append( '}' ); } -QVariantList QgsJsonUtils::parseArray( const QString &json, QVariant::Type type ) +QVariantList QgsJsonUtils::parseArray( const QString &json, QMetaType::Type type ) { QString errorMessage; QVariantList result; @@ -373,11 +373,11 @@ QVariantList QgsJsonUtils::parseArray( const QString &json, QVariant::Type type else if ( item.is_null() ) { // Fallback to int - v = QVariant( type == QVariant::Type::Invalid ? QVariant::Type::Int : type ); + v = QVariant( QMetaType( type == QMetaType::UnknownType ? QMetaType::Type::Int : type ) ); } // If a destination type was specified (it's not invalid), try to convert - if ( type != QVariant::Invalid ) + if ( type != QMetaType::UnknownType ) { if ( ! v.convert( static_cast( type ) ) ) { @@ -410,7 +410,7 @@ json QgsJsonUtils::jsonFromVariant( const QVariant &val ) return nullptr; } json j; - if ( val.type() == QVariant::Type::Map ) + if ( val.typeId() == QMetaType::QVariantMap ) { const QVariantMap &vMap = val.toMap(); json jMap = json::object(); @@ -420,7 +420,7 @@ json QgsJsonUtils::jsonFromVariant( const QVariant &val ) } j = jMap; } - else if ( val.type() == QVariant::Type::List || val.type() == QVariant::Type::StringList ) + else if ( val.typeId() == QMetaType::QVariantList || val.typeId() == QMetaType::QStringList ) { const QVariantList &vList = val.toList(); json jList = json::array(); diff --git a/src/core/qgsjsonutils.h b/src/core/qgsjsonutils.h index 2911787bbdfd..061a3ddf2a33 100644 --- a/src/core/qgsjsonutils.h +++ b/src/core/qgsjsonutils.h @@ -361,7 +361,7 @@ class CORE_EXPORT QgsJsonUtils * the conversion is not possible. * \since QGIS 3.0 */ - Q_INVOKABLE static QVariantList parseArray( const QString &json, QVariant::Type type = QVariant::Invalid ); + Q_INVOKABLE static QVariantList parseArray( const QString &json, QMetaType::Type type = QMetaType::UnknownType ); /** diff --git a/src/core/qgsobjectcustomproperties.cpp b/src/core/qgsobjectcustomproperties.cpp index 44244b983d15..0aa5c6d3c55e 100644 --- a/src/core/qgsobjectcustomproperties.cpp +++ b/src/core/qgsobjectcustomproperties.cpp @@ -79,7 +79,7 @@ void QgsObjectCustomProperties::readXml( const QDomNode &parentNode, const QStri } const QVariant newProps = QgsXmlUtils::readVariant( propsNode.firstChildElement() ); - if ( newProps.type() == QVariant::Map ) + if ( newProps.typeId() == QMetaType::QVariantMap ) { #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) const QVariantMap propsMap = newProps.toMap(); diff --git a/src/core/qgsofflineediting.cpp b/src/core/qgsofflineediting.cpp index 9f6092d42ba7..7c07a194918a 100644 --- a/src/core/qgsofflineediting.cpp +++ b/src/core/qgsofflineediting.cpp @@ -547,20 +547,20 @@ void QgsOfflineEditing::convertToOfflineLayer( QgsVectorLayer *layer, sqlite3 *d for ( const auto &field : providerFields ) { QString dataType; - const QVariant::Type type = field.type(); - if ( type == QVariant::Int || type == QVariant::LongLong ) + const QMetaType::Type type = field.type(); + if ( type == QMetaType::Int || type == QMetaType::LongLong ) { dataType = QStringLiteral( "INTEGER" ); } - else if ( type == QVariant::Double ) + else if ( type == QMetaType::Double ) { dataType = QStringLiteral( "REAL" ); } - else if ( type == QVariant::String ) + else if ( type == QMetaType::QString ) { dataType = QStringLiteral( "TEXT" ); } - else if ( type == QVariant::StringList || type == QVariant::List ) + else if ( type == QMetaType::QStringList || type == QMetaType::QVariantList ) { dataType = QStringLiteral( "TEXT" ); showWarning( tr( "Field '%1' from layer %2 has been converted from a list to a string of comma-separated values." ).arg( field.name(), layer->name() ) ); @@ -713,27 +713,27 @@ void QgsOfflineEditing::convertToOfflineLayer( QgsVectorLayer *layer, sqlite3 *d for ( const auto &field : providerFields ) { const QString fieldName( field.name() ); - const QVariant::Type type = field.type(); + const QMetaType::Type type = field.type(); OGRFieldType ogrType( OFTString ); OGRFieldSubType ogrSubType = OFSTNone; - if ( type == QVariant::Int ) + if ( type == QMetaType::Int ) ogrType = OFTInteger; - else if ( type == QVariant::LongLong ) + else if ( type == QMetaType::LongLong ) ogrType = OFTInteger64; - else if ( type == QVariant::Double ) + else if ( type == QMetaType::Double ) ogrType = OFTReal; - else if ( type == QVariant::Time ) + else if ( type == QMetaType::QTime ) ogrType = OFTTime; - else if ( type == QVariant::Date ) + else if ( type == QMetaType::QDate ) ogrType = OFTDate; - else if ( type == QVariant::DateTime ) + else if ( type == QMetaType::QDateTime ) ogrType = OFTDateTime; - else if ( type == QVariant::Bool ) + else if ( type == QMetaType::Bool ) { ogrType = OFTInteger; ogrSubType = OFSTBoolean; } - else if ( type == QVariant::StringList || type == QVariant::List ) + else if ( type == QMetaType::QStringList || type == QMetaType::QVariantList ) { ogrType = OFTString; ogrSubType = OFSTJSON; @@ -821,7 +821,7 @@ void QgsOfflineEditing::convertToOfflineLayer( QgsVectorLayer *layer, sqlite3 *d for ( int it = 0; it < attrs.count(); ++it ) { QVariant attr = attrs.at( it ); - if ( layer->fields().at( it ).type() == QVariant::StringList || layer->fields().at( it ).type() == QVariant::List ) + if ( layer->fields().at( it ).type() == QMetaType::QStringList || layer->fields().at( it ).type() == QMetaType::QVariantList ) { attr = QgsJsonUtils::encodeValue( attr ); } @@ -927,8 +927,8 @@ void QgsOfflineEditing::applyAttributesAdded( QgsVectorLayer *remoteLayer, sqlit const QgsVectorDataProvider *provider = remoteLayer->dataProvider(); const QList nativeTypes = provider->nativeTypes(); - // NOTE: uses last matching QVariant::Type of nativeTypes - QMap < QVariant::Type, QString /*typeName*/ > typeNameLookup; + // NOTE: uses last matching QMetaType::Type of nativeTypes + QMap < QMetaType::Type, QString /*typeName*/ > typeNameLookup; for ( int i = 0; i < nativeTypes.size(); i++ ) { const QgsVectorDataProvider::NativeType nativeType = nativeTypes.at( i ); @@ -999,20 +999,20 @@ void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer *offlineLayer, QgsVec if ( remoteAttributeIndex == -1 ) continue; QVariant attr = attrs.at( it ); - if ( remoteLayer->fields().at( remoteAttributeIndex ).type() == QVariant::StringList ) + if ( remoteLayer->fields().at( remoteAttributeIndex ).type() == QMetaType::QStringList ) { - if ( attr.type() == QVariant::StringList || attr.type() == QVariant::List ) + if ( attr.typeId() == QMetaType::QStringList || attr.typeId() == QMetaType::QVariantList ) { attr = attr.toStringList(); } else { - attr = QgsJsonUtils::parseArray( attr.toString(), QVariant::String ); + attr = QgsJsonUtils::parseArray( attr.toString(), QMetaType::QString ); } } - else if ( remoteLayer->fields().at( remoteAttributeIndex ).type() == QVariant::List ) + else if ( remoteLayer->fields().at( remoteAttributeIndex ).type() == QMetaType::QVariantList ) { - if ( attr.type() == QVariant::StringList || attr.type() == QVariant::List ) + if ( attr.typeId() == QMetaType::QStringList || attr.typeId() == QMetaType::QVariantList ) { attr = attr.toList(); } @@ -1070,11 +1070,11 @@ void QgsOfflineEditing::applyAttributeValueChanges( QgsVectorLayer *offlineLayer const int remoteAttributeIndex = attrLookup[ values.at( i ).attr ]; QVariant attr = values.at( i ).value; - if ( remoteLayer->fields().at( remoteAttributeIndex ).type() == QVariant::StringList ) + if ( remoteLayer->fields().at( remoteAttributeIndex ).type() == QMetaType::QStringList ) { - attr = QgsJsonUtils::parseArray( attr.toString(), QVariant::String ); + attr = QgsJsonUtils::parseArray( attr.toString(), QMetaType::QString ); } - else if ( remoteLayer->fields().at( remoteAttributeIndex ).type() == QVariant::List ) + else if ( remoteLayer->fields().at( remoteAttributeIndex ).type() == QMetaType::QVariantList ) { attr = QgsJsonUtils::parseArray( attr.toString(), remoteLayer->fields().at( remoteAttributeIndex ).subType() ); } @@ -1372,7 +1372,7 @@ QList QgsOfflineEditing::sqlQueryAttributesAdded( sqlite3 *db, const Q while ( ret == SQLITE_ROW ) { const QgsField field( QString( reinterpret_cast< const char * >( sqlite3_column_text( stmt, 0 ) ) ), - static_cast< QVariant::Type >( sqlite3_column_int( stmt, 1 ) ), + static_cast< QMetaType::Type >( sqlite3_column_int( stmt, 1 ) ), QString(), // typeName sqlite3_column_int( stmt, 2 ), sqlite3_column_int( stmt, 3 ), @@ -1580,7 +1580,7 @@ void QgsOfflineEditing::committedAttributeValuesChanges( const QString &qgisLaye const QgsAttributeMap attrMap = cit.value(); for ( QgsAttributeMap::const_iterator it = attrMap.constBegin(); it != attrMap.constEnd(); ++it ) { - QString value = it.value().type() == QVariant::StringList || it.value().type() == QVariant::List ? QgsJsonUtils::encodeValue( it.value() ) : it.value().toString(); + QString value = it.value().typeId() == QMetaType::QStringList || it.value().typeId() == QMetaType::QVariantList ? QgsJsonUtils::encodeValue( it.value() ) : it.value().toString(); value.replace( QLatin1String( "'" ), QLatin1String( "''" ) ); // escape quote const QString sql = QStringLiteral( "INSERT INTO 'log_feature_updates' VALUES ( %1, %2, %3, %4, '%5' )" ) .arg( layerId ) @@ -1694,9 +1694,9 @@ int QgsOfflineEditing::getLayerPkIdx( const QgsVectorLayer *layer ) const if ( pkAttrs.length() == 1 ) { const QgsField pkField = layer->fields().at( pkAttrs[0] ); - const QVariant::Type pkType = pkField.type(); + const QMetaType::Type pkType = pkField.type(); - if ( pkType == QVariant::String ) + if ( pkType == QMetaType::QString ) { return pkAttrs[0]; } diff --git a/src/core/qgsogcutils.cpp b/src/core/qgsogcutils.cpp index 69cd8db320d4..e6544f872d42 100644 --- a/src/core/qgsogcutils.cpp +++ b/src/core/qgsogcutils.cpp @@ -2172,19 +2172,19 @@ QDomElement QgsOgcUtilsExprToFilter::expressionLiteralToOgcFilter( const QgsExpr QString value; switch ( node->value().type() ) { - case QVariant::Int: + case QMetaType::Int: value = QString::number( node->value().toInt() ); break; - case QVariant::Double: + case QMetaType::Double: value = qgsDoubleToString( node->value().toDouble() ); break; - case QVariant::String: + case QMetaType::QString: value = node->value().toString(); break; - case QVariant::Date: + case QMetaType::QDate: value = node->value().toDate().toString( Qt::ISODate ); break; - case QVariant::DateTime: + case QMetaType::QDateTime: value = node->value().toDateTime().toString( Qt::ISODate ); break; @@ -2668,16 +2668,16 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement: QString value; switch ( node->value().type() ) { - case QVariant::Int: + case QMetaType::Int: value = QString::number( node->value().toInt() ); break; - case QVariant::LongLong: + case QMetaType::LongLong: value = QString::number( node->value().toLongLong() ); break; - case QVariant::Double: + case QMetaType::Double: value = qgsDoubleToString( node->value().toDouble() ); break; - case QVariant::String: + case QMetaType::QString: value = node->value().toString(); break; @@ -2862,7 +2862,7 @@ bool QgsOgcUtilsSQLStatementToFilter::processSRSName( const QgsSQLStatement::Nod return false; } const QgsSQLStatement::NodeLiteral *lit = static_cast( lastArg ); - if ( lit->value().type() == QVariant::Int ) + if ( lit->value().typeId() == QMetaType::Int ) { if ( mFilterVersion == QgsOgcUtils::FILTER_OGC_1_0 ) { @@ -2957,11 +2957,11 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement: } const QgsSQLStatement::NodeLiteral *lit = static_cast( arg ); double val = 0.0; - if ( lit->value().type() == QVariant::Int ) + if ( lit->value().typeId() == QMetaType::Int ) val = lit->value().toInt(); - else if ( lit->value().type() == QVariant::LongLong ) + else if ( lit->value().typeId() == QMetaType::LongLong ) val = lit->value().toLongLong(); - else if ( lit->value().type() == QVariant::Double ) + else if ( lit->value().typeId() == QMetaType::Double ) val = lit->value().toDouble(); else { @@ -3115,16 +3115,16 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement: QString unit( QStringLiteral( "m" ) ); switch ( lit->value().type() ) { - case QVariant::Int: + case QMetaType::Int: distance = QString::number( lit->value().toInt() ); break; - case QVariant::LongLong: + case QMetaType::LongLong: distance = QString::number( lit->value().toLongLong() ); break; - case QVariant::Double: + case QMetaType::Double: distance = qgsDoubleToString( lit->value().toDouble() ); break; - case QVariant::String: + case QMetaType::QString: { distance = lit->value().toString(); for ( int i = 0; i < distance.size(); i++ ) diff --git a/src/core/qgsogrutils.cpp b/src/core/qgsogrutils.cpp index 70be1a7686a7..ba305f78a26d 100644 --- a/src/core/qgsogrutils.cpp +++ b/src/core/qgsogrutils.cpp @@ -237,12 +237,12 @@ std::unique_ptr< OGRField > QgsOgrUtils::variantToOGRField( const QVariant &valu { std::unique_ptr< OGRField > res = std::make_unique< OGRField >(); - switch ( value.type() ) + switch ( value.userType() ) { - case QVariant::Invalid: + case QMetaType::UnknownType: OGR_RawField_SetUnset( res.get() ); break; - case QVariant::Bool: + case QMetaType::Bool: { const int val = value.toBool() ? 1 : 0; if ( type == OFTInteger ) @@ -258,7 +258,7 @@ std::unique_ptr< OGRField > QgsOgrUtils::variantToOGRField( const QVariant &valu } break; } - case QVariant::Int: + case QMetaType::Int: { const int val = value.toInt(); if ( type == OFTInteger ) @@ -274,7 +274,7 @@ std::unique_ptr< OGRField > QgsOgrUtils::variantToOGRField( const QVariant &valu } break; } - case QVariant::LongLong: + case QMetaType::LongLong: { const qint64 val = value.toLongLong(); if ( type == OFTInteger ) @@ -303,7 +303,7 @@ std::unique_ptr< OGRField > QgsOgrUtils::variantToOGRField( const QVariant &valu } break; } - case QVariant::Double: + case QMetaType::Double: { double val = value.toDouble(); if ( type == OFTInteger ) @@ -343,8 +343,8 @@ std::unique_ptr< OGRField > QgsOgrUtils::variantToOGRField( const QVariant &valu } break; } - case QVariant::Char: - case QVariant::String: + case QMetaType::QChar: + case QMetaType::QString: { if ( type == OFTString ) res->String = CPLStrdup( value.toString().toUtf8().constData() ); @@ -355,7 +355,7 @@ std::unique_ptr< OGRField > QgsOgrUtils::variantToOGRField( const QVariant &valu } break; } - case QVariant::Date: + case QMetaType::QDate: { if ( type == OFTDate ) { @@ -372,7 +372,7 @@ std::unique_ptr< OGRField > QgsOgrUtils::variantToOGRField( const QVariant &valu } break; } - case QVariant::Time: + case QMetaType::QTime: { if ( type == OFTTime ) { @@ -389,7 +389,7 @@ std::unique_ptr< OGRField > QgsOgrUtils::variantToOGRField( const QVariant &valu } break; } - case QVariant::DateTime: + case QMetaType::QDateTime: { if ( type == OFTDateTime ) { @@ -464,38 +464,38 @@ QgsFields QgsOgrUtils::readOgrFields( OGRFeatureH ogrFet, QTextCodec *encoding ) } QString name = encoding ? encoding->toUnicode( OGR_Fld_GetNameRef( fldDef ) ) : QString::fromUtf8( OGR_Fld_GetNameRef( fldDef ) ); - QVariant::Type varType; + QMetaType::Type varType; switch ( OGR_Fld_GetType( fldDef ) ) { case OFTInteger: if ( OGR_Fld_GetSubType( fldDef ) == OFSTBoolean ) - varType = QVariant::Bool; + varType = QMetaType::Bool; else - varType = QVariant::Int; + varType = QMetaType::Int; break; case OFTInteger64: - varType = QVariant::LongLong; + varType = QMetaType::LongLong; break; case OFTReal: - varType = QVariant::Double; + varType = QMetaType::Double; break; case OFTDate: - varType = QVariant::Date; + varType = QMetaType::QDate; break; case OFTTime: - varType = QVariant::Time; + varType = QMetaType::QTime; break; case OFTDateTime: - varType = QVariant::DateTime; + varType = QMetaType::QDateTime; break; case OFTString: if ( OGR_Fld_GetSubType( fldDef ) == OFSTJSON ) - varType = QVariant::Map; + varType = QMetaType::QVariantMap; else - varType = QVariant::String; + varType = QMetaType::QString; break; default: - varType = QVariant::String; // other unsupported, leave it as a string + varType = QMetaType::QString; // other unsupported, leave it as a string } fields.append( QgsField( name, varType ) ); } @@ -545,7 +545,7 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField { switch ( field.type() ) { - case QVariant::String: + case QMetaType::QString: { if ( encoding ) value = QVariant( encoding->toUnicode( OGR_F_GetFieldAsString( ogrFet, attIndex ) ) ); @@ -561,21 +561,21 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField break; } - case QVariant::Int: + case QMetaType::Int: value = QVariant( OGR_F_GetFieldAsInteger( ogrFet, attIndex ) ); break; - case QVariant::Bool: + case QMetaType::Bool: value = QVariant( bool( OGR_F_GetFieldAsInteger( ogrFet, attIndex ) ) ); break; - case QVariant::LongLong: + case QMetaType::LongLong: value = QVariant( OGR_F_GetFieldAsInteger64( ogrFet, attIndex ) ); break; - case QVariant::Double: + case QMetaType::Double: value = QVariant( OGR_F_GetFieldAsDouble( ogrFet, attIndex ) ); break; - case QVariant::Date: - case QVariant::DateTime: - case QVariant::Time: + case QMetaType::QDate: + case QMetaType::QDateTime: + case QMetaType::QTime: { int year, month, day, hour, minute, tzf; float second; @@ -584,9 +584,9 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField OGR_F_GetFieldAsDateTimeEx( ogrFet, attIndex, &year, &month, &day, &hour, &minute, &second, &tzf ); float millisecondPart = std::modf( second, &secondsPart ); - if ( field.type() == QVariant::Date ) + if ( field.type() == QMetaType::QDate ) value = QDate( year, month, day ); - else if ( field.type() == QVariant::Time ) + else if ( field.type() == QMetaType::QTime ) value = QTime( hour, minute, static_cast< int >( secondsPart ), static_cast< int >( std::round( 1000 * millisecondPart ) ) ); else { @@ -598,7 +598,7 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField } break; - case QVariant::ByteArray: + case QMetaType::QByteArray: { int size = 0; const GByte *b = OGR_F_GetFieldAsBinary( ogrFet, attIndex, &size ); @@ -612,7 +612,7 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField break; } - case QVariant::StringList: + case QMetaType::QStringList: { QStringList list; char **lst = OGR_F_GetFieldAsStringList( ogrFet, attIndex ); @@ -632,11 +632,11 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField break; } - case QVariant::List: + case QMetaType::QVariantList: { switch ( field.subType() ) { - case QVariant::String: + case QMetaType::QString: { QStringList list; char **lst = OGR_F_GetFieldAsStringList( ogrFet, attIndex ); @@ -656,7 +656,7 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField break; } - case QVariant::Int: + case QMetaType::Int: { QVariantList list; int count = 0; @@ -673,7 +673,7 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField break; } - case QVariant::Double: + case QMetaType::Double: { QVariantList list; int count = 0; @@ -690,7 +690,7 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField break; } - case QVariant::LongLong: + case QMetaType::LongLong: { QVariantList list; int count = 0; @@ -718,7 +718,7 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField break; } - case QVariant::Map: + case QMetaType::QVariantMap: { //it has to be JSON //it's null if no json format @@ -736,7 +736,7 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField } else { - value = QVariant( field.type() ); + value = QVariant( QMetaType( field.type() ) ); } return value; @@ -1880,40 +1880,40 @@ std::unique_ptr QgsOgrUtils::symbolFromStyleString( const QString &st return nullptr; } -void QgsOgrUtils::ogrFieldTypeToQVariantType( OGRFieldType ogrType, OGRFieldSubType ogrSubType, QVariant::Type &variantType, QVariant::Type &variantSubType ) +void QgsOgrUtils::ogrFieldTypeToQVariantType( OGRFieldType ogrType, OGRFieldSubType ogrSubType, QMetaType::Type &variantType, QMetaType::Type &variantSubType ) { - variantType = QVariant::Type::Invalid; - variantSubType = QVariant::Type::Invalid; + variantType = QMetaType::UnknownType; + variantSubType = QMetaType::UnknownType; switch ( ogrType ) { case OFTInteger: if ( ogrSubType == OFSTBoolean ) { - variantType = QVariant::Bool; + variantType = QMetaType::Bool; ogrSubType = OFSTBoolean; } else - variantType = QVariant::Int; + variantType = QMetaType::Int; break; case OFTInteger64: - variantType = QVariant::LongLong; + variantType = QMetaType::LongLong; break; case OFTReal: - variantType = QVariant::Double; + variantType = QMetaType::Double; break; case OFTDate: - variantType = QVariant::Date; + variantType = QMetaType::QDate; break; case OFTTime: - variantType = QVariant::Time; + variantType = QMetaType::QTime; break; case OFTDateTime: - variantType = QVariant::DateTime; + variantType = QMetaType::QDateTime; break; case OFTBinary: - variantType = QVariant::ByteArray; + variantType = QMetaType::QByteArray; break; case OFTString: @@ -1921,84 +1921,84 @@ void QgsOgrUtils::ogrFieldTypeToQVariantType( OGRFieldType ogrType, OGRFieldSubT if ( ogrSubType == OFSTJSON ) { ogrSubType = OFSTJSON; - variantType = QVariant::Map; - variantSubType = QVariant::String; + variantType = QMetaType::QVariantMap; + variantSubType = QMetaType::QString; } else { - variantType = QVariant::String; + variantType = QMetaType::QString; } break; case OFTStringList: case OFTWideStringList: - variantType = QVariant::StringList; - variantSubType = QVariant::String; + variantType = QMetaType::QStringList; + variantSubType = QMetaType::QString; break; case OFTIntegerList: - variantType = QVariant::List; - variantSubType = QVariant::Int; + variantType = QMetaType::QVariantList; + variantSubType = QMetaType::Int; break; case OFTRealList: - variantType = QVariant::List; - variantSubType = QVariant::Double; + variantType = QMetaType::QVariantList; + variantSubType = QMetaType::Double; break; case OFTInteger64List: - variantType = QVariant::List; - variantSubType = QVariant::LongLong; + variantType = QMetaType::QVariantList; + variantSubType = QMetaType::LongLong; break; } } -void QgsOgrUtils::variantTypeToOgrFieldType( QVariant::Type variantType, OGRFieldType &ogrType, OGRFieldSubType &ogrSubType ) +void QgsOgrUtils::variantTypeToOgrFieldType( QMetaType::Type variantType, OGRFieldType &ogrType, OGRFieldSubType &ogrSubType ) { ogrSubType = OFSTNone; switch ( variantType ) { - case QVariant::Bool: + case QMetaType::Bool: ogrType = OFTInteger; ogrSubType = OFSTBoolean; break; - case QVariant::Int: + case QMetaType::Int: ogrType = OFTInteger; break; - case QVariant::LongLong: + case QMetaType::LongLong: ogrType = OFTInteger64; break; - case QVariant::Double: + case QMetaType::Double: ogrType = OFTReal; break; - case QVariant::Char: + case QMetaType::QChar: ogrType = OFTString; break; - case QVariant::String: + case QMetaType::QString: ogrType = OFTString; break; - case QVariant::StringList: + case QMetaType::QStringList: ogrType = OFTStringList; break; - case QVariant::ByteArray: + case QMetaType::QByteArray: ogrType = OFTBinary; break; - case QVariant::Date: + case QMetaType::QDate: ogrType = OFTDate; break; - case QVariant::Time: + case QMetaType::QTime: ogrType = OFTTime; break; - case QVariant::DateTime: + case QMetaType::QDateTime: ogrType = OFTDateTime; break; @@ -2083,13 +2083,13 @@ QList QgsOgrUtils::nativeFieldTypesForDriver( QList nativeTypes; nativeTypes - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::Int ), QStringLiteral( "integer" ), QVariant::Int, 0, nMaxIntLen ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::LongLong ), QStringLiteral( "integer64" ), QVariant::LongLong, 0, nMaxInt64Len ) - << QgsVectorDataProvider::NativeType( QObject::tr( "Decimal number (real)" ), QStringLiteral( "double" ), QVariant::Double, 0, nMaxDoubleLen, 0, nMaxDoublePrec ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::String ), QStringLiteral( "string" ), QVariant::String, 0, 65535 ); + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Int ), QStringLiteral( "integer" ), QMetaType::Int, 0, nMaxIntLen ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::LongLong ), QStringLiteral( "integer64" ), QMetaType::LongLong, 0, nMaxInt64Len ) + << QgsVectorDataProvider::NativeType( QObject::tr( "Decimal number (real)" ), QStringLiteral( "double" ), QMetaType::Double, 0, nMaxDoubleLen, 0, nMaxDoublePrec ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QString ), QStringLiteral( "string" ), QMetaType::QString, 0, 65535 ); if ( driverName == QLatin1String( "GPKG" ) ) - nativeTypes << QgsVectorDataProvider::NativeType( QObject::tr( "JSON (string)" ), QStringLiteral( "JSON" ), QVariant::Map, 0, 0, 0, 0, QVariant::String ); + nativeTypes << QgsVectorDataProvider::NativeType( QObject::tr( "JSON (string)" ), QStringLiteral( "JSON" ), QMetaType::QVariantMap, 0, 0, 0, 0, QMetaType::QString ); bool supportsDate = true; bool supportsTime = true; @@ -2128,42 +2128,42 @@ QList QgsOgrUtils::nativeFieldTypesForDriver( if ( supportsDate ) { nativeTypes - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::Date ), QStringLiteral( "date" ), QVariant::Date, nDateLen, nDateLen ); + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QDate ), QStringLiteral( "date" ), QMetaType::QDate, nDateLen, nDateLen ); } if ( supportsTime ) { nativeTypes - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::Time ), QStringLiteral( "time" ), QVariant::Time ); + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QTime ), QStringLiteral( "time" ), QMetaType::QTime ); } if ( supportsDateTime ) { nativeTypes - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::DateTime ), QStringLiteral( "datetime" ), QVariant::DateTime ); + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QDateTime ), QStringLiteral( "datetime" ), QMetaType::QDateTime ); } if ( supportsBinary ) { nativeTypes - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::ByteArray ), QStringLiteral( "binary" ), QVariant::ByteArray ); + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QByteArray ), QStringLiteral( "binary" ), QMetaType::QByteArray ); } if ( supportIntegerList ) { nativeTypes - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::List, QVariant::Int ), QStringLiteral( "integerlist" ), QVariant::List, 0, 0, 0, 0, QVariant::Int ); + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QVariantList, QMetaType::Int ), QStringLiteral( "integerlist" ), QMetaType::QVariantList, 0, 0, 0, 0, QMetaType::Int ); } if ( supportInteger64List ) { nativeTypes - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::List, QVariant::LongLong ), QStringLiteral( "integer64list" ), QVariant::List, 0, 0, 0, 0, QVariant::LongLong ); + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QVariantList, QMetaType::LongLong ), QStringLiteral( "integer64list" ), QMetaType::QVariantList, 0, 0, 0, 0, QMetaType::LongLong ); } if ( supportRealList ) { nativeTypes - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::List, QVariant::Double ), QStringLiteral( "doublelist" ), QVariant::List, 0, 0, 0, 0, QVariant::Double ); + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QVariantList, QMetaType::Double ), QStringLiteral( "doublelist" ), QMetaType::QVariantList, 0, 0, 0, 0, QMetaType::Double ); } if ( supportsStringList ) { nativeTypes - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QVariant::StringList ), QStringLiteral( "stringlist" ), QVariant::List, 0, 0, 0, 0, QVariant::String ); + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::QStringList ), QStringLiteral( "stringlist" ), QMetaType::QVariantList, 0, 0, 0, 0, QMetaType::QString ); } const char *pszDataSubTypes = GDALGetMetadataItem( driver, GDAL_DMD_CREATIONFIELDDATASUBTYPES, nullptr ); @@ -2171,7 +2171,7 @@ QList QgsOgrUtils::nativeFieldTypesForDriver( { // boolean data type nativeTypes - << QgsVectorDataProvider::NativeType( QObject::tr( "Boolean" ), QStringLiteral( "bool" ), QVariant::Bool ); + << QgsVectorDataProvider::NativeType( QObject::tr( "Boolean" ), QStringLiteral( "bool" ), QMetaType::Bool ); } return nativeTypes; @@ -2187,8 +2187,8 @@ std::unique_ptr< QgsFieldDomain > QgsOgrUtils::convertFieldDomain( OGRFieldDomai const QString name{ OGR_FldDomain_GetName( domain ) }; const QString description{ OGR_FldDomain_GetDescription( domain ) }; - QVariant::Type fieldType = QVariant::Type::Invalid; - QVariant::Type fieldSubType = QVariant::Type::Invalid; + QMetaType::Type fieldType = QMetaType::UnknownType; + QMetaType::Type fieldSubType = QMetaType::UnknownType; const OGRFieldType domainFieldType = OGR_FldDomain_GetFieldType( domain ); const OGRFieldSubType domainFieldSubType = OGR_FldDomain_GetFieldSubType( domain ); ogrFieldTypeToQVariantType( domainFieldType, domainFieldSubType, fieldType, fieldSubType ); diff --git a/src/core/qgsogrutils.h b/src/core/qgsogrutils.h index 55918c9d071e..09d4021010fa 100644 --- a/src/core/qgsogrutils.h +++ b/src/core/qgsogrutils.h @@ -398,7 +398,7 @@ class CORE_EXPORT QgsOgrUtils static std::unique_ptr< QgsSymbol > symbolFromStyleString( const QString &string, Qgis::SymbolType type ) SIP_FACTORY; /** - * Converts an OGR field type and sub type to the best matching QVariant::Type equivalent. + * Converts an OGR field type and sub type to the best matching QMetaType::Type equivalent. * * \param ogrType OGR field type * \param ogrSubType OGR field sub type @@ -408,7 +408,7 @@ class CORE_EXPORT QgsOgrUtils * \note Not available in Python bindings * \since QGIS 3.26 */ - static void ogrFieldTypeToQVariantType( OGRFieldType ogrType, OGRFieldSubType ogrSubType, QVariant::Type &variantType, QVariant::Type &variantSubType ) SIP_SKIP; + static void ogrFieldTypeToQVariantType( OGRFieldType ogrType, OGRFieldSubType ogrSubType, QMetaType::Type &variantType, QMetaType::Type &variantSubType ) SIP_SKIP; /** * Converts an QVariant type to the best matching OGR field type and sub type. @@ -420,7 +420,7 @@ class CORE_EXPORT QgsOgrUtils * \note Not available in Python bindings * \since QGIS 3.26 */ - static void variantTypeToOgrFieldType( QVariant::Type variantType, OGRFieldType &ogrType, OGRFieldSubType &ogrSubType ) SIP_SKIP; + static void variantTypeToOgrFieldType( QMetaType::Type variantType, OGRFieldType &ogrType, OGRFieldSubType &ogrSubType ) SIP_SKIP; /** * Converts a string to a variant, using the provider OGR field \a type and \a subType to determine the most appropriate diff --git a/src/core/qgspostgresstringutils.cpp b/src/core/qgspostgresstringutils.cpp index 07c0285f5dcc..29ecb508ddcc 100644 --- a/src/core/qgspostgresstringutils.cpp +++ b/src/core/qgspostgresstringutils.cpp @@ -128,10 +128,10 @@ QString QgsPostgresStringUtils::buildArray( const QVariantList &list ) for ( const QVariant &v : std::as_const( list ) ) { // Convert to proper type - switch ( v.type() ) + switch ( v.userType() ) { - case QVariant::Type::Int: - case QVariant::Type::LongLong: + case QMetaType::Type::Int: + case QMetaType::Type::LongLong: sl.push_back( v.toString() ); break; default: diff --git a/src/core/qgsproperty.cpp b/src/core/qgsproperty.cpp index 472b1f3e5ca9..4c6d8670199b 100644 --- a/src/core/qgsproperty.cpp +++ b/src/core/qgsproperty.cpp @@ -618,7 +618,7 @@ QDateTime QgsProperty::valueAsDateTime( const QgsExpressionContext &context, con } QDateTime dateTime; - if ( val.type() == QVariant::DateTime ) + if ( val.typeId() == QMetaType::QDateTime ) { dateTime = val.value(); } @@ -668,7 +668,7 @@ QColor QgsProperty::valueAsColor( const QgsExpressionContext &context, const QCo return defaultColor; QColor color; - if ( val.type() == QVariant::Color ) + if ( val.typeId() == QMetaType::QColor ) { color = val.value(); } diff --git a/src/core/qgsrelation.cpp b/src/core/qgsrelation.cpp index ac4204f6d48b..bc566e7aeccb 100644 --- a/src/core/qgsrelation.cpp +++ b/src/core/qgsrelation.cpp @@ -225,7 +225,7 @@ QString QgsRelation::getRelatedFeaturesFilter( const QgsFeature &feature ) const int referencingIdx = referencingLayer()->fields().lookupField( pair.referencingField() ); if ( referencingIdx >= 0 ) { - QVariant::Type fieldType = referencingLayer()->fields().at( referencingIdx ).type(); + QMetaType::Type fieldType = referencingLayer()->fields().at( referencingIdx ).type(); conditions << QgsExpression::createFieldEqualityExpression( pair.referencingField(), val, fieldType ); } else @@ -247,7 +247,7 @@ QgsFeatureRequest QgsRelation::getReferencedFeatureRequest( const QgsAttributes int referencingIdx = referencingLayer()->fields().lookupField( pair.referencingField() ); if ( referencedIdx >= 0 ) { - QVariant::Type fieldType = referencedLayer()->fields().at( referencedIdx ).type(); + QMetaType::Type fieldType = referencedLayer()->fields().at( referencedIdx ).type(); conditions << QgsExpression::createFieldEqualityExpression( pair.referencedField(), attributes.at( referencingIdx ), fieldType ); } else diff --git a/src/core/qgssqlexpressioncompiler.cpp b/src/core/qgssqlexpressioncompiler.cpp index 64f7d3918cfa..8001c7df9779 100644 --- a/src/core/qgssqlexpressioncompiler.cpp +++ b/src/core/qgssqlexpressioncompiler.cpp @@ -68,16 +68,16 @@ QString QgsSqlExpressionCompiler::quotedValue( const QVariant &value, bool &ok ) switch ( value.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: return value.toString(); - case QVariant::Bool: + case QMetaType::Bool: return value.toBool() ? QStringLiteral( "TRUE" ) : QStringLiteral( "FALSE" ); default: - case QVariant::String: + case QMetaType::QString: QString v = value.toString(); v.replace( '\'', QLatin1String( "''" ) ); if ( v.contains( '\\' ) ) @@ -365,7 +365,7 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compileNode( const Qg { const QgsExpressionNodeLiteral *n = static_cast( node ); bool ok = false; - if ( mFlags.testFlag( CaseInsensitiveStringMatch ) && n->value().type() == QVariant::String ) + if ( mFlags.testFlag( CaseInsensitiveStringMatch ) && n->value().typeId() == QMetaType::QString ) { // provider uses case insensitive matching, so if literal was a string then we only have a Partial compilation and need to // double check results using QGIS' expression engine @@ -509,7 +509,7 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::replaceNodeByStaticCa if ( node->hasCachedStaticValue() ) { bool ok = false; - if ( mFlags.testFlag( CaseInsensitiveStringMatch ) && node->cachedStaticValue().type() == QVariant::String ) + if ( mFlags.testFlag( CaseInsensitiveStringMatch ) && node->cachedStaticValue().typeId() == QMetaType::QString ) { // provider uses case insensitive matching, so if literal was a string then we only have a Partial compilation and need to // double check results using QGIS' expression engine diff --git a/src/core/qgssqliteutils.cpp b/src/core/qgssqliteutils.cpp index 7a192f871693..8b08ee8cecfe 100644 --- a/src/core/qgssqliteutils.cpp +++ b/src/core/qgssqliteutils.cpp @@ -271,17 +271,17 @@ QString QgsSqliteUtils::quotedValue( const QVariant &value ) switch ( value.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: return value.toString(); - case QVariant::Bool: + case QMetaType::Bool: //SQLite has no boolean literals return value.toBool() ? QStringLiteral( "1" ) : QStringLiteral( "0" ); default: - case QVariant::String: + case QMetaType::QString: QString v = value.toString(); // https://www.sqlite.org/lang_expr.html : // """A string constant is formed by enclosing the string in single quotes ('). diff --git a/src/core/qgssqlstatement.cpp b/src/core/qgssqlstatement.cpp index 367c99fe1192..c23bae6feefa 100644 --- a/src/core/qgssqlstatement.cpp +++ b/src/core/qgssqlstatement.cpp @@ -487,15 +487,15 @@ QString QgsSQLStatement::NodeLiteral::dump() const switch ( mValue.type() ) { - case QVariant::Int: + case QMetaType::Int: return QString::number( mValue.toInt() ); - case QVariant::LongLong: + case QMetaType::LongLong: return QString::number( mValue.toLongLong() ); - case QVariant::Double: + case QMetaType::Double: return QString::number( mValue.toDouble() ); - case QVariant::String: + case QMetaType::QString: return quotedString( mValue.toString() ); - case QVariant::Bool: + case QMetaType::Bool: return mValue.toBool() ? "TRUE" : "FALSE"; default: return tr( "[unsupported type: %1; value: %2]" ).arg( mValue.typeName(), mValue.toString() ); diff --git a/src/core/qgsstringstatisticalsummary.cpp b/src/core/qgsstringstatisticalsummary.cpp index 670f4345d3af..60a4ac9fe5a5 100644 --- a/src/core/qgsstringstatisticalsummary.cpp +++ b/src/core/qgsstringstatisticalsummary.cpp @@ -67,7 +67,7 @@ void QgsStringStatisticalSummary::addString( const QString &string ) void QgsStringStatisticalSummary::addValue( const QVariant &value ) { - if ( value.type() == QVariant::String ) + if ( value.typeId() == QMetaType::QString ) { testString( value.toString() ); } @@ -100,7 +100,7 @@ void QgsStringStatisticalSummary::calculateFromVariants( const QVariantList &val const auto constValues = values; for ( const QVariant &variant : constValues ) { - if ( variant.type() == QVariant::String ) + if ( variant.typeId() == QMetaType::QString ) { testString( variant.toString() ); } diff --git a/src/core/qgsvariantutils.cpp b/src/core/qgsvariantutils.cpp index f228e506a4af..2143ff0fee9d 100644 --- a/src/core/qgsvariantutils.cpp +++ b/src/core/qgsvariantutils.cpp @@ -34,125 +34,125 @@ #include #include -QString QgsVariantUtils::typeToDisplayString( QVariant::Type type, QVariant::Type subType ) +QString QgsVariantUtils::typeToDisplayString( QMetaType::Type type, QMetaType::Type subType ) { switch ( type ) { - case QVariant::Invalid: + case QMetaType::UnknownType: break; - case QVariant::Bool: + case QMetaType::Bool: return QObject::tr( "Boolean" ); - case QVariant::Int: + case QMetaType::Int: return QObject::tr( "Integer (32 bit)" ); - case QVariant::UInt: + case QMetaType::UInt: return QObject::tr( "Integer (unsigned 32 bit)" ); - case QVariant::LongLong: + case QMetaType::LongLong: return QObject::tr( "Integer (64 bit)" ); - case QVariant::ULongLong: + case QMetaType::ULongLong: return QObject::tr( "Integer (unsigned 64 bit)" ); - case QVariant::Double: + case QMetaType::Double: return QObject::tr( "Decimal (double)" ); - case QVariant::Char: + case QMetaType::QChar: return QObject::tr( "Character" ); - case QVariant::Map: + case QMetaType::QVariantMap: return QObject::tr( "Map" ); - case QVariant::List: + case QMetaType::QVariantList: { switch ( subType ) { - case QVariant::Int: + case QMetaType::Int: return QObject::tr( "Integer List" ); - case QVariant::LongLong: + case QMetaType::LongLong: return QObject::tr( "Integer (64 bit) List" ); - case QVariant::Double: + case QMetaType::Double: return QObject::tr( "Decimal (double) List" ); default: return QObject::tr( "List" ); } } - case QVariant::String: + case QMetaType::QString: return QObject::tr( "Text (string)" ); - case QVariant::StringList: + case QMetaType::QStringList: return QObject::tr( "String List" ); - case QVariant::ByteArray: + case QMetaType::QByteArray: return QObject::tr( "Binary Object (BLOB)" ); - case QVariant::BitArray: + case QMetaType::QBitArray: return QObject::tr( "Bit Array" ); - case QVariant::Date: + case QMetaType::QDate: return QObject::tr( "Date" ); - case QVariant::Time: + case QMetaType::QTime: return QObject::tr( "Time" ); - case QVariant::DateTime: + case QMetaType::QDateTime: return QObject::tr( "Date & Time" ); - case QVariant::Url: + case QMetaType::QUrl: return QObject::tr( "URL" ); - case QVariant::Locale: + case QMetaType::QLocale: return QObject::tr( "Locale" ); - case QVariant::Rect: - case QVariant::RectF: + case QMetaType::QRect: + case QMetaType::QRectF: return QObject::tr( "Rectangle" ); - case QVariant::Size: - case QVariant::SizeF: + case QMetaType::QSize: + case QMetaType::QSizeF: return QObject::tr( "Size" ); - case QVariant::Line: - case QVariant::LineF: + case QMetaType::QLine: + case QMetaType::QLineF: return QObject::tr( "Line" ); - case QVariant::Point: - case QVariant::PointF: + case QMetaType::QPoint: + case QMetaType::QPointF: return QObject::tr( "Point" ); - case QVariant::RegularExpression: + case QMetaType::QRegularExpression: return QObject::tr( "Regular Expression" ); - case QVariant::Hash: + case QMetaType::QVariantHash: return QObject::tr( "Hash" ); - case QVariant::EasingCurve: + case QMetaType::QEasingCurve: return QObject::tr( "Easing Curve" ); - case QVariant::Uuid: + case QMetaType::QUuid: return QObject::tr( "UUID" ); - case QVariant::ModelIndex: - case QVariant::PersistentModelIndex: + case QMetaType::QModelIndex: + case QMetaType::QPersistentModelIndex: return QObject::tr( "Model Index" ); - case QVariant::Font: + case QMetaType::QFont: return QObject::tr( "Font" ); - case QVariant::Pixmap: + case QMetaType::QPixmap: return QObject::tr( "Pixmap" ); - case QVariant::Brush: + case QMetaType::QBrush: return QObject::tr( "Brush" ); - case QVariant::Color: + case QMetaType::QColor: return QObject::tr( "Color" ); - case QVariant::Palette: + case QMetaType::QPalette: return QObject::tr( "Palette" ); - case QVariant::Image: + case QMetaType::QImage: return QObject::tr( "Image" ); - case QVariant::Polygon: - case QVariant::PolygonF: + case QMetaType::QPolygon: + case QMetaType::QPolygonF: return QObject::tr( "Polygon" ); - case QVariant::Region: + case QMetaType::QRegion: return QObject::tr( "Region" ); - case QVariant::Bitmap: + case QMetaType::QBitmap: return QObject::tr( "Bitmap" ); - case QVariant::Cursor: + case QMetaType::QCursor: return QObject::tr( "Cursor" ); - case QVariant::KeySequence: + case QMetaType::QKeySequence: return QObject::tr( "Key Sequence" ); - case QVariant::Pen: + case QMetaType::QPen: return QObject::tr( "Pen" ); - case QVariant::TextLength: + case QMetaType::QTextLength: return QObject::tr( "Text Length" ); - case QVariant::TextFormat: + case QMetaType::QTextFormat: return QObject::tr( "Text Format" ); - case QVariant::Matrix4x4: + case QMetaType::QMatrix4x4: return QObject::tr( "Matrix" ); - case QVariant::Transform: + case QMetaType::QTransform: return QObject::tr( "Transform" ); - case QVariant::Vector2D: - case QVariant::Vector3D: - case QVariant::Vector4D: + case QMetaType::QVector2D: + case QMetaType::QVector3D: + case QMetaType::QVector4D: return QObject::tr( "Vector" ); - case QVariant::Quaternion: + case QMetaType::QQuaternion: return QObject::tr( "Quaternion" ); - case QVariant::Icon: + case QMetaType::QIcon: return QObject::tr( "Icon" ); - case QVariant::SizePolicy: + case QMetaType::QSizePolicy: return QObject::tr( "Size Policy" ); default: @@ -166,199 +166,200 @@ bool QgsVariantUtils::isNull( const QVariant &variant ) if ( variant.isNull() || !variant.isValid() ) return true; - switch ( variant.type() ) + switch ( variant.userType() ) { - case QVariant::Invalid: - case QVariant::Bool: - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::Double: - case QVariant::Map: - case QVariant::List: - case QVariant::StringList: - case QVariant::Url: - case QVariant::Locale: - case QVariant::RegularExpression: - case QVariant::Hash: - case QVariant::EasingCurve: - case QVariant::ModelIndex: - case QVariant::PersistentModelIndex: + case QMetaType::UnknownType: + case QMetaType::Bool: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::Double: + case QMetaType::QVariantMap: + case QMetaType::QVariantList: + case QMetaType::QStringList: + case QMetaType::QUrl: + case QMetaType::QLocale: + case QMetaType::QRegularExpression: + case QMetaType::QVariantHash: + case QMetaType::QEasingCurve: + case QMetaType::QModelIndex: + case QMetaType::QPersistentModelIndex: - case QVariant::LastType: + // TODO there is some LastCoreType or LastGuiType but are they relevant + case QMetaType::LastCoreType: return false; - case QVariant::Date: + case QMetaType::QDate: if ( variant.toDate().isNull() ) { QgsDebugError( QStringLiteral( "NULL QDateTime was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Time: + case QMetaType::QTime: if ( variant.toTime().isNull() ) { QgsDebugError( QStringLiteral( "NULL QTime was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::DateTime: + case QMetaType::QDateTime: if ( variant.toDate().isNull() ) { QgsDebugError( QStringLiteral( "NULL QDate was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Char: + case QMetaType::QChar: if ( variant.toChar().isNull() ) { QgsDebugError( QStringLiteral( "NULL QChar was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::String: + case QMetaType::QString: if ( variant.toString().isNull() ) { QgsDebugError( QStringLiteral( "NULL QString was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::ByteArray: + case QMetaType::QByteArray: if ( variant.toByteArray().isNull() ) { QgsDebugError( QStringLiteral( "NULL QByteArray was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::BitArray: + case QMetaType::QBitArray: if ( variant.toBitArray().isNull() ) { QgsDebugError( QStringLiteral( "NULL QBitArray was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Rect: + case QMetaType::QRect: if ( variant.toRect().isNull() ) { QgsDebugError( QStringLiteral( "NULL QRect was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::RectF: + case QMetaType::QRectF: if ( variant.toRectF().isNull() ) { QgsDebugError( QStringLiteral( "NULL QRectF was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Size: + case QMetaType::QSize: if ( variant.toSize().isNull() ) { QgsDebugError( QStringLiteral( "NULL QSize was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::SizeF: + case QMetaType::QSizeF: if ( variant.toSizeF().isNull() ) { QgsDebugError( QStringLiteral( "NULL QSizeF was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Line: + case QMetaType::QLine: if ( variant.toLine().isNull() ) { QgsDebugError( QStringLiteral( "NULL QLine was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::LineF: + case QMetaType::QLineF: if ( variant.toLineF().isNull() ) { QgsDebugError( QStringLiteral( "NULL QLineF was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Point: + case QMetaType::QPoint: if ( variant.toPoint().isNull() ) { QgsDebugError( QStringLiteral( "NULL QPoint was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::PointF: + case QMetaType::QPointF: if ( variant.toPointF().isNull() ) { QgsDebugError( QStringLiteral( "NULL QPointF was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Uuid: + case QMetaType::QUuid: if ( variant.toUuid().isNull() ) { QgsDebugError( QStringLiteral( "NULL QUuid was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Pixmap: + case QMetaType::QPixmap: if ( variant.value< QPixmap >().isNull() ) { QgsDebugError( QStringLiteral( "NULL QPixmap was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Image: + case QMetaType::QImage: if ( variant.value< QImage >().isNull() ) { QgsDebugError( QStringLiteral( "NULL QImage was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Region: + case QMetaType::QRegion: if ( variant.value< QRegion >().isNull() ) { QgsDebugError( QStringLiteral( "NULL QRegion was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Bitmap: + case QMetaType::QBitmap: if ( variant.value< QBitmap >().isNull() ) { QgsDebugError( QStringLiteral( "NULL QBitmap was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Icon: + case QMetaType::QIcon: if ( variant.value< QIcon >().isNull() ) { QgsDebugError( QStringLiteral( "NULL QIcon was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Vector2D: + case QMetaType::QVector2D: if ( variant.value< QVector2D >().isNull() ) { QgsDebugError( QStringLiteral( "NULL QVector2D was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Vector3D: + case QMetaType::QVector3D: if ( variant.value< QVector3D >().isNull() ) { QgsDebugError( QStringLiteral( "NULL QVector3D was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Vector4D: + case QMetaType::QVector4D: if ( variant.value< QVector4D >().isNull() ) { QgsDebugError( QStringLiteral( "NULL QVector4D was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); return true; } return false; - case QVariant::Quaternion: + case QMetaType::QQuaternion: if ( variant.value< QQuaternion >().isNull() ) { QgsDebugError( QStringLiteral( "NULL QQuaternion was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) ); @@ -366,23 +367,23 @@ bool QgsVariantUtils::isNull( const QVariant &variant ) } return false; - case QVariant::Color: - case QVariant::Font: - case QVariant::Brush: - case QVariant::Polygon: - case QVariant::Palette: - case QVariant::Cursor: - case QVariant::KeySequence: - case QVariant::Pen: - case QVariant::TextLength: - case QVariant::PolygonF: - case QVariant::TextFormat: - case QVariant::Transform: - case QVariant::Matrix4x4: - case QVariant::SizePolicy: + case QMetaType::QColor: + case QMetaType::QFont: + case QMetaType::QBrush: + case QMetaType::QPolygon: + case QMetaType::QPalette: + case QMetaType::QCursor: + case QMetaType::QKeySequence: + case QMetaType::QPen: + case QMetaType::QTextLength: + case QMetaType::QPolygonF: + case QMetaType::QTextFormat: + case QMetaType::QTransform: + case QMetaType::QMatrix4x4: + case QMetaType::QSizePolicy: break; - case QVariant::UserType: + case QMetaType::User: break; default: @@ -391,5 +392,3 @@ bool QgsVariantUtils::isNull( const QVariant &variant ) return false; } - - diff --git a/src/core/qgsvariantutils.h b/src/core/qgsvariantutils.h index 115efd451cda..3e0cc28bd874 100644 --- a/src/core/qgsvariantutils.h +++ b/src/core/qgsvariantutils.h @@ -37,7 +37,7 @@ class CORE_EXPORT QgsVariantUtils * * The optional \a subType can be used to specify the type of variant list or map values. */ - static QString typeToDisplayString( QVariant::Type type, QVariant::Type subType = QVariant::Type::Invalid ); + static QString typeToDisplayString( QMetaType::Type type, QMetaType::Type subType = QMetaType::UnknownType ); /** * Returns TRUE if the specified \a variant should be considered a NULL value. diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index 2f936c27aca6..7765666515ad 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -624,7 +624,7 @@ void QgsVectorFileWriter::init( QString vectorFileName, switch ( attrField.type() ) { - case QVariant::LongLong: + case QMetaType::LongLong: { const char *pszDataTypes = GDALGetMetadataItem( poDriver, GDAL_DMD_CREATIONFIELDDATATYPES, nullptr ); if ( pszDataTypes && strstr( pszDataTypes, "Integer64" ) ) @@ -635,26 +635,26 @@ void QgsVectorFileWriter::init( QString vectorFileName, ogrPrecision = 0; break; } - case QVariant::String: + case QMetaType::QString: ogrType = OFTString; if ( ( ogrWidth <= 0 || ogrWidth > 255 ) && mOgrDriverName == QLatin1String( "ESRI Shapefile" ) ) ogrWidth = 255; break; - case QVariant::Int: + case QMetaType::Int: ogrType = OFTInteger; ogrWidth = ogrWidth > 0 && ogrWidth <= 10 ? ogrWidth : 10; ogrPrecision = 0; break; - case QVariant::Bool: + case QMetaType::Bool: ogrType = OFTInteger; ogrSubType = OFSTBoolean; ogrWidth = 1; ogrPrecision = 0; break; - case QVariant::Double: + case QMetaType::Double: #if GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(3,3,1) if ( mOgrDriverName == QLatin1String( "GPKG" ) && attrField.precision() == 0 && attrField.name().compare( fidFieldName, Qt::CaseInsensitive ) == 0 ) { @@ -666,11 +666,11 @@ void QgsVectorFileWriter::init( QString vectorFileName, ogrType = OFTReal; break; - case QVariant::Date: + case QMetaType::QDate: ogrType = OFTDate; break; - case QVariant::Time: + case QMetaType::QTime: if ( mOgrDriverName == QLatin1String( "ESRI Shapefile" ) ) { ogrType = OFTString; @@ -682,7 +682,7 @@ void QgsVectorFileWriter::init( QString vectorFileName, } break; - case QVariant::DateTime: + case QMetaType::QDateTime: if ( mOgrDriverName == QLatin1String( "ESRI Shapefile" ) ) { ogrType = OFTString; @@ -694,11 +694,11 @@ void QgsVectorFileWriter::init( QString vectorFileName, } break; - case QVariant::ByteArray: + case QMetaType::QByteArray: ogrType = OFTBinary; break; - case QVariant::StringList: + case QMetaType::QStringList: { // handle GPKG conversion to JSON if ( mOgrDriverName == QLatin1String( "GPKG" ) ) @@ -712,7 +712,7 @@ void QgsVectorFileWriter::init( QString vectorFileName, if ( pszDataTypes && strstr( pszDataTypes, "StringList" ) ) { ogrType = OFTStringList; - mSupportedListSubTypes.insert( QVariant::String ); + mSupportedListSubTypes.insert( QMetaType::QString ); } else { @@ -722,7 +722,7 @@ void QgsVectorFileWriter::init( QString vectorFileName, break; } - case QVariant::Map: + case QMetaType::QVariantMap: { // handle GPKG conversion to JSON const char *pszDataSubTypes = GDALGetMetadataItem( poDriver, GDAL_DMD_CREATIONFIELDDATASUBTYPES, nullptr ); @@ -737,7 +737,7 @@ void QgsVectorFileWriter::init( QString vectorFileName, //intentional fall-through FALLTHROUGH - case QVariant::List: + case QMetaType::QVariantList: // handle GPKG conversion to JSON if ( mOgrDriverName == QLatin1String( "GPKG" ) ) { @@ -747,13 +747,13 @@ void QgsVectorFileWriter::init( QString vectorFileName, } // fall through to default for other unsupported types - if ( attrField.subType() == QVariant::String ) + if ( attrField.subType() == QMetaType::QString ) { const char *pszDataTypes = GDALGetMetadataItem( poDriver, GDAL_DMD_CREATIONFIELDDATATYPES, nullptr ); if ( pszDataTypes && strstr( pszDataTypes, "StringList" ) ) { ogrType = OFTStringList; - mSupportedListSubTypes.insert( QVariant::String ); + mSupportedListSubTypes.insert( QMetaType::QString ); } else { @@ -762,13 +762,13 @@ void QgsVectorFileWriter::init( QString vectorFileName, } break; } - else if ( attrField.subType() == QVariant::Int ) + else if ( attrField.subType() == QMetaType::Int ) { const char *pszDataTypes = GDALGetMetadataItem( poDriver, GDAL_DMD_CREATIONFIELDDATATYPES, nullptr ); if ( pszDataTypes && strstr( pszDataTypes, "IntegerList" ) ) { ogrType = OFTIntegerList; - mSupportedListSubTypes.insert( QVariant::Int ); + mSupportedListSubTypes.insert( QMetaType::Int ); } else { @@ -777,13 +777,13 @@ void QgsVectorFileWriter::init( QString vectorFileName, } break; } - else if ( attrField.subType() == QVariant::Double ) + else if ( attrField.subType() == QMetaType::Double ) { const char *pszDataTypes = GDALGetMetadataItem( poDriver, GDAL_DMD_CREATIONFIELDDATATYPES, nullptr ); if ( pszDataTypes && strstr( pszDataTypes, "RealList" ) ) { ogrType = OFTRealList; - mSupportedListSubTypes.insert( QVariant::Double ); + mSupportedListSubTypes.insert( QMetaType::Double ); } else { @@ -792,13 +792,13 @@ void QgsVectorFileWriter::init( QString vectorFileName, } break; } - else if ( attrField.subType() == QVariant::LongLong ) + else if ( attrField.subType() == QMetaType::LongLong ) { const char *pszDataTypes = GDALGetMetadataItem( poDriver, GDAL_DMD_CREATIONFIELDDATATYPES, nullptr ); if ( pszDataTypes && strstr( pszDataTypes, "Integer64List" ) ) { ogrType = OFTInteger64List; - mSupportedListSubTypes.insert( QVariant::LongLong ); + mSupportedListSubTypes.insert( QMetaType::LongLong ); } else { @@ -2742,29 +2742,29 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur switch ( field.type() ) { - case QVariant::Int: + case QMetaType::Int: OGR_F_SetFieldInteger( poFeature.get(), ogrField, attrValue.toInt() ); break; - case QVariant::LongLong: + case QMetaType::LongLong: OGR_F_SetFieldInteger64( poFeature.get(), ogrField, attrValue.toLongLong() ); break; - case QVariant::Bool: + case QMetaType::Bool: OGR_F_SetFieldInteger( poFeature.get(), ogrField, attrValue.toInt() ); break; - case QVariant::String: + case QMetaType::QString: OGR_F_SetFieldString( poFeature.get(), ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() ); break; - case QVariant::Double: + case QMetaType::Double: OGR_F_SetFieldDouble( poFeature.get(), ogrField, attrValue.toDouble() ); break; - case QVariant::Date: + case QMetaType::QDate: OGR_F_SetFieldDateTime( poFeature.get(), ogrField, attrValue.toDate().year(), attrValue.toDate().month(), attrValue.toDate().day(), 0, 0, 0, 0 ); break; - case QVariant::DateTime: + case QMetaType::QDateTime: if ( mOgrDriverName == QLatin1String( "ESRI Shapefile" ) ) { OGR_F_SetFieldString( poFeature.get(), ogrField, mCodec->fromUnicode( attrValue.toDateTime().toString( QStringLiteral( "yyyy/MM/dd hh:mm:ss.zzz" ) ) ).constData() ); @@ -2784,7 +2784,7 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur QgsOgrUtils::OGRTZFlagFromQt( dt ) ); } break; - case QVariant::Time: + case QMetaType::QTime: if ( mOgrDriverName == QLatin1String( "ESRI Shapefile" ) ) { OGR_F_SetFieldString( poFeature.get(), ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() ); @@ -2801,17 +2801,17 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur } break; - case QVariant::ByteArray: + case QMetaType::QByteArray: { const QByteArray ba = attrValue.toByteArray(); OGR_F_SetFieldBinary( poFeature.get(), ogrField, ba.size(), const_cast< GByte * >( reinterpret_cast< const GByte * >( ba.data() ) ) ); break; } - case QVariant::Invalid: + case QMetaType::UnknownType: break; - case QVariant::StringList: + case QMetaType::QStringList: { // handle GPKG conversion to JSON if ( mOgrDriverName == QLatin1String( "GPKG" ) ) @@ -2827,7 +2827,7 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur } QStringList list = attrValue.toStringList(); - if ( mSupportedListSubTypes.contains( QVariant::String ) ) + if ( mSupportedListSubTypes.contains( QMetaType::QString ) ) { int count = list.count(); char **lst = new char *[count + 1]; @@ -2851,7 +2851,7 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur break; } - case QVariant::List: + case QMetaType::QVariantList: // handle GPKG conversion to JSON if ( mOgrDriverName == QLatin1String( "GPKG" ) ) { @@ -2866,10 +2866,10 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur } // fall through to default for unsupported types - if ( field.subType() == QVariant::String ) + if ( field.subType() == QMetaType::QString ) { QStringList list = attrValue.toStringList(); - if ( mSupportedListSubTypes.contains( QVariant::String ) ) + if ( mSupportedListSubTypes.contains( QMetaType::QString ) ) { int count = list.count(); char **lst = new char *[count + 1]; @@ -2892,10 +2892,10 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur } break; } - else if ( field.subType() == QVariant::Int ) + else if ( field.subType() == QMetaType::Int ) { const QVariantList list = attrValue.toList(); - if ( mSupportedListSubTypes.contains( QVariant::Int ) ) + if ( mSupportedListSubTypes.contains( QMetaType::Int ) ) { const int count = list.count(); int *lst = new int[count]; @@ -2923,10 +2923,10 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur } break; } - else if ( field.subType() == QVariant::Double ) + else if ( field.subType() == QMetaType::Double ) { const QVariantList list = attrValue.toList(); - if ( mSupportedListSubTypes.contains( QVariant::Double ) ) + if ( mSupportedListSubTypes.contains( QMetaType::Double ) ) { const int count = list.count(); double *lst = new double[count]; @@ -2954,10 +2954,10 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur } break; } - else if ( field.subType() == QVariant::LongLong ) + else if ( field.subType() == QMetaType::LongLong ) { const QVariantList list = attrValue.toList(); - if ( mSupportedListSubTypes.contains( QVariant::LongLong ) ) + if ( mSupportedListSubTypes.contains( QMetaType::LongLong ) ) { const int count = list.count(); long long *lst = new long long[count]; @@ -2988,7 +2988,7 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur //intentional fall-through FALLTHROUGH - case QVariant::Map: + case QMetaType::QVariantMap: { // handle GPKG conversion to JSON const char *pszDataSubTypes = GDALGetMetadataItem( OGRGetDriverByName( mOgrDriverName.toLocal8Bit().constData() ), GDAL_DMD_CREATIONFIELDDATASUBTYPES, nullptr ); @@ -3397,14 +3397,14 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::prepareWriteAsVectorFormat { for ( int i = 0; i < details.outputFields.size(); i++ ) { - if ( details.outputFields.at( i ).type() == QVariant::LongLong ) + if ( details.outputFields.at( i ).type() == QMetaType::LongLong ) { QVariant min; QVariant max; layer->minimumAndMaximumValue( i, min, max ); if ( std::max( std::llabs( min.toLongLong() ), std::llabs( max.toLongLong() ) ) < std::numeric_limits::max() ) { - details.outputFields[i].setType( QVariant::Int ); + details.outputFields[i].setType( QMetaType::Int ); } } } diff --git a/src/core/qgsvectorfilewriter.h b/src/core/qgsvectorfilewriter.h index f371814ce1e3..3cb19c912347 100644 --- a/src/core/qgsvectorfilewriter.h +++ b/src/core/qgsvectorfilewriter.h @@ -1068,7 +1068,7 @@ class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink std::unique_ptr< QgsCoordinateTransform > mCoordinateTransform; bool mUsingTransaction = false; - QSet< QVariant::Type > mSupportedListSubTypes; + QSet< QMetaType::Type > mSupportedListSubTypes; Qgis::VectorFileWriterCapabilities mCapabilities; diff --git a/src/core/qgsvirtuallayerdefinition.cpp b/src/core/qgsvirtuallayerdefinition.cpp index 4b31629b4aed..17f27cc976ba 100644 --- a/src/core/qgsvirtuallayerdefinition.cpp +++ b/src/core/qgsvirtuallayerdefinition.cpp @@ -147,15 +147,15 @@ QgsVirtualLayerDefinition QgsVirtualLayerDefinition::fromUrl( const QUrl &url ) const QString fieldType( match.captured( 2 ) ); if ( fieldType == QLatin1String( "int" ) ) { - fields.append( QgsField( fieldName, QVariant::LongLong, fieldType ) ); + fields.append( QgsField( fieldName, QMetaType::LongLong, fieldType ) ); } else if ( fieldType == QLatin1String( "real" ) ) { - fields.append( QgsField( fieldName, QVariant::Double, fieldType ) ); + fields.append( QgsField( fieldName, QMetaType::Double, fieldType ) ); } if ( fieldType == QLatin1String( "text" ) ) { - fields.append( QgsField( fieldName, QVariant::String, fieldType ) ); + fields.append( QgsField( fieldName, QMetaType::QString, fieldType ) ); } } } @@ -218,14 +218,14 @@ QUrl QgsVirtualLayerDefinition::toUrl() const const auto constFields = fields(); for ( const QgsField &f : constFields ) { - if ( f.type() == QVariant::Int - || f.type() == QVariant::UInt - || f.type() == QVariant::Bool - || f.type() == QVariant::LongLong ) + if ( f.type() == QMetaType::Int + || f.type() == QMetaType::UInt + || f.type() == QMetaType::Bool + || f.type() == QMetaType::LongLong ) urlQuery.addQueryItem( QStringLiteral( "field" ), f.name() + ":int" ); - else if ( f.type() == QVariant::Double ) + else if ( f.type() == QMetaType::Double ) urlQuery.addQueryItem( QStringLiteral( "field" ), f.name() + ":real" ); - else if ( f.type() == QVariant::String ) + else if ( f.type() == QMetaType::QString ) urlQuery.addQueryItem( QStringLiteral( "field" ), f.name() + ":text" ); } diff --git a/src/core/qgsxmlutils.cpp b/src/core/qgsxmlutils.cpp index aa785e9e95d9..39e085a95023 100644 --- a/src/core/qgsxmlutils.cpp +++ b/src/core/qgsxmlutils.cpp @@ -106,15 +106,15 @@ QDomElement QgsXmlUtils::writeRectangle( const QgsRectangle &rect, QDomDocument QDomElement QgsXmlUtils::writeVariant( const QVariant &value, QDomDocument &doc ) { QDomElement element = doc.createElement( QStringLiteral( "Option" ) ); - switch ( value.type() ) + switch ( value.userType() ) { - case QVariant::Invalid: + case QMetaType::UnknownType: { element.setAttribute( QStringLiteral( "type" ), QStringLiteral( "invalid" ) ); break; } - case QVariant::Map: + case QMetaType::QVariantMap: { const QVariantMap map = value.toMap(); @@ -128,7 +128,7 @@ QDomElement QgsXmlUtils::writeVariant( const QVariant &value, QDomDocument &doc break; } - case QVariant::List: + case QMetaType::QVariantList: { const QVariantList list = value.toList(); @@ -142,7 +142,7 @@ QDomElement QgsXmlUtils::writeVariant( const QVariant &value, QDomDocument &doc break; } - case QVariant::StringList: + case QMetaType::QStringList: { const QStringList list = value.toStringList(); @@ -156,43 +156,43 @@ QDomElement QgsXmlUtils::writeVariant( const QVariant &value, QDomDocument &doc break; } - case QVariant::Int: - case QVariant::UInt: - case QVariant::Bool: - case QVariant::Double: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::String: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::Bool: + case QMetaType::Double: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::QString: element.setAttribute( QStringLiteral( "type" ), QVariant::typeToName( value.type() ) ); element.setAttribute( QStringLiteral( "value" ), value.toString() ); break; - case QVariant::Char: + case QMetaType::QChar: element.setAttribute( QStringLiteral( "type" ), QVariant::typeToName( value.type() ) ); element.setAttribute( QStringLiteral( "value" ), QgsVariantUtils::isNull( value ) ? QString() : QString( value.toChar() ) ); break; - case QVariant::Color: + case QMetaType::QColor: element.setAttribute( QStringLiteral( "type" ), QStringLiteral( "color" ) ); element.setAttribute( QStringLiteral( "value" ), value.value< QColor >().isValid() ? QgsSymbolLayerUtils::encodeColor( value.value< QColor >() ) : QString() ); break; - case QVariant::DateTime: + case QMetaType::QDateTime: element.setAttribute( QStringLiteral( "type" ), QStringLiteral( "datetime" ) ); element.setAttribute( QStringLiteral( "value" ), value.value< QDateTime >().isValid() ? value.toDateTime().toString( Qt::ISODate ) : QString() ); break; - case QVariant::Date: + case QMetaType::QDate: element.setAttribute( QStringLiteral( "type" ), QStringLiteral( "date" ) ); element.setAttribute( QStringLiteral( "value" ), value.value< QDate >().isValid() ? value.toDate().toString( Qt::ISODate ) : QString() ); break; - case QVariant::Time: + case QMetaType::QTime: element.setAttribute( QStringLiteral( "type" ), QStringLiteral( "time" ) ); element.setAttribute( QStringLiteral( "value" ), value.value< QTime >().isValid() ? value.toTime().toString( Qt::ISODate ) : QString() ); break; - case QVariant::UserType: + case QMetaType::User: { if ( value.userType() == QMetaType::type( "QgsProperty" ) ) { diff --git a/src/core/qgsxmlutils.h b/src/core/qgsxmlutils.h index 48f05e3f1f86..de09326fde95 100644 --- a/src/core/qgsxmlutils.h +++ b/src/core/qgsxmlutils.h @@ -73,10 +73,10 @@ class CORE_EXPORT QgsXmlUtils * * Supported types are * - * - QVariant::Map - * - QVariant::Int - * - QVariant::Double - * - QVariant::String + * - QMetaType::QVariantMap + * - QMetaType::Int + * - QMetaType::Double + * - QMetaType::QString * - QgsProperty (since QGIS 3.4) * - QgsCoordinateReferenceSystem (since QGIS 3.4) */ diff --git a/src/core/raster/qgsexiftools.cpp b/src/core/raster/qgsexiftools.cpp index f883d7960c68..d01f4a42bf5d 100644 --- a/src/core/raster/qgsexiftools.cpp +++ b/src/core/raster/qgsexiftools.cpp @@ -483,7 +483,7 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const { actualValue = QStringLiteral( "%1/1000" ).arg( static_cast< int>( std::floor( std::abs( value.toDouble() ) * 1000 ) ) ); } - else if ( value.type() == QVariant::DateTime ) + else if ( value.typeId() == QMetaType::QDateTime ) { const QDateTime dateTime = value.toDateTime(); if ( tag == QLatin1String( "Exif.Image.DateTime" ) || @@ -498,7 +498,7 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const actualValue = dateTime.toString( Qt::ISODate ); } } - else if ( value.type() == QVariant::Date ) + else if ( value.typeId() == QMetaType::QDate ) { const QDate date = value.toDate(); if ( tag == QLatin1String( "Exif.GPSInfo.GPSDateStamp" ) ) @@ -510,7 +510,7 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const actualValue = date.toString( QStringLiteral( "yyyy-MM-dd" ) ); } } - else if ( value.type() == QVariant::Time ) + else if ( value.typeId() == QMetaType::QTime ) { const QTime time = value.toTime(); if ( tag == QLatin1String( "Exif.GPSInfo.GPSTimeStamp" ) ) @@ -529,8 +529,8 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const const bool isXmp = tag.startsWith( QLatin1String( "Xmp." ) ); image->readMetadata(); - if ( actualValue.type() == QVariant::Int || - actualValue.type() == QVariant::LongLong ) + if ( actualValue.typeId() == QMetaType::Int || + actualValue.typeId() == QMetaType::LongLong ) { if ( isXmp ) { @@ -543,8 +543,8 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const exifData[tag.toStdString()] = static_cast( actualValue.toLongLong() ); } } - if ( actualValue.type() == QVariant::UInt || - actualValue.type() == QVariant::ULongLong ) + if ( actualValue.typeId() == QMetaType::UInt || + actualValue.typeId() == QMetaType::ULongLong ) { if ( isXmp ) { @@ -557,7 +557,7 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const exifData[tag.toStdString()] = static_cast( actualValue.toULongLong() ); } } - else if ( actualValue.type() == QVariant::Double ) + else if ( actualValue.typeId() == QMetaType::Double ) { if ( isXmp ) { diff --git a/src/core/raster/qgsrasterattributetable.cpp b/src/core/raster/qgsrasterattributetable.cpp index ee45be536628..be8e82f3e29d 100644 --- a/src/core/raster/qgsrasterattributetable.cpp +++ b/src/core/raster/qgsrasterattributetable.cpp @@ -303,16 +303,16 @@ bool QgsRasterAttributeTable::insertField( int position, const Field &field, QSt for ( auto it = mData.begin(); it != mData.end(); ++it ) { - QVariant defaultValue( field.type ); + QVariant defaultValue( QMetaType( field.type ) ); // Set default values switch ( field.type ) { - case QVariant::Type::Char: - case QVariant::Type::Int: - case QVariant::Type::UInt: - case QVariant::Type::LongLong: - case QVariant::Type::ULongLong: - case QVariant::Type::Double: + case QMetaType::Type::Char: + case QMetaType::Type::Int: + case QMetaType::Type::UInt: + case QMetaType::Type::LongLong: + case QMetaType::Type::ULongLong: + case QMetaType::Type::Double: defaultValue = 0; break; default: @@ -337,7 +337,7 @@ bool QgsRasterAttributeTable::insertField( int position, const Field &field, QSt return true; } -bool QgsRasterAttributeTable::insertField( int position, const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QVariant::Type type, QString *errorMessage ) +bool QgsRasterAttributeTable::insertField( int position, const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QMetaType::Type type, QString *errorMessage ) { return insertField( position, { name, usage, type}, errorMessage ); } @@ -348,7 +348,7 @@ bool QgsRasterAttributeTable::insertColor( int position, QString *errorMessage ) int idx { position }; for ( const Qgis::RasterAttributeTableFieldUsage usage : std::as_const( colors ) ) { - if ( ! insertField( idx, usageName( usage ), usage, QVariant::Type::Int, errorMessage ) ) + if ( ! insertField( idx, usageName( usage ), usage, QMetaType::Type::Int, errorMessage ) ) { return false; } @@ -389,7 +389,7 @@ bool QgsRasterAttributeTable::insertRamp( int position, QString *errorMessage ) int idx { position }; for ( const Qgis::RasterAttributeTableFieldUsage usage : std::as_const( colors ) ) { - if ( ! insertField( idx, usageName( usage ), usage, QVariant::Type::Int, errorMessage ) ) + if ( ! insertField( idx, usageName( usage ), usage, QMetaType::Type::Int, errorMessage ) ) { return false; } @@ -398,7 +398,7 @@ bool QgsRasterAttributeTable::insertRamp( int position, QString *errorMessage ) return true; } -bool QgsRasterAttributeTable::appendField( const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QVariant::Type type, QString *errorMessage ) +bool QgsRasterAttributeTable::appendField( const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QMetaType::Type type, QString *errorMessage ) { return insertField( mFields.count(), name, usage, type, errorMessage ); } @@ -570,15 +570,15 @@ bool QgsRasterAttributeTable::readFromFile( const QString &path, QString *errorM for ( const QgsField &field : ratDbfSource.fields() ) { const Qgis::RasterAttributeTableFieldUsage usage { guessFieldUsage( field.name(), field.type() ) }; - QVariant::Type type { field.type() }; + QMetaType::Type type { field.type() }; // DBF sets all int fields to long but for RGBA it doesn't make sense - if ( type == QVariant::Type::LongLong && + if ( type == QMetaType::Type::LongLong && ( usage == Qgis::RasterAttributeTableFieldUsage::Red || usage == Qgis::RasterAttributeTableFieldUsage::RedMax || usage == Qgis::RasterAttributeTableFieldUsage::RedMin || usage == Qgis::RasterAttributeTableFieldUsage::Green || usage == Qgis::RasterAttributeTableFieldUsage::GreenMax || usage == Qgis::RasterAttributeTableFieldUsage::GreenMin || usage == Qgis::RasterAttributeTableFieldUsage::Blue || usage == Qgis::RasterAttributeTableFieldUsage::BlueMax || usage == Qgis::RasterAttributeTableFieldUsage::BlueMin || usage == Qgis::RasterAttributeTableFieldUsage::Alpha || usage == Qgis::RasterAttributeTableFieldUsage::AlphaMax || usage == Qgis::RasterAttributeTableFieldUsage::AlphaMin ) ) { - type = QVariant::Int; + type = QMetaType::Int; } if ( usage == Qgis::RasterAttributeTableFieldUsage::MinMax || usage == Qgis::RasterAttributeTableFieldUsage::Min || usage == Qgis::RasterAttributeTableFieldUsage::Max ) @@ -596,7 +596,7 @@ bool QgsRasterAttributeTable::readFromFile( const QString &path, QString *errorM } // Do we have a value field? If not, try to guess one - if ( ! hasValueField && mFields.count() > 1 && ( mFields.at( 0 ).type == QVariant::Int || mFields.at( 0 ).type == QVariant::Char || mFields.at( 0 ).type == QVariant::UInt || mFields.at( 0 ).type == QVariant::LongLong || mFields.at( 0 ).type == QVariant::ULongLong ) ) + if ( ! hasValueField && mFields.count() > 1 && ( mFields.at( 0 ).type == QMetaType::Int || mFields.at( 0 ).type == QMetaType::QChar || mFields.at( 0 ).type == QMetaType::UInt || mFields.at( 0 ).type == QMetaType::LongLong || mFields.at( 0 ).type == QMetaType::ULongLong ) ) { mFields[0].usage = Qgis::RasterAttributeTableFieldUsage::MinMax; } @@ -700,7 +700,7 @@ const QgsRasterAttributeTable::Field QgsRasterAttributeTable::fieldByName( const { *ok = false; } - return Field( QString(), Qgis::RasterAttributeTableFieldUsage::Generic, QVariant::String ); + return Field( QString(), Qgis::RasterAttributeTableFieldUsage::Generic, QMetaType::QString ); } const QList QgsRasterAttributeTable::fieldsByUsage( const Qgis::RasterAttributeTableFieldUsage fieldUsage ) const @@ -859,7 +859,7 @@ QVariantList QgsRasterAttributeTable::row( const double matchValue ) const return QVariantList(); } -Qgis::RasterAttributeTableFieldUsage QgsRasterAttributeTable::guessFieldUsage( const QString &name, const QVariant::Type type ) +Qgis::RasterAttributeTableFieldUsage QgsRasterAttributeTable::guessFieldUsage( const QString &name, const QMetaType::Type type ) { static const QStringList minValueNames { { QStringLiteral( "min" ), @@ -879,7 +879,7 @@ Qgis::RasterAttributeTableFieldUsage QgsRasterAttributeTable::guessFieldUsage( c const QString fieldLower { name.toLower() }; - if ( type == QVariant::Double || type == QVariant::Int || type == QVariant::UInt || type == QVariant::LongLong || type == QVariant::ULongLong ) + if ( type == QMetaType::Double || type == QMetaType::Int || type == QMetaType::UInt || type == QMetaType::LongLong || type == QMetaType::ULongLong ) { if ( minValueNames.contains( fieldLower ) ) { @@ -899,7 +899,7 @@ Qgis::RasterAttributeTableFieldUsage QgsRasterAttributeTable::guessFieldUsage( c return Qgis::RasterAttributeTableFieldUsage::PixelCount; } // Colors (not double) - else if ( type != QVariant::Double ) + else if ( type != QMetaType::Double ) { if ( fieldLower.contains( "red" ) || fieldLower == QLatin1String( "r" ) ) { @@ -965,7 +965,7 @@ Qgis::RasterAttributeTableFieldUsage QgsRasterAttributeTable::guessFieldUsage( c // end colors } - if ( type == QVariant::String ) // default to name for strings + if ( type == QMetaType::QString ) // default to name for strings { return Qgis::RasterAttributeTableFieldUsage::Name; } @@ -1061,12 +1061,12 @@ QgsRasterAttributeTable *QgsRasterAttributeTable::createFromRaster( QgsRasterLay if ( const QgsPalettedRasterRenderer *palettedRenderer = dynamic_cast( renderer ) ) { QgsRasterAttributeTable *rat = new QgsRasterAttributeTable(); - rat->appendField( QStringLiteral( "Value" ), Qgis::RasterAttributeTableFieldUsage::MinMax, QVariant::Type::Double ); - rat->appendField( QStringLiteral( "Class" ), Qgis::RasterAttributeTableFieldUsage::Name, QVariant::Type::String ); - rat->appendField( QStringLiteral( "Red" ), Qgis::RasterAttributeTableFieldUsage::Red, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "Green" ), Qgis::RasterAttributeTableFieldUsage::Green, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "Blue" ), Qgis::RasterAttributeTableFieldUsage::Blue, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "Alpha" ), Qgis::RasterAttributeTableFieldUsage::Alpha, QVariant::Type::Int ); + rat->appendField( QStringLiteral( "Value" ), Qgis::RasterAttributeTableFieldUsage::MinMax, QMetaType::Type::Double ); + rat->appendField( QStringLiteral( "Class" ), Qgis::RasterAttributeTableFieldUsage::Name, QMetaType::QString ); + rat->appendField( QStringLiteral( "Red" ), Qgis::RasterAttributeTableFieldUsage::Red, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "Green" ), Qgis::RasterAttributeTableFieldUsage::Green, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "Blue" ), Qgis::RasterAttributeTableFieldUsage::Blue, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "Alpha" ), Qgis::RasterAttributeTableFieldUsage::Alpha, QMetaType::Type::Int ); const QgsPalettedRasterRenderer::ClassData classes { palettedRenderer->classes() }; @@ -1094,17 +1094,17 @@ QgsRasterAttributeTable *QgsRasterAttributeTable::createFromRaster( QgsRasterLay case QgsColorRampShader::Type::Interpolated: { - rat->appendField( QStringLiteral( "Min" ), Qgis::RasterAttributeTableFieldUsage::Min, QVariant::Type::Double ); - rat->appendField( QStringLiteral( "Max" ), Qgis::RasterAttributeTableFieldUsage::Max, QVariant::Type::Double ); - rat->appendField( QStringLiteral( "Class" ), Qgis::RasterAttributeTableFieldUsage::Name, QVariant::Type::String ); - rat->appendField( QStringLiteral( "RedMin" ), Qgis::RasterAttributeTableFieldUsage::RedMin, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "GreenMin" ), Qgis::RasterAttributeTableFieldUsage::GreenMin, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "BlueMin" ), Qgis::RasterAttributeTableFieldUsage::BlueMin, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "AlphaMin" ), Qgis::RasterAttributeTableFieldUsage::AlphaMin, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "RedMax" ), Qgis::RasterAttributeTableFieldUsage::RedMax, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "GreenMax" ), Qgis::RasterAttributeTableFieldUsage::GreenMax, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "BlueMax" ), Qgis::RasterAttributeTableFieldUsage::BlueMax, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "AlphaMax" ), Qgis::RasterAttributeTableFieldUsage::AlphaMax, QVariant::Type::Int ); + rat->appendField( QStringLiteral( "Min" ), Qgis::RasterAttributeTableFieldUsage::Min, QMetaType::Type::Double ); + rat->appendField( QStringLiteral( "Max" ), Qgis::RasterAttributeTableFieldUsage::Max, QMetaType::Type::Double ); + rat->appendField( QStringLiteral( "Class" ), Qgis::RasterAttributeTableFieldUsage::Name, QMetaType::QString ); + rat->appendField( QStringLiteral( "RedMin" ), Qgis::RasterAttributeTableFieldUsage::RedMin, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "GreenMin" ), Qgis::RasterAttributeTableFieldUsage::GreenMin, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "BlueMin" ), Qgis::RasterAttributeTableFieldUsage::BlueMin, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "AlphaMin" ), Qgis::RasterAttributeTableFieldUsage::AlphaMin, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "RedMax" ), Qgis::RasterAttributeTableFieldUsage::RedMax, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "GreenMax" ), Qgis::RasterAttributeTableFieldUsage::GreenMax, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "BlueMax" ), Qgis::RasterAttributeTableFieldUsage::BlueMax, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "AlphaMax" ), Qgis::RasterAttributeTableFieldUsage::AlphaMax, QMetaType::Type::Int ); const QList rampItems { shaderFunction->colorRampItemList() }; if ( rampItems.size() > 1 ) { @@ -1127,13 +1127,13 @@ QgsRasterAttributeTable *QgsRasterAttributeTable::createFromRaster( QgsRasterLay case QgsColorRampShader::Type::Discrete: { - rat->appendField( QStringLiteral( "Min" ), Qgis::RasterAttributeTableFieldUsage::Min, QVariant::Type::Double ); - rat->appendField( QStringLiteral( "Max" ), Qgis::RasterAttributeTableFieldUsage::Max, QVariant::Type::Double ); - rat->appendField( QStringLiteral( "Class" ), Qgis::RasterAttributeTableFieldUsage::Name, QVariant::Type::String ); - rat->appendField( QStringLiteral( "Red" ), Qgis::RasterAttributeTableFieldUsage::Red, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "Green" ), Qgis::RasterAttributeTableFieldUsage::Green, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "Blue" ), Qgis::RasterAttributeTableFieldUsage::Blue, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "Alpha" ), Qgis::RasterAttributeTableFieldUsage::Alpha, QVariant::Type::Int ); + rat->appendField( QStringLiteral( "Min" ), Qgis::RasterAttributeTableFieldUsage::Min, QMetaType::Type::Double ); + rat->appendField( QStringLiteral( "Max" ), Qgis::RasterAttributeTableFieldUsage::Max, QMetaType::Type::Double ); + rat->appendField( QStringLiteral( "Class" ), Qgis::RasterAttributeTableFieldUsage::Name, QMetaType::QString ); + rat->appendField( QStringLiteral( "Red" ), Qgis::RasterAttributeTableFieldUsage::Red, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "Green" ), Qgis::RasterAttributeTableFieldUsage::Green, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "Blue" ), Qgis::RasterAttributeTableFieldUsage::Blue, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "Alpha" ), Qgis::RasterAttributeTableFieldUsage::Alpha, QMetaType::Type::Int ); const QList rampItems { shaderFunction->colorRampItemList() }; if ( rampItems.size( ) > 1 ) { @@ -1156,12 +1156,12 @@ QgsRasterAttributeTable *QgsRasterAttributeTable::createFromRaster( QgsRasterLay case QgsColorRampShader::Type::Exact: { - rat->appendField( QStringLiteral( "Value" ), Qgis::RasterAttributeTableFieldUsage::MinMax, QVariant::Type::Double ); - rat->appendField( QStringLiteral( "Class" ), Qgis::RasterAttributeTableFieldUsage::Name, QVariant::Type::String ); - rat->appendField( QStringLiteral( "Red" ), Qgis::RasterAttributeTableFieldUsage::Red, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "Green" ), Qgis::RasterAttributeTableFieldUsage::Green, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "Blue" ), Qgis::RasterAttributeTableFieldUsage::Blue, QVariant::Type::Int ); - rat->appendField( QStringLiteral( "Alpha" ), Qgis::RasterAttributeTableFieldUsage::Alpha, QVariant::Type::Int ); + rat->appendField( QStringLiteral( "Value" ), Qgis::RasterAttributeTableFieldUsage::MinMax, QMetaType::Type::Double ); + rat->appendField( QStringLiteral( "Class" ), Qgis::RasterAttributeTableFieldUsage::Name, QMetaType::QString ); + rat->appendField( QStringLiteral( "Red" ), Qgis::RasterAttributeTableFieldUsage::Red, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "Green" ), Qgis::RasterAttributeTableFieldUsage::Green, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "Blue" ), Qgis::RasterAttributeTableFieldUsage::Blue, QMetaType::Type::Int ); + rat->appendField( QStringLiteral( "Alpha" ), Qgis::RasterAttributeTableFieldUsage::Alpha, QMetaType::Type::Int ); const QList rampItems { shaderFunction->colorRampItemList() }; for ( const QgsColorRampShader::ColorRampItem &rampItem : std::as_const( rampItems ) ) { @@ -1199,26 +1199,26 @@ QHash() << QVariant::String << QVariant::Int << QVariant::LongLong << QVariant::Double } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::PixelCount, { tr( "Histogram Pixel Count" ), true, false, false, false, true, false, QList() << QVariant::LongLong } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Name, { tr( "Class Name" ), false, false, false, false, true, true, QList() << QVariant::String } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::MinMax, { tr( "Class Value (min=max)" ), true, true, false, false, true, false, QList() << QVariant::Int << QVariant::LongLong << QVariant::Double } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Min, { tr( "Class Minimum Value" ), true, true, false, false, true, false, QList() << QVariant::Int << QVariant::LongLong << QVariant::Double } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Max, { tr( "Class Maximum Value" ), true, true, false, false, true, false, QList() << QVariant::Int << QVariant::LongLong << QVariant::Double } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Red, { tr( "Red Color Value (0-255)" ), true, false, true, false, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Green, { tr( "Green Color Value (0-255)" ), true, false, true, false, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Blue, { tr( "Blue Color Value (0-255)" ), true, false, true, false, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Alpha, { tr( "Alpha Color Value (0-255)" ), true, false, true, false, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::RedMin, { tr( "Red Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::GreenMin, { tr( "Green Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::BlueMin, { tr( "Blue Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::AlphaMin, { tr( "Alpha Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::RedMax, { tr( "Red Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::GreenMax, { tr( "Green Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::BlueMax, { tr( "Blue Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QVariant::Int } ); - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::AlphaMax, { tr( "Alpha Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QVariant::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Generic, { tr( "General Purpose Field" ), false, false, false, false, true, true, QList() << QMetaType::QString << QMetaType::Int << QMetaType::LongLong << QMetaType::Double } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::PixelCount, { tr( "Histogram Pixel Count" ), true, false, false, false, true, false, QList() << QMetaType::LongLong } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Name, { tr( "Class Name" ), false, false, false, false, true, true, QList() << QMetaType::QString } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::MinMax, { tr( "Class Value (min=max)" ), true, true, false, false, true, false, QList() << QMetaType::Int << QMetaType::LongLong << QMetaType::Double } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Min, { tr( "Class Minimum Value" ), true, true, false, false, true, false, QList() << QMetaType::Int << QMetaType::LongLong << QMetaType::Double } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Max, { tr( "Class Maximum Value" ), true, true, false, false, true, false, QList() << QMetaType::Int << QMetaType::LongLong << QMetaType::Double } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Red, { tr( "Red Color Value (0-255)" ), true, false, true, false, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Green, { tr( "Green Color Value (0-255)" ), true, false, true, false, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Blue, { tr( "Blue Color Value (0-255)" ), true, false, true, false, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::Alpha, { tr( "Alpha Color Value (0-255)" ), true, false, true, false, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::RedMin, { tr( "Red Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::GreenMin, { tr( "Green Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::BlueMin, { tr( "Blue Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::AlphaMin, { tr( "Alpha Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::RedMax, { tr( "Red Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::GreenMax, { tr( "Green Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::BlueMax, { tr( "Blue Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QMetaType::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::AlphaMax, { tr( "Alpha Color Minimum Value (0-255)" ), true, false, false, true, true, false, QList() << QMetaType::Int } ); // Unsupported!! - QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::MaxCount, { tr( "Maximum GFU value(equals to GFU_AlphaMax+1 currently)" ), true, false, false, true, false, false, QList() << QVariant::Int } ); + QgsRasterAttributeTable::sUsageInformation.insert( Qgis::RasterAttributeTableFieldUsage::MaxCount, { tr( "Maximum GFU value(equals to GFU_AlphaMax+1 currently)" ), true, false, false, true, false, false, QList() << QMetaType::Int } ); } ); return QgsRasterAttributeTable::sUsageInformation; } @@ -1391,26 +1391,26 @@ QgsGradientColorRamp QgsRasterAttributeTable::colorRamp( QStringList &labels, co const QVariant val( orderedRat.value( rowIdx, labelIdx ) ); bool ok { true }; QString res; - switch ( val.type() ) + switch ( val.userType() ) { - case QVariant::Type::Char: + case QMetaType::Type::Char: return QString( val.toChar() ); - case QVariant::Type::Int: + case QMetaType::Type::Int: res = QLocale().toString( val.toInt( &ok ) ); break; - case QVariant::Type::LongLong: + case QMetaType::Type::LongLong: res = QLocale().toString( val.toLongLong( &ok ) ); break; - case QVariant::Type::UInt: + case QMetaType::Type::UInt: res = QLocale().toString( val.toUInt( &ok ) ); break; - case QVariant::Type::ULongLong: + case QMetaType::Type::ULongLong: res = QLocale().toString( val.toULongLong( &ok ) ); break; - case QVariant::Type::Double: + case QMetaType::Type::Double: res = QLocale().toString( val.toDouble( &ok ), 'g' ); break; - case QVariant::Type::String: + case QMetaType::QString: default: return val.toString( ); } diff --git a/src/core/raster/qgsrasterattributetable.h b/src/core/raster/qgsrasterattributetable.h index f174e2e50979..e79218d87003 100644 --- a/src/core/raster/qgsrasterattributetable.h +++ b/src/core/raster/qgsrasterattributetable.h @@ -78,7 +78,7 @@ class CORE_EXPORT QgsRasterAttributeTable bool maybeClass = false; //! Usage allowed types - QList allowedTypes; + QList allowedTypes; }; /** @@ -94,7 +94,7 @@ class CORE_EXPORT QgsRasterAttributeTable /** * Creates a new Field with \a name, \a type and \a usage. */ - Field( const QString &name, const Qgis::RasterAttributeTableFieldUsage &usage, const QVariant::Type type ): name( name ), usage( usage ), type( type ) {} + Field( const QString &name, const Qgis::RasterAttributeTableFieldUsage &usage, const QMetaType::Type type ): name( name ), usage( usage ), type( type ) {} /** * Returns TRUE if the field carries a color component (Red, Green, Blue and optionally Alpha) information. @@ -108,7 +108,7 @@ class CORE_EXPORT QgsRasterAttributeTable QString name; Qgis::RasterAttributeTableFieldUsage usage; - QVariant::Type type; + QMetaType::Type type; }; /** @@ -246,7 +246,7 @@ class CORE_EXPORT QgsRasterAttributeTable /** * Creates a new field from \a name, \a usage and \a type and inserts it at \a position, optionally reporting any error in \a errorMessage, returns TRUE on success. */ - bool insertField( int position, const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QVariant::Type type, QString *errorMessage SIP_OUT = nullptr ); + bool insertField( int position, const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QMetaType::Type type, QString *errorMessage SIP_OUT = nullptr ); /** * Create RGBA fields and inserts them at \a position, optionally reporting any error in \a errorMessage, returns TRUE on success. @@ -267,7 +267,7 @@ class CORE_EXPORT QgsRasterAttributeTable /** * Creates a new field from \a name, \a usage and \a type and appends it to the fields, optionally reporting any error in \a errorMessage, returns TRUE on success. */ - bool appendField( const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QVariant::Type type, QString *errorMessage SIP_OUT = nullptr ); + bool appendField( const QString &name, const Qgis::RasterAttributeTableFieldUsage usage, const QMetaType::Type type, QString *errorMessage SIP_OUT = nullptr ); /** * Appends a new \a field, optionally reporting any error in \a errorMessage, returns TRUE on success. @@ -389,7 +389,7 @@ class CORE_EXPORT QgsRasterAttributeTable /** * Try to determine the field usage from its \a name and \a type. */ - static Qgis::RasterAttributeTableFieldUsage guessFieldUsage( const QString &name, const QVariant::Type type ); + static Qgis::RasterAttributeTableFieldUsage guessFieldUsage( const QString &name, const QMetaType::Type type ); /** * Returns the (possibly empty) path of the file-based RAT, the path is set when a RAT is read or written from/to a file. diff --git a/src/core/settings/qgssettings.cpp b/src/core/settings/qgssettings.cpp index b392c0ad733e..09c5b06a58e3 100644 --- a/src/core/settings/qgssettings.cpp +++ b/src/core/settings/qgssettings.cpp @@ -303,7 +303,7 @@ void QgsSettings::setValue( const QString &key, const QVariant &value, const Qgs // Do not store if it hasn't changed from default value // First check if the values are different and if at least one of them is valid. // The valid check is required because different invalid QVariant types - // like QVariant(QVariant::String) and QVariant(QVariant::Int)) + // like QVariant(QMetaType::QString) and QVariant(QMetaType::Int)) // may be considered different and we don't want to store the value in that case. const QVariant currentValue = QgsSettings::value( prefixedKey( key, section ) ); if ( ( currentValue.isValid() || value.isValid() ) && ( currentValue != value ) ) diff --git a/src/core/symbology/qgscategorizedsymbolrenderer.cpp b/src/core/symbology/qgscategorizedsymbolrenderer.cpp index 6a56306e246d..1e0d6eae4485 100644 --- a/src/core/symbology/qgscategorizedsymbolrenderer.cpp +++ b/src/core/symbology/qgscategorizedsymbolrenderer.cpp @@ -192,7 +192,7 @@ void QgsCategorizedSymbolRenderer::rebuildHash() for ( const QgsRendererCategory &cat : std::as_const( mCategories ) ) { const QVariant val = cat.value(); - if ( val.type() == QVariant::List ) + if ( val.typeId() == QMetaType::QVariantList ) { const QVariantList list = val.toList(); for ( const QVariant &v : list ) @@ -549,8 +549,8 @@ QString QgsCategorizedSymbolRenderer::filter( const QgsFields &fields ) noneActive = noneActive && !cat.renderState(); allActive = allActive && cat.renderState(); - QVariant::Type valType = isExpression ? cat.value().type() : fields.at( attrNum ).type(); - const bool isList = cat.value().type() == QVariant::List; + QMetaType::Type valType = isExpression ? static_cast( cat.value().userType() ) : fields.at( attrNum ).type(); + const bool isList = cat.value().typeId() == QMetaType::QVariantList; QString value = QgsExpression::quotedValue( cat.value(), valType ); if ( !cat.renderState() ) @@ -565,7 +565,7 @@ QString QgsCategorizedSymbolRenderer::filter( const QgsFields &fields ) if ( !inactiveValues.isEmpty() ) inactiveValues.append( ',' ); - inactiveValues.append( QgsExpression::quotedValue( v, isExpression ? v.type() : fields.at( attrNum ).type() ) ); + inactiveValues.append( QgsExpression::quotedValue( v, isExpression ? static_cast( v.userType() ) : fields.at( attrNum ).type() ) ); } } else @@ -589,7 +589,7 @@ QString QgsCategorizedSymbolRenderer::filter( const QgsFields &fields ) if ( !activeValues.isEmpty() ) activeValues.append( ',' ); - activeValues.append( QgsExpression::quotedValue( v, isExpression ? v.type() : fields.at( attrNum ).type() ) ); + activeValues.append( QgsExpression::quotedValue( v, isExpression ? static_cast( v.userType() ) : fields.at( attrNum ).type() ) ); } } else @@ -813,17 +813,17 @@ QDomElement QgsCategorizedSymbolRenderer::save( QDomDocument &doc, const QgsRead // String for type // We just need string and three numeric types: double, ulong and long for unsigned, signed and float/double - const auto stringForType = []( const QVariant::Type type ) -> QString + const auto stringForType = []( const QMetaType::Type type ) -> QString { - if ( type == QVariant::Char || type == QVariant::Int || type == QVariant::LongLong ) + if ( type == QMetaType::QChar || type == QMetaType::Int || type == QMetaType::LongLong ) { return QStringLiteral( "long" ); } - else if ( type == QVariant::UInt || type == QVariant::ULongLong ) + else if ( type == QMetaType::UInt || type == QMetaType::ULongLong ) { return QStringLiteral( "ulong" ); } - else if ( type == QVariant::Double ) + else if ( type == QMetaType::Double ) { return QStringLiteral( "double" ) ; } @@ -847,21 +847,21 @@ QDomElement QgsCategorizedSymbolRenderer::save( QDomDocument &doc, const QgsRead symbols.insert( symbolName, cat.symbol() ); QDomElement catElem = doc.createElement( QStringLiteral( "category" ) ); - if ( cat.value().type() == QVariant::List ) + if ( cat.value().typeId() == QMetaType::QVariantList ) { const QVariantList list = cat.value().toList(); for ( const QVariant &v : list ) { QDomElement valueElem = doc.createElement( QStringLiteral( "val" ) ); valueElem.setAttribute( QStringLiteral( "value" ), v.toString() ); - valueElem.setAttribute( QStringLiteral( "type" ), stringForType( v.type() ) ); + valueElem.setAttribute( QStringLiteral( "type" ), stringForType( static_cast( v.userType() ) ) ); catElem.appendChild( valueElem ); } } else { catElem.setAttribute( QStringLiteral( "value" ), cat.value().toString() ); - catElem.setAttribute( QStringLiteral( "type" ), stringForType( cat.value().type() ) ); + catElem.setAttribute( QStringLiteral( "type" ), stringForType( static_cast( cat.value().userType() ) ) ); } catElem.setAttribute( QStringLiteral( "symbol" ), symbolName ); catElem.setAttribute( QStringLiteral( "label" ), cat.label() ); @@ -933,10 +933,10 @@ QString QgsCategorizedSymbolRenderer::displayString( const QVariant &v, int prec return QgsApplication::nullRepresentation(); } - const bool isNumeric {v.type() == QVariant::Double || v.type() == QVariant::Int || v.type() == QVariant::UInt || v.type() == QVariant::LongLong || v.type() == QVariant::ULongLong}; + const bool isNumeric {v.typeId() == QMetaType::Double || v.typeId() == QMetaType::Int || v.typeId() == QMetaType::UInt || v.typeId() == QMetaType::LongLong || v.typeId() == QMetaType::ULongLong}; // Special treatment for numeric types if group separator is set or decimalPoint is not a dot - if ( v.type() == QVariant::Double ) + if ( v.typeId() == QMetaType::Double ) { // if value doesn't contain a double (a default value expression for instance), // apply no transformation @@ -1010,7 +1010,7 @@ QString QgsCategorizedSymbolRenderer::displayString( const QVariant &v, int prec if ( ok ) return QLocale().toString( converted ); } - else if ( v.type() == QVariant::ByteArray ) + else if ( v.typeId() == QMetaType::QByteArray ) { return QObject::tr( "BLOB" ); } @@ -1019,7 +1019,7 @@ QString QgsCategorizedSymbolRenderer::displayString( const QVariant &v, int prec return v.toString(); }; - if ( v.type() == QVariant::StringList || v.type() == QVariant::List ) + if ( v.typeId() == QMetaType::QStringList || v.typeId() == QMetaType::QVariantList ) { // Note that this code is never hit because the joining of lists (merged categories) happens // in data(); I'm leaving this here anyway because it is tested and it may be useful for @@ -1090,7 +1090,7 @@ QSet QgsCategorizedSymbolRenderer::legendKeysForFeature( const QgsFeatu for ( const QgsRendererCategory &cat : mCategories ) { bool match = false; - if ( cat.value().type() == QVariant::List ) + if ( cat.value().typeId() == QMetaType::QVariantList ) { const QVariantList list = cat.value().toList(); for ( const QVariant &v : list ) @@ -1105,9 +1105,9 @@ QSet QgsCategorizedSymbolRenderer::legendKeysForFeature( const QgsFeatu else { // Numeric NULL cat value is stored as an empty string - if ( QgsVariantUtils::isNull( value ) && ( value.type() == QVariant::Double || value.type() == QVariant::Int || - value.type() == QVariant::UInt || value.type() == QVariant::LongLong || - value.type() == QVariant::ULongLong ) ) + if ( QgsVariantUtils::isNull( value ) && ( value.typeId() == QMetaType::Double || value.typeId() == QMetaType::Int || + value.typeId() == QMetaType::UInt || value.typeId() == QMetaType::LongLong || + value.typeId() == QMetaType::ULongLong ) ) { match = cat.value().toString().isEmpty(); } @@ -1142,12 +1142,12 @@ QString QgsCategorizedSymbolRenderer::legendKeyToExpression( const QString &key, const int fieldIndex = layer ? layer->fields().lookupField( mAttrName ) : -1; const bool isNumeric = layer && fieldIndex >= 0 ? layer->fields().at( fieldIndex ).isNumeric() : false; - const QVariant::Type fieldType = layer && fieldIndex >= 0 ? layer->fields().at( fieldIndex ).type() : QVariant::Invalid; + const QMetaType::Type fieldType = layer && fieldIndex >= 0 ? layer->fields().at( fieldIndex ).type() : QMetaType::UnknownType; const QString attributeComponent = QgsExpression::quoteFieldExpression( mAttrName, layer ); ok = true; const QgsRendererCategory &cat = mCategories[ ruleIndex ]; - if ( cat.value().type() == QVariant::List ) + if ( cat.value().typeId() == QMetaType::QVariantList ) { const QVariantList list = cat.value().toList(); QStringList parts; @@ -1170,7 +1170,7 @@ QString QgsCategorizedSymbolRenderer::legendKeyToExpression( const QString &key, if ( QgsVariantUtils::isNull( value ) ) return QStringLiteral( "%1 IS NULL" ).arg( attributeComponent ); - else if ( fieldType == QVariant::Type::Invalid ) + else if ( fieldType == QMetaType::UnknownType ) return QStringLiteral( "%1 = %2" ).arg( attributeComponent, QgsExpression::quotedValue( value ) ); else return QStringLiteral( "%1 = %2" ).arg( attributeComponent, QgsExpression::quotedValue( value, fieldType ) ); @@ -1453,4 +1453,3 @@ QgsCategoryList QgsCategorizedSymbolRenderer::createCategories( const QList= %2) AND (%1 <= %3)" ).arg( attributeComponent, QgsExpression::quotedValue( range.lowerValue(), QVariant::Double ), - QgsExpression::quotedValue( range.upperValue(), QVariant::Double ) ); + return QStringLiteral( "(%1 >= %2) AND (%1 <= %3)" ).arg( attributeComponent, QgsExpression::quotedValue( range.lowerValue(), QMetaType::Double ), + QgsExpression::quotedValue( range.upperValue(), QMetaType::Double ) ); } QgsSymbol *QgsGraduatedSymbolRenderer::sourceSymbol() diff --git a/src/core/symbology/qgsinterpolatedlinerenderer.cpp b/src/core/symbology/qgsinterpolatedlinerenderer.cpp index 07e391ae576f..1b56bae5953b 100644 --- a/src/core/symbology/qgsinterpolatedlinerenderer.cpp +++ b/src/core/symbology/qgsinterpolatedlinerenderer.cpp @@ -1042,7 +1042,7 @@ QgsColorRampShader QgsInterpolatedLineSymbolLayer::createColorRampShaderFromProp { QgsColorRampShader colorRampShader; - if ( properties.type() != QVariant::Map ) + if ( properties.typeId() != QMetaType::QVariantMap ) return colorRampShader; QVariantMap shaderVariantMap = properties.toMap(); @@ -1059,14 +1059,14 @@ QgsColorRampShader QgsInterpolatedLineSymbolLayer::createColorRampShaderFromProp if ( shaderVariantMap.contains( QStringLiteral( "color_ramp_shader_items_list" ) ) ) { QVariant colorRampItemsVar = shaderVariantMap.value( QStringLiteral( "color_ramp_shader_items_list" ) ); - if ( colorRampItemsVar.type() == QVariant::List ) + if ( colorRampItemsVar.typeId() == QMetaType::QVariantList ) { QVariantList itemVariantList = colorRampItemsVar.toList(); QList colorRampItemList; for ( const QVariant &itemVar : std::as_const( itemVariantList ) ) { QgsColorRampShader::ColorRampItem item; - if ( itemVar.type() != QVariant::Map ) + if ( itemVar.typeId() != QMetaType::QVariantMap ) continue; QVariantMap itemVarMap = itemVar.toMap(); if ( !itemVarMap.contains( QStringLiteral( "label" ) ) || !itemVarMap.contains( QStringLiteral( "color" ) ) || !itemVarMap.contains( QStringLiteral( "value" ) ) ) diff --git a/src/core/symbology/qgslinesymbollayer.cpp b/src/core/symbology/qgslinesymbollayer.cpp index 65fda7645ee7..34f6c8e7ed63 100644 --- a/src/core/symbology/qgslinesymbollayer.cpp +++ b/src/core/symbology/qgslinesymbollayer.cpp @@ -3403,7 +3403,7 @@ QgsRasterLineSymbolLayer *QgsRasterLineSymbolLayer::clone() const void QgsRasterLineSymbolLayer::resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving ) { const QVariantMap::iterator it = properties.find( QStringLiteral( "imageFile" ) ); - if ( it != properties.end() && it.value().type() == QVariant::String ) + if ( it != properties.end() && it.value().typeId() == QMetaType::QString ) { if ( saving ) it.value() = QgsSymbolLayerUtils::svgSymbolPathToName( it.value().toString(), pathResolver ); diff --git a/src/core/symbology/qgsmarkersymbollayer.cpp b/src/core/symbology/qgsmarkersymbollayer.cpp index 61bdf59b64f8..0c3776ce2ce6 100644 --- a/src/core/symbology/qgsmarkersymbollayer.cpp +++ b/src/core/symbology/qgsmarkersymbollayer.cpp @@ -3092,7 +3092,7 @@ void QgsRasterMarkerSymbolLayer::setCommonProperties( const QVariantMap &propert void QgsRasterMarkerSymbolLayer::resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving ) { const QVariantMap::iterator it = properties.find( QStringLiteral( "name" ) ); - if ( it != properties.end() && it.value().type() == QVariant::String ) + if ( it != properties.end() && it.value().typeId() == QMetaType::QString ) { if ( saving ) it.value() = QgsSymbolLayerUtils::svgSymbolPathToName( it.value().toString(), pathResolver ); diff --git a/src/core/symbology/qgsrulebasedrenderer.cpp b/src/core/symbology/qgsrulebasedrenderer.cpp index d0c00fa15114..46c9f3e0cb90 100644 --- a/src/core/symbology/qgsrulebasedrenderer.cpp +++ b/src/core/symbology/qgsrulebasedrenderer.cpp @@ -1320,9 +1320,9 @@ void QgsRuleBasedRenderer::refineRuleCategories( QgsRuleBasedRenderer::Rule *ini // not quoting numbers saves a type cast if ( QgsVariantUtils::isNull( cat.value() ) ) value = "NULL"; - else if ( cat.value().type() == QVariant::Int ) + else if ( cat.value().typeId() == QMetaType::Int ) value = cat.value().toString(); - else if ( cat.value().type() == QVariant::Double ) + else if ( cat.value().typeId() == QMetaType::Double ) // we loose precision here - so we may miss some categories :-( // TODO: have a possibility to construct expressions directly as a parse tree to avoid loss of precision value = QString::number( cat.value().toDouble(), 'f', 4 ); @@ -1471,14 +1471,14 @@ QgsRuleBasedRenderer *QgsRuleBasedRenderer::convertFromRenderer( const QgsFeatur rule->setLabel( category.label() ); //We first define the rule corresponding to the category - if ( category.value().type() == QVariant::List ) + if ( category.value().typeId() == QMetaType::QVariantList ) { QStringList values; const QVariantList list = category.value().toList(); for ( const QVariant &v : list ) { //If the value is a number, we can use it directly, otherwise we need to quote it in the rule - if ( QVariant( v ).convert( QVariant::Double ) ) + if ( QVariant( v ).convert( QMetaType::Double ) ) { values << v.toString(); } @@ -1500,7 +1500,7 @@ QgsRuleBasedRenderer *QgsRuleBasedRenderer::convertFromRenderer( const QgsFeatur else { //If the value is a number, we can use it directly, otherwise we need to quote it in the rule - if ( category.value().convert( QVariant::Double ) ) + if ( category.value().convert( QMetaType::Double ) ) { value = category.value().toString(); } diff --git a/src/core/symbology/qgssymbollayerutils.cpp b/src/core/symbology/qgssymbollayerutils.cpp index 06b01b23d53e..27d5951f63e3 100644 --- a/src/core/symbology/qgssymbollayerutils.cpp +++ b/src/core/symbology/qgssymbollayerutils.cpp @@ -556,7 +556,7 @@ QPointF QgsSymbolLayerUtils::toPoint( const QVariant &value, bool *ok ) if ( QgsVariantUtils::isNull( value ) ) return QPoint(); - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { const QVariantList list = value.toList(); if ( list.size() != 2 ) @@ -620,7 +620,7 @@ QSizeF QgsSymbolLayerUtils::toSize( const QVariant &value, bool *ok ) if ( QgsVariantUtils::isNull( value ) ) return QSizeF(); - if ( value.type() == QVariant::List ) + if ( value.typeId() == QMetaType::QVariantList ) { const QVariantList list = value.toList(); if ( list.size() != 2 ) @@ -3214,7 +3214,7 @@ QgsStringMap QgsSymbolLayerUtils::getVendorOptionList( QDomElement &element ) QVariantMap QgsSymbolLayerUtils::parseProperties( const QDomElement &element ) { const QVariant newSymbols = QgsXmlUtils::readVariant( element.firstChildElement( QStringLiteral( "Option" ) ) ); - if ( newSymbols.type() == QVariant::Map ) + if ( newSymbols.typeId() == QMetaType::QVariantMap ) { return newSymbols.toMap(); } diff --git a/src/core/textrenderer/qgstextfragment.h b/src/core/textrenderer/qgstextfragment.h index 5080a7a458a8..a973f6a23253 100644 --- a/src/core/textrenderer/qgstextfragment.h +++ b/src/core/textrenderer/qgstextfragment.h @@ -23,6 +23,10 @@ class QTextFragment; +// TODO needed by shiboken generator, protect with #ifdef +#include + + /** * \class QgsTextFragment * \ingroup core diff --git a/src/core/tiledscene/qgstiledsceneboundingvolume.h b/src/core/tiledscene/qgstiledsceneboundingvolume.h index 7997be904d88..4f3104b1fef4 100644 --- a/src/core/tiledscene/qgstiledsceneboundingvolume.h +++ b/src/core/tiledscene/qgstiledsceneboundingvolume.h @@ -56,7 +56,7 @@ class CORE_EXPORT QgsAbstractTiledSceneBoundingVolume default: sipType = 0; break; - }; + } SIP_END #endif diff --git a/src/core/vector/qgsfielddomain.cpp b/src/core/vector/qgsfielddomain.cpp index 20229d5ac292..68771a5e0415 100644 --- a/src/core/vector/qgsfielddomain.cpp +++ b/src/core/vector/qgsfielddomain.cpp @@ -20,7 +20,7 @@ // QgsFieldDomain // -QgsFieldDomain::QgsFieldDomain( const QString &name, const QString &description, QVariant::Type fieldType ) +QgsFieldDomain::QgsFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType ) : mName( name ) , mDescription( description ) , mFieldType( fieldType ) @@ -47,7 +47,7 @@ bool QgsCodedValue::operator!=( const QgsCodedValue &other ) const // QgsCodedFieldDomain // -QgsCodedFieldDomain::QgsCodedFieldDomain( const QString &name, const QString &description, QVariant::Type fieldType, const QList &values ) +QgsCodedFieldDomain::QgsCodedFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType, const QList &values ) : QgsFieldDomain( name, description, fieldType ) , mValues( values ) { @@ -76,7 +76,7 @@ QgsCodedFieldDomain *QgsCodedFieldDomain::clone() const // QgsRangeFieldDomain // -QgsRangeFieldDomain::QgsRangeFieldDomain( const QString &name, const QString &description, QVariant::Type fieldType, const QVariant &minimum, bool minimumIsInclusive, const QVariant &maximum, bool maximumIsInclusive ) +QgsRangeFieldDomain::QgsRangeFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType, const QVariant &minimum, bool minimumIsInclusive, const QVariant &maximum, bool maximumIsInclusive ) : QgsFieldDomain( name, description, fieldType ) , mMin( minimum ) , mMax( maximum ) @@ -109,7 +109,7 @@ QgsRangeFieldDomain *QgsRangeFieldDomain::clone() const // QgsGlobFieldDomain // -QgsGlobFieldDomain::QgsGlobFieldDomain( const QString &name, const QString &description, QVariant::Type fieldType, const QString &glob ) +QgsGlobFieldDomain::QgsGlobFieldDomain( const QString &name, const QString &description, QMetaType::Type fieldType, const QString &glob ) : QgsFieldDomain( name, description, fieldType ) , mGlob( glob ) { diff --git a/src/core/vector/qgsfielddomain.h b/src/core/vector/qgsfielddomain.h index 0cce6befaf06..ca0484228e11 100644 --- a/src/core/vector/qgsfielddomain.h +++ b/src/core/vector/qgsfielddomain.h @@ -61,7 +61,7 @@ class CORE_EXPORT QgsFieldDomain */ QgsFieldDomain( const QString &name, const QString &description, - QVariant::Type fieldType ); + QMetaType::Type fieldType ); virtual ~QgsFieldDomain(); @@ -113,14 +113,14 @@ class CORE_EXPORT QgsFieldDomain * * \see setFieldType() */ - QVariant::Type fieldType() const { return mFieldType; } + QMetaType::Type fieldType() const { return mFieldType; } /** * Sets the associated field \a type. * * \see fieldType() */ - void setFieldType( QVariant::Type type ) { mFieldType = type; } + void setFieldType( QMetaType::Type type ) { mFieldType = type; } /** * Returns the split policy. @@ -155,7 +155,7 @@ class CORE_EXPORT QgsFieldDomain QString mName; QString mDescription; - QVariant::Type mFieldType = QVariant::Type::String; + QMetaType::Type mFieldType = QMetaType::QString; Qgis::FieldDomainSplitPolicy mSplitPolicy = Qgis::FieldDomainSplitPolicy::DefaultValue; Qgis::FieldDomainMergePolicy mMergePolicy = Qgis::FieldDomainMergePolicy::DefaultValue; @@ -235,7 +235,7 @@ class CORE_EXPORT QgsCodedFieldDomain : public QgsFieldDomain */ QgsCodedFieldDomain( const QString &name, const QString &description, - QVariant::Type fieldType, + QMetaType::Type fieldType, const QList &values ); #ifndef SIP_RUN @@ -298,7 +298,7 @@ class CORE_EXPORT QgsRangeFieldDomain : public QgsFieldDomain */ QgsRangeFieldDomain( const QString &name, const QString &description, - QVariant::Type fieldType, + QMetaType::Type fieldType, const QVariant &minimum, bool minimumIsInclusive, const QVariant &maximum, @@ -431,7 +431,7 @@ class CORE_EXPORT QgsGlobFieldDomain : public QgsFieldDomain */ QgsGlobFieldDomain( const QString &name, const QString &description, - QVariant::Type fieldType, + QMetaType::Type fieldType, const QString &glob ); #ifndef SIP_RUN diff --git a/src/core/vector/qgsvectordataprovider.cpp b/src/core/vector/qgsvectordataprovider.cpp index 94a1578819ad..b7e788c64410 100644 --- a/src/core/vector/qgsvectordataprovider.cpp +++ b/src/core/vector/qgsvectordataprovider.cpp @@ -37,8 +37,8 @@ #include const int QgsVectorDataProvider::EditingCapabilities = AddFeatures | DeleteFeatures | - ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes | - RenameAttributes; + ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes | + RenameAttributes; QgsVectorDataProvider::QgsVectorDataProvider( const QString &uri, const ProviderOptions &options, QgsDataProvider::ReadFlags flags ) : QgsDataProvider( uri, options, flags ) @@ -623,17 +623,17 @@ void QgsVectorDataProvider::fillMinMaxCache() const const QgsFields flds = fields(); for ( int i = 0; i < flds.count(); ++i ) { - if ( flds.at( i ).type() == QVariant::Int ) + if ( flds.at( i ).type() == QMetaType::Int ) { mCacheMinValues[i] = QVariant( std::numeric_limits::max() ); mCacheMaxValues[i] = QVariant( std::numeric_limits::lowest() ); } - else if ( flds.at( i ).type() == QVariant::LongLong ) + else if ( flds.at( i ).type() == QMetaType::LongLong ) { mCacheMinValues[i] = QVariant( std::numeric_limits::max() ); mCacheMaxValues[i] = QVariant( std::numeric_limits::lowest() ); } - else if ( flds.at( i ).type() == QVariant::Double ) + else if ( flds.at( i ).type() == QMetaType::Double ) { mCacheMinValues[i] = QVariant( std::numeric_limits::max() ); mCacheMaxValues[i] = QVariant( std::numeric_limits::lowest() ); @@ -663,7 +663,7 @@ void QgsVectorDataProvider::fillMinMaxCache() const switch ( flds.at( attributeIndex ).type() ) { - case QVariant::Int: + case QMetaType::Int: { const int value = varValue.toInt(); if ( value < mCacheMinValues[ attributeIndex ].toInt() ) @@ -672,7 +672,7 @@ void QgsVectorDataProvider::fillMinMaxCache() const mCacheMaxValues[ attributeIndex ] = value; break; } - case QVariant::LongLong: + case QMetaType::LongLong: { const qlonglong value = varValue.toLongLong(); if ( value < mCacheMinValues[ attributeIndex ].toLongLong() ) @@ -681,7 +681,7 @@ void QgsVectorDataProvider::fillMinMaxCache() const mCacheMaxValues[ attributeIndex ] = value; break; } - case QVariant::Double: + case QMetaType::Double: { const double value = varValue.toDouble(); if ( value < mCacheMinValues[ attributeIndex ].toDouble() ) @@ -690,7 +690,7 @@ void QgsVectorDataProvider::fillMinMaxCache() const mCacheMaxValues[ attributeIndex ] = value; break; } - case QVariant::DateTime: + case QMetaType::QDateTime: { const QDateTime value = varValue.toDateTime(); if ( value < mCacheMinValues[ attributeIndex ].toDateTime() || !mCacheMinValues[ attributeIndex ].isValid() ) @@ -699,7 +699,7 @@ void QgsVectorDataProvider::fillMinMaxCache() const mCacheMaxValues[ attributeIndex ] = value; break; } - case QVariant::Date: + case QMetaType::QDate: { const QDate value = varValue.toDate(); if ( value < mCacheMinValues[ attributeIndex ].toDate() || !mCacheMinValues[ attributeIndex ].isValid() ) @@ -708,7 +708,7 @@ void QgsVectorDataProvider::fillMinMaxCache() const mCacheMaxValues[ attributeIndex ] = value; break; } - case QVariant::Time: + case QMetaType::QTime: { const QTime value = varValue.toTime(); if ( value < mCacheMinValues[ attributeIndex ].toTime() || !mCacheMinValues[ attributeIndex ].isValid() ) @@ -737,12 +737,12 @@ void QgsVectorDataProvider::fillMinMaxCache() const mCacheMinMaxDirty = false; } -QVariant QgsVectorDataProvider::convertValue( QVariant::Type type, const QString &value ) +QVariant QgsVectorDataProvider::convertValue( QMetaType::Type type, const QString &value ) { QVariant v( value ); if ( !v.convert( type ) || value.isNull() ) - v = QVariant( type ); + v = QVariant( QMetaType( type ) ); return v; } diff --git a/src/core/vector/qgsvectordataprovider.h b/src/core/vector/qgsvectordataprovider.h index ebadcd2a02da..bf777758631f 100644 --- a/src/core/vector/qgsvectordataprovider.h +++ b/src/core/vector/qgsvectordataprovider.h @@ -480,7 +480,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat struct NativeType { - NativeType( const QString &typeDesc, const QString &typeName, QVariant::Type type, int minLen = 0, int maxLen = 0, int minPrec = 0, int maxPrec = 0, QVariant::Type subType = QVariant::Invalid ) + NativeType( const QString &typeDesc, const QString &typeName, QMetaType::Type type, int minLen = 0, int maxLen = 0, int minPrec = 0, int maxPrec = 0, QMetaType::Type subType = QMetaType::UnknownType ) : mTypeDesc( typeDesc ) , mTypeName( typeName ) , mType( type ) @@ -493,12 +493,12 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat QString mTypeDesc; QString mTypeName; - QVariant::Type mType; + QMetaType::Type mType; int mMinLen; int mMaxLen; int mMinPrec; int mMaxPrec; - QVariant::Type mSubType; + QMetaType::Type mSubType; }; /** @@ -576,7 +576,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat */ virtual QgsAbstractVectorLayerLabeling *createLabeling( const QVariantMap &configuration = QVariantMap() ) const SIP_FACTORY; - static QVariant convertValue( QVariant::Type type, const QString &value ); + static QVariant convertValue( QMetaType::Type type, const QString &value ); /** * Returns the transaction this data provider is included in, if any. diff --git a/src/core/vector/qgsvectorlayerfeatureiterator.cpp b/src/core/vector/qgsvectorlayerfeatureiterator.cpp index e1cf3fb8998e..8514044a721f 100644 --- a/src/core/vector/qgsvectorlayerfeatureiterator.cpp +++ b/src/core/vector/qgsvectorlayerfeatureiterator.cpp @@ -1195,13 +1195,13 @@ void QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect( Qg QString v = joinValue.toString(); switch ( joinValue.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: break; default: - case QVariant::String: + case QMetaType::QString: v.replace( '\'', QLatin1String( "''" ) ); v.prepend( '\'' ).append( '\'' ); break; diff --git a/src/core/vector/qgsvectorlayertemporalproperties.cpp b/src/core/vector/qgsvectorlayertemporalproperties.cpp index dfdc3325b66d..44c905cdacf8 100644 --- a/src/core/vector/qgsvectorlayertemporalproperties.cpp +++ b/src/core/vector/qgsvectorlayertemporalproperties.cpp @@ -452,7 +452,7 @@ QString QgsVectorLayerTemporalProperties::createFilterString( const QgsVectorLay { if ( context.layer() && context.layer()->fields().lookupField( fieldName ) >= 0 - && context.layer()->fields().at( context.layer()->fields().lookupField( fieldName ) ).type() != QVariant::DateTime ) + && context.layer()->fields().at( context.layer()->fields().lookupField( fieldName ) ).type() != QMetaType::QDateTime ) { return QStringLiteral( "to_datetime( %1 )" ) .arg( QgsExpression::quotedColumnRef( fieldName ) ); } @@ -643,7 +643,7 @@ void QgsVectorLayerTemporalProperties::guessDefaultsFromFields( const QgsFields for ( const QgsField &field : fields ) { - if ( field.type() != QVariant::Date && field.type() != QVariant::DateTime ) + if ( field.type() != QMetaType::QDate && field.type() != QMetaType::QDateTime ) continue; if ( !foundStart ) @@ -681,7 +681,7 @@ void QgsVectorLayerTemporalProperties::guessDefaultsFromFields( const QgsFields // loop again, looking for likely "single field" candidates for ( const QgsField &field : fields ) { - if ( field.type() != QVariant::Date && field.type() != QVariant::DateTime ) + if ( field.type() != QMetaType::QDate && field.type() != QMetaType::QDateTime ) continue; for ( const QString &candidate : sSingleFieldCandidates ) diff --git a/src/core/vector/qgsvectorlayerutils.cpp b/src/core/vector/qgsvectorlayerutils.cpp index c1ff6af219d7..e8990681b701 100644 --- a/src/core/vector/qgsvectorlayerutils.cpp +++ b/src/core/vector/qgsvectorlayerutils.cpp @@ -231,7 +231,7 @@ QVariant QgsVectorLayerUtils::createUniqueValue( const QgsVectorLayer *layer, in { switch ( field.type() ) { - case QVariant::String: + case QMetaType::QString: { QString base; if ( seed.isValid() ) @@ -311,7 +311,7 @@ QVariant QgsVectorLayerUtils::createUniqueValueFromCache( const QgsVectorLayer * { switch ( field.type() ) { - case QVariant::String: + case QMetaType::QString: { QString base; if ( seed.isValid() ) @@ -715,7 +715,7 @@ void QgsVectorLayerUtils::matchAttributesToFields( QgsFeature &feature, const Qg for ( const QgsField &field : fields ) { int index = feature.fields().lookupField( field.name() ); - attributes.append( index >= 0 ? feature.attribute( index ) : QVariant( field.type() ) ); + attributes.append( index >= 0 ? feature.attribute( index ) : QVariant( QMetaType( field.type() ) ) ); } feature.setAttributes( attributes ); } @@ -736,7 +736,7 @@ void QgsVectorLayerUtils::matchAttributesToFields( QgsFeature &feature, const Qg attributes.reserve( fields.count() ); for ( int i = feature.attributes().count(); i < fields.count(); ++i ) { - attributes.append( QVariant( fields.at( i ).type() ) ); + attributes.append( QVariant( QMetaType( fields.at( i ).type() ) ) ); } feature.setAttributes( attributes ); } @@ -1253,7 +1253,7 @@ QString QgsVectorLayerUtils::guessFriendlyIdentifierField( const QgsFields &fiel // no good matches found by name, so scan through and look for the first string field for ( const QgsField &field : fields ) { - if ( field.type() == QVariant::String ) + if ( field.type() == QMetaType::QString ) return field.name(); } diff --git a/src/core/vectortile/qgsmapboxglstyleconverter.cpp b/src/core/vectortile/qgsmapboxglstyleconverter.cpp index 4241fb5a5efc..b2614c1141ef 100644 --- a/src/core/vectortile/qgsmapboxglstyleconverter.cpp +++ b/src/core/vectortile/qgsmapboxglstyleconverter.cpp @@ -238,16 +238,16 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg const QVariant jsonFillColor = jsonPaint.value( isBackgroundStyle ? QStringLiteral( "background-color" ) : QStringLiteral( "fill-color" ) ); switch ( jsonFillColor.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyFillColor, parseInterpolateColorByZoom( jsonFillColor.toMap(), context, &fillColor ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyFillColor, parseValueList( jsonFillColor.toList(), PropertyType::Color, context, 1, 255, &fillColor ) ); break; - case QVariant::String: + case QMetaType::QString: fillColor = parseColor( jsonFillColor.toString(), context ); break; @@ -281,16 +281,16 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg const QVariant jsonFillOutlineColor = jsonPaint.value( QStringLiteral( "fill-outline-color" ) ); switch ( jsonFillOutlineColor.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeColor, parseInterpolateColorByZoom( jsonFillOutlineColor.toMap(), context, &fillOutlineColor ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeColor, parseValueList( jsonFillOutlineColor.toList(), PropertyType::Color, context, 1, 255, &fillOutlineColor ) ); break; - case QVariant::String: + case QMetaType::QString: fillOutlineColor = parseColor( jsonFillOutlineColor.toString(), context ); break; @@ -308,14 +308,14 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg const QVariant jsonFillOpacity = jsonPaint.value( isBackgroundStyle ? QStringLiteral( "background-opacity" ) : QStringLiteral( "fill-opacity" ) ); switch ( jsonFillOpacity.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: fillOpacity = jsonFillOpacity.toDouble(); rasterOpacity = fillOpacity; break; - case QVariant::Map: + case QMetaType::QVariantMap: if ( ddProperties.isActive( QgsSymbolLayer::PropertyFillColor ) ) { symbol->setDataDefinedProperty( QgsSymbol::PropertyOpacity, parseInterpolateByZoom( jsonFillOpacity.toMap(), context, 100 ) ); @@ -328,8 +328,8 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg } break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: if ( ddProperties.isActive( QgsSymbolLayer::PropertyFillColor ) ) { symbol->setDataDefinedProperty( QgsSymbol::PropertyOpacity, parseValueList( jsonFillOpacity.toList(), PropertyType::Numeric, context, 100, 100 ) ); @@ -356,12 +356,12 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg switch ( jsonFillTranslate.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyOffset, parseInterpolatePointByZoom( jsonFillTranslate.toMap(), context, context.pixelSizeConversionFactor(), &fillTranslate ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: fillTranslate = QPointF( jsonFillTranslate.toList().value( 0 ).toDouble() * context.pixelSizeConversionFactor(), jsonFillTranslate.toList().value( 1 ).toDouble() * context.pixelSizeConversionFactor() ); break; @@ -484,8 +484,8 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg const QVariant jsonLinePattern = jsonPaint.value( QStringLiteral( "line-pattern" ) ); switch ( jsonLinePattern.type() ) { - case QVariant::Map: - case QVariant::String: + case QMetaType::QVariantMap: + case QMetaType::QString: { QSize spriteSize; QString spriteProperty, spriteSizeProperty; @@ -494,8 +494,8 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg break; } - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: default: break; } @@ -515,18 +515,18 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg const QVariant jsonLineColor = jsonPaint.value( QStringLiteral( "line-color" ) ); switch ( jsonLineColor.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyFillColor, parseInterpolateColorByZoom( jsonLineColor.toMap(), context, &lineColor ) ); ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeColor, ddProperties.property( QgsSymbolLayer::PropertyFillColor ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyFillColor, parseValueList( jsonLineColor.toList(), PropertyType::Color, context, 1, 255, &lineColor ) ); ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeColor, ddProperties.property( QgsSymbolLayer::PropertyFillColor ) ); break; - case QVariant::String: + case QMetaType::QString: lineColor = parseColor( jsonLineColor.toString(), context ); break; @@ -549,20 +549,20 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg const QVariant jsonLineWidth = jsonPaint.value( QStringLiteral( "line-width" ) ); switch ( jsonLineWidth.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: lineWidth = jsonLineWidth.toDouble() * context.pixelSizeConversionFactor(); break; - case QVariant::Map: + case QMetaType::QVariantMap: lineWidth = -1; lineWidthProperty = parseInterpolateByZoom( jsonLineWidth.toMap(), context, context.pixelSizeConversionFactor(), &lineWidth ); ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeWidth, lineWidthProperty ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: lineWidthProperty = parseValueList( jsonLineWidth.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor(), 255, nullptr, &lineWidth ); ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeWidth, lineWidthProperty ); break; @@ -579,19 +579,19 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg const QVariant jsonLineOffset = jsonPaint.value( QStringLiteral( "line-offset" ) ); switch ( jsonLineOffset.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: lineOffset = -jsonLineOffset.toDouble() * context.pixelSizeConversionFactor(); break; - case QVariant::Map: + case QMetaType::QVariantMap: lineWidth = -1; ddProperties.setProperty( QgsSymbolLayer::PropertyOffset, parseInterpolateByZoom( jsonLineOffset.toMap(), context, context.pixelSizeConversionFactor() * -1, &lineOffset ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyOffset, parseValueList( jsonLineOffset.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor() * -1, 255, nullptr, &lineOffset ) ); break; @@ -607,13 +607,13 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg const QVariant jsonLineOpacity = jsonPaint.value( QStringLiteral( "line-opacity" ) ); switch ( jsonLineOpacity.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: lineOpacity = jsonLineOpacity.toDouble(); break; - case QVariant::Map: + case QMetaType::QVariantMap: if ( ddProperties.isActive( QgsSymbolLayer::PropertyStrokeColor ) ) { context.pushWarning( QObject::tr( "%1: Could not set opacity of layer, opacity already defined in stroke color" ).arg( context.layerId() ) ); @@ -624,8 +624,8 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg } break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: if ( ddProperties.isActive( QgsSymbolLayer::PropertyStrokeColor ) ) { context.pushWarning( QObject::tr( "%1: Could not set opacity of layer, opacity already defined in stroke color" ).arg( context.layerId() ) ); @@ -648,7 +648,7 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg const QVariant jsonLineDashArray = jsonPaint.value( QStringLiteral( "line-dasharray" ) ); switch ( jsonLineDashArray.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: { QString arrayExpression; if ( !lineWidthProperty.asExpression().isEmpty() ) @@ -671,8 +671,8 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg break; } - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: { const QVariantList dashSource = jsonLineDashArray.toList(); @@ -820,16 +820,16 @@ bool QgsMapBoxGlStyleConverter::parseCircleLayer( const QVariantMap &jsonLayer, const QVariant jsonCircleColor = jsonPaint.value( QStringLiteral( "circle-color" ) ); switch ( jsonCircleColor.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyFillColor, parseInterpolateColorByZoom( jsonCircleColor.toMap(), context, &circleFillColor ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyFillColor, parseValueList( jsonCircleColor.toList(), PropertyType::Color, context, 1, 255, &circleFillColor ) ); break; - case QVariant::String: + case QMetaType::QString: circleFillColor = parseColor( jsonCircleColor.toString(), context ); break; @@ -851,19 +851,19 @@ bool QgsMapBoxGlStyleConverter::parseCircleLayer( const QVariantMap &jsonLayer, const QVariant jsonCircleRadius = jsonPaint.value( QStringLiteral( "circle-radius" ) ); switch ( jsonCircleRadius.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: circleDiameter = jsonCircleRadius.toDouble() * context.pixelSizeConversionFactor() * 2; break; - case QVariant::Map: + case QMetaType::QVariantMap: circleDiameter = -1; ddProperties.setProperty( QgsSymbolLayer::PropertyWidth, parseInterpolateByZoom( jsonCircleRadius.toMap(), context, context.pixelSizeConversionFactor() * 2, &circleDiameter ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyWidth, parseValueList( jsonCircleRadius.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor() * 2, 255, nullptr, &circleDiameter ) ); break; @@ -879,18 +879,18 @@ bool QgsMapBoxGlStyleConverter::parseCircleLayer( const QVariantMap &jsonLayer, const QVariant jsonCircleOpacity = jsonPaint.value( QStringLiteral( "circle-opacity" ) ); switch ( jsonCircleOpacity.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: circleOpacity = jsonCircleOpacity.toDouble(); break; - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyFillColor, parseInterpolateOpacityByZoom( jsonCircleOpacity.toMap(), circleFillColor.isValid() ? circleFillColor.alpha() : 255, &context ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyFillColor, parseValueList( jsonCircleOpacity.toList(), PropertyType::Opacity, context, 1, circleFillColor.isValid() ? circleFillColor.alpha() : 255 ) ); break; @@ -911,16 +911,16 @@ bool QgsMapBoxGlStyleConverter::parseCircleLayer( const QVariantMap &jsonLayer, const QVariant jsonCircleStrokeColor = jsonPaint.value( QStringLiteral( "circle-stroke-color" ) ); switch ( jsonCircleStrokeColor.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeColor, parseInterpolateColorByZoom( jsonCircleStrokeColor.toMap(), context, &circleStrokeColor ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeColor, parseValueList( jsonCircleStrokeColor.toList(), PropertyType::Color, context, 1, 255, &circleStrokeColor ) ); break; - case QVariant::String: + case QMetaType::QString: circleStrokeColor = parseColor( jsonCircleStrokeColor.toString(), context ); break; @@ -937,19 +937,19 @@ bool QgsMapBoxGlStyleConverter::parseCircleLayer( const QVariantMap &jsonLayer, const QVariant circleStrokeWidthJson = jsonPaint.value( QStringLiteral( "circle-stroke-width" ) ); switch ( circleStrokeWidthJson.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: circleStrokeWidth = circleStrokeWidthJson.toDouble() * context.pixelSizeConversionFactor(); break; - case QVariant::Map: + case QMetaType::QVariantMap: circleStrokeWidth = -1.0; ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeWidth, parseInterpolateByZoom( circleStrokeWidthJson.toMap(), context, context.pixelSizeConversionFactor(), &circleStrokeWidth ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeWidth, parseValueList( circleStrokeWidthJson.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor(), 255, nullptr, &circleStrokeWidth ) ); break; @@ -965,18 +965,18 @@ bool QgsMapBoxGlStyleConverter::parseCircleLayer( const QVariantMap &jsonLayer, const QVariant jsonCircleStrokeOpacity = jsonPaint.value( QStringLiteral( "circle-stroke-opacity" ) ); switch ( jsonCircleStrokeOpacity.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: circleStrokeOpacity = jsonCircleStrokeOpacity.toDouble(); break; - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeColor, parseInterpolateOpacityByZoom( jsonCircleStrokeOpacity.toMap(), circleStrokeColor.isValid() ? circleStrokeColor.alpha() : 255, &context ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyStrokeColor, parseValueList( jsonCircleStrokeOpacity.toList(), PropertyType::Opacity, context, 1, circleStrokeColor.isValid() ? circleStrokeColor.alpha() : 255 ) ); break; @@ -998,12 +998,12 @@ bool QgsMapBoxGlStyleConverter::parseCircleLayer( const QVariantMap &jsonLayer, switch ( jsonCircleTranslate.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyOffset, parseInterpolatePointByZoom( jsonCircleTranslate.toMap(), context, context.pixelSizeConversionFactor(), &circleTranslate ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: circleTranslate = QPointF( jsonCircleTranslate.toList().value( 0 ).toDouble() * context.pixelSizeConversionFactor(), jsonCircleTranslate.toList().value( 1 ).toDouble() * context.pixelSizeConversionFactor() ); break; @@ -1080,20 +1080,20 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, const QVariant jsonTextSize = jsonLayout.value( QStringLiteral( "text-size" ) ); switch ( jsonTextSize.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: textSize = jsonTextSize.toDouble() * context.pixelSizeConversionFactor(); break; - case QVariant::Map: + case QMetaType::QVariantMap: textSize = -1; textSizeProperty = parseInterpolateByZoom( jsonTextSize.toMap(), context, context.pixelSizeConversionFactor(), &textSize ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: textSize = -1; textSizeProperty = parseValueList( jsonTextSize.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor(), 255, nullptr, &textSize ); break; @@ -1118,18 +1118,18 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, const QVariant jsonTextMaxWidth = jsonLayout.value( QStringLiteral( "text-max-width" ) ); switch ( jsonTextMaxWidth.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: textMaxWidth = jsonTextMaxWidth.toDouble() * EM_TO_CHARS; break; - case QVariant::Map: + case QMetaType::QVariantMap: ddLabelProperties.setProperty( QgsPalLayerSettings::AutoWrapLength, parseInterpolateByZoom( jsonTextMaxWidth.toMap(), context, EM_TO_CHARS, &textMaxWidth ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddLabelProperties.setProperty( QgsPalLayerSettings::AutoWrapLength, parseValueList( jsonTextMaxWidth.toList(), PropertyType::Numeric, context, EM_TO_CHARS, 255, nullptr, &textMaxWidth ) ); break; @@ -1150,18 +1150,18 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, const QVariant jsonTextLetterSpacing = jsonLayout.value( QStringLiteral( "text-letter-spacing" ) ); switch ( jsonTextLetterSpacing.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: textLetterSpacing = jsonTextLetterSpacing.toDouble(); break; - case QVariant::Map: + case QMetaType::QVariantMap: ddLabelProperties.setProperty( QgsPalLayerSettings::FontLetterSpacing, parseInterpolateByZoom( jsonTextLetterSpacing.toMap(), context, 1, &textLetterSpacing ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddLabelProperties.setProperty( QgsPalLayerSettings::FontLetterSpacing, parseValueList( jsonTextLetterSpacing.toList(), PropertyType::Numeric, context, 1, 255, nullptr, &textLetterSpacing ) ); break; @@ -1234,8 +1234,8 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, }; const QVariant jsonTextFont = jsonLayout.value( QStringLiteral( "text-font" ) ); - if ( jsonTextFont.type() != QVariant::List && jsonTextFont.type() != QVariant::StringList && jsonTextFont.type() != QVariant::String - && jsonTextFont.type() != QVariant::Map ) + if ( jsonTextFont.typeId() != QMetaType::QVariantList && jsonTextFont.typeId() != QMetaType::QStringList && jsonTextFont.typeId() != QMetaType::QString + && jsonTextFont.typeId() != QMetaType::QVariantMap ) { context.pushWarning( QObject::tr( "%1: Skipping unsupported text-font type (%2)" ).arg( context.layerId(), QMetaType::typeName( jsonTextFont.type() ) ) ); } @@ -1243,16 +1243,16 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, { switch ( jsonTextFont.type() ) { - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: fontName = jsonTextFont.toList().value( 0 ).toString(); break; - case QVariant::String: + case QMetaType::QString: fontName = jsonTextFont.toString(); break; - case QVariant::Map: + case QMetaType::QVariantMap: { QString familyCaseString = QStringLiteral( "CASE " ); QString styleCaseString = QStringLiteral( "CASE " ); @@ -1264,8 +1264,8 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, { // bottom zoom and value const QVariant bz = stops.value( i ).toList().value( 0 ); - const QString bv = stops.value( i ).toList().value( 1 ).type() == QVariant::String ? stops.value( i ).toList().value( 1 ).toString() : stops.value( i ).toList().value( 1 ).toList().value( 0 ).toString(); - if ( bz.type() == QVariant::List || bz.type() == QVariant::StringList ) + const QString bv = stops.value( i ).toList().value( 1 ).typeId() == QMetaType::QString ? stops.value( i ).toList().value( 1 ).toString() : stops.value( i ).toList().value( 1 ).toList().value( 0 ).toString(); + if ( bz.typeId() == QMetaType::QVariantList || bz.typeId() == QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Expressions in interpolation function are not supported, skipping." ).arg( context.layerId() ) ); error = true; @@ -1274,7 +1274,7 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, // top zoom const QVariant tz = stops.value( i + 1 ).toList().value( 0 ); - if ( tz.type() == QVariant::List || tz.type() == QVariant::StringList ) + if ( tz.typeId() == QMetaType::QVariantList || tz.typeId() == QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Expressions in interpolation function are not supported, skipping." ).arg( context.layerId() ) ); error = true; @@ -1300,7 +1300,7 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, if ( error ) break; - const QString bv = stops.constLast().toList().value( 1 ).type() == QVariant::String ? stops.constLast().toList().value( 1 ).toString() : stops.constLast().toList().value( 1 ).toList().value( 0 ).toString(); + const QString bv = stops.constLast().toList().value( 1 ).typeId() == QMetaType::QString ? stops.constLast().toList().value( 1 ).toString() : stops.constLast().toList().value( 1 ).toList().value( 0 ).toString(); if ( splitFontFamily( bv, fontFamily, fontStyleName ) ) { familyCaseString += QStringLiteral( "ELSE %1 END" ).arg( QgsExpression::quotedValue( fontFamily ) ); @@ -1370,16 +1370,16 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, const QVariant jsonTextColor = jsonPaint.value( QStringLiteral( "text-color" ) ); switch ( jsonTextColor.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddLabelProperties.setProperty( QgsPalLayerSettings::Color, parseInterpolateColorByZoom( jsonTextColor.toMap(), context, &textColor ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddLabelProperties.setProperty( QgsPalLayerSettings::Color, parseValueList( jsonTextColor.toList(), PropertyType::Color, context, 1, 255, &textColor ) ); break; - case QVariant::String: + case QMetaType::QString: textColor = parseColor( jsonTextColor.toString(), context ); break; @@ -1401,16 +1401,16 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, const QVariant jsonBufferColor = jsonPaint.value( QStringLiteral( "text-halo-color" ) ); switch ( jsonBufferColor.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddLabelProperties.setProperty( QgsPalLayerSettings::BufferColor, parseInterpolateColorByZoom( jsonBufferColor.toMap(), context, &bufferColor ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddLabelProperties.setProperty( QgsPalLayerSettings::BufferColor, parseValueList( jsonBufferColor.toList(), PropertyType::Color, context, 1, 255, &bufferColor ) ); break; - case QVariant::String: + case QMetaType::QString: bufferColor = parseColor( jsonBufferColor.toString(), context ); break; @@ -1430,19 +1430,19 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, const QVariant jsonHaloWidth = jsonPaint.value( QStringLiteral( "text-halo-width" ) ); switch ( jsonHaloWidth.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: bufferSize = jsonHaloWidth.toDouble() * context.pixelSizeConversionFactor() * BUFFER_SIZE_SCALE; break; - case QVariant::Map: + case QMetaType::QVariantMap: bufferSize = 1; ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseInterpolateByZoom( jsonHaloWidth.toMap(), context, context.pixelSizeConversionFactor() * BUFFER_SIZE_SCALE, &bufferSize ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: bufferSize = 1; ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseValueList( jsonHaloWidth.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor() * BUFFER_SIZE_SCALE, 255, nullptr, &bufferSize ) ); break; @@ -1459,9 +1459,9 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, const QVariant jsonTextHaloBlur = jsonPaint.value( QStringLiteral( "text-halo-blur" ) ); switch ( jsonTextHaloBlur.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: { haloBlurSize = jsonTextHaloBlur.toDouble() * context.pixelSizeConversionFactor(); break; @@ -1531,14 +1531,14 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, const QVariant jsonTextField = jsonLayout.value( QStringLiteral( "text-field" ) ); switch ( jsonTextField.type() ) { - case QVariant::String: + case QMetaType::QString: { labelSettings.fieldName = processLabelField( jsonTextField.toString(), labelSettings.isExpression ); break; } - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: { const QVariantList textFieldList = jsonTextField.toList(); /* @@ -1577,7 +1577,7 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, break; } - case QVariant::Map: + case QMetaType::QVariantMap: { const QVariantList stops = jsonTextField.toMap().value( QStringLiteral( "stops" ) ).toList(); if ( !stops.empty() ) @@ -1643,7 +1643,7 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, // units are ems! switch ( jsonTextOffset.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: textOffsetProperty = parseInterpolatePointByZoom( jsonTextOffset.toMap(), context, !textSizeProperty ? textSize : 1.0, &textOffset ); if ( !textSizeProperty ) { @@ -1656,8 +1656,8 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, ddLabelProperties.setProperty( QgsPalLayerSettings::LinePlacementOptions, QStringLiteral( "if(array_get(%1,1)>0,'BL','AL')" ).arg( textOffsetProperty ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: textOffset = QPointF( jsonTextOffset.toList().value( 0 ).toDouble() * textSize, jsonTextOffset.toList().value( 1 ).toDouble() * textSize ); break; @@ -1704,15 +1704,15 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, switch ( jsonTextJustify.type() ) { - case QVariant::String: + case QMetaType::QString: textAlign = jsonTextJustify.toString(); break; - case QVariant::List: + case QMetaType::QVariantList: ddLabelProperties.setProperty( QgsPalLayerSettings::OffsetQuad, QgsProperty::fromExpression( parseStringStops( jsonTextJustify.toList(), context, conversionMap, &textAlign ) ) ); break; - case QVariant::Map: + case QMetaType::QVariantMap: ddLabelProperties.setProperty( QgsPalLayerSettings::OffsetQuad, parseInterpolateStringByZoom( jsonTextJustify.toMap(), context, conversionMap, &textAlign ) ); break; @@ -1757,15 +1757,15 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, switch ( jsonTextAnchor.type() ) { - case QVariant::String: + case QMetaType::QString: textAnchor = jsonTextAnchor.toString(); break; - case QVariant::List: + case QMetaType::QVariantList: ddLabelProperties.setProperty( QgsPalLayerSettings::OffsetQuad, QgsProperty::fromExpression( parseStringStops( jsonTextAnchor.toList(), context, conversionMap, &textAnchor ) ) ); break; - case QVariant::Map: + case QMetaType::QVariantMap: ddLabelProperties.setProperty( QgsPalLayerSettings::OffsetQuad, parseInterpolateStringByZoom( jsonTextAnchor.toMap(), context, conversionMap, &textAnchor ) ); break; @@ -1802,12 +1802,12 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, // units are ems! switch ( jsonTextOffset.type() ) { - case QVariant::Map: + case QMetaType::QVariantMap: ddLabelProperties.setProperty( QgsPalLayerSettings::OffsetXY, parseInterpolatePointByZoom( jsonTextOffset.toMap(), context, textSize, &textOffset ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: textOffset = QPointF( jsonTextOffset.toList().value( 0 ).toDouble() * textSize, jsonTextOffset.toList().value( 1 ).toDouble() * textSize ); break; @@ -1899,18 +1899,18 @@ bool QgsMapBoxGlStyleConverter::parseSymbolLayerAsRenderer( const QVariantMap &j const QVariant jsonSpacing = jsonLayout.value( QStringLiteral( "symbol-spacing" ) ); switch ( jsonSpacing.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: spacing = jsonSpacing.toDouble() * context.pixelSizeConversionFactor(); break; - case QVariant::Map: + case QMetaType::QVariantMap: ddProperties.setProperty( QgsSymbolLayer::PropertyInterval, parseInterpolateByZoom( jsonSpacing.toMap(), context, context.pixelSizeConversionFactor(), &spacing ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: ddProperties.setProperty( QgsSymbolLayer::PropertyInterval, parseValueList( jsonSpacing.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor(), 255, nullptr, &spacing ) ); break; @@ -1946,18 +1946,18 @@ bool QgsMapBoxGlStyleConverter::parseSymbolLayerAsRenderer( const QVariantMap &j const QVariant jsonIconRotate = jsonLayout.value( QStringLiteral( "icon-rotate" ) ); switch ( jsonIconRotate.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: rotation = jsonIconRotate.toDouble(); break; - case QVariant::Map: + case QMetaType::QVariantMap: markerDdProperties.setProperty( QgsSymbolLayer::PropertyAngle, parseInterpolateByZoom( jsonIconRotate.toMap(), context, context.pixelSizeConversionFactor(), &rotation ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: markerDdProperties.setProperty( QgsSymbolLayer::PropertyAngle, parseValueList( jsonIconRotate.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor(), 255, nullptr, &rotation ) ); break; @@ -2000,9 +2000,9 @@ bool QgsMapBoxGlStyleConverter::parseSymbolLayerAsRenderer( const QVariantMap &j QgsProperty property; switch ( jsonIconSize.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: { size = jsonIconSize.toDouble(); if ( !spriteSizeProperty.isEmpty() ) @@ -2013,12 +2013,12 @@ bool QgsMapBoxGlStyleConverter::parseSymbolLayerAsRenderer( const QVariantMap &j break; } - case QVariant::Map: + case QMetaType::QVariantMap: property = parseInterpolateByZoom( jsonIconSize.toMap(), context, 1, &size ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: default: context.pushWarning( QObject::tr( "%1: Skipping non-implemented icon-size type (%2)" ).arg( context.layerId(), QMetaType::typeName( jsonIconSize.type() ) ) ); break; @@ -2081,9 +2081,9 @@ bool QgsMapBoxGlStyleConverter::parseSymbolLayerAsRenderer( const QVariantMap &j QgsProperty property; switch ( jsonIconSize.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: { size = jsonIconSize.toDouble(); if ( !spriteSizeProperty.isEmpty() ) @@ -2094,12 +2094,12 @@ bool QgsMapBoxGlStyleConverter::parseSymbolLayerAsRenderer( const QVariantMap &j break; } - case QVariant::Map: + case QMetaType::QVariantMap: property = parseInterpolateByZoom( jsonIconSize.toMap(), context, 1, &size ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: default: context.pushWarning( QObject::tr( "%1: Skipping non-implemented icon-size type (%2)" ).arg( context.layerId(), QMetaType::typeName( jsonIconSize.type() ) ) ); break; @@ -2126,18 +2126,18 @@ bool QgsMapBoxGlStyleConverter::parseSymbolLayerAsRenderer( const QVariantMap &j const QVariant jsonIconRotate = jsonLayout.value( QStringLiteral( "icon-rotate" ) ); switch ( jsonIconRotate.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: rotation = jsonIconRotate.toDouble(); break; - case QVariant::Map: + case QMetaType::QVariantMap: markerDdProperties.setProperty( QgsSymbolLayer::PropertyAngle, parseInterpolateByZoom( jsonIconRotate.toMap(), context, context.pixelSizeConversionFactor(), &rotation ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: markerDdProperties.setProperty( QgsSymbolLayer::PropertyAngle, parseValueList( jsonIconRotate.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor(), 255, nullptr, &rotation ) ); break; @@ -2153,18 +2153,18 @@ bool QgsMapBoxGlStyleConverter::parseSymbolLayerAsRenderer( const QVariantMap &j const QVariant jsonIconOpacity = jsonPaint.value( QStringLiteral( "icon-opacity" ) ); switch ( jsonIconOpacity.type() ) { - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: iconOpacity = jsonIconOpacity.toDouble(); break; - case QVariant::Map: + case QMetaType::QVariantMap: markerDdProperties.setProperty( QgsSymbolLayer::PropertyOpacity, parseInterpolateByZoom( jsonIconOpacity.toMap(), context, 100, &iconOpacity ) ); break; - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: markerDdProperties.setProperty( QgsSymbolLayer::PropertyOpacity, parseValueList( jsonIconOpacity.toList(), PropertyType::Numeric, context, 100, 255, nullptr, &iconOpacity ) ); break; @@ -2429,7 +2429,7 @@ QString QgsMapBoxGlStyleConverter::parsePointStops( double base, const QVariantL // bottom zoom and value const QVariant bz = stops.value( i ).toList().value( 0 ); const QVariant bv = stops.value( i ).toList().value( 1 ); - if ( bv.type() != QVariant::List && bv.type() != QVariant::StringList ) + if ( bv.typeId() != QMetaType::QVariantList && bv.typeId() != QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Skipping unsupported offset interpolation type (%2)." ).arg( context.layerId(), QMetaType::typeName( bz.type() ) ) ); return QString(); @@ -2438,7 +2438,7 @@ QString QgsMapBoxGlStyleConverter::parsePointStops( double base, const QVariantL // top zoom and value const QVariant tz = stops.value( i + 1 ).toList().value( 0 ); const QVariant tv = stops.value( i + 1 ).toList().value( 1 ); - if ( tv.type() != QVariant::List && tv.type() != QVariant::StringList ) + if ( tv.typeId() != QMetaType::QVariantList && tv.typeId() != QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Skipping unsupported offset interpolation type (%2)." ).arg( context.layerId(), QMetaType::typeName( tz.type() ) ) ); return QString(); @@ -2508,7 +2508,7 @@ QString QgsMapBoxGlStyleConverter::parseStops( double base, const QVariantList & // bottom zoom and value const QVariant bz = stops.value( i ).toList().value( 0 ); const QVariant bv = stops.value( i ).toList().value( 1 ); - if ( bz.type() == QVariant::List || bz.type() == QVariant::StringList ) + if ( bz.typeId() == QMetaType::QVariantList || bz.typeId() == QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Expressions in interpolation function are not supported, skipping." ).arg( context.layerId() ) ); return QString(); @@ -2517,7 +2517,7 @@ QString QgsMapBoxGlStyleConverter::parseStops( double base, const QVariantList & // top zoom and value const QVariant tz = stops.value( i + 1 ).toList().value( 0 ); const QVariant tv = stops.value( i + 1 ).toList().value( 1 ); - if ( tz.type() == QVariant::List || tz.type() == QVariant::StringList ) + if ( tz.typeId() == QMetaType::QVariantList || tz.typeId() == QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Expressions in interpolation function are not supported, skipping." ).arg( context.layerId() ) ); return QString(); @@ -2535,7 +2535,7 @@ QString QgsMapBoxGlStyleConverter::parseStops( double base, const QVariantList & const QVariant z = stops.last().toList().value( 0 ); const QVariant v = stops.last().toList().value( 1 ); QString vStr = v.toString(); - if ( ( QMetaType::Type )v.type() == QMetaType::QVariantList ) + if ( ( QMetaType::Type )v.typeId() == QMetaType::QVariantList ) { vStr = parseExpression( v.toList(), context ); caseString += QStringLiteral( "WHEN @vector_tile_zoom > %1 " @@ -2559,7 +2559,7 @@ QString QgsMapBoxGlStyleConverter::parseStringStops( const QVariantList &stops, // bottom zoom and value const QVariant bz = stops.value( i ).toList().value( 0 ); const QString bv = stops.value( i ).toList().value( 1 ).toString(); - if ( bz.type() == QVariant::List || bz.type() == QVariant::StringList ) + if ( bz.typeId() == QMetaType::QVariantList || bz.typeId() == QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Expressions in interpolation function are not supported, skipping." ).arg( context.layerId() ) ); return QString(); @@ -2567,7 +2567,7 @@ QString QgsMapBoxGlStyleConverter::parseStringStops( const QVariantList &stops, // top zoom const QVariant tz = stops.value( i + 1 ).toList().value( 0 ); - if ( tz.type() == QVariant::List || tz.type() == QVariant::StringList ) + if ( tz.typeId() == QMetaType::QVariantList || tz.typeId() == QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Expressions in interpolation function are not supported, skipping." ).arg( context.layerId() ) ); return QString(); @@ -2594,7 +2594,7 @@ QString QgsMapBoxGlStyleConverter::parseLabelStops( const QVariantList &stops, Q { // bottom zoom and value const QVariant bz = stops.value( i ).toList().value( 0 ); - if ( bz.type() == QVariant::List || bz.type() == QVariant::StringList ) + if ( bz.typeId() == QMetaType::QVariantList || bz.typeId() == QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Lists in label interpolation function are not supported, skipping." ).arg( context.layerId() ) ); return QString(); @@ -2602,7 +2602,7 @@ QString QgsMapBoxGlStyleConverter::parseLabelStops( const QVariantList &stops, Q // top zoom const QVariant tz = stops.value( i + 1 ).toList().value( 0 ); - if ( tz.type() == QVariant::List || tz.type() == QVariant::StringList ) + if ( tz.typeId() == QMetaType::QVariantList || tz.typeId() == QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Lists in label interpolation function are not supported, skipping." ).arg( context.layerId() ) ); return QString(); @@ -2622,7 +2622,7 @@ QString QgsMapBoxGlStyleConverter::parseLabelStops( const QVariantList &stops, Q { const QVariant bz = stops.constLast().toList().value( 0 ); - if ( bz.type() == QVariant::List || bz.type() == QVariant::StringList ) + if ( bz.typeId() == QMetaType::QVariantList || bz.typeId() == QMetaType::QStringList ) { context.pushWarning( QObject::tr( "%1: Lists in label interpolation function are not supported, skipping." ).arg( context.layerId() ) ); return QString(); @@ -2831,7 +2831,7 @@ QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateListByZoom( const QVarian QString QgsMapBoxGlStyleConverter::parseColorExpression( const QVariant &colorExpression, QgsMapBoxGlStyleConversionContext &context ) { - if ( ( QMetaType::Type )colorExpression.type() == QMetaType::QVariantList ) + if ( ( QMetaType::Type )colorExpression.typeId() == QMetaType::QVariantList ) { return parseExpression( colorExpression.toList(), context, true ); } @@ -2840,7 +2840,7 @@ QString QgsMapBoxGlStyleConverter::parseColorExpression( const QVariant &colorEx QColor QgsMapBoxGlStyleConverter::parseColor( const QVariant &color, QgsMapBoxGlStyleConversionContext &context ) { - if ( color.type() != QVariant::String ) + if ( color.typeId() != QMetaType::QString ) { context.pushWarning( QObject::tr( "%1: Could not parse non-string color %2, skipping" ).arg( context.layerId(), color.toString() ) ); return QColor(); @@ -2880,11 +2880,11 @@ QString QgsMapBoxGlStyleConverter::interpolateExpression( double zoomMin, double QString minValueExpr = valueMin.toString(); QString maxValueExpr = valueMax.toString(); - if ( ( QMetaType::Type )valueMin.type() == QMetaType::QVariantList ) + if ( ( QMetaType::Type )valueMin.typeId() == QMetaType::QVariantList ) { minValueExpr = parseExpression( valueMin.toList(), context ); } - if ( ( QMetaType::Type )valueMax.type() == QMetaType::QVariantList ) + if ( ( QMetaType::Type )valueMax.typeId() == QMetaType::QVariantList ) { maxValueExpr = parseExpression( valueMax.toList(), context ); } @@ -3043,11 +3043,11 @@ QString QgsMapBoxGlStyleConverter::parseExpression( const QVariantList &expressi const QString attribute = expression.value( 1 ).toList().value( 1 ).toString(); if ( expression.size() == 5 - && expression.at( 3 ).type() == QVariant::Bool && expression.at( 3 ).toBool() == true - && expression.at( 4 ).type() == QVariant::Bool && expression.at( 4 ).toBool() == false ) + && expression.at( 3 ).typeId() == QMetaType::Bool && expression.at( 3 ).toBool() == true + && expression.at( 4 ).typeId() == QMetaType::Bool && expression.at( 4 ).toBool() == false ) { // simple case, make a nice simple expression instead of a CASE statement - if ( expression.at( 2 ).type() == QVariant::List || expression.at( 2 ).type() == QVariant::StringList ) + if ( expression.at( 2 ).typeId() == QMetaType::QVariantList || expression.at( 2 ).typeId() == QMetaType::QStringList ) { QStringList parts; for ( const QVariant &p : expression.at( 2 ).toList() ) @@ -3060,8 +3060,8 @@ QString QgsMapBoxGlStyleConverter::parseExpression( const QVariantList &expressi else return QgsExpression::createFieldEqualityExpression( attribute, expression.at( 2 ).toList().value( 0 ) ); } - else if ( expression.at( 2 ).type() == QVariant::String || expression.at( 2 ).type() == QVariant::Int - || expression.at( 2 ).type() == QVariant::Double || expression.at( 2 ).type() == QVariant::LongLong ) + else if ( expression.at( 2 ).typeId() == QMetaType::QString || expression.at( 2 ).typeId() == QMetaType::Int + || expression.at( 2 ).typeId() == QMetaType::Double || expression.at( 2 ).typeId() == QMetaType::LongLong ) { return QgsExpression::createFieldEqualityExpression( attribute, expression.at( 2 ) ); } @@ -3076,7 +3076,7 @@ QString QgsMapBoxGlStyleConverter::parseExpression( const QVariantList &expressi QString caseString = QStringLiteral( "CASE " ); for ( int i = 2; i < expression.size() - 2; i += 2 ) { - if ( expression.at( i ).type() == QVariant::List || expression.at( i ).type() == QVariant::StringList ) + if ( expression.at( i ).typeId() == QMetaType::QVariantList || expression.at( i ).typeId() == QMetaType::QStringList ) { QStringList parts; for ( const QVariant &p : expression.at( i ).toList() ) @@ -3089,8 +3089,8 @@ QString QgsMapBoxGlStyleConverter::parseExpression( const QVariantList &expressi else caseString += QStringLiteral( "WHEN %1 " ).arg( QgsExpression::createFieldEqualityExpression( attribute, expression.at( i ).toList().value( 0 ) ) ); } - else if ( expression.at( i ).type() == QVariant::String || expression.at( i ).type() == QVariant::Int - || expression.at( i ).type() == QVariant::Double || expression.at( i ).type() == QVariant::LongLong ) + else if ( expression.at( i ).typeId() == QMetaType::QString || expression.at( i ).typeId() == QMetaType::Int + || expression.at( i ).typeId() == QMetaType::Double || expression.at( i ).typeId() == QMetaType::LongLong ) { caseString += QStringLiteral( "WHEN (%1) " ).arg( QgsExpression::createFieldEqualityExpression( attribute, expression.at( i ) ) ); } @@ -3164,7 +3164,7 @@ QString QgsMapBoxGlStyleConverter::retrieveSpriteAsBase64( const QVariant &value switch ( value.type() ) { - case QVariant::String: + case QMetaType::QString: { QString spriteName = value.toString(); const thread_local QRegularExpression fieldNameMatch( QStringLiteral( "{([^}]+)}" ) ); @@ -3216,7 +3216,7 @@ QString QgsMapBoxGlStyleConverter::retrieveSpriteAsBase64( const QVariant &value break; } - case QVariant::Map: + case QMetaType::QVariantMap: { const QVariantList stops = value.toMap().value( QStringLiteral( "stops" ) ).toList(); if ( stops.size() == 0 ) @@ -3267,7 +3267,7 @@ QString QgsMapBoxGlStyleConverter::retrieveSpriteAsBase64( const QVariant &value break; } - case QVariant::List: + case QMetaType::QVariantList: { const QVariantList json = value.toList(); const QString method = json.value( 0 ).toString(); @@ -3333,12 +3333,12 @@ QString QgsMapBoxGlStyleConverter::parseValue( const QVariant &value, QgsMapBoxG QColor c; switch ( value.type() ) { - case QVariant::List: - case QVariant::StringList: + case QMetaType::QVariantList: + case QMetaType::QStringList: return parseExpression( value.toList(), context, colorExpected ); - case QVariant::Bool: - case QVariant::String: + case QMetaType::Bool: + case QMetaType::QString: if ( colorExpected ) { QColor c = parseColor( value, context ); @@ -3349,12 +3349,12 @@ QString QgsMapBoxGlStyleConverter::parseValue( const QVariant &value, QgsMapBoxG } return QgsExpression::quotedValue( value ); - case QVariant::Int: - case QVariant::LongLong: - case QVariant::Double: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::Double: return value.toString(); - case QVariant::Color: + case QMetaType::QColor: c = value.value(); return QString( "color_rgba(%1,%2,%3,%4)" ).arg( c.red() ).arg( c.green() ).arg( c.blue() ).arg( c.alpha() ); @@ -3375,7 +3375,7 @@ QString QgsMapBoxGlStyleConverter::parseKey( const QVariant &value, QgsMapBoxGlS { return QStringLiteral( "level" ); } - else if ( ( value.type() == QVariant::List && value.toList().size() == 1 ) || value.type() == QVariant::StringList ) + else if ( ( value.typeId() == QMetaType::QVariantList && value.toList().size() == 1 ) || value.typeId() == QMetaType::QStringList ) { if ( value.toList().size() > 1 ) return value.toList().at( 1 ).toString(); @@ -3389,7 +3389,7 @@ QString QgsMapBoxGlStyleConverter::parseKey( const QVariant &value, QgsMapBoxGlS return valueString; } } - else if ( value.type() == QVariant::List && value.toList().size() > 1 ) + else if ( value.typeId() == QMetaType::QVariantList && value.toList().size() > 1 ) { return parseExpression( value.toList(), context ); } diff --git a/src/core/vectortile/qgsvectortilelayer.cpp b/src/core/vectortile/qgsvectortilelayer.cpp index 8e80d0f513f8..62df5a510cbb 100644 --- a/src/core/vectortile/qgsvectortilelayer.cpp +++ b/src/core/vectortile/qgsvectortilelayer.cpp @@ -708,8 +708,8 @@ void QgsVectorTileLayer::selectByGeometry( const QgsGeometry &geometry, const Qg auto addDerivedFields = []( QgsFeature & feature, const int tileZoom, const QString & layer ) { QgsFields fields = feature.fields(); - fields.append( QgsField( QStringLiteral( "tile_zoom" ), QVariant::Int ) ); - fields.append( QgsField( QStringLiteral( "tile_layer" ), QVariant::String ) ); + fields.append( QgsField( QStringLiteral( "tile_zoom" ), QMetaType::Int ) ); + fields.append( QgsField( QStringLiteral( "tile_layer" ), QMetaType::QString ) ); QgsAttributes attributes = feature.attributes(); attributes << tileZoom << layer; feature.setFields( fields ); diff --git a/src/core/vectortile/qgsvectortilematrixset.cpp b/src/core/vectortile/qgsvectortilematrixset.cpp index 4114df589ef9..0faf3fb6cf96 100644 --- a/src/core/vectortile/qgsvectortilematrixset.cpp +++ b/src/core/vectortile/qgsvectortilematrixset.cpp @@ -154,7 +154,7 @@ bool QgsVectorTileMatrixSet::fromEsriJson( const QVariantMap &json, const QVaria childIndex = 3; const QVariant childNode = node.at( childIndex ); - if ( childNode.type() == QVariant::List ) + if ( childNode.typeId() == QMetaType::QVariantList ) { node = childNode.toList(); column = tile.column() * 2; diff --git a/src/core/vectortile/qgsvectortilemvtencoder.cpp b/src/core/vectortile/qgsvectortilemvtencoder.cpp index e60514983279..b8a4a723e8ca 100644 --- a/src/core/vectortile/qgsvectortilemvtencoder.cpp +++ b/src/core/vectortile/qgsvectortilemvtencoder.cpp @@ -286,11 +286,11 @@ void QgsVectorTileMVTEncoder::addFeature( vector_tile::Tile_Layer *tileLayer, co valueIndex = tileLayer->values_size() - 1; mKnownValues[v] = valueIndex; - if ( v.type() == QVariant::Double ) + if ( v.typeId() == QMetaType::Double ) value->set_double_value( v.toDouble() ); - else if ( v.type() == QVariant::Int ) + else if ( v.typeId() == QMetaType::Int ) value->set_int_value( v.toInt() ); - else if ( v.type() == QVariant::Bool ) + else if ( v.typeId() == QMetaType::Bool ) value->set_bool_value( v.toBool() ); else value->set_string_value( v.toString().toUtf8().toStdString() ); diff --git a/src/core/vectortile/qgsvectortileutils.cpp b/src/core/vectortile/qgsvectortileutils.cpp index 209448d0ef35..bbaa45464d3f 100644 --- a/src/core/vectortile/qgsvectortileutils.cpp +++ b/src/core/vectortile/qgsvectortileutils.cpp @@ -59,7 +59,7 @@ QgsFields QgsVectorTileUtils::makeQgisFields( const QSet &flds ) std::sort( fieldsSorted.begin(), fieldsSorted.end() ); for ( const QString &fieldName : std::as_const( fieldsSorted ) ) { - fields.append( QgsField( fieldName, QVariant::String ) ); + fields.append( QgsField( fieldName, QMetaType::QString ) ); } return fields; } diff --git a/src/core/vectortile/qgsvectortilewriter.cpp b/src/core/vectortile/qgsvectortilewriter.cpp index e12654e7c803..031b7794e4c2 100644 --- a/src/core/vectortile/qgsvectortilewriter.cpp +++ b/src/core/vectortile/qgsvectortilewriter.cpp @@ -292,9 +292,9 @@ QString QgsVectorTileWriter::mbtilesJsonSchema() for ( const QgsField &field : fields ) { QString fieldTypeStr; - if ( field.type() == QVariant::Bool ) + if ( field.type() == QMetaType::Bool ) fieldTypeStr = QStringLiteral( "Boolean" ); - else if ( field.type() == QVariant::Int || field.type() == QVariant::Double ) + else if ( field.type() == QMetaType::Int || field.type() == QMetaType::Double ) fieldTypeStr = QStringLiteral( "Number" ); else fieldTypeStr = QStringLiteral( "String" );