Compare commits

...

49 Commits

Author SHA1 Message Date
Jonathan Lurie
74c66877f7
Merge 4bab898301d3e80bea6ab38f864a5a37fb2f2685 into 85e00b755b12821fb40dba0286c7231c2a6b611a 2025-10-01 10:32:30 +10:00
Jonathan Lurie
4bab898301 removed blank line 2025-09-17 14:09:22 +02:00
Jonathan Lurie
eca451bf4a addresing review 2025-09-08 11:39:44 +02:00
Jonathan Lurie
e6efa0a5c6 fix after review 2025-09-04 13:32:32 +02:00
Jonathan Lurie
0ae2327be1
Merge branch 'master' into model-designer-update 2025-07-04 09:59:16 +02:00
jonathanlurie
64bef5c290 adding some more UT 2025-07-03 16:38:43 +02:00
jonathanlurie
e30a729a28 fix friendly string for point, add UT 2025-07-03 11:54:34 +02:00
jonathanlurie
40b7b18358 WIP userFriendlString testing 2025-06-23 17:35:03 +02:00
jonathanlurie
b1fcfad0fa updating comments 2025-06-20 10:24:06 +02:00
jonathanlurie
939fcf9ea2 using static default color 2025-06-19 15:32:10 +02:00
jonathanlurie
16cdae82ce Better function naming 2025-06-19 15:27:19 +02:00
jonathanlurie
2743ea2fa7 avoid abbreviations 3 2025-06-19 15:03:18 +02:00
jonathanlurie
93dd35920a avoid abbreviations 2 2025-06-19 14:57:20 +02:00
jonathanlurie
3f5c2a7a1b avoid abbreviations 2025-06-19 14:56:50 +02:00
jonathanlurie
9c1035e773 rename method to socketColor 2025-06-19 14:54:48 +02:00
jonathanlurie
293be69903 better crs string 2025-06-19 14:29:43 +02:00
jonathanlurie
8bd12426d7 add translations for invalid data time 2025-06-19 14:23:09 +02:00
jonathanlurie
17b26806d6 wkt encoded geometries now display geom type in graphic item 2025-06-19 13:29:31 +02:00
jonathanlurie
b29f446c7c add geometry type name getter 2025-06-19 10:31:25 +02:00
jonathanlurie
76ac2f916b moved param colors to types 2025-06-13 15:16:20 +02:00
jonathanlurie
7ba380c851 apply fixes 2025-06-13 13:12:27 +02:00
jonathanlurie
9670c98118 Merge branch 'master' into model-designer-update 2025-06-04 11:35:59 +02:00
jonathanlurie
5b7c964178 Merge branch 'master' into model-designer-update 2025-05-27 09:15:58 +02:00
jonathanlurie
8a8c0f4501 make fields shorter 2025-05-26 16:54:50 +02:00
jonathanlurie
a44563fd4d shorter gradient 2025-05-26 15:22:03 +02:00
jonathanlurie
5a121ceb95 gradient along path when type is fluid 2025-05-26 14:32:37 +02:00
jonathanlurie
620db939b8 Update color groups 2025-05-23 16:34:56 +02:00
jonathanlurie
0f54c08f4c Merge branch 'master' into model-designer-update 2025-05-23 09:59:14 +02:00
jonathanlurie
4ebabb5ba6 Merge branch 'master' into model-designer-update 2025-05-20 16:47:16 +02:00
jonathanlurie
cce86d7cff WIP tailored prompt for param type 2025-05-16 16:53:38 +02:00
jonathanlurie
0e1e1505eb output socket now are always filled 2025-05-15 11:51:28 +02:00
jonathanlurie
f84c4ff43b merging switch cases 2025-05-15 11:35:51 +02:00
jonathanlurie
1af32010e8 Adjusted start socket position and style 2025-05-15 11:34:28 +02:00
jonathanlurie
1f622fb9b5 moving the socket with a small offset to better align 2025-05-14 16:53:29 +02:00
jonathanlurie
287fc1b0f2 simplified getting socket colors 2025-05-14 16:26:07 +02:00
jonathanlurie
46ebf8dff2 moved virtual method body to cpp file 2 2025-05-14 15:07:25 +02:00
jonathanlurie
1dda85e367 moved virtual method body to cpp file 2025-05-14 14:08:36 +02:00
jonathanlurie
f36e86ff5d refectored param color logic 2025-05-13 18:01:20 +02:00
jonathanlurie
c4b0d73b7d removed unnecessary else returns 2025-05-13 14:33:51 +02:00
jonathanlurie
9bacaee3c6 return empty string to signal error 2025-05-13 14:26:16 +02:00
jonathanlurie
545e264c70 removed var used only once 2025-05-13 14:14:30 +02:00
jonathanlurie
9b95398cdb simplified button positioning 2025-05-13 14:12:30 +02:00
jonathanlurie
2fe7c92204 now using virtual method for getting param data type 2025-05-12 16:47:56 +02:00
jonathanlurie
19e318fb1b formatting 2025-05-12 15:51:52 +02:00
jonathanlurie
12c1264293 testing with better line jumps 2 2025-05-12 15:15:49 +02:00
jonathanlurie
9b45dedeb7 Added color names 2025-05-12 15:13:05 +02:00
jonathanlurie
a7b079752a Merge branch 'master' into model-designer-update 2025-05-12 15:02:48 +02:00
github-actions[bot]
192298a388 auto-fix pre-commit issues 2025-05-08 07:16:15 +00:00
jonathanlurie
99613254d1 adding model designer style customization 2025-05-07 18:39:13 +02:00
33 changed files with 1159 additions and 107 deletions

View File

@ -1,19 +1,19 @@
# The following has been generated automatically from src/core/processing/qgsprocessingoutputs.h
try:
QgsProcessingOutputMapLayer.typeName = staticmethod(QgsProcessingOutputMapLayer.typeName)
QgsProcessingOutputMapLayer.__overridden_methods__ = ['type']
QgsProcessingOutputMapLayer.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputMapLayer.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputVectorLayer.typeName = staticmethod(QgsProcessingOutputVectorLayer.typeName)
QgsProcessingOutputVectorLayer.__overridden_methods__ = ['type']
QgsProcessingOutputVectorLayer.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputVectorLayer.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputRasterLayer.typeName = staticmethod(QgsProcessingOutputRasterLayer.typeName)
QgsProcessingOutputRasterLayer.__overridden_methods__ = ['type']
QgsProcessingOutputRasterLayer.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputRasterLayer.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -25,13 +25,13 @@ except (NameError, AttributeError):
pass
try:
QgsProcessingOutputMultipleLayers.typeName = staticmethod(QgsProcessingOutputMultipleLayers.typeName)
QgsProcessingOutputMultipleLayers.__overridden_methods__ = ['type', 'valueAsString']
QgsProcessingOutputMultipleLayers.__overridden_methods__ = ['type', 'modelColor', 'valueAsString']
QgsProcessingOutputMultipleLayers.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputHtml.typeName = staticmethod(QgsProcessingOutputHtml.typeName)
QgsProcessingOutputHtml.__overridden_methods__ = ['type', 'valueAsFormattedString']
QgsProcessingOutputHtml.__overridden_methods__ = ['type', 'modelColor', 'valueAsFormattedString']
QgsProcessingOutputHtml.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -43,31 +43,31 @@ except (NameError, AttributeError):
pass
try:
QgsProcessingOutputNumber.typeName = staticmethod(QgsProcessingOutputNumber.typeName)
QgsProcessingOutputNumber.__overridden_methods__ = ['type', 'valueAsString']
QgsProcessingOutputNumber.__overridden_methods__ = ['modelColor', 'type', 'valueAsString']
QgsProcessingOutputNumber.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputString.typeName = staticmethod(QgsProcessingOutputString.typeName)
QgsProcessingOutputString.__overridden_methods__ = ['type']
QgsProcessingOutputString.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputString.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputBoolean.typeName = staticmethod(QgsProcessingOutputBoolean.typeName)
QgsProcessingOutputBoolean.__overridden_methods__ = ['type', 'valueAsString']
QgsProcessingOutputBoolean.__overridden_methods__ = ['modelColor', 'type', 'valueAsString']
QgsProcessingOutputBoolean.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputFolder.typeName = staticmethod(QgsProcessingOutputFolder.typeName)
QgsProcessingOutputFolder.__overridden_methods__ = ['type', 'valueAsFormattedString']
QgsProcessingOutputFolder.__overridden_methods__ = ['type', 'modelColor', 'valueAsFormattedString']
QgsProcessingOutputFolder.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputFile.typeName = staticmethod(QgsProcessingOutputFile.typeName)
QgsProcessingOutputFile.__overridden_methods__ = ['type', 'valueAsFormattedString']
QgsProcessingOutputFile.__overridden_methods__ = ['type', 'modelColor', 'valueAsFormattedString']
QgsProcessingOutputFile.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -79,12 +79,12 @@ except (NameError, AttributeError):
pass
try:
QgsProcessingOutputVectorTileLayer.typeName = staticmethod(QgsProcessingOutputVectorTileLayer.typeName)
QgsProcessingOutputVectorTileLayer.__overridden_methods__ = ['type']
QgsProcessingOutputVectorTileLayer.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputVectorTileLayer.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputDefinition.__virtual_methods__ = ['valueAsString', 'valueAsFormattedString']
QgsProcessingOutputDefinition.__virtual_methods__ = ['modelColor', 'valueAsString', 'valueAsFormattedString']
QgsProcessingOutputDefinition.__abstract_methods__ = ['type']
QgsProcessingOutputDefinition.__group__ = ['processing']
except (NameError, AttributeError):

View File

@ -82,7 +82,7 @@ except (NameError, AttributeError):
try:
QgsProcessingParameterCrs.typeName = staticmethod(QgsProcessingParameterCrs.typeName)
QgsProcessingParameterCrs.fromScriptCode = staticmethod(QgsProcessingParameterCrs.fromScriptCode)
QgsProcessingParameterCrs.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsString', 'valueAsJsonObject']
QgsProcessingParameterCrs.__overridden_methods__ = ['userFriendlyString', 'clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsString', 'valueAsJsonObject']
QgsProcessingParameterCrs.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -103,7 +103,7 @@ except (NameError, AttributeError):
try:
QgsProcessingParameterGeometry.typeName = staticmethod(QgsProcessingParameterGeometry.typeName)
QgsProcessingParameterGeometry.fromScriptCode = staticmethod(QgsProcessingParameterGeometry.fromScriptCode)
QgsProcessingParameterGeometry.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterGeometry.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterGeometry.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -137,25 +137,25 @@ except (NameError, AttributeError):
pass
try:
QgsProcessingParameterDistance.typeName = staticmethod(QgsProcessingParameterDistance.typeName)
QgsProcessingParameterDistance.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterDistance.__overridden_methods__ = ['userFriendlyString', 'clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterDistance.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingParameterArea.typeName = staticmethod(QgsProcessingParameterArea.typeName)
QgsProcessingParameterArea.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterArea.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterArea.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingParameterVolume.typeName = staticmethod(QgsProcessingParameterVolume.typeName)
QgsProcessingParameterVolume.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterVolume.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterVolume.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingParameterDuration.typeName = staticmethod(QgsProcessingParameterDuration.typeName)
QgsProcessingParameterDuration.__overridden_methods__ = ['clone', 'type', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterDuration.__overridden_methods__ = ['clone', 'type', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterDuration.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -183,7 +183,7 @@ except (NameError, AttributeError):
try:
QgsProcessingParameterEnum.typeName = staticmethod(QgsProcessingParameterEnum.typeName)
QgsProcessingParameterEnum.fromScriptCode = staticmethod(QgsProcessingParameterEnum.fromScriptCode)
QgsProcessingParameterEnum.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsPythonComment', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterEnum.__overridden_methods__ = ['userFriendlyString', 'clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsPythonComment', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterEnum.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -326,7 +326,7 @@ except (NameError, AttributeError):
try:
QgsProcessingParameterDateTime.typeName = staticmethod(QgsProcessingParameterDateTime.typeName)
QgsProcessingParameterDateTime.fromScriptCode = staticmethod(QgsProcessingParameterDateTime.fromScriptCode)
QgsProcessingParameterDateTime.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'toolTip', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterDateTime.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'toolTip', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterDateTime.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -389,7 +389,7 @@ try:
except (NameError, AttributeError):
pass
try:
QgsProcessingParameterDefinition.__virtual_methods__ = ['isDestination', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsJsonObject', 'valueAsString', 'valueAsStringList', 'valueAsPythonComment', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'dependsOnOtherParameters', 'toolTip']
QgsProcessingParameterDefinition.__virtual_methods__ = ['modelColor', 'userFriendlyString', 'isDestination', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsJsonObject', 'valueAsString', 'valueAsStringList', 'valueAsPythonComment', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'dependsOnOtherParameters', 'toolTip']
QgsProcessingParameterDefinition.__abstract_methods__ = ['clone', 'type']
QgsProcessingParameterDefinition.__group__ = ['processing']
except (NameError, AttributeError):

View File

@ -1,6 +1,7 @@
# The following has been generated automatically from src/core/processing/qgsprocessingparametertype.h
try:
QgsProcessingParameterType.__virtual_methods__ = ['pythonImportString', 'className', 'flags', 'metadata', 'acceptedPythonTypes', 'acceptedStringValues', 'acceptedDataTypes']
QgsProcessingParameterType.defaultModelColor = staticmethod(QgsProcessingParameterType.defaultModelColor)
QgsProcessingParameterType.__virtual_methods__ = ['pythonImportString', 'className', 'flags', 'metadata', 'acceptedPythonTypes', 'acceptedStringValues', 'acceptedDataTypes', 'modelColor']
QgsProcessingParameterType.__abstract_methods__ = ['create', 'description', 'name', 'id', 'acceptedParameterTypes', 'acceptedOutputTypes']
QgsProcessingParameterType.__group__ = ['processing']
except (NameError, AttributeError):

View File

@ -65,6 +65,13 @@ Constructor for QgsProcessingOutputDefinition.
virtual ~QgsProcessingOutputDefinition();
virtual QColor modelColor() const;
%Docstring
Returns the color to use for the output in model designer windows.
.. versionadded:: 4.0
%End
virtual QString type() const = 0;
%Docstring
Unique output type name.
@ -189,6 +196,9 @@ raster), use :py:class:`QgsProcessingOutputVectorLayer` or
Constructor for QgsProcessingOutputMapLayer.
%End
virtual QColor modelColor() const;
static QString typeName();
%Docstring
Returns the type name for the output class.
@ -215,6 +225,9 @@ A vector layer output for processing algorithms.
Constructor for QgsProcessingOutputVectorLayer.
%End
virtual QColor modelColor() const;
static QString typeName();
%Docstring
Returns the type name for the output class.
@ -257,6 +270,9 @@ Constructor for QgsProcessingOutputRasterLayer.
%Docstring
Returns the type name for the output class.
%End
virtual QColor modelColor() const;
virtual QString type() const;
};
@ -316,8 +332,10 @@ Returns the type name for the output class.
%End
virtual QString type() const;
virtual QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
virtual QColor modelColor() const;
virtual QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
};
@ -342,6 +360,9 @@ Constructor for QgsProcessingOutputHtml.
Returns the type name for the output class.
%End
virtual QString type() const;
virtual QColor modelColor() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
};
@ -370,6 +391,7 @@ Constructor for QgsProcessingOutputVariant.
%Docstring
Returns the type name for the output class.
%End
virtual QString type() const;
virtual QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
@ -393,6 +415,9 @@ A numeric output for processing algorithms.
Constructor for QgsProcessingOutputNumber.
%End
virtual QColor modelColor() const;
static QString typeName();
%Docstring
Returns the type name for the output class.
@ -423,6 +448,9 @@ Constructor for QgsProcessingOutputString.
%Docstring
Returns the type name for the output class.
%End
virtual QColor modelColor() const;
virtual QString type() const;
};
@ -444,6 +472,9 @@ A boolean output for processing algorithms.
Constructor for :py:class:`QgsProcessingOutputNumber`.
%End
virtual QColor modelColor() const;
static QString typeName();
%Docstring
Returns the type name for the output class.
@ -475,8 +506,10 @@ Constructor for QgsProcessingOutputFolder.
Returns the type name for the output class.
%End
virtual QString type() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
virtual QColor modelColor() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
};
@ -501,8 +534,10 @@ Constructor for QgsProcessingOutputFile.
Returns the type name for the output class.
%End
virtual QString type() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
virtual QColor modelColor() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
};
@ -554,6 +589,9 @@ Constructor for QgsProcessingOutputVectorTileLayer.
%Docstring
Returns the type name for the output class.
%End
virtual QColor modelColor() const;
virtual QString type() const;
};

View File

@ -438,6 +438,27 @@ Constructor for QgsProcessingParameterDefinition.
virtual ~QgsProcessingParameterDefinition();
virtual QColor modelColor() const;
%Docstring
Returns the color to use for the parameter in model designer windows.
The default implementation retrieves the color from the parameter type,
see :py:func:`QgsProcessingParameterType.modelColor()`.
.. versionadded:: 4.0
%End
virtual QString userFriendlyString( const QVariant &value ) const;
%Docstring
Returns a user-friendly string representation of the provided parameter
``value``.
The returned string is to be used for display purposes only, and should
be translated as required.
.. versionadded:: 4.0
%End
virtual QgsProcessingParameterDefinition *clone() const = 0 /Factory/;
%Docstring
Creates a clone of the parameter definition.
@ -1994,6 +2015,9 @@ A coordinate reference system parameter for processing algorithms.
Constructor for QgsProcessingParameterCrs.
%End
virtual QString userFriendlyString( const QVariant &value ) const;
static QString typeName();
%Docstring
Returns the type name for the parameter class.
@ -2167,6 +2191,7 @@ Sets the allow multipart geometries
.. seealso:: :py:func:`allowMultipart`
%End
virtual QString userFriendlyString( const QVariant &value ) const;
static QgsProcessingParameterGeometry *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
@ -2316,6 +2341,7 @@ Constructor for QgsProcessingParameterMatrix.
%Docstring
Returns the type name for the parameter class.
%End
virtual QgsProcessingParameterDefinition *clone() const /Factory/;
virtual QString type() const;
@ -2512,6 +2538,7 @@ Constructor for QgsProcessingParameterNumber.
%Docstring
Returns the type name for the parameter class.
%End
virtual QgsProcessingParameterDefinition *clone() const /Factory/;
virtual QString type() const;
@ -2620,6 +2647,9 @@ Constructor for QgsProcessingParameterDistance.
Returns the type name for the parameter class.
%End
virtual QString userFriendlyString( const QVariant &value ) const;
virtual QgsProcessingParameterDistance *clone() const /Factory/;
@ -2758,6 +2788,8 @@ Sets the default area ``unit`` for the parameter.
virtual bool fromVariantMap( const QVariantMap &map );
virtual QString userFriendlyString( const QVariant &value ) const;
};
@ -2848,6 +2880,8 @@ Sets the default volume ``unit`` for the parameter.
virtual bool fromVariantMap( const QVariantMap &map );
virtual QString userFriendlyString( const QVariant &value ) const;
};
@ -2907,6 +2941,8 @@ Sets the default duration ``unit`` for the parameter.
virtual bool fromVariantMap( const QVariantMap &map );
virtual QString userFriendlyString( const QVariant &value ) const;
};
@ -2977,6 +3013,7 @@ Constructor for QgsProcessingParameterRange.
%Docstring
Returns the type name for the parameter class.
%End
virtual QgsProcessingParameterDefinition *clone() const /Factory/;
virtual QString type() const;
@ -3106,6 +3143,9 @@ values.
Constructor for QgsProcessingParameterEnum.
%End
virtual QString userFriendlyString( const QVariant &value ) const;
static QString typeName();
%Docstring
Returns the type name for the parameter class.
@ -4523,6 +4563,7 @@ varying color opacity.
%Docstring
Returns the type name for the parameter class.
%End
virtual QgsProcessingParameterDefinition *clone() const /Factory/;
virtual QString type() const;
@ -4861,6 +4902,8 @@ Sets the acceptable data ``type`` for the parameter.
virtual bool fromVariantMap( const QVariantMap &map );
virtual QString userFriendlyString( const QVariant &value ) const;
static QgsProcessingParameterDateTime *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring

View File

@ -23,6 +23,13 @@ Makes metadata of processing parameters available.
%End
public:
static QColor defaultModelColor();
%Docstring
Returns the default color for a processing parameter.
.. versionadded:: 4.0
%End
virtual QgsProcessingParameterDefinition *create( const QString &name ) const = 0 /Factory/;
%Docstring
Creates a new parameter of this type.
@ -175,6 +182,16 @@ for the parameter.
.. seealso:: :py:func:`acceptedOutputTypes`
.. versionadded:: 3.44
%End
virtual QColor modelColor() const;
%Docstring
Returns the color to use for the parameter in model designer windows.
The default implementation returns
:py:func:`~QgsProcessingParameterType.defaultModelColor`.
.. versionadded:: 4.0
%End
};

View File

@ -16,7 +16,7 @@ QgsModelComponentGraphicItem.Flag.__and__ = lambda flag1, flag2: _force_int(flag
QgsModelComponentGraphicItem.Flag.__or__ = lambda flag1, flag2: QgsModelComponentGraphicItem.Flag(_force_int(flag1) | _force_int(flag2))
try:
QgsModelComponentGraphicItem.__attribute_docs__ = {'requestModelRepaint': 'Emitted by the item to request a repaint of the parent model scene.\n', 'aboutToChange': 'Emitted when the definition of the associated component is about to be\nchanged by the item.\n\nThe ``text`` argument gives the translated text describing the change\nabout to occur, and the optional ``id`` can be used to group the\nassociated undo commands.\n', 'changed': 'Emitted when the definition of the associated component is changed by\nthe item.\n', 'repaintArrows': 'Emitted when item requests that all connected arrows are repainted.\n', 'updateArrowPaths': 'Emitted when item requires that all connected arrow paths are\nrecalculated.\n', 'sizePositionChanged': "Emitted when the item's size or position changes.\n"}
QgsModelComponentGraphicItem.__virtual_methods__ = ['flags', 'linkPointCount', 'linkPointText', 'editComment', 'canDeleteComponent', 'deleteComponent', 'editComponent', 'strokeStyle', 'titleAlignment', 'iconPicture', 'iconPixmap']
QgsModelComponentGraphicItem.__virtual_methods__ = ['flags', 'linkedParameterDataType', 'linkPointCount', 'linkPointText', 'editComment', 'canDeleteComponent', 'deleteComponent', 'editComponent', 'strokeStyle', 'titleAlignment', 'iconPicture', 'iconPixmap']
QgsModelComponentGraphicItem.__abstract_methods__ = ['fillColor', 'strokeColor', 'textColor', 'updateStoredComponentPosition']
QgsModelComponentGraphicItem.__overridden_methods__ = ['mouseDoubleClickEvent', 'hoverEnterEvent', 'hoverMoveEvent', 'hoverLeaveEvent', 'itemChange', 'boundingRect', 'contains', 'paint']
QgsModelComponentGraphicItem.__signal_arguments__ = {'aboutToChange': ['text: str', 'id: int = 0']}
@ -30,7 +30,7 @@ try:
except (NameError, AttributeError):
pass
try:
QgsModelParameterGraphicItem.__overridden_methods__ = ['contextMenuEvent', 'canDeleteComponent', 'fillColor', 'strokeColor', 'textColor', 'iconPicture', 'linkPointCount', 'linkPointText', 'updateStoredComponentPosition', 'deleteComponent']
QgsModelParameterGraphicItem.__overridden_methods__ = ['contextMenuEvent', 'canDeleteComponent', 'linkedParameterDataType', 'linkColor', 'fillColor', 'strokeColor', 'textColor', 'iconPicture', 'linkPointCount', 'linkPointText', 'updateStoredComponentPosition', 'deleteComponent']
QgsModelParameterGraphicItem.__group__ = ['processing', 'models']
except (NameError, AttributeError):
pass

View File

@ -112,6 +112,8 @@ Shows a preview of moving the item from its stored position by ``dx``,
Sets a new scene ``rect`` for the item.
%End
virtual QString linkedParameterDataType( Qt::Edge edge, int index ) const;
virtual void mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event );
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent *event );
@ -324,6 +326,13 @@ comment
Updates the item's button positions, based on the current item rect.
%End
QColor fallbackColor() const;
%Docstring
Returns the fallback color if the parameter or output does not have a
specific color.
.. versionadded:: 4.0
%End
};
QFlags<QgsModelComponentGraphicItem::Flag> operator|(QgsModelComponentGraphicItem::Flag f1, QFlags<QgsModelComponentGraphicItem::Flag> f2);
@ -362,6 +371,12 @@ Ownership of ``parameter`` is transferred to the item.
virtual bool canDeleteComponent();
virtual QString linkedParameterDataType( Qt::Edge /* unused in this implementation because parameters only have a bottom edge */, int index ) const;
virtual QColor linkColor( Qt::Edge edge, int index ) const;
protected:
virtual QColor fillColor( State state ) const;

View File

@ -182,6 +182,23 @@ Return the component associated to the socket.
%Docstring
Return the parent graphic item associated to the socket.
%End
QColor socketColor() const;
%Docstring
Returns the color of the socket based on the type of data the param
corresponds to.
.. versionadded:: 4.0
%End
bool isDefaultParameterValue() const;
%Docstring
Returns ``True`` if the parameter is set to the default parameter value.
.. versionadded:: 4.0
%End
signals:
};

View File

@ -1,19 +1,19 @@
# The following has been generated automatically from src/core/processing/qgsprocessingoutputs.h
try:
QgsProcessingOutputMapLayer.typeName = staticmethod(QgsProcessingOutputMapLayer.typeName)
QgsProcessingOutputMapLayer.__overridden_methods__ = ['type']
QgsProcessingOutputMapLayer.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputMapLayer.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputVectorLayer.typeName = staticmethod(QgsProcessingOutputVectorLayer.typeName)
QgsProcessingOutputVectorLayer.__overridden_methods__ = ['type']
QgsProcessingOutputVectorLayer.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputVectorLayer.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputRasterLayer.typeName = staticmethod(QgsProcessingOutputRasterLayer.typeName)
QgsProcessingOutputRasterLayer.__overridden_methods__ = ['type']
QgsProcessingOutputRasterLayer.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputRasterLayer.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -25,13 +25,13 @@ except (NameError, AttributeError):
pass
try:
QgsProcessingOutputMultipleLayers.typeName = staticmethod(QgsProcessingOutputMultipleLayers.typeName)
QgsProcessingOutputMultipleLayers.__overridden_methods__ = ['type', 'valueAsString']
QgsProcessingOutputMultipleLayers.__overridden_methods__ = ['type', 'modelColor', 'valueAsString']
QgsProcessingOutputMultipleLayers.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputHtml.typeName = staticmethod(QgsProcessingOutputHtml.typeName)
QgsProcessingOutputHtml.__overridden_methods__ = ['type', 'valueAsFormattedString']
QgsProcessingOutputHtml.__overridden_methods__ = ['type', 'modelColor', 'valueAsFormattedString']
QgsProcessingOutputHtml.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -43,31 +43,31 @@ except (NameError, AttributeError):
pass
try:
QgsProcessingOutputNumber.typeName = staticmethod(QgsProcessingOutputNumber.typeName)
QgsProcessingOutputNumber.__overridden_methods__ = ['type', 'valueAsString']
QgsProcessingOutputNumber.__overridden_methods__ = ['modelColor', 'type', 'valueAsString']
QgsProcessingOutputNumber.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputString.typeName = staticmethod(QgsProcessingOutputString.typeName)
QgsProcessingOutputString.__overridden_methods__ = ['type']
QgsProcessingOutputString.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputString.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputBoolean.typeName = staticmethod(QgsProcessingOutputBoolean.typeName)
QgsProcessingOutputBoolean.__overridden_methods__ = ['type', 'valueAsString']
QgsProcessingOutputBoolean.__overridden_methods__ = ['modelColor', 'type', 'valueAsString']
QgsProcessingOutputBoolean.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputFolder.typeName = staticmethod(QgsProcessingOutputFolder.typeName)
QgsProcessingOutputFolder.__overridden_methods__ = ['type', 'valueAsFormattedString']
QgsProcessingOutputFolder.__overridden_methods__ = ['type', 'modelColor', 'valueAsFormattedString']
QgsProcessingOutputFolder.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputFile.typeName = staticmethod(QgsProcessingOutputFile.typeName)
QgsProcessingOutputFile.__overridden_methods__ = ['type', 'valueAsFormattedString']
QgsProcessingOutputFile.__overridden_methods__ = ['type', 'modelColor', 'valueAsFormattedString']
QgsProcessingOutputFile.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -79,12 +79,12 @@ except (NameError, AttributeError):
pass
try:
QgsProcessingOutputVectorTileLayer.typeName = staticmethod(QgsProcessingOutputVectorTileLayer.typeName)
QgsProcessingOutputVectorTileLayer.__overridden_methods__ = ['type']
QgsProcessingOutputVectorTileLayer.__overridden_methods__ = ['modelColor', 'type']
QgsProcessingOutputVectorTileLayer.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingOutputDefinition.__virtual_methods__ = ['valueAsString', 'valueAsFormattedString']
QgsProcessingOutputDefinition.__virtual_methods__ = ['modelColor', 'valueAsString', 'valueAsFormattedString']
QgsProcessingOutputDefinition.__abstract_methods__ = ['type']
QgsProcessingOutputDefinition.__group__ = ['processing']
except (NameError, AttributeError):

View File

@ -82,7 +82,7 @@ except (NameError, AttributeError):
try:
QgsProcessingParameterCrs.typeName = staticmethod(QgsProcessingParameterCrs.typeName)
QgsProcessingParameterCrs.fromScriptCode = staticmethod(QgsProcessingParameterCrs.fromScriptCode)
QgsProcessingParameterCrs.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsString', 'valueAsJsonObject']
QgsProcessingParameterCrs.__overridden_methods__ = ['userFriendlyString', 'clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsString', 'valueAsJsonObject']
QgsProcessingParameterCrs.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -103,7 +103,7 @@ except (NameError, AttributeError):
try:
QgsProcessingParameterGeometry.typeName = staticmethod(QgsProcessingParameterGeometry.typeName)
QgsProcessingParameterGeometry.fromScriptCode = staticmethod(QgsProcessingParameterGeometry.fromScriptCode)
QgsProcessingParameterGeometry.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterGeometry.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterGeometry.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -137,25 +137,25 @@ except (NameError, AttributeError):
pass
try:
QgsProcessingParameterDistance.typeName = staticmethod(QgsProcessingParameterDistance.typeName)
QgsProcessingParameterDistance.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterDistance.__overridden_methods__ = ['userFriendlyString', 'clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterDistance.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingParameterArea.typeName = staticmethod(QgsProcessingParameterArea.typeName)
QgsProcessingParameterArea.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterArea.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterArea.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingParameterVolume.typeName = staticmethod(QgsProcessingParameterVolume.typeName)
QgsProcessingParameterVolume.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterVolume.__overridden_methods__ = ['clone', 'type', 'dependsOnOtherParameters', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterVolume.__group__ = ['processing']
except (NameError, AttributeError):
pass
try:
QgsProcessingParameterDuration.typeName = staticmethod(QgsProcessingParameterDuration.typeName)
QgsProcessingParameterDuration.__overridden_methods__ = ['clone', 'type', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterDuration.__overridden_methods__ = ['clone', 'type', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterDuration.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -183,7 +183,7 @@ except (NameError, AttributeError):
try:
QgsProcessingParameterEnum.typeName = staticmethod(QgsProcessingParameterEnum.typeName)
QgsProcessingParameterEnum.fromScriptCode = staticmethod(QgsProcessingParameterEnum.fromScriptCode)
QgsProcessingParameterEnum.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsPythonComment', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterEnum.__overridden_methods__ = ['userFriendlyString', 'clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsPythonComment', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterEnum.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -326,7 +326,7 @@ except (NameError, AttributeError):
try:
QgsProcessingParameterDateTime.typeName = staticmethod(QgsProcessingParameterDateTime.typeName)
QgsProcessingParameterDateTime.fromScriptCode = staticmethod(QgsProcessingParameterDateTime.fromScriptCode)
QgsProcessingParameterDateTime.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'toolTip', 'asPythonString', 'toVariantMap', 'fromVariantMap']
QgsProcessingParameterDateTime.__overridden_methods__ = ['clone', 'type', 'checkValueIsAcceptable', 'valueAsPythonString', 'toolTip', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'userFriendlyString']
QgsProcessingParameterDateTime.__group__ = ['processing']
except (NameError, AttributeError):
pass
@ -389,7 +389,7 @@ try:
except (NameError, AttributeError):
pass
try:
QgsProcessingParameterDefinition.__virtual_methods__ = ['isDestination', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsJsonObject', 'valueAsString', 'valueAsStringList', 'valueAsPythonComment', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'dependsOnOtherParameters', 'toolTip']
QgsProcessingParameterDefinition.__virtual_methods__ = ['modelColor', 'userFriendlyString', 'isDestination', 'checkValueIsAcceptable', 'valueAsPythonString', 'valueAsJsonObject', 'valueAsString', 'valueAsStringList', 'valueAsPythonComment', 'asScriptCode', 'asPythonString', 'toVariantMap', 'fromVariantMap', 'dependsOnOtherParameters', 'toolTip']
QgsProcessingParameterDefinition.__abstract_methods__ = ['clone', 'type']
QgsProcessingParameterDefinition.__group__ = ['processing']
except (NameError, AttributeError):

View File

@ -1,6 +1,7 @@
# The following has been generated automatically from src/core/processing/qgsprocessingparametertype.h
try:
QgsProcessingParameterType.__virtual_methods__ = ['pythonImportString', 'className', 'flags', 'metadata', 'acceptedPythonTypes', 'acceptedStringValues', 'acceptedDataTypes']
QgsProcessingParameterType.defaultModelColor = staticmethod(QgsProcessingParameterType.defaultModelColor)
QgsProcessingParameterType.__virtual_methods__ = ['pythonImportString', 'className', 'flags', 'metadata', 'acceptedPythonTypes', 'acceptedStringValues', 'acceptedDataTypes', 'modelColor']
QgsProcessingParameterType.__abstract_methods__ = ['create', 'description', 'name', 'id', 'acceptedParameterTypes', 'acceptedOutputTypes']
QgsProcessingParameterType.__group__ = ['processing']
except (NameError, AttributeError):

View File

@ -65,6 +65,13 @@ Constructor for QgsProcessingOutputDefinition.
virtual ~QgsProcessingOutputDefinition();
virtual QColor modelColor() const;
%Docstring
Returns the color to use for the output in model designer windows.
.. versionadded:: 4.0
%End
virtual QString type() const = 0;
%Docstring
Unique output type name.
@ -189,6 +196,9 @@ raster), use :py:class:`QgsProcessingOutputVectorLayer` or
Constructor for QgsProcessingOutputMapLayer.
%End
virtual QColor modelColor() const;
static QString typeName();
%Docstring
Returns the type name for the output class.
@ -215,6 +225,9 @@ A vector layer output for processing algorithms.
Constructor for QgsProcessingOutputVectorLayer.
%End
virtual QColor modelColor() const;
static QString typeName();
%Docstring
Returns the type name for the output class.
@ -257,6 +270,9 @@ Constructor for QgsProcessingOutputRasterLayer.
%Docstring
Returns the type name for the output class.
%End
virtual QColor modelColor() const;
virtual QString type() const;
};
@ -316,8 +332,10 @@ Returns the type name for the output class.
%End
virtual QString type() const;
virtual QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
virtual QColor modelColor() const;
virtual QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
};
@ -342,6 +360,9 @@ Constructor for QgsProcessingOutputHtml.
Returns the type name for the output class.
%End
virtual QString type() const;
virtual QColor modelColor() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
};
@ -370,6 +391,7 @@ Constructor for QgsProcessingOutputVariant.
%Docstring
Returns the type name for the output class.
%End
virtual QString type() const;
virtual QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
@ -393,6 +415,9 @@ A numeric output for processing algorithms.
Constructor for QgsProcessingOutputNumber.
%End
virtual QColor modelColor() const;
static QString typeName();
%Docstring
Returns the type name for the output class.
@ -423,6 +448,9 @@ Constructor for QgsProcessingOutputString.
%Docstring
Returns the type name for the output class.
%End
virtual QColor modelColor() const;
virtual QString type() const;
};
@ -444,6 +472,9 @@ A boolean output for processing algorithms.
Constructor for :py:class:`QgsProcessingOutputNumber`.
%End
virtual QColor modelColor() const;
static QString typeName();
%Docstring
Returns the type name for the output class.
@ -475,8 +506,10 @@ Constructor for QgsProcessingOutputFolder.
Returns the type name for the output class.
%End
virtual QString type() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
virtual QColor modelColor() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
};
@ -501,8 +534,10 @@ Constructor for QgsProcessingOutputFile.
Returns the type name for the output class.
%End
virtual QString type() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
virtual QColor modelColor() const;
virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok /Out/ ) const;
};
@ -554,6 +589,9 @@ Constructor for QgsProcessingOutputVectorTileLayer.
%Docstring
Returns the type name for the output class.
%End
virtual QColor modelColor() const;
virtual QString type() const;
};

View File

@ -438,6 +438,27 @@ Constructor for QgsProcessingParameterDefinition.
virtual ~QgsProcessingParameterDefinition();
virtual QColor modelColor() const;
%Docstring
Returns the color to use for the parameter in model designer windows.
The default implementation retrieves the color from the parameter type,
see :py:func:`QgsProcessingParameterType.modelColor()`.
.. versionadded:: 4.0
%End
virtual QString userFriendlyString( const QVariant &value ) const;
%Docstring
Returns a user-friendly string representation of the provided parameter
``value``.
The returned string is to be used for display purposes only, and should
be translated as required.
.. versionadded:: 4.0
%End
virtual QgsProcessingParameterDefinition *clone() const = 0 /Factory/;
%Docstring
Creates a clone of the parameter definition.
@ -1994,6 +2015,9 @@ A coordinate reference system parameter for processing algorithms.
Constructor for QgsProcessingParameterCrs.
%End
virtual QString userFriendlyString( const QVariant &value ) const;
static QString typeName();
%Docstring
Returns the type name for the parameter class.
@ -2167,6 +2191,7 @@ Sets the allow multipart geometries
.. seealso:: :py:func:`allowMultipart`
%End
virtual QString userFriendlyString( const QVariant &value ) const;
static QgsProcessingParameterGeometry *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
@ -2316,6 +2341,7 @@ Constructor for QgsProcessingParameterMatrix.
%Docstring
Returns the type name for the parameter class.
%End
virtual QgsProcessingParameterDefinition *clone() const /Factory/;
virtual QString type() const;
@ -2512,6 +2538,7 @@ Constructor for QgsProcessingParameterNumber.
%Docstring
Returns the type name for the parameter class.
%End
virtual QgsProcessingParameterDefinition *clone() const /Factory/;
virtual QString type() const;
@ -2620,6 +2647,9 @@ Constructor for QgsProcessingParameterDistance.
Returns the type name for the parameter class.
%End
virtual QString userFriendlyString( const QVariant &value ) const;
virtual QgsProcessingParameterDistance *clone() const /Factory/;
@ -2758,6 +2788,8 @@ Sets the default area ``unit`` for the parameter.
virtual bool fromVariantMap( const QVariantMap &map );
virtual QString userFriendlyString( const QVariant &value ) const;
};
@ -2848,6 +2880,8 @@ Sets the default volume ``unit`` for the parameter.
virtual bool fromVariantMap( const QVariantMap &map );
virtual QString userFriendlyString( const QVariant &value ) const;
};
@ -2907,6 +2941,8 @@ Sets the default duration ``unit`` for the parameter.
virtual bool fromVariantMap( const QVariantMap &map );
virtual QString userFriendlyString( const QVariant &value ) const;
};
@ -2977,6 +3013,7 @@ Constructor for QgsProcessingParameterRange.
%Docstring
Returns the type name for the parameter class.
%End
virtual QgsProcessingParameterDefinition *clone() const /Factory/;
virtual QString type() const;
@ -3106,6 +3143,9 @@ values.
Constructor for QgsProcessingParameterEnum.
%End
virtual QString userFriendlyString( const QVariant &value ) const;
static QString typeName();
%Docstring
Returns the type name for the parameter class.
@ -4523,6 +4563,7 @@ varying color opacity.
%Docstring
Returns the type name for the parameter class.
%End
virtual QgsProcessingParameterDefinition *clone() const /Factory/;
virtual QString type() const;
@ -4861,6 +4902,8 @@ Sets the acceptable data ``type`` for the parameter.
virtual bool fromVariantMap( const QVariantMap &map );
virtual QString userFriendlyString( const QVariant &value ) const;
static QgsProcessingParameterDateTime *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring

View File

@ -23,6 +23,13 @@ Makes metadata of processing parameters available.
%End
public:
static QColor defaultModelColor();
%Docstring
Returns the default color for a processing parameter.
.. versionadded:: 4.0
%End
virtual QgsProcessingParameterDefinition *create( const QString &name ) const = 0 /Factory/;
%Docstring
Creates a new parameter of this type.
@ -175,6 +182,16 @@ for the parameter.
.. seealso:: :py:func:`acceptedOutputTypes`
.. versionadded:: 3.44
%End
virtual QColor modelColor() const;
%Docstring
Returns the color to use for the parameter in model designer windows.
The default implementation returns
:py:func:`~QgsProcessingParameterType.defaultModelColor`.
.. versionadded:: 4.0
%End
};

View File

@ -1,7 +1,7 @@
# The following has been generated automatically from src/gui/processing/models/qgsmodelcomponentgraphicitem.h
try:
QgsModelComponentGraphicItem.__attribute_docs__ = {'requestModelRepaint': 'Emitted by the item to request a repaint of the parent model scene.\n', 'aboutToChange': 'Emitted when the definition of the associated component is about to be\nchanged by the item.\n\nThe ``text`` argument gives the translated text describing the change\nabout to occur, and the optional ``id`` can be used to group the\nassociated undo commands.\n', 'changed': 'Emitted when the definition of the associated component is changed by\nthe item.\n', 'repaintArrows': 'Emitted when item requests that all connected arrows are repainted.\n', 'updateArrowPaths': 'Emitted when item requires that all connected arrow paths are\nrecalculated.\n', 'sizePositionChanged': "Emitted when the item's size or position changes.\n"}
QgsModelComponentGraphicItem.__virtual_methods__ = ['flags', 'linkPointCount', 'linkPointText', 'editComment', 'canDeleteComponent', 'deleteComponent', 'editComponent', 'strokeStyle', 'titleAlignment', 'iconPicture', 'iconPixmap']
QgsModelComponentGraphicItem.__virtual_methods__ = ['flags', 'linkedParameterDataType', 'linkPointCount', 'linkPointText', 'editComment', 'canDeleteComponent', 'deleteComponent', 'editComponent', 'strokeStyle', 'titleAlignment', 'iconPicture', 'iconPixmap']
QgsModelComponentGraphicItem.__abstract_methods__ = ['fillColor', 'strokeColor', 'textColor', 'updateStoredComponentPosition']
QgsModelComponentGraphicItem.__overridden_methods__ = ['mouseDoubleClickEvent', 'hoverEnterEvent', 'hoverMoveEvent', 'hoverLeaveEvent', 'itemChange', 'boundingRect', 'contains', 'paint']
QgsModelComponentGraphicItem.__signal_arguments__ = {'aboutToChange': ['text: str', 'id: int = 0']}
@ -15,7 +15,7 @@ try:
except (NameError, AttributeError):
pass
try:
QgsModelParameterGraphicItem.__overridden_methods__ = ['contextMenuEvent', 'canDeleteComponent', 'fillColor', 'strokeColor', 'textColor', 'iconPicture', 'linkPointCount', 'linkPointText', 'updateStoredComponentPosition', 'deleteComponent']
QgsModelParameterGraphicItem.__overridden_methods__ = ['contextMenuEvent', 'canDeleteComponent', 'linkedParameterDataType', 'linkColor', 'fillColor', 'strokeColor', 'textColor', 'iconPicture', 'linkPointCount', 'linkPointText', 'updateStoredComponentPosition', 'deleteComponent']
QgsModelParameterGraphicItem.__group__ = ['processing', 'models']
except (NameError, AttributeError):
pass

View File

@ -112,6 +112,8 @@ Shows a preview of moving the item from its stored position by ``dx``,
Sets a new scene ``rect`` for the item.
%End
virtual QString linkedParameterDataType( Qt::Edge edge, int index ) const;
virtual void mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event );
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent *event );
@ -324,6 +326,13 @@ comment
Updates the item's button positions, based on the current item rect.
%End
QColor fallbackColor() const;
%Docstring
Returns the fallback color if the parameter or output does not have a
specific color.
.. versionadded:: 4.0
%End
};
QFlags<QgsModelComponentGraphicItem::Flag> operator|(QgsModelComponentGraphicItem::Flag f1, QFlags<QgsModelComponentGraphicItem::Flag> f2);
@ -362,6 +371,12 @@ Ownership of ``parameter`` is transferred to the item.
virtual bool canDeleteComponent();
virtual QString linkedParameterDataType( Qt::Edge /* unused in this implementation because parameters only have a bottom edge */, int index ) const;
virtual QColor linkColor( Qt::Edge edge, int index ) const;
protected:
virtual QColor fillColor( State state ) const;

View File

@ -182,6 +182,23 @@ Return the component associated to the socket.
%Docstring
Return the parent graphic item associated to the socket.
%End
QColor socketColor() const;
%Docstring
Returns the color of the socket based on the type of data the param
corresponds to.
.. versionadded:: 4.0
%End
bool isDefaultParameterValue() const;
%Docstring
Returns ``True`` if the parameter is set to the default parameter value.
.. versionadded:: 4.0
%End
signals:
};

View File

@ -224,8 +224,21 @@ QString QgsProcessingModelChildParameterSource::friendlyIdentifier( QgsProcessin
switch ( mSource )
{
case Qgis::ProcessingModelChildParameterSource::ModelParameter:
return model ? model->parameterDefinition( mParameterName )->description() : mParameterName;
{
if ( model )
{
const QgsProcessingParameterDefinition *paramDefinition = model->parameterDefinition( mParameterName );
// A model can be valid (non null) but we could be looking for a null parameter (if input if not set yet)
if ( paramDefinition )
{
return model->parameterDefinition( mParameterName )->description();
}
}
return mParameterName;
}
case Qgis::ProcessingModelChildParameterSource::ChildOutput:
{
if ( model )
@ -242,11 +255,11 @@ QString QgsProcessingModelChildParameterSource::friendlyIdentifier( QgsProcessin
break;
}
}
return QObject::tr( "'%1' from algorithm '%2'" ).arg( outputName, alg.description() );
return QObject::tr( "<%1>" ).arg( alg.description() );
}
else
{
return QObject::tr( "'%1' from algorithm '%2'" ).arg( mOutputName, mChildId );
return QObject::tr( "<%1>" ).arg( mChildId );
}
}

View File

@ -48,6 +48,11 @@ QString QgsProcessingOutputDefinition::valueAsFormattedString( const QVariant &v
return valueAsString( value, context, ok );
}
QColor QgsProcessingOutputDefinition::modelColor() const
{
return QColor( 128, 128, 128 ); /* mid gray */
}
QgsProcessingOutputVectorLayer::QgsProcessingOutputVectorLayer( const QString &name, const QString &description, Qgis::ProcessingSourceType type )
: QgsProcessingOutputDefinition( name, description )
, mDataType( type )
@ -63,10 +68,20 @@ void QgsProcessingOutputVectorLayer::setDataType( Qgis::ProcessingSourceType typ
mDataType = type;
}
QColor QgsProcessingOutputVectorLayer::modelColor() const
{
return QColor( 122, 0, 47 ); /* burgundy */
}
QgsProcessingOutputRasterLayer::QgsProcessingOutputRasterLayer( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
QColor QgsProcessingOutputRasterLayer::modelColor() const
{
return QColor( 0, 180, 180 ); /* turquoise */
}
QgsProcessingOutputPointCloudLayer::QgsProcessingOutputPointCloudLayer( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
@ -75,6 +90,11 @@ QgsProcessingOutputVectorTileLayer::QgsProcessingOutputVectorTileLayer( const QS
: QgsProcessingOutputDefinition( name, description )
{}
QColor QgsProcessingOutputVectorTileLayer::modelColor() const
{
return QColor( 137, 150, 171 ); /* cold gray */
}
QgsProcessingOutputHtml::QgsProcessingOutputHtml( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
@ -90,6 +110,11 @@ QString QgsProcessingOutputHtml::valueAsFormattedString( const QVariant &value,
return valueAsString( value, context, ok );
}
QColor QgsProcessingOutputHtml::modelColor() const
{
return QColor( 255, 131, 23 ); /* orange */
}
QgsProcessingOutputNumber::QgsProcessingOutputNumber( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
@ -112,10 +137,20 @@ QString QgsProcessingOutputNumber::valueAsString( const QVariant &value, QgsProc
return QgsProcessingOutputDefinition::valueAsString( value, context, ok );
}
QColor QgsProcessingOutputNumber::modelColor() const
{
return QColor( 34, 157, 214 ); /* blue */
}
QgsProcessingOutputString::QgsProcessingOutputString( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
QColor QgsProcessingOutputString::modelColor() const
{
return QColor( 255, 131, 23 ); /* orange */
}
QgsProcessingOutputBoolean::QgsProcessingOutputBoolean( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
@ -131,6 +166,11 @@ QString QgsProcessingOutputBoolean::valueAsString( const QVariant &value, QgsPro
return QgsProcessingOutputDefinition::valueAsString( value, context, ok );
}
QColor QgsProcessingOutputBoolean::modelColor() const
{
return QColor( 51, 201, 28 ); /* green */
}
QgsProcessingOutputFolder::QgsProcessingOutputFolder( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
@ -146,6 +186,11 @@ QString QgsProcessingOutputFolder::valueAsFormattedString( const QVariant &value
return valueAsString( value, context, ok );
}
QColor QgsProcessingOutputFolder::modelColor() const
{
return QColor( 80, 80, 80 ); /* dark gray */
}
QgsProcessingOutputFile::QgsProcessingOutputFile( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
@ -161,6 +206,11 @@ QString QgsProcessingOutputFile::valueAsFormattedString( const QVariant &value,
return valueAsString( value, context, ok );
}
QColor QgsProcessingOutputFile::modelColor() const
{
return QColor( 80, 80, 80 ); /* dark gray */
}
QgsProcessingOutputMapLayer::QgsProcessingOutputMapLayer( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
@ -170,6 +220,11 @@ QString QgsProcessingOutputMapLayer::type() const
return typeName();
}
QColor QgsProcessingOutputMapLayer::modelColor() const
{
return QColor( 137, 150, 171 ); /* cold gray */
}
QgsProcessingOutputMultipleLayers::QgsProcessingOutputMultipleLayers( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
@ -210,6 +265,11 @@ QString QgsProcessingOutputMultipleLayers::valueAsString( const QVariant &value,
return QgsProcessingOutputDefinition::valueAsString( value, context, ok );
}
QColor QgsProcessingOutputMultipleLayers::modelColor() const
{
return QColor( 137, 150, 171 ); /* cold gray */
}
QgsProcessingOutputConditionalBranch::QgsProcessingOutputConditionalBranch( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
@ -266,3 +326,4 @@ QString QgsProcessingOutputVariant::valueAsString( const QVariant &value, QgsPro
}
return QgsProcessingOutputDefinition::valueAsString( value, context, ok );
}

View File

@ -18,6 +18,7 @@
#ifndef QGSPROCESSINGOUTPUTS_H
#define QGSPROCESSINGOUTPUTS_H
#include <QColor>
#include "qgis_core.h"
#include "qgis.h"
@ -85,6 +86,13 @@ class CORE_EXPORT QgsProcessingOutputDefinition
virtual ~QgsProcessingOutputDefinition() = default;
/**
* Returns the color to use for the output in model designer windows.
*
* \since QGIS 4.0
*/
virtual QColor modelColor() const;
/**
* Unique output type name.
*/
@ -195,6 +203,8 @@ class CORE_EXPORT QgsProcessingOutputMapLayer : public QgsProcessingOutputDefini
*/
QgsProcessingOutputMapLayer( const QString &name, const QString &description = QString() );
QColor modelColor() const override;
/**
* Returns the type name for the output class.
*/
@ -218,6 +228,8 @@ class CORE_EXPORT QgsProcessingOutputVectorLayer : public QgsProcessingOutputDef
*/
QgsProcessingOutputVectorLayer( const QString &name, const QString &description = QString(), Qgis::ProcessingSourceType type = Qgis::ProcessingSourceType::VectorAnyGeometry );
QColor modelColor() const override;
/**
* Returns the type name for the output class.
*/
@ -259,6 +271,8 @@ class CORE_EXPORT QgsProcessingOutputRasterLayer : public QgsProcessingOutputDef
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputRaster" ); }
QColor modelColor() const override;
QString type() const override { return typeName(); }
};
@ -310,8 +324,9 @@ class CORE_EXPORT QgsProcessingOutputMultipleLayers : public QgsProcessingOutput
*/
static QString typeName() { return QStringLiteral( "outputMultilayer" ); }
QString type() const override;
QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
QColor modelColor() const override;
QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
};
/**
@ -333,6 +348,8 @@ class CORE_EXPORT QgsProcessingOutputHtml : public QgsProcessingOutputDefinition
*/
static QString typeName() { return QStringLiteral( "outputHtml" ); }
QString type() const override { return typeName(); }
QColor modelColor() const override;
QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
};
@ -356,6 +373,7 @@ class CORE_EXPORT QgsProcessingOutputVariant : public QgsProcessingOutputDefinit
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputVariant" ); }
QString type() const override;
QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
@ -375,6 +393,8 @@ class CORE_EXPORT QgsProcessingOutputNumber : public QgsProcessingOutputDefiniti
*/
QgsProcessingOutputNumber( const QString &name, const QString &description = QString() );
QColor modelColor() const override;
/**
* Returns the type name for the output class.
*/
@ -402,6 +422,8 @@ class CORE_EXPORT QgsProcessingOutputString : public QgsProcessingOutputDefiniti
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputString" ); }
QColor modelColor() const override;
QString type() const override { return typeName(); }
};
@ -420,6 +442,8 @@ class CORE_EXPORT QgsProcessingOutputBoolean : public QgsProcessingOutputDefinit
*/
QgsProcessingOutputBoolean( const QString &name, const QString &description = QString() );
QColor modelColor() const override ;
/**
* Returns the type name for the output class.
*/
@ -448,8 +472,9 @@ class CORE_EXPORT QgsProcessingOutputFolder : public QgsProcessingOutputDefiniti
*/
static QString typeName() { return QStringLiteral( "outputFolder" ); }
QString type() const override { return typeName(); }
QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
QColor modelColor() const override;
QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
};
/**
@ -471,8 +496,9 @@ class CORE_EXPORT QgsProcessingOutputFile : public QgsProcessingOutputDefinition
*/
static QString typeName() { return QStringLiteral( "outputFile" ); }
QString type() const override { return typeName(); }
QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
QColor modelColor() const override;
QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
};
/**
@ -517,6 +543,8 @@ class CORE_EXPORT QgsProcessingOutputVectorTileLayer : public QgsProcessingOutpu
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputVectorTile" ); }
QColor modelColor() const override;
QString type() const override { return typeName(); }
};

View File

@ -39,6 +39,7 @@
#include "qgsproviderregistry.h"
#include "qgsvariantutils.h"
#include "qgsmessagelog.h"
#include "qgsunittypes.h"
#include <functional>
#include <QRegularExpression>
@ -66,7 +67,6 @@ bool QgsProcessingFeatureSourceDefinition::loadVariant( const QVariantMap &map )
return true;
}
//
// QgsProcessingRasterLayerDefinition
//
@ -3061,6 +3061,73 @@ QgsProcessingParameterDefinition *QgsProcessingParameterBoolean::clone() const
return new QgsProcessingParameterBoolean( *this );
}
QColor QgsProcessingParameterDefinition::modelColor() const
{
QgsProcessingParameterType *paramType = QgsApplication::processingRegistry()->parameterType( type() );
if ( paramType )
{
return paramType->modelColor();
}
return QgsProcessingParameterType::defaultModelColor();
}
QString QgsProcessingParameterDefinition::userFriendlyString( const QVariant &value ) const
{
if ( QgsVariantUtils::isNull( value ) )
return QString();
if ( value.userType() == qMetaTypeId<QgsPointXY>() )
{
const QgsPointXY r = value.value<QgsPointXY>();
return QStringLiteral( "%1, %2" ).arg( qgsDoubleToString( r.x(), 4 ),
qgsDoubleToString( r.y(), 4 ) );
}
else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
{
const QgsReferencedPointXY r = value.value<QgsReferencedPointXY>();
return QStringLiteral( "%1, %2 [%3]" ).arg(
qgsDoubleToString( r.x(), 4 ),
qgsDoubleToString( r.y(), 4 ),
r.crs().authid()
);
}
else if ( value.userType() == qMetaTypeId<QgsRectangle>() )
{
const QgsGeometry g = QgsGeometry::fromRect( value.value<QgsRectangle>() );
return QgsWkbTypes::geometryDisplayString( g.type() );
}
else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
{
const QgsReferencedGeometry g = QgsReferencedGeometry::fromReferencedRect( value.value<QgsReferencedRectangle>() );
if ( !g.isNull() )
{
return QStringLiteral( "%1 [%2]" ).arg( QgsWkbTypes::geometryDisplayString( g.type() ), g.crs().userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) );
}
return QgsWkbTypes::geometryDisplayString( g.type() );
}
else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
{
const QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( value );
if ( fromVar.sink.propertyType() == Qgis::PropertyType::Static )
{
return fromVar.sink.staticValue().toString();
}
else
{
return fromVar.sink.asExpression();
}
}
return value.toString();
}
QString QgsProcessingParameterBoolean::valueAsPythonString( const QVariant &val, QgsProcessingContext & ) const
{
if ( !val.isValid() )
@ -3220,6 +3287,21 @@ QgsProcessingParameterCrs *QgsProcessingParameterCrs::fromScriptCode( const QStr
return new QgsProcessingParameterCrs( name, description, definition.compare( QLatin1String( "none" ), Qt::CaseInsensitive ) == 0 ? QVariant() : definition, isOptional );
}
QString QgsProcessingParameterCrs::userFriendlyString( const QVariant &value ) const
{
if ( QgsVariantUtils::isNull( value ) )
return QString();
QgsCoordinateReferenceSystem crs( value.toString() );
if ( crs.isValid() )
return crs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString );
return QObject::tr( "Invalid CRS" );
}
QgsProcessingParameterMapLayer::QgsProcessingParameterMapLayer( const QString &name, const QString &description, const QVariant &defaultValue, bool optional, const QList<int> &types )
: QgsProcessingParameterDefinition( name, description, defaultValue, optional )
, QgsProcessingParameterLimitedDataTypes( types )
@ -3652,7 +3734,8 @@ QString QgsProcessingParameterExtent::valueAsPythonString( const QVariant &value
return QStringLiteral( "'%1, %3, %2, %4 [%5]'" ).arg( qgsDoubleToString( r.xMinimum() ),
qgsDoubleToString( r.yMinimum() ),
qgsDoubleToString( r.xMaximum() ),
qgsDoubleToString( r.yMaximum() ), r.crs().authid() );
qgsDoubleToString( r.yMaximum() ),
r.crs().authid() );
}
else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
{
@ -3802,6 +3885,7 @@ QgsProcessingParameterPoint *QgsProcessingParameterPoint::fromScriptCode( const
return new QgsProcessingParameterPoint( name, description, definition, isOptional );
}
QgsProcessingParameterGeometry::QgsProcessingParameterGeometry( const QString &name, const QString &description,
const QVariant &defaultValue, bool optional, const QList<int> &geometryTypes, bool allowMultipart )
: QgsProcessingParameterDefinition( name, description, defaultValue, optional ),
@ -4073,6 +4157,45 @@ QgsProcessingParameterGeometry *QgsProcessingParameterGeometry::fromScriptCode(
return new QgsProcessingParameterGeometry( name, description, definition, isOptional );
}
QString QgsProcessingParameterGeometry::userFriendlyString( const QVariant &value ) const
{
if ( QgsVariantUtils::isNull( value ) )
return QString();
if ( value.isValid() )
{
if ( value.userType() == qMetaTypeId< QgsGeometry>() )
{
const QgsGeometry g = value.value<QgsGeometry>();
return QgsWkbTypes::geometryDisplayString( g.type() );
}
else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
{
const QgsReferencedGeometry g = value.value<QgsReferencedGeometry>();
if ( !g.isNull() )
{
return QStringLiteral( "%1 [%2]" ).arg( QgsWkbTypes::geometryDisplayString( g.type() ), g.crs().userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ));
}
return QgsWkbTypes::geometryDisplayString( g.type() );
}
else if ( value.userType() == QMetaType::QString )
{
// In the case of a WKT-(string) encoded geometry, the type of geometry is going to be displayed
// rather than the possibly very long WKT payload
QgsGeometry g = QgsGeometry::fromWkt( value.toString() );
if ( !g.isNull() )
{
return QgsWkbTypes::geometryDisplayString( g.type() );
}
}
}
return QObject::tr( "Invalid geometry" );
}
QgsProcessingParameterFile::QgsProcessingParameterFile( const QString &name, const QString &description, Qgis::ProcessingFileParameterBehavior behavior, const QString &extension, const QVariant &defaultValue, bool optional, const QString &fileFilter )
: QgsProcessingParameterDefinition( name, description, defaultValue, optional )
, mBehavior( behavior )
@ -5391,6 +5514,14 @@ QString QgsProcessingParameterEnum::asPythonString( const QgsProcessing::PythonO
return QString();
}
QString QgsProcessingParameterEnum::userFriendlyString( const QVariant &value ) const
{
if ( QgsVariantUtils::isNull( value ) )
return QString();
return options().at( value.toInt() );
}
QStringList QgsProcessingParameterEnum::options() const
{
return mOptions;
@ -7855,6 +7986,14 @@ bool QgsProcessingParameterDistance::fromVariantMap( const QVariantMap &map )
}
QString QgsProcessingParameterDistance::userFriendlyString( const QVariant &value ) const
{
if ( QgsVariantUtils::isNull( value ) )
return QString();
return QStringLiteral( "%1 %2" ).arg( value.toString(), QgsUnitTypes::toAbbreviatedString( defaultUnit() ) );
}
//
// QgsProcessingParameterArea
@ -7937,6 +8076,14 @@ bool QgsProcessingParameterArea::fromVariantMap( const QVariantMap &map )
}
QString QgsProcessingParameterArea::userFriendlyString( const QVariant &value ) const
{
if ( QgsVariantUtils::isNull( value ) )
return QString();
return QStringLiteral( "%1 %2" ).arg( value.toString(), QgsUnitTypes::toAbbreviatedString( defaultUnit() ) );
}
//
// QgsProcessingParameterVolume
@ -8018,6 +8165,13 @@ bool QgsProcessingParameterVolume::fromVariantMap( const QVariantMap &map )
return true;
}
QString QgsProcessingParameterVolume::userFriendlyString( const QVariant &value ) const
{
if ( QgsVariantUtils::isNull( value ) )
return QString();
return QStringLiteral( "%1 %2" ).arg( value.toString(), QgsUnitTypes::toAbbreviatedString( defaultUnit() ) );
}
//
// QgsProcessingParameterDuration
@ -8075,6 +8229,14 @@ bool QgsProcessingParameterDuration::fromVariantMap( const QVariantMap &map )
return true;
}
QString QgsProcessingParameterDuration::userFriendlyString( const QVariant &value ) const
{
if ( QgsVariantUtils::isNull( value ) )
return QString();
return QStringLiteral( "%1 %2" ).arg( value.toString(), QgsUnitTypes::toAbbreviatedString( defaultUnit() ) );
}
//
// QgsProcessingParameterScale
@ -8932,6 +9094,40 @@ QgsProcessingParameterDateTime *QgsProcessingParameterDateTime::fromScriptCode(
}
QString QgsProcessingParameterDateTime:: userFriendlyString( const QVariant &value ) const
{
if ( QgsVariantUtils::isNull( value ) )
return QString();
if ( value.userType() == QMetaType::Type::QDateTime )
{
const QDateTime dt = value.toDateTime();
if ( !dt.isValid() )
return QObject::tr( "Invalid datetime" );
else
return dt.toString( Qt::ISODate );
}
else if ( value.userType() == QMetaType::Type::QDate )
{
const QDate dt = value.toDate();
if ( !dt.isValid() )
return QObject::tr( "Invalid date" );
else
return dt.toString( Qt::ISODate );
}
else if ( value.userType() == QMetaType::Type::QTime )
{
const QTime dt = value.toTime();
if ( !dt.isValid() )
return QObject::tr( "Invalid time" );
else
return dt.toString( Qt::ISODate );
}
return value.toString();
}
//
// QgsProcessingParameterProviderConnection

View File

@ -28,6 +28,7 @@
#include "qgsremappingproxyfeaturesink.h"
#include <QMap>
#include <limits>
#include <QColor>
class QgsProcessingContext;
class QgsProcessingAlgorithm;
@ -554,6 +555,23 @@ class CORE_EXPORT QgsProcessingParameterDefinition
virtual ~QgsProcessingParameterDefinition() = default;
/**
* Returns the color to use for the parameter in model designer windows.
*
* The default implementation retrieves the color from the parameter type, see QgsProcessingParameterType::modelColor().
*
* \since QGIS 4.0
*/
virtual QColor modelColor() const;
/**
* Returns a user-friendly string representation of the provided parameter \a value.
*
* The returned string is to be used for display purposes only, and should be translated as required.
* \since QGIS 4.0
*/
virtual QString userFriendlyString( const QVariant &value ) const;
/**
* Creates a clone of the parameter definition.
*/
@ -1906,6 +1924,8 @@ class CORE_EXPORT QgsProcessingParameterCrs : public QgsProcessingParameterDefin
QgsProcessingParameterCrs( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false );
QString userFriendlyString( const QVariant &value ) const override;
/**
* Returns the type name for the parameter class.
*/
@ -2054,7 +2074,7 @@ class CORE_EXPORT QgsProcessingParameterGeometry : public QgsProcessingParameter
*/
void setAllowMultipart( bool allowMultipart ) { mAllowMultipart = allowMultipart; }
QString userFriendlyString( const QVariant &value ) const override;
/**
* Creates a new parameter using the definition from a script code.
@ -2185,6 +2205,7 @@ class CORE_EXPORT QgsProcessingParameterMatrix : public QgsProcessingParameterDe
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "matrix" ); }
QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
@ -2356,6 +2377,7 @@ class CORE_EXPORT QgsProcessingParameterNumber : public QgsProcessingParameterDe
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "number" ); }
QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
@ -2454,6 +2476,8 @@ class CORE_EXPORT QgsProcessingParameterDistance : public QgsProcessingParameter
*/
static QString typeName() { return QStringLiteral( "distance" ); } // cppcheck-suppress duplInheritedMember
QString userFriendlyString( const QVariant &value ) const override;
QgsProcessingParameterDistance *clone() const override SIP_FACTORY;
QString type() const override;
@ -2573,6 +2597,7 @@ class CORE_EXPORT QgsProcessingParameterArea : public QgsProcessingParameterNumb
QVariantMap toVariantMap() const override;
bool fromVariantMap( const QVariantMap &map ) override;
QString userFriendlyString( const QVariant &value ) const override;
private:
@ -2656,6 +2681,7 @@ class CORE_EXPORT QgsProcessingParameterVolume : public QgsProcessingParameterNu
QVariantMap toVariantMap() const override;
bool fromVariantMap( const QVariantMap &map ) override;
QString userFriendlyString( const QVariant &value ) const override;
private:
@ -2712,6 +2738,7 @@ class CORE_EXPORT QgsProcessingParameterDuration : public QgsProcessingParameter
QVariantMap toVariantMap() const override;
bool fromVariantMap( const QVariantMap &map ) override;
QString userFriendlyString( const QVariant &value ) const override;
private:
@ -2778,6 +2805,7 @@ class CORE_EXPORT QgsProcessingParameterRange : public QgsProcessingParameterDef
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "range" ); }
QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
QString type() const override { return typeName(); }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
@ -2889,6 +2917,8 @@ class CORE_EXPORT QgsProcessingParameterEnum : public QgsProcessingParameterDefi
bool optional = false,
bool usesStaticStrings = false );
QString userFriendlyString( const QVariant &value ) const override;
/**
* Returns the type name for the parameter class.
*/
@ -4090,6 +4120,7 @@ class CORE_EXPORT QgsProcessingParameterColor : public QgsProcessingParameterDef
* Returns the type name for the parameter class.
*/
static QString typeName() { return QStringLiteral( "color" ); }
QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
QString type() const override { return typeName(); }
QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
@ -4373,6 +4404,7 @@ class CORE_EXPORT QgsProcessingParameterDateTime : public QgsProcessingParameter
QVariantMap toVariantMap() const override;
bool fromVariantMap( const QVariantMap &map ) override;
QString userFriendlyString( const QVariant &value ) const override;
/**
* Creates a new parameter using the definition from a script code.

View File

@ -17,6 +17,11 @@
#include "qgsprocessingparametertype.h"
QColor QgsProcessingParameterType::defaultModelColor()
{
return QColor( 128, 128, 128 ); /* mid gray */
}
Qgis::ProcessingParameterTypeFlags QgsProcessingParameterType::flags() const
{
return Qgis::ProcessingParameterTypeFlag::ExposeToModeler;
@ -51,3 +56,8 @@ QList<int> QgsProcessingParameterType::acceptedDataTypes( const QgsProcessingPar
{
return QList<int>();
}
QColor QgsProcessingParameterType::modelColor() const
{
return defaultModelColor();
}

View File

@ -34,6 +34,13 @@ class CORE_EXPORT QgsProcessingParameterType
{
public:
/**
* Returns the default color for a processing parameter.
*
* \since QGIS 4.0
*/
static QColor defaultModelColor();
/**
* Creates a new parameter of this type.
*/
@ -171,6 +178,15 @@ class CORE_EXPORT QgsProcessingParameterType
*/
virtual QList<int> acceptedDataTypes( const QgsProcessingParameterDefinition *parameter ) const;
/**
* Returns the color to use for the parameter in model designer windows.
*
* The default implementation returns defaultModelColor().
*
* \since QGIS 4.0
*/
virtual QColor modelColor() const;
};
#endif // QGSPROCESSINGPARAMETERTYPE_H

View File

@ -97,6 +97,8 @@ class CORE_EXPORT QgsProcessingParameterTypeRasterLayer : public QgsProcessingPa
<< QgsProcessingOutputFile::typeName()
<< QgsProcessingOutputFolder::typeName();
}
QColor modelColor() const override { return QColor( 0, 180, 180 ); /* turquoise */ };
};
/**
@ -169,6 +171,8 @@ class CORE_EXPORT QgsProcessingParameterTypeMeshLayer : public QgsProcessingPara
<< QgsProcessingOutputFile::typeName()
<< QgsProcessingOutputFolder::typeName();
}
QColor modelColor() const override { return QColor( 137, 150, 171 ); /* cold gray */ };
};
/**
@ -250,6 +254,8 @@ class CORE_EXPORT QgsProcessingParameterTypeVectorLayer : public QgsProcessingPa
else
return QList<int>();
}
QColor modelColor() const override { return QColor( 122, 0, 47 ); /* burgundy */ };
};
/**
@ -330,6 +336,8 @@ class CORE_EXPORT QgsProcessingParameterTypeMapLayer : public QgsProcessingParam
<< QgsProcessingOutputFile::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 137, 150, 171 ); /* cold gray */ };
};
/**
@ -421,6 +429,8 @@ class CORE_EXPORT QgsProcessingParameterTypeBoolean : public QgsProcessingParame
<< QgsProcessingOutputVariant::typeName()
<< QgsProcessingOutputBoolean::typeName();
}
QColor modelColor() const override { return QColor( 51, 201, 28 ); /* green */ };
};
/**
@ -493,6 +503,8 @@ class CORE_EXPORT QgsProcessingParameterTypeExpression : public QgsProcessingPar
<< QgsProcessingOutputNumber::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 255, 131, 23 ); /* orange */ };
};
/**
@ -580,6 +592,8 @@ class CORE_EXPORT QgsProcessingParameterTypeCrs : public QgsProcessingParameterT
<< QgsProcessingOutputString::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 255, 131, 23 ); /* orange */ };
};
/**
@ -646,6 +660,8 @@ class CORE_EXPORT QgsProcessingParameterTypeRange : public QgsProcessingParamete
return QStringList() << QgsProcessingOutputString::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 34, 157, 214 ); /* blue */ };
};
/**
@ -714,6 +730,8 @@ class CORE_EXPORT QgsProcessingParameterTypePoint : public QgsProcessingParamete
<< QgsProcessingOutputString::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 122, 0, 47 ); /* burgundy */ };
};
/**
@ -782,6 +800,8 @@ class CORE_EXPORT QgsProcessingParameterTypeGeometry : public QgsProcessingParam
<< QgsProcessingOutputString::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 122, 0, 47 ); /* burgundy */ };
};
/**
@ -851,6 +871,8 @@ class CORE_EXPORT QgsProcessingParameterTypeEnum : public QgsProcessingParameter
<< QgsProcessingOutputVariant::typeName()
<< QgsProcessingOutputNumber::typeName();
}
QColor modelColor() const override { return QColor( 152, 68, 201 ); /* purple */ };
};
/**
@ -935,6 +957,8 @@ class CORE_EXPORT QgsProcessingParameterTypeExtent : public QgsProcessingParamet
<< QgsProcessingOutputMapLayer::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 34, 157, 214 ); /* blue */ };
};
/**
@ -998,6 +1022,8 @@ class CORE_EXPORT QgsProcessingParameterTypeMatrix : public QgsProcessingParamet
{
return QStringList();
}
QColor modelColor() const override { return QColor( 34, 157, 214 ); /* blue */ };
};
/**
@ -1067,6 +1093,8 @@ class CORE_EXPORT QgsProcessingParameterTypeFile : public QgsProcessingParameter
<< QgsProcessingOutputVectorLayer::typeName()
<< QgsProcessingOutputMapLayer::typeName();
}
QColor modelColor() const override { return QColor( 80, 80, 80 ); /* dark gray */ };
};
/**
@ -1224,6 +1252,8 @@ class CORE_EXPORT QgsProcessingParameterTypeVectorDestination : public QgsProces
{
return QStringList() << QObject::tr( "Path for new vector layer" );
}
QColor modelColor() const override { return QColor( 122, 0, 47 ); /* burgundy */ };
};
/**
@ -1300,6 +1330,8 @@ class CORE_EXPORT QgsProcessingParameterTypeFileDestination : public QgsProcessi
<< QgsProcessingOutputVectorLayer::typeName()
<< QgsProcessingOutputMapLayer::typeName();
}
QColor modelColor() const override { return QColor( 80, 80, 80 ); /* dark gray */ };
};
/**
@ -1375,6 +1407,8 @@ class CORE_EXPORT QgsProcessingParameterTypeFolderDestination : public QgsProces
<< QgsProcessingOutputString::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 80, 80, 80 ); /* dark gray */ };
};
/**
@ -1435,6 +1469,8 @@ class CORE_EXPORT QgsProcessingParameterTypeRasterDestination : public QgsProces
{
return QStringList() << QObject::tr( "Path for new raster layer" );
}
QColor modelColor() const override { return QColor( 0, 180, 180 ); /* turquoise */ };
};
/**
@ -1515,6 +1551,8 @@ class CORE_EXPORT QgsProcessingParameterTypeString : public QgsProcessingParamet
<< QgsProcessingOutputFolder::typeName()
<< QgsProcessingOutputString::typeName();
}
QColor modelColor() const override { return QColor( 255, 131, 23 ); /* orange */ };
};
/**
@ -1652,6 +1690,8 @@ class CORE_EXPORT QgsProcessingParameterTypeMultipleLayers : public QgsProcessin
<< QgsProcessingOutputString::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 137, 150, 171 ); /* cold gray */ };
};
/**
@ -1735,6 +1775,8 @@ class CORE_EXPORT QgsProcessingParameterTypeFeatureSource : public QgsProcessing
else
return QList<int>();
}
QColor modelColor() const override { return QColor( 122, 0, 47 ); /* burgundy */ };
};
/**
@ -1807,6 +1849,8 @@ class CORE_EXPORT QgsProcessingParameterTypeNumber : public QgsProcessingParamet
<< QgsProcessingOutputVariant::typeName()
<< QgsProcessingOutputString::typeName();
}
QColor modelColor() const override { return QColor( 34, 157, 214 ); /* blue */ };
};
/**
@ -1861,6 +1905,8 @@ class CORE_EXPORT QgsProcessingParameterTypeDistance : public QgsProcessingParam
<< QObject::tr( "field:FIELD_NAME to use a data defined value taken from the FIELD_NAME field" )
<< QObject::tr( "expression:SOME EXPRESSION to use a data defined value calculated using a custom QGIS expression" );
}
QColor modelColor() const override { return QColor( 34, 157, 214 ); /* blue */ };
};
@ -2027,6 +2073,8 @@ class CORE_EXPORT QgsProcessingParameterTypeDuration : public QgsProcessingParam
<< QObject::tr( "field:FIELD_NAME to use a data defined value taken from the FIELD_NAME field" )
<< QObject::tr( "expression:SOME EXPRESSION to use a data defined value calculated using a custom QGIS expression" );
}
QColor modelColor() const override { return QColor( 34, 157, 214 ); /* blue */ };
};
/**
@ -2079,6 +2127,8 @@ class CORE_EXPORT QgsProcessingParameterTypeScale : public QgsProcessingParamete
{
return QStringList() << QObject::tr( "A numeric value representing the scale denominator" );
}
QColor modelColor() const override { return QColor( 34, 157, 214 ); /* blue */ };
};
/**
@ -2205,6 +2255,8 @@ class CORE_EXPORT QgsProcessingParameterTypeFeatureSink : public QgsProcessingPa
{
return QStringList() << QObject::tr( "Path for new vector layer" );
}
QColor modelColor() const override { return QColor( 122, 0, 47 ); /* burgundy */ };
};
/**
@ -2404,6 +2456,8 @@ class CORE_EXPORT QgsProcessingParameterTypeColor : public QgsProcessingParamete
<< QgsProcessingOutputString::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 34, 157, 214 ); /* blue */ };
};
/**
@ -2603,6 +2657,8 @@ class CORE_EXPORT QgsProcessingParameterTypeDateTime : public QgsProcessingParam
<< QgsProcessingOutputString::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 255, 131, 23 ); /* orange */ };
};
/**
@ -2873,6 +2929,8 @@ class CORE_EXPORT QgsProcessingParameterTypePointCloudLayer : public QgsProcessi
<< QgsProcessingOutputFile::typeName()
<< QgsProcessingOutputFolder::typeName();
}
QColor modelColor() const override { return QColor( 137, 150, 171 ); /* cold gray */ };
};
/**
@ -2943,6 +3001,8 @@ class CORE_EXPORT QgsProcessingParameterTypeAnnotationLayer : public QgsProcessi
<< QgsProcessingOutputMapLayer::typeName()
<< QgsProcessingOutputVariant::typeName();
}
QColor modelColor() const override { return QColor( 137, 150, 171 ); /* cold gray */ };
};
/**
@ -3003,6 +3063,8 @@ class CORE_EXPORT QgsProcessingParameterTypePointCloudDestination : public QgsPr
{
return QStringList() << QObject::tr( "Path for new point cloud layer" );
}
QColor modelColor() const override { return QColor( 80, 80, 80 ); /* dark gray */ };
};
/**
@ -3129,6 +3191,8 @@ class CORE_EXPORT QgsProcessingParameterTypeVectorTileDestination : public QgsPr
{
return QStringList() << QObject::tr( "Path for new vector tile layer" );
}
QColor modelColor() const override { return QColor( 80, 80, 80 ); /* dark gray */ };
};
#endif // QGSPROCESSINGPARAMETERTYPEIMPL_H

View File

@ -20,6 +20,7 @@
#include "qgsapplication.h"
#include "qgsmodelgraphicsscene.h"
#include "qgsmodelcomponentgraphicitem.h"
#include "qgsmodelgraphicitem.h"
#include <QPainter>
#include <QApplication>
#include <QPalette>
@ -72,7 +73,7 @@ QgsModelArrowItem::QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, M
void QgsModelArrowItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * )
{
QColor color = mColor;
QColor color = mStartItem->linkColor( mStartEdge, mStartIndex );
if ( mStartItem->state() == QgsModelComponentGraphicItem::Selected || mEndItem->state() == QgsModelComponentGraphicItem::Selected )
color.setAlpha( 220 );
@ -81,22 +82,23 @@ void QgsModelArrowItem::paint( QPainter *painter, const QStyleOptionGraphicsItem
else
color.setAlpha( 80 );
//
QPen p = pen();
p.setColor( color );
p.setWidth( 1 );
p.setWidth( 0 );
painter->setPen( p );
painter->setBrush( color );
painter->setRenderHint( QPainter::Antialiasing );
switch ( mStartMarker )
{
case Marker::Circle:
painter->drawEllipse( mStartPoint, 3.0, 3.0 );
break;
case Marker::ArrowHead:
drawArrowHead( painter, mStartPoint, path().pointAtPercent( 0.0 ) - path().pointAtPercent( 0.05 ) );
break;
// start marker are no longer drawn
case Marker::Circle:
case Marker::NoMarker:
break;
}
@ -113,7 +115,26 @@ void QgsModelArrowItem::paint( QPainter *painter, const QStyleOptionGraphicsItem
break;
}
painter->setBrush( color );
painter->setRenderHint( QPainter::Antialiasing );
painter->setBrush( Qt::NoBrush );
// Set the painter back to regular stroke thickness
p = pen();
QColor endColor = mEndItem->linkColor( mEndEdge, mEndIndex );
color.setAlpha( 255 );
QLinearGradient gradient;
QPointF startPoint = path().pointAtPercent( 0.3 );
QPointF endPoint = path().pointAtPercent( 0.7 );
gradient.setStart( startPoint );
gradient.setFinalStop( endPoint );
gradient.setColorAt( 0, color );
gradient.setColorAt( 1, endColor );
p.setBrush( QBrush( gradient ) );
p.setWidth( 2 );
painter->setPen( p );
painter->drawPath( path() );
}

View File

@ -29,6 +29,7 @@
#include "qgsmodelviewmouseevent.h"
#include "qgsmodelgroupboxdefinitionwidget.h"
#include "qgsmessagelog.h"
#include "qgsprocessingparameters.h"
#include <QSvgRenderer>
#include <QPicture>
@ -496,40 +497,43 @@ QPixmap QgsModelComponentGraphicItem::iconPixmap() const
return QPixmap();
}
void QgsModelComponentGraphicItem::updateButtonPositions()
{
mEditButton->setPosition( QPointF( itemSize().width() / 2.0 - mButtonSize.width() / 2.0 - BUTTON_MARGIN, itemSize().height() / 2.0 - mButtonSize.height() / 2.0 - BUTTON_MARGIN ) );
mDeleteButton->setPosition( QPointF( itemSize().width() / 2.0 - mButtonSize.width() / 2.0 - BUTTON_MARGIN, mButtonSize.height() / 2.0 - itemSize().height() / 2.0 + BUTTON_MARGIN ) );
if ( mExpandTopButton )
{
const QPointF pt = linkPoint( Qt::TopEdge, -1, true );
mExpandTopButton->setPosition( QPointF( 0, pt.y() ) );
}
if ( mExpandBottomButton )
{
const QPointF pt = linkPoint( Qt::BottomEdge, -1, false );
mExpandBottomButton->setPosition( QPointF( 0, pt.y() ) );
bool collapsed = mComponent->linksCollapsed( Qt::BottomEdge );
for ( QgsModelDesignerSocketGraphicItem *socket : std::as_const( mOutSockets ) )
{
const QPointF pt = linkPoint( Qt::BottomEdge, socket->index(), false );
socket->setPosition( pt );
socket->setVisible( !collapsed );
}
}
bool collapsed = mComponent->linksCollapsed( Qt::TopEdge );
for ( QgsModelDesignerSocketGraphicItem *socket : std::as_const( mInSockets ) )
if ( mExpandTopButton )
{
const QPointF pt = linkPoint( Qt::TopEdge, socket->index(), true );
socket->setPosition( pt );
socket->setVisible( !collapsed );
}
const QPointF pt = linkPoint( Qt::TopEdge, -1, true );
mExpandTopButton->setPosition( QPointF( 0, pt.y() ) );
collapsed = mComponent->linksCollapsed( Qt::BottomEdge );
for ( QgsModelDesignerSocketGraphicItem *socket : std::as_const( mOutSockets ) )
{
const QPointF pt = linkPoint( Qt::BottomEdge, socket->index(), false );
socket->setPosition( pt );
socket->setVisible( !collapsed );
bool collapsed = mComponent->linksCollapsed( Qt::TopEdge );
for ( QgsModelDesignerSocketGraphicItem *socket : std::as_const( mInSockets ) )
{
const QPointF pt = linkPoint( Qt::TopEdge, socket->index(), true );
socket->setPosition( pt );
socket->setVisible( !collapsed );
}
}
}
QSizeF QgsModelComponentGraphicItem::itemSize() const
{
return !mTempSize.isValid() ? mComponent->size() : mTempSize;
@ -563,15 +567,19 @@ void QgsModelComponentGraphicItem::fold( Qt::Edge edge, bool folded )
// TODO - this is not so nice, consider moving this to model class
if ( QgsProcessingModelChildAlgorithm *child = dynamic_cast<QgsProcessingModelChildAlgorithm *>( mComponent.get() ) )
{
mModel->childAlgorithm( child->childId() ).setLinksCollapsed( edge, folded );
}
else if ( QgsProcessingModelParameter *param = dynamic_cast<QgsProcessingModelParameter *>( mComponent.get() ) )
{
mModel->parameterComponent( param->parameterName() ).setLinksCollapsed( edge, folded );
}
else if ( QgsProcessingModelOutput *output = dynamic_cast<QgsProcessingModelOutput *>( mComponent.get() ) )
{
mModel->childAlgorithm( output->childId() ).modelOutput( output->name() ).setLinksCollapsed( edge, folded );
}
updateButtonPositions();
prepareGeometryChange();
emit updateArrowPaths();
emit changed();
@ -627,8 +635,8 @@ QPointF QgsModelComponentGraphicItem::linkPoint( Qt::Edge edge, int index, bool
const QFontMetricsF fm( mFont );
const double w = fm.boundingRect( text ).width();
const double h = fm.height() * 1.2 * ( pointIndex + 1 ) + fm.height() / 2.0;
const double y = h + itemSize().height() / 2.0 + 5;
const double x = !mComponent->linksCollapsed( Qt::BottomEdge ) ? ( -itemSize().width() / 2 + 33 + w + 5 ) : 10;
const double y = h + itemSize().height() / 2.0 + 6.4;
const double x = !mComponent->linksCollapsed( Qt::BottomEdge ) ? ( -itemSize().width() / 2 + 33 + w + 10 ) : 10.4;
return QPointF( incoming ? -itemSize().width() / 2 + offsetX : x, y );
}
break;
@ -756,8 +764,8 @@ QgsModelParameterGraphicItem::QgsModelParameterGraphicItem( QgsProcessingModelPa
svg.render( &painter );
painter.end();
if ( const QgsProcessingParameterDefinition *paramDef = model->parameterDefinition( parameter->parameterName() ) )
setLabel( paramDef->description() );
if ( const QgsProcessingParameterDefinition *parameterDefinition = model->parameterDefinition( parameter->parameterName() ) )
setLabel( parameterDefinition->description() );
else
setLabel( QObject::tr( "Error (%1)" ).arg( parameter->parameterName() ) );
}
@ -838,17 +846,59 @@ QString QgsModelParameterGraphicItem::linkPointText( Qt::Edge, int index ) const
return QString();
}
if ( const QgsProcessingModelParameter *parameter = dynamic_cast< const QgsProcessingModelParameter * >( component() ) )
{
QString text = this->model()->parameterDefinition( parameter->parameterName() )->type();
// Getting the default value to append to the box name
if ( const QgsProcessingParameterDefinition *paramDef = this->model()->parameterDefinition( parameter->parameterName() ) )
{
const QVariant paramValue = paramDef->defaultValue();
if ( paramValue.isValid() )
{
text += ": " + paramDef->userFriendlyString( paramValue );
}
}
return truncatedTextForItem( text );
}
return QString();
}
QString QgsModelParameterGraphicItem::linkedParameterDataType( Qt::Edge /* unused in this implementation because parameters only have a bottom edge */, int index ) const
{
if ( index < 0 )
{
return QString();
}
if ( const QgsProcessingModelParameter *parameter = dynamic_cast< const QgsProcessingModelParameter * >( component() ) )
{
return this->model()->parameterDefinition( parameter->parameterName() )->type();
}
return QString();
}
QColor QgsModelParameterGraphicItem::linkColor( Qt::Edge /* unused in this implementation because parameters only have a bottom edge */, int index ) const
{
if ( index < 0 )
{
return fallbackColor();
}
if ( const QgsProcessingModelParameter *parameter = dynamic_cast< const QgsProcessingModelParameter * >( component() ) )
{
return this->model()->parameterDefinition( parameter->parameterName() )->modelColor();
}
return fallbackColor();
}
void QgsModelParameterGraphicItem::updateStoredComponentPosition( const QPointF &pos, const QSizeF &size )
{
if ( QgsProcessingModelParameter *param = dynamic_cast<QgsProcessingModelParameter *>( component() ) )
@ -1087,6 +1137,88 @@ int QgsModelChildAlgorithmGraphicItem::linkPointCount( Qt::Edge edge ) const
return 0;
}
QString QgsModelComponentGraphicItem::linkedParameterDataType( Qt::Edge edge, int index ) const
{
if ( const QgsProcessingModelChildAlgorithm *child = dynamic_cast<const QgsProcessingModelChildAlgorithm *>( component() ) )
{
if ( !child->algorithm() )
{
return QString();
}
switch ( edge )
{
case Qt::BottomEdge:
{
if ( index <= child->algorithm()->outputDefinitions().size() - 1 )
{
return child->algorithm()->outputDefinitions().at( index )->type();
}
return QString();
}
case Qt::TopEdge:
{
QgsProcessingParameterDefinitions params = child->algorithm()->parameterDefinitions();
if ( index <= params.size() - 1 )
{
return params.at( index )->type();
}
return QString();
}
case Qt::LeftEdge:
case Qt::RightEdge:
break;
}
}
return QString();
}
QColor QgsModelComponentGraphicItem::linkColor( Qt::Edge edge, int index ) const
{
if ( const QgsProcessingModelChildAlgorithm *child = dynamic_cast<const QgsProcessingModelChildAlgorithm *>( component() ) )
{
if ( !child->algorithm() )
{
return fallbackColor();
}
switch ( edge )
{
case Qt::BottomEdge:
{
if ( index <= child->algorithm()->outputDefinitions().size() - 1 )
{
return child->algorithm()->outputDefinitions().at( index )->modelColor();
}
return fallbackColor();
}
case Qt::TopEdge:
{
QgsProcessingParameterDefinitions params = child->algorithm()->parameterDefinitions();
if ( index <= params.size() - 1 )
{
return params.at( index )->modelColor();
}
return fallbackColor();
}
case Qt::LeftEdge:
case Qt::RightEdge:
break;
}
}
return fallbackColor();
}
QString QgsModelChildAlgorithmGraphicItem::linkPointText( Qt::Edge edge, int index ) const
{
if ( index < 0 )
@ -1099,6 +1231,7 @@ QString QgsModelChildAlgorithmGraphicItem::linkPointText( Qt::Edge edge, int ind
const QVariantMap inputs = mResults.inputs();
const QVariantMap outputs = mResults.outputs();
switch ( edge )
{
case Qt::BottomEdge:
@ -1115,10 +1248,6 @@ QString QgsModelChildAlgorithmGraphicItem::linkPointText( Qt::Edge edge, int ind
const QgsProcessingOutputDefinition *output = child->algorithm()->outputDefinitions().at( index );
QString title = output->description();
if ( outputs.contains( output->name() ) )
{
title += QStringLiteral( ": %1" ).arg( outputs.value( output->name() ).toString() );
}
return truncatedTextForItem( title );
}
@ -1140,9 +1269,51 @@ QString QgsModelChildAlgorithmGraphicItem::linkPointText( Qt::Edge edge, int ind
return QString();
}
QString title = params.at( index )->description();
if ( !inputs.value( params.at( index )->name() ).toString().isEmpty() )
title += QStringLiteral( ": %1" ).arg( inputs.value( params.at( index )->name() ).toString() );
const QgsProcessingParameterDefinition *param = params.at( index );
QString name = param->name();
QString title = param->description();
QgsProcessingModelChildParameterSources paramSources = child->parameterSources().value( name );
QString parameterValueAsString;
if ( paramSources.empty() )
{
QgsProcessingModelChildParameterSource firstParameterSource = paramSources[0];
switch ( firstParameterSource.source() )
{
case Qgis::ProcessingModelChildParameterSource::ChildOutput:
parameterValueAsString = QStringLiteral( ": %1" ).arg(
firstParameterSource.friendlyIdentifier( const_cast<QgsProcessingModelAlgorithm *>( model() ) )
);
break;
case Qgis::ProcessingModelChildParameterSource::Expression:
parameterValueAsString = QStringLiteral( ": %1" ).arg( firstParameterSource.expression() );
break;
case Qgis::ProcessingModelChildParameterSource::ExpressionText:
parameterValueAsString = QStringLiteral( ": %1" ).arg( firstParameterSource.expressionText() );
break;
case Qgis::ProcessingModelChildParameterSource::ModelOutput:
parameterValueAsString = QStringLiteral( ": <%1>" ).arg( firstParameterSource.friendlyIdentifier( const_cast<QgsProcessingModelAlgorithm *>( model() ) ) );
break;
case Qgis::ProcessingModelChildParameterSource::ModelParameter:
{
const QString friendlyName = firstParameterSource.friendlyIdentifier( const_cast<QgsProcessingModelAlgorithm *>( model() ) );
parameterValueAsString = friendlyName.isEmpty() ? QStringLiteral( ":" ) : QStringLiteral( ": <%1>" ).arg( friendlyName );
break;
}
case Qgis::ProcessingModelChildParameterSource::StaticValue:
default:
const QVariant paramValue = paramSources[0].staticValue();
parameterValueAsString = QStringLiteral( ": %1" ).arg( param->userFriendlyString( paramValue ) );
}
title += parameterValueAsString;
}
return truncatedTextForItem( title );
}

View File

@ -137,8 +137,22 @@ class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
*/
void setItemRect( QRectF rect );
/**
* Returns the data type of the linked parameter at the specified \a index on the specified \a edge.
*
* \since QGIS 4.0
*/
virtual QString linkedParameterDataType( Qt::Edge edge, int index ) const;
#ifndef SIP_RUN
/**
* Returns the color of the link at the specified \a index on the specified \a edge.
*
* \since QGIS 4.0
*/
virtual QColor linkColor( Qt::Edge edge, int index ) const;
/**
* Shows a preview of setting a new \a rect for the item.
*/
@ -237,7 +251,7 @@ class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
/**
* Returns the output socket graphics items at the specified \a index.
*
*
* May return NULLPTR if no corresponding output socket exists.
* \since QGIS 3.44
*/
@ -363,6 +377,13 @@ class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
*/
void updateButtonPositions();
/**
* Returns the fallback color if the parameter or output does not have a specific color.
*
* \since QGIS 4.0
*/
QColor fallbackColor() const { return mFallbackColor; };
private:
QSizeF itemSize() const;
@ -400,6 +421,7 @@ class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
bool mIsHovering = false;
QSizeF mTempSize;
QColor mFallbackColor = QColor( 128, 128, 128 ); /* mid gray */
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsModelComponentGraphicItem::Flags )
@ -427,6 +449,10 @@ class GUI_EXPORT QgsModelParameterGraphicItem : public QgsModelComponentGraphicI
void contextMenuEvent( QGraphicsSceneContextMenuEvent *event ) override;
bool canDeleteComponent() override;
QString linkedParameterDataType( Qt::Edge, int index ) const override;
QColor linkColor( Qt::Edge edge, int index ) const override;
protected:
QColor fillColor( State state ) const override;
QColor strokeColor( State state ) const override;

View File

@ -21,6 +21,11 @@
#include "qgsmodelgraphicsview.h"
#include "qgsmodelviewtool.h"
#include "qgsmodelviewmouseevent.h"
#include "qgsprocessingmodelcomponent.h"
#include "qgsprocessingoutputs.h"
#include "qgsprocessingparameters.h"
#include "qgsprocessingmodelchildalgorithm.h"
#include "qgsprocessingalgorithm.h"
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
#include <QSvgRenderer>
@ -180,13 +185,35 @@ QgsModelDesignerSocketGraphicItem::QgsModelDesignerSocketGraphicItem( QgsModelCo
void QgsModelDesignerSocketGraphicItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * )
{
painter->setPen( QPen() );
painter->setBrush( QBrush( QColor( 0, 0, 0, mHoverState ? 200 : 33 ), Qt::SolidPattern ) );
QColor outlineColor = socketColor();
QColor fillColor = QColor( outlineColor );
if ( isInput() )
{
fillColor.setAlpha( isDefaultParameterValue() ? 30 : 255 );
}
else
{
// outputs are always filled sockets
fillColor.setAlpha( 255 );
}
// Outline style
painter->setPen( QPen( outlineColor, mHoverState ? mSocketOutlineWidth * 2 : mSocketOutlineWidth ) );
// Fill style
painter->setBrush( QBrush( fillColor, Qt::SolidPattern ) );
painter->setRenderHint( QPainter::Antialiasing );
constexpr float DISPLAY_SIZE = 3.2;
painter->drawEllipse( position(), DISPLAY_SIZE, DISPLAY_SIZE );
// Radius of the socket circle
constexpr float DISPLAY_SIZE = 4;
// Offset of the socket to separate from the label
constexpr float ELLIPSE_OFFSET = 0.4;
QPointF ellipsePosition = QPointF( position().x() + ELLIPSE_OFFSET, position().y() + ELLIPSE_OFFSET );
painter->drawEllipse( ellipsePosition, DISPLAY_SIZE, DISPLAY_SIZE );
/* Uncomment to display bounding box */
#if 0
painter->save();
@ -197,4 +224,70 @@ void QgsModelDesignerSocketGraphicItem::paint( QPainter *painter, const QStyleOp
#endif
}
QColor QgsModelDesignerSocketGraphicItem::socketColor() const
{
return mComponentItem->linkColor( mEdge, mIndex );
}
bool QgsModelDesignerSocketGraphicItem::isDefaultParameterValue() const
{
if ( !mComponent )
{
return false;
}
const QgsProcessingModelChildAlgorithm *child = dynamic_cast<const QgsProcessingModelChildAlgorithm *>( mComponent );
if ( !child )
{
return false;
}
bool isDefaultValue = true;
// We can only know if the socket should be filled if the algorithm is non null
if ( child->algorithm() )
{
switch ( mEdge )
{
// Input params
case Qt::TopEdge:
{
const QgsProcessingParameterDefinitions params = child->algorithm()->parameterDefinitions();
const QgsProcessingParameterDefinition *param = params.value( mIndex );
if ( !param )
break;
const QString name = param->name();
QgsProcessingModelChildParameterSources paramSources = child->parameterSources().value( name );
if ( paramSources.empty() )
{
break;
}
// The default value can only happen in the case of the parameter uses a static value
if ( paramSources[0].source() != Qgis::ProcessingModelChildParameterSource::StaticValue )
{
isDefaultValue = false;
break;
}
isDefaultValue = paramSources[0].staticValue() == param->defaultValue();
break;
}
// Outputs
case Qt::BottomEdge:
case Qt::LeftEdge:
case Qt::RightEdge:
break;
}
}
return isDefaultValue;
}
///@endcond

View File

@ -171,7 +171,7 @@ class GUI_EXPORT QgsModelDesignerSocketGraphicItem : public QgsModelDesignerFlat
void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
/**
* Returns the index of this socket in either QgsModelDesignerSocketGraphicItem::mInSockets
* Returns the index of this socket in either QgsModelDesignerSocketGraphicItem::mInSockets
* or QgsModelDesignerSocketGraphicItem::mOutSockets array
*/
int index() const { return mIndex; };
@ -201,11 +201,27 @@ class GUI_EXPORT QgsModelDesignerSocketGraphicItem : public QgsModelDesignerFlat
*/
QgsModelComponentGraphicItem *componentItem() { return mComponentItem; };
/*
* Returns the color of the socket based on the type of data the param corresponds to.
* \since QGIS 4.0
*/
QColor socketColor() const;
/*
* Returns TRUE if the parameter is set to the default parameter value.
* \since QGIS 4.0
*/
bool isDefaultParameterValue() const;
signals:
private:
QgsModelComponentGraphicItem *mComponentItem = nullptr;
QgsProcessingModelComponent *mComponent = nullptr;
int mIndex = -1;
Qt::Edge mEdge = Qt::Edge::TopEdge;
QColor mSocketColor = QColor( 200, 200, 200 );
float mSocketOutlineWidth = 1.5;
};
///@endcond

View File

@ -122,7 +122,7 @@ void QgsModelViewToolLink::modelReleaseEvent( QgsModelViewMouseEvent *event )
* whether the user dragged :
* - From an input socket to an output socket
* - From an output socket to an input socket
*
*
* In the code, we always come back to the first case
*/
if ( !mToSocket->isInput() )

View File

@ -2996,6 +2996,9 @@ void TestQgsProcessing::parameterBoolean()
QCOMPARE( def->valueAsPythonString( QVariant(), context ), QStringLiteral( "None" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
QCOMPARE( def->userFriendlyString( QVariant( true ) ), QString( "true" ) );
QCOMPARE( def->userFriendlyString( QVariant( false ) ), QString( "false" ) );
QString pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterBoolean('non_optional_default_false', '', defaultValue=None)" ) );
@ -3211,6 +3214,8 @@ void TestQgsProcessing::parameterCrs()
QVERIFY( def->checkValueIsAcceptable( QgsProcessingFeatureSourceDefinition( QgsProperty::fromValue( QVariant::fromValue( r1 ) ) ) ) );
QVERIFY( def->checkValueIsAcceptable( QgsProcessingOutputLayerDefinition( r1->id() ) ) );
QCOMPARE( def->userFriendlyString( QVariant( "EPSG:3857" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ).userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) );
// using map layer
QVariantMap params;
params.insert( "non_optional", v1->id() );
@ -3870,6 +3875,10 @@ void TestQgsProcessing::parameterExtent()
QCOMPARE( def->valueAsJsonObject( QStringLiteral( "c:\\test\\new data\\test.dat" ), context ), QVariant( QStringLiteral( "c:\\test\\new data\\test.dat" ) ) );
QCOMPARE( def->valueAsJsonObject( QgsGeometry::fromWkt( QStringLiteral( "LineString( 10 10, 20 20)" ) ), context ), QVariant( QStringLiteral( "LineString (10 10, 20 20)" ) ) );
QCOMPARE( def->userFriendlyString( QgsReferencedRectangle( QgsRectangle( 11, 12, 13, 14 ), QgsCoordinateReferenceSystem( "epsg:4326" ) ) ), QStringLiteral( "[EPSG:4326] Polygon" ) );
QCOMPARE( def->userFriendlyString( QgsRectangle( 11, 12, 13, 14 ) ), QStringLiteral( "Polygon" ) );
QCOMPARE( def->userFriendlyString( QVariant( "1,2,3,4" ) ), QStringLiteral( "1,2,3,4" ) );
bool ok = false;
QCOMPARE( def->valueAsString( QVariant(), context, ok ), QString() );
QVERIFY( ok );
@ -4111,6 +4120,12 @@ void TestQgsProcessing::parameterPoint()
QCOMPARE( def->valueAsJsonObject( QgsReferencedPointXY( QgsPointXY( 11, 12 ), QgsCoordinateReferenceSystem( "epsg:4326" ) ), context ), QVariant( QStringLiteral( "11,12 [EPSG:4326]" ) ) );
QCOMPARE( def->valueAsJsonObject( QgsGeometry::fromWkt( QStringLiteral( "LineString( 10 10, 20 20)" ) ), context ), QVariant( QStringLiteral( "LineString (10 10, 20 20)" ) ) );
QCOMPARE( def->userFriendlyString( QgsReferencedPointXY( QgsPointXY( 11, 12 ), QgsCoordinateReferenceSystem( "epsg:4326" ) ) ), QStringLiteral( "[EPSG:4326] 11, 12" ) );
QCOMPARE( def->userFriendlyString( QgsPointXY( 11, 12 ) ), QStringLiteral( "11, 12" ) );
QCOMPARE( def->userFriendlyString( QgsReferencedPointXY( QgsPointXY( 11.1, 12.2 ), QgsCoordinateReferenceSystem( "epsg:4326" ) ) ), QStringLiteral( "[EPSG:4326] 11.1, 12.2" ) );
QCOMPARE( def->userFriendlyString( QgsPointXY( 11.1, 12.2 ) ), QStringLiteral( "11.1, 12.2" ) );
bool ok = false;
QCOMPARE( def->valueAsString( QVariant(), context, ok ), QString() );
QVERIFY( ok );
@ -4326,6 +4341,10 @@ void TestQgsProcessing::parameterGeometry()
// With Srid as string
QCOMPARE( def->valueAsPythonString( QgsReferencedGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString( 10 10, 20 20)" ) ), QgsCoordinateReferenceSystem( "EPSG:4326" ) ), context ), QStringLiteral( "'CRS=EPSG:4326;LineString (10 10, 20 20)'" ) );
QCOMPARE( def->userFriendlyString( QgsGeometry::fromWkt( QStringLiteral( "Polygon ((11.1 12.2, 13.3 12.2, 13.3 14.4, 11.1 14.4, 11.1 12.2))" ) ) ), QStringLiteral( "Polygon" ) );
QCOMPARE( def->userFriendlyString( QgsReferencedGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString( 10 10, 20 20)" ) ), QgsCoordinateReferenceSystem( "EPSG:4326" ) ) ), QStringLiteral( "[EPSG:4326] Line" ) );
QCOMPARE( def->userFriendlyString( QStringLiteral( "Polygon ((11.1 12.2, 13.3 12.2, 13.3 14.4, 11.1 14.4, 11.1 12.2))" ) ), QStringLiteral( "Polygon" ) );
QCOMPARE( def->valueAsJsonObject( QVariant(), context ), QVariant() );
QCOMPARE( def->valueAsJsonObject( "LineString( 10 10, 20 20)", context ), QVariant( QStringLiteral( "LineString( 10 10, 20 20)" ) ) );
QCOMPARE( def->valueAsJsonObject( QgsGeometry::fromWkt( QStringLiteral( "LineString( 10 10, 20 20)" ) ), context ), QVariant( QStringLiteral( "LineString (10 10, 20 20)" ) ) );
@ -4505,6 +4524,8 @@ void TestQgsProcessing::parameterFile()
QCOMPARE( def->valueAsJsonObject( "uri='complex' username=\"complex\"", context ), QVariant( QStringLiteral( "uri='complex' username=\"complex\"" ) ) );
QCOMPARE( def->valueAsJsonObject( QStringLiteral( "c:\\test\\new data\\test.dat" ), context ), QVariant( QStringLiteral( "c:\\test\\new data\\test.dat" ) ) );
QCOMPARE( def->userFriendlyString( "bricks.bmp" ), QStringLiteral( "bricks.bmp" ) );
const QString testDataDir = QStringLiteral( TEST_DATA_DIR ) + '/'; //defined in CmakeLists.txt
// ensure valueAsJsonObject doesn't try to load a file path as a layer
QCOMPARE( context.temporaryLayerStore()->count(), 0 );
@ -5256,6 +5277,8 @@ void TestQgsProcessing::parameterDistance()
QCOMPARE( def->valueAsPythonString( QStringLiteral( "1.1" ), context ), QStringLiteral( "1.1" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
QCOMPARE( def->userFriendlyString( QVariant( 5 ) ), QStringLiteral( "5 ft" ) );
QCOMPARE( def->valueAsJsonObject( QVariant(), context ), QVariant() );
QCOMPARE( def->valueAsJsonObject( 5, context ), QVariant( 5 ) );
QCOMPARE( def->valueAsJsonObject( QStringLiteral( "1.1" ), context ), QVariant( QStringLiteral( "1.1" ) ) );
@ -5371,6 +5394,7 @@ void TestQgsProcessing::parameterArea()
QCOMPARE( def->valueAsPythonString( 5, context ), QStringLiteral( "5" ) );
QCOMPARE( def->valueAsPythonString( QStringLiteral( "1.1" ), context ), QStringLiteral( "1.1" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
QCOMPARE( def->userFriendlyString( QVariant( 5 ) ), QStringLiteral( "5 square feet" ) );
QCOMPARE( def->valueAsJsonObject( QVariant(), context ), QVariant() );
QCOMPARE( def->valueAsJsonObject( 5, context ), QVariant( 5 ) );
@ -5487,6 +5511,7 @@ void TestQgsProcessing::parameterVolume()
QCOMPARE( def->valueAsPythonString( 5, context ), QStringLiteral( "5" ) );
QCOMPARE( def->valueAsPythonString( QStringLiteral( "1.1" ), context ), QStringLiteral( "1.1" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
QCOMPARE( def->userFriendlyString( QVariant( 5 ) ), QStringLiteral( "5 cubic feet" ) );
QCOMPARE( def->valueAsJsonObject( QVariant(), context ), QVariant() );
QCOMPARE( def->valueAsJsonObject( 5, context ), QVariant( 5 ) );
@ -5600,6 +5625,8 @@ void TestQgsProcessing::parameterDuration()
QCOMPARE( def->valueAsPythonString( QStringLiteral( "1.1" ), context ), QStringLiteral( "1.1" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
QCOMPARE( def->userFriendlyString( QVariant( 5 ) ), QStringLiteral( "5 d" ) );
QCOMPARE( def->valueAsJsonObject( QVariant(), context ), QVariant() );
QCOMPARE( def->valueAsJsonObject( 5, context ), QVariant( 5 ) );
QCOMPARE( def->valueAsJsonObject( QStringLiteral( "1.1" ), context ), QVariant( QStringLiteral( "1.1" ) ) );
@ -5703,6 +5730,8 @@ void TestQgsProcessing::parameterScale()
QCOMPARE( def->valueAsPythonString( QStringLiteral( "1.1" ), context ), QStringLiteral( "1.1" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
QCOMPARE( def->userFriendlyString( QVariant( 5 ) ), QStringLiteral( "5" ) );
QCOMPARE( def->valueAsJsonObject( QVariant(), context ), QVariant() );
QCOMPARE( def->valueAsJsonObject( 5, context ), QVariant( "5" ) );
QCOMPARE( def->valueAsJsonObject( QStringLiteral( "1.1" ), context ), QVariant( QStringLiteral( "1.1" ) ) );
@ -5822,6 +5851,8 @@ void TestQgsProcessing::parameterNumber()
QCOMPARE( def->valueAsPythonString( QStringLiteral( "1.1" ), context ), QStringLiteral( "1.1" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProperty::fromExpression( "\"a\"=1" ) ), context ), QStringLiteral( "QgsProperty.fromExpression('\"a\"=1')" ) );
QCOMPARE( def->userFriendlyString( QVariant( 5 ) ), QStringLiteral( "5" ) );
QCOMPARE( def->valueAsJsonObject( QVariant(), context ), QVariant() );
QCOMPARE( def->valueAsJsonObject( 5, context ), QVariant( "5" ) );
QCOMPARE( def->valueAsJsonObject( QStringLiteral( "1.1" ), context ), QVariant( QStringLiteral( "1.1" ) ) );
@ -6443,6 +6474,10 @@ void TestQgsProcessing::parameterEnum()
QCOMPARE( def->valueAsPythonComment( QVariantList() << 1 << 2, context ), QStringLiteral( "B,C" ) );
QCOMPARE( def->valueAsPythonComment( QStringLiteral( "1,2" ), context ), QStringLiteral( "B,C" ) );
QCOMPARE( def->userFriendlyString( QVariant( 0 ) ), QString( "A" ) );
QCOMPARE( def->userFriendlyString( QVariant( 1 ) ), QString( "B" ) );
QCOMPARE( def->userFriendlyString( QVariant( 2 ) ), QString( "C" ) );
pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterEnum('non_optional', '', options=['A','B','C'], allowMultiple=True, usesStaticStrings=False, defaultValue=5)" ) );
@ -6694,6 +6729,8 @@ void TestQgsProcessing::parameterString()
QCOMPARE( def->valueAsPythonString( "uri='complex' username=\"complex\"", context ), QStringLiteral( "'uri=\\'complex\\' username=\"complex\"'" ) );
QCOMPARE( def->valueAsPythonString( QStringLiteral( "c:\\test\\new data\\test.dat" ), context ), QStringLiteral( "'c:\\\\test\\\\new data\\\\test.dat'" ) );
QCOMPARE( def->userFriendlyString( QVariant( "Hello" ) ), QStringLiteral( "Hello" ) );
QCOMPARE( def->valueAsJsonObject( QVariant(), context ), QVariant() );
QCOMPARE( def->valueAsJsonObject( 5, context ), QVariant( 5 ) );
QCOMPARE( def->valueAsJsonObject( QStringLiteral( "abc" ), context ), QVariant( QStringLiteral( "abc" ) ) );
@ -9711,6 +9748,8 @@ void TestQgsProcessing::parameterColor()
QCOMPARE( def->valueAsPythonString( QColor( 255, 0, 0 ), context ), QStringLiteral( "QColor(255, 0, 0)" ) );
QCOMPARE( def->valueAsPythonString( QColor( 255, 0, 0, 100 ), context ), QStringLiteral( "QColor(255, 0, 0, 100)" ) );
QCOMPARE( def->userFriendlyString( QColor( 255, 0, 0 ) ), QStringLiteral( "#ff0000" ) );
QCOMPARE( def->valueAsJsonObject( QVariant(), context ), QVariant() );
QCOMPARE( def->valueAsJsonObject( QStringLiteral( "#ff0000" ), context ), QVariant( QStringLiteral( "#ff0000" ) ) );
QCOMPARE( def->valueAsJsonObject( QColor(), context ), QVariant( QString() ) );
@ -11174,6 +11213,10 @@ void TestQgsProcessing::parameterDateTime()
QCOMPARE( def->valueAsString( QDate( 2014, 12, 31 ), context, ok ), QStringLiteral( "2014-12-31" ) );
QVERIFY( ok );
QCOMPARE( def->userFriendlyString( QDate( 2014, 12, 31 ) ), QStringLiteral( "2014-12-31" ) );
QCOMPARE( def->userFriendlyString( QTime( 12, 11, 10 ) ), QStringLiteral( "12:11:10" ) );
QCOMPARE( def->userFriendlyString( QDateTime( QDate( 2014, 12, 31 ), QTime( 12, 11, 10 ) ) ), QStringLiteral( "2014-12-31T12:11:10" ) );
pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterDateTime('non_optional', '', type=QgsProcessingParameterDateTime.Date, minValue=QDateTime(QDate(2015, 1, 1), QTime(0, 0, 0)), maxValue=QDateTime(QDate(2015, 12, 31), QTime(0, 0, 0)), defaultValue=QDate(2010, 4, 3))" ) );