@@ -1350,14 +1350,48 @@ class CORE_EXPORT QgsProcessingParameterExpression : public QgsProcessingParamet
1350
1350
1351
1351
};
1352
1352
1353
+
1354
+ /* *
1355
+ * \class QgsProcessingParameterLimitedDataTypes
1356
+ * \ingroup core
1357
+ * Can be inherited by parameters which require limits to their acceptable data types.
1358
+ * \since QGIS 3.0
1359
+ */
1360
+ class CORE_EXPORT QgsProcessingParameterLimitedDataTypes
1361
+ {
1362
+ public:
1363
+
1364
+ /* *
1365
+ * Constructor for QgsProcessingParameterLimitedDataTypes, with a list of acceptable data \a types.
1366
+ */
1367
+ QgsProcessingParameterLimitedDataTypes ( const QList< int > &types = QList< int >() );
1368
+
1369
+ /* *
1370
+ * Returns the geometry types for sources acceptable by the parameter.
1371
+ * \see setDataTypes()
1372
+ */
1373
+ QList< int > dataTypes () const ;
1374
+
1375
+ /* *
1376
+ * Sets the geometry \a types for sources acceptable by the parameter.
1377
+ * \see dataTypes()
1378
+ */
1379
+ void setDataTypes ( const QList< int > &types );
1380
+
1381
+ protected:
1382
+
1383
+ // ! List of acceptable data types for the parameter
1384
+ QList< int > mDataTypes ;
1385
+ };
1386
+
1353
1387
/* *
1354
1388
* \class QgsProcessingParameterVectorLayer
1355
1389
* \ingroup core
1356
1390
* A vector layer (with or without geometry) parameter for processing algorithms. Consider using
1357
1391
* the more versatile QgsProcessingParameterFeatureSource wherever possible.
1358
1392
* \since QGIS 3.0
1359
1393
*/
1360
- class CORE_EXPORT QgsProcessingParameterVectorLayer : public QgsProcessingParameterDefinition
1394
+ class CORE_EXPORT QgsProcessingParameterVectorLayer : public QgsProcessingParameterDefinition, public QgsProcessingParameterLimitedDataTypes
1361
1395
{
1362
1396
public:
1363
1397
@@ -1379,18 +1413,6 @@ class CORE_EXPORT QgsProcessingParameterVectorLayer : public QgsProcessingParame
1379
1413
bool checkValueIsAcceptable ( const QVariant &input, QgsProcessingContext *context = nullptr ) const override ;
1380
1414
QString valueAsPythonString ( const QVariant &value, QgsProcessingContext &context ) const override ;
1381
1415
1382
- /* *
1383
- * Returns the geometry types for sources acceptable by the parameter.
1384
- * \see setDataTypes()
1385
- */
1386
- QList< int > dataTypes () const ;
1387
-
1388
- /* *
1389
- * Sets the geometry \a types for sources acceptable by the parameter.
1390
- * \see dataTypes()
1391
- */
1392
- void setDataTypes ( const QList< int > &types );
1393
-
1394
1416
QVariantMap toVariantMap () const override ;
1395
1417
bool fromVariantMap ( const QVariantMap &map ) override ;
1396
1418
@@ -1399,11 +1421,6 @@ class CORE_EXPORT QgsProcessingParameterVectorLayer : public QgsProcessingParame
1399
1421
*/
1400
1422
static QgsProcessingParameterVectorLayer *fromScriptCode ( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1401
1423
1402
- private:
1403
-
1404
- QList< int > mDataTypes = QList< int >() << QgsProcessing::TypeVectorAnyGeometry;
1405
-
1406
-
1407
1424
};
1408
1425
1409
1426
/* *
@@ -1497,13 +1514,14 @@ class CORE_EXPORT QgsProcessingParameterField : public QgsProcessingParameterDef
1497
1514
1498
1515
};
1499
1516
1517
+
1500
1518
/* *
1501
1519
* \class QgsProcessingParameterFeatureSource
1502
1520
* \ingroup core
1503
1521
* An input feature source (such as vector layers) parameter for processing algorithms.
1504
1522
* \since QGIS 3.0
1505
1523
*/
1506
- class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingParameterDefinition
1524
+ class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingParameterDefinition, public QgsProcessingParameterLimitedDataTypes
1507
1525
{
1508
1526
public:
1509
1527
@@ -1524,18 +1542,6 @@ class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingPara
1524
1542
QString valueAsPythonString ( const QVariant &value, QgsProcessingContext &context ) const override ;
1525
1543
QString asScriptCode () const override ;
1526
1544
1527
- /* *
1528
- * Returns the geometry types for sources acceptable by the parameter.
1529
- * \see setDataTypes()
1530
- */
1531
- QList< int > dataTypes () const ;
1532
-
1533
- /* *
1534
- * Sets the geometry \a types for sources acceptable by the parameter.
1535
- * \see dataTypes()
1536
- */
1537
- void setDataTypes ( const QList< int > &types );
1538
-
1539
1545
QVariantMap toVariantMap () const override ;
1540
1546
bool fromVariantMap ( const QVariantMap &map ) override ;
1541
1547
@@ -1544,10 +1550,6 @@ class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingPara
1544
1550
*/
1545
1551
static QgsProcessingParameterFeatureSource *fromScriptCode ( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1546
1552
1547
- private:
1548
-
1549
- QList< int > mDataTypes = QList< int >() << QgsProcessing::TypeVectorAnyGeometry;
1550
-
1551
1553
};
1552
1554
1553
1555
/* *
0 commit comments