fix after review

This commit is contained in:
Jonathan Lurie 2025-09-04 13:32:32 +02:00
parent 0ae2327be1
commit e6efa0a5c6
23 changed files with 35 additions and 83 deletions

View File

@ -14,7 +14,6 @@ try:
QgsGeometry.collectGeometry = staticmethod(QgsGeometry.collectGeometry) QgsGeometry.collectGeometry = staticmethod(QgsGeometry.collectGeometry)
QgsGeometry.createWedgeBuffer = staticmethod(QgsGeometry.createWedgeBuffer) QgsGeometry.createWedgeBuffer = staticmethod(QgsGeometry.createWedgeBuffer)
QgsGeometry.createWedgeBufferFromAngles = staticmethod(QgsGeometry.createWedgeBufferFromAngles) QgsGeometry.createWedgeBufferFromAngles = staticmethod(QgsGeometry.createWedgeBufferFromAngles)
QgsGeometry.name = staticmethod(QgsGeometry.name)
QgsGeometry.unaryUnion = staticmethod(QgsGeometry.unaryUnion) QgsGeometry.unaryUnion = staticmethod(QgsGeometry.unaryUnion)
QgsGeometry.polygonize = staticmethod(QgsGeometry.polygonize) QgsGeometry.polygonize = staticmethod(QgsGeometry.polygonize)
QgsGeometry.fromQPointF = staticmethod(QgsGeometry.fromQPointF) QgsGeometry.fromQPointF = staticmethod(QgsGeometry.fromQPointF)

View File

@ -329,11 +329,6 @@ Polygon geometry.
.. versionadded:: 3.40 .. versionadded:: 3.40
%End %End
static QString name( Qgis::GeometryType type );
%Docstring
Returns a user friendly name as a string out of the type
%End
void fromWkb( const QByteArray &wkb ); void fromWkb( const QByteArray &wkb );
%Docstring %Docstring
@ -353,11 +348,6 @@ etc.)
Returns type of the geometry as a :py:class:`Qgis`.GeometryType Returns type of the geometry as a :py:class:`Qgis`.GeometryType
.. seealso:: :py:func:`wkbType` .. seealso:: :py:func:`wkbType`
%End
QString typeName() const /HoldGIL/;
%Docstring
Returns the type name as a string
%End %End
bool isEmpty() const /HoldGIL/; bool isEmpty() const /HoldGIL/;

View File

@ -69,7 +69,7 @@ Constructor for QgsProcessingOutputDefinition.
%Docstring %Docstring
Returns the color to use for the output in model designer windows. Returns the color to use for the output in model designer windows.
.. versionadded:: 3.44 .. versionadded:: 4.0
%End %End
virtual QString type() const = 0; virtual QString type() const = 0;

View File

@ -366,8 +366,10 @@ Constructor for QgsProcessingParameterDefinition.
virtual QColor modelColor() const; virtual QColor modelColor() const;
%Docstring %Docstring
Returns the color to use for the parameter type in model designer Returns the color to use for the parameter in model designer windows.
windows.
The default implementation retrieves the color from the parameter type,
see :py:func:`QgsProcessingParameterType.modelColor()`.
.. versionadded:: 4.0 .. versionadded:: 4.0
%End %End

View File

@ -188,8 +188,8 @@ for the parameter.
%Docstring %Docstring
Returns the color to use for the parameter in model designer windows. Returns the color to use for the parameter in model designer windows.
The default implementation retrieves the color from the parameter type, The default implementation returns
see :py:func:`QgsProcessingParameterType.modelColor()`. :py:func:`~QgsProcessingParameterType.defaultModelColor`.
.. versionadded:: 4.0 .. versionadded:: 4.0
%End %End

View File

@ -330,6 +330,8 @@ Updates the item's button positions, based on the current item rect.
%Docstring %Docstring
Returns the fallback color if the parameter or output does not have a Returns the fallback color if the parameter or output does not have a
specific color. specific color.
.. versionadded:: 4.0
%End %End
}; };
QFlags<QgsModelComponentGraphicItem::Flag> operator|(QgsModelComponentGraphicItem::Flag f1, QFlags<QgsModelComponentGraphicItem::Flag> f2); QFlags<QgsModelComponentGraphicItem::Flag> operator|(QgsModelComponentGraphicItem::Flag f1, QFlags<QgsModelComponentGraphicItem::Flag> f2);

View File

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

View File

@ -14,7 +14,6 @@ try:
QgsGeometry.collectGeometry = staticmethod(QgsGeometry.collectGeometry) QgsGeometry.collectGeometry = staticmethod(QgsGeometry.collectGeometry)
QgsGeometry.createWedgeBuffer = staticmethod(QgsGeometry.createWedgeBuffer) QgsGeometry.createWedgeBuffer = staticmethod(QgsGeometry.createWedgeBuffer)
QgsGeometry.createWedgeBufferFromAngles = staticmethod(QgsGeometry.createWedgeBufferFromAngles) QgsGeometry.createWedgeBufferFromAngles = staticmethod(QgsGeometry.createWedgeBufferFromAngles)
QgsGeometry.name = staticmethod(QgsGeometry.name)
QgsGeometry.unaryUnion = staticmethod(QgsGeometry.unaryUnion) QgsGeometry.unaryUnion = staticmethod(QgsGeometry.unaryUnion)
QgsGeometry.polygonize = staticmethod(QgsGeometry.polygonize) QgsGeometry.polygonize = staticmethod(QgsGeometry.polygonize)
QgsGeometry.fromQPointF = staticmethod(QgsGeometry.fromQPointF) QgsGeometry.fromQPointF = staticmethod(QgsGeometry.fromQPointF)

View File

@ -329,11 +329,6 @@ Polygon geometry.
.. versionadded:: 3.40 .. versionadded:: 3.40
%End %End
static QString name( Qgis::GeometryType type );
%Docstring
Returns a user friendly name as a string out of the type
%End
void fromWkb( const QByteArray &wkb ); void fromWkb( const QByteArray &wkb );
%Docstring %Docstring
@ -353,11 +348,6 @@ etc.)
Returns type of the geometry as a :py:class:`Qgis`.GeometryType Returns type of the geometry as a :py:class:`Qgis`.GeometryType
.. seealso:: :py:func:`wkbType` .. seealso:: :py:func:`wkbType`
%End
QString typeName() const /HoldGIL/;
%Docstring
Returns the type name as a string
%End %End
bool isEmpty() const /HoldGIL/; bool isEmpty() const /HoldGIL/;

View File

@ -69,7 +69,7 @@ Constructor for QgsProcessingOutputDefinition.
%Docstring %Docstring
Returns the color to use for the output in model designer windows. Returns the color to use for the output in model designer windows.
.. versionadded:: 3.44 .. versionadded:: 4.0
%End %End
virtual QString type() const = 0; virtual QString type() const = 0;

View File

@ -366,8 +366,10 @@ Constructor for QgsProcessingParameterDefinition.
virtual QColor modelColor() const; virtual QColor modelColor() const;
%Docstring %Docstring
Returns the color to use for the parameter type in model designer Returns the color to use for the parameter in model designer windows.
windows.
The default implementation retrieves the color from the parameter type,
see :py:func:`QgsProcessingParameterType.modelColor()`.
.. versionadded:: 4.0 .. versionadded:: 4.0
%End %End

View File

@ -188,8 +188,8 @@ for the parameter.
%Docstring %Docstring
Returns the color to use for the parameter in model designer windows. Returns the color to use for the parameter in model designer windows.
The default implementation retrieves the color from the parameter type, The default implementation returns
see :py:func:`QgsProcessingParameterType.modelColor()`. :py:func:`~QgsProcessingParameterType.defaultModelColor`.
.. versionadded:: 4.0 .. versionadded:: 4.0
%End %End

View File

@ -330,6 +330,8 @@ Updates the item's button positions, based on the current item rect.
%Docstring %Docstring
Returns the fallback color if the parameter or output does not have a Returns the fallback color if the parameter or output does not have a
specific color. specific color.
.. versionadded:: 4.0
%End %End
}; };
QFlags<QgsModelComponentGraphicItem::Flag> operator|(QgsModelComponentGraphicItem::Flag f1, QFlags<QgsModelComponentGraphicItem::Flag> f2); QFlags<QgsModelComponentGraphicItem::Flag> operator|(QgsModelComponentGraphicItem::Flag f1, QFlags<QgsModelComponentGraphicItem::Flag> f2);

View File

@ -199,7 +199,6 @@ Returns ``True`` if the parameter is set to the default parameter value.
signals: signals:
}; };

View File

@ -476,19 +476,6 @@ QgsGeometry QgsGeometry::createWedgeBufferFromAngles( const QgsPoint &center, do
return QgsGeometry( std::move( cp ) ); return QgsGeometry( std::move( cp ) );
} }
QString QgsGeometry::name( Qgis::GeometryType type )
{
switch ( type )
{
case Qgis::GeometryType::Line: return QString( "Line" );
case Qgis::GeometryType::Point: return QString( "Point" );
case Qgis::GeometryType::Polygon: return QString( "Polygon" );
case Qgis::GeometryType::Null: return QString( "Null" );
case Qgis::GeometryType::Unknown:
default: return QString( "Unknown" );
}
}
void QgsGeometry::fromWkb( unsigned char *wkb, int length ) void QgsGeometry::fromWkb( unsigned char *wkb, int length )
{ {
QgsConstWkbPtr ptr( wkb, length ); QgsConstWkbPtr ptr( wkb, length );
@ -523,16 +510,6 @@ Qgis::GeometryType QgsGeometry::type() const
return QgsWkbTypes::geometryType( d->geometry->wkbType() ); return QgsWkbTypes::geometryType( d->geometry->wkbType() );
} }
QString QgsGeometry::typeName() const
{
if ( !d->geometry )
{
return QgsGeometry::name( Qgis::GeometryType::Null );
}
return QgsGeometry::name( type() );
}
bool QgsGeometry::isEmpty() const bool QgsGeometry::isEmpty() const
{ {
if ( !d->geometry ) if ( !d->geometry )

View File

@ -380,11 +380,6 @@ class CORE_EXPORT QgsGeometry
static QgsGeometry createWedgeBufferFromAngles( const QgsPoint &center, double startAngle, double endAngle, static QgsGeometry createWedgeBufferFromAngles( const QgsPoint &center, double startAngle, double endAngle,
double outerRadius, double innerRadius = 0 ); double outerRadius, double innerRadius = 0 );
/**
* Returns a user friendly name as a string out of the type
*/
static QString name( Qgis::GeometryType type );
/** /**
* Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length. * Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
* This class will take ownership of the buffer. * This class will take ownership of the buffer.
@ -409,11 +404,6 @@ class CORE_EXPORT QgsGeometry
*/ */
Qgis::GeometryType type() const SIP_HOLDGIL; Qgis::GeometryType type() const SIP_HOLDGIL;
/**
* Returns the type name as a QString
*/
QString typeName() const SIP_HOLDGIL;
/** /**
* Returns TRUE if the geometry is empty (eg a linestring with no vertices, * Returns TRUE if the geometry is empty (eg a linestring with no vertices,
* or a collection with no geometries). A null geometry will always * or a collection with no geometries). A null geometry will always

View File

@ -89,7 +89,7 @@ class CORE_EXPORT QgsProcessingOutputDefinition
/** /**
* Returns the color to use for the output in model designer windows. * Returns the color to use for the output in model designer windows.
* *
* \since QGIS 3.44 * \since QGIS 4.0
*/ */
virtual QColor modelColor() const; virtual QColor modelColor() const;

View File

@ -3054,7 +3054,7 @@ QString QgsProcessingParameterDefinition::userFriendlyString( const QVariant &va
else if ( value.userType() == qMetaTypeId<QgsRectangle>() ) else if ( value.userType() == qMetaTypeId<QgsRectangle>() )
{ {
const QgsGeometry g = QgsGeometry::fromRect( value.value<QgsRectangle>() ); const QgsGeometry g = QgsGeometry::fromRect( value.value<QgsRectangle>() );
return g.typeName(); return QgsWkbTypes::geometryDisplayString( g.type() );
} }
else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() ) else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
@ -3063,9 +3063,9 @@ QString QgsProcessingParameterDefinition::userFriendlyString( const QVariant &va
if ( !g.isNull() ) if ( !g.isNull() )
{ {
return QStringLiteral( "[%1] %2" ).arg( g.crs().userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), g.typeName() ); return QStringLiteral( "[%1] %2" ).arg( g.crs().userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), QgsWkbTypes::geometryDisplayString( g.type() ) );
} }
return g.typeName(); return QgsWkbTypes::geometryDisplayString( g.type() );
} }
else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() ) else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
@ -4099,7 +4099,7 @@ QString QgsProcessingParameterGeometry::userFriendlyString( const QVariant &valu
if ( value.userType() == qMetaTypeId< QgsGeometry>() ) if ( value.userType() == qMetaTypeId< QgsGeometry>() )
{ {
const QgsGeometry g = value.value<QgsGeometry>(); const QgsGeometry g = value.value<QgsGeometry>();
return g.typeName(); return QgsWkbTypes::geometryDisplayString( g.type() );
} }
else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() ) else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
@ -4107,9 +4107,9 @@ QString QgsProcessingParameterGeometry::userFriendlyString( const QVariant &valu
const QgsReferencedGeometry g = value.value<QgsReferencedGeometry>(); const QgsReferencedGeometry g = value.value<QgsReferencedGeometry>();
if ( !g.isNull() ) if ( !g.isNull() )
{ {
return QStringLiteral( "[%1] %2" ).arg( g.crs().userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), g.typeName() ); return QStringLiteral( "[%1] %2" ).arg( g.crs().userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), QgsWkbTypes::geometryDisplayString( g.type() ) );
} }
return g.typeName(); return QgsWkbTypes::geometryDisplayString( g.type() );
} }
else if ( value.userType() == QMetaType::QString ) else if ( value.userType() == QMetaType::QString )
@ -4119,7 +4119,7 @@ QString QgsProcessingParameterGeometry::userFriendlyString( const QVariant &valu
QgsGeometry g = QgsGeometry::fromWkt( value.toString() ); QgsGeometry g = QgsGeometry::fromWkt( value.toString() );
if ( !g.isNull() ) if ( !g.isNull() )
{ {
return g.typeName(); return QgsWkbTypes::geometryDisplayString( g.type() );
} }
} }
} }

View File

@ -462,7 +462,9 @@ class CORE_EXPORT QgsProcessingParameterDefinition
virtual ~QgsProcessingParameterDefinition() = default; virtual ~QgsProcessingParameterDefinition() = default;
/** /**
* Returns the color to use for the parameter type in model designer windows. * 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 * \since QGIS 4.0
*/ */

View File

@ -181,7 +181,7 @@ class CORE_EXPORT QgsProcessingParameterType
/** /**
* Returns the color to use for the parameter in model designer windows. * 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(). * The default implementation returns defaultModelColor().
* *
* \since QGIS 4.0 * \since QGIS 4.0
*/ */

View File

@ -106,7 +106,7 @@ void QgsModelArrowItem::paint( QPainter *painter, const QStyleOptionGraphicsItem
switch ( mEndMarker ) switch ( mEndMarker )
{ {
case Marker::Circle: case Marker::Circle:
painter->drawEllipse( mEndPoint, 3, 3 ); painter->drawEllipse( mEndPoint, 3.0, 3.0 );
break; break;
case Marker::ArrowHead: case Marker::ArrowHead:
drawArrowHead( painter, mEndPoint, path().pointAtPercent( 1.0 ) - path().pointAtPercent( 0.95 ) ); drawArrowHead( painter, mEndPoint, path().pointAtPercent( 1.0 ) - path().pointAtPercent( 0.95 ) );

View File

@ -572,8 +572,7 @@ void QgsModelComponentGraphicItem::fold( Qt::Edge edge, bool folded )
} }
else if ( QgsProcessingModelParameter *param = dynamic_cast<QgsProcessingModelParameter *>( mComponent.get() ) ) else if ( QgsProcessingModelParameter *param = dynamic_cast<QgsProcessingModelParameter *>( mComponent.get() ) )
{ {
QgsProcessingModelParameter parameterComponent = mModel->parameterComponent( param->parameterName() ); mModel->parameterComponent( param->parameterName() ).setLinksCollapsed( edge, folded );
parameterComponent.setLinksCollapsed( edge, folded );
} }
else if ( QgsProcessingModelOutput *output = dynamic_cast<QgsProcessingModelOutput *>( mComponent.get() ) ) else if ( QgsProcessingModelOutput *output = dynamic_cast<QgsProcessingModelOutput *>( mComponent.get() ) )
{ {
@ -1274,11 +1273,10 @@ QString QgsModelChildAlgorithmGraphicItem::linkPointText( Qt::Edge edge, int ind
QString name = param->name(); QString name = param->name();
QString title = param->description(); QString title = param->description();
QgsProcessingModelChildParameterSources paramSources = child->parameterSources().value( name ); QgsProcessingModelChildParameterSources paramSources = child->parameterSources().value( name );
QString parameterValueAsString; QString parameterValueAsString;
if ( paramSources.size() > 0 ) if ( paramSources.empty() )
{ {
QgsProcessingModelChildParameterSource firstParameterSource = paramSources[0]; QgsProcessingModelChildParameterSource firstParameterSource = paramSources[0];

View File

@ -369,6 +369,8 @@ class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
/** /**
* Returns the fallback color if the parameter or output does not have a specific color. * Returns the fallback color if the parameter or output does not have a specific color.
*
* \since QGIS 4.0
*/ */
QColor fallbackColor() const { return mFallbackColor; }; QColor fallbackColor() const { return mFallbackColor; };