now using virtual method for getting param data type

This commit is contained in:
jonathanlurie 2025-05-12 16:47:56 +02:00
parent 19e318fb1b
commit 2fe7c92204
7 changed files with 14 additions and 24 deletions

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', 'getLinkedParamDataType', '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', 'getLinkedParamDataType', 'fillColor', 'strokeColor', 'textColor', 'iconPicture', 'linkPointCount', 'linkPointText', 'updateStoredComponentPosition', 'deleteComponent']
QgsModelParameterGraphicItem.__group__ = ['processing', 'models']
except (NameError, AttributeError):
pass

View File

@ -112,7 +112,7 @@ Shows a preview of moving the item from its stored position by ``dx``,
Sets a new scene ``rect`` for the item.
%End
QString getLinkedParamDataType( Qt::Edge edge, int index );
virtual QString getLinkedParamDataType( Qt::Edge edge, int index );
virtual void mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event );
@ -364,7 +364,8 @@ Ownership of ``parameter`` is transferred to the item.
virtual bool canDeleteComponent();
QString getLinkedParamDataType( Qt::Edge edge, int index );
virtual QString getLinkedParamDataType( Qt::Edge /* unused in this implementation because parameters only have a bottom edge */, int index );
protected:
virtual QColor fillColor( State state ) const;

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', 'getLinkedParamDataType', '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', 'getLinkedParamDataType', 'fillColor', 'strokeColor', 'textColor', 'iconPicture', 'linkPointCount', 'linkPointText', 'updateStoredComponentPosition', 'deleteComponent']
QgsModelParameterGraphicItem.__group__ = ['processing', 'models']
except (NameError, AttributeError):
pass

View File

@ -112,7 +112,7 @@ Shows a preview of moving the item from its stored position by ``dx``,
Sets a new scene ``rect`` for the item.
%End
QString getLinkedParamDataType( Qt::Edge edge, int index );
virtual QString getLinkedParamDataType( Qt::Edge edge, int index );
virtual void mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event );
@ -364,7 +364,8 @@ Ownership of ``parameter`` is transferred to the item.
virtual bool canDeleteComponent();
QString getLinkedParamDataType( Qt::Edge edge, int index );
virtual QString getLinkedParamDataType( Qt::Edge /* unused in this implementation because parameters only have a bottom edge */, int index );
protected:
virtual QColor fillColor( State state ) const;

View File

@ -73,19 +73,7 @@ QgsModelArrowItem::QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, M
void QgsModelArrowItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * )
{
QString dataType;
// Possibly, the mComponentItem is an instance of QgsModelParameterGraphicItem. In this case,
// it needs to be explicitely casted so that the relevant getLinkedParamDataType method is being called
if ( QgsModelParameterGraphicItem *paramItem = dynamic_cast<QgsModelParameterGraphicItem *>( mStartItem ) )
{
dataType = paramItem->getLinkedParamDataType( mStartEdge, mStartIndex );
}
else
{
dataType = mStartItem->getLinkedParamDataType( mStartEdge, mStartIndex );
}
QString dataType = mStartItem->getLinkedParamDataType( mStartEdge, mStartIndex );
QColor color = QgsModelDesignerSocketGraphicItem::typeToColorLookup( dataType );
if ( mStartItem->state() == QgsModelComponentGraphicItem::Selected || mEndItem->state() == QgsModelComponentGraphicItem::Selected )

View File

@ -888,7 +888,7 @@ QString QgsModelParameterGraphicItem::linkPointText( Qt::Edge, int index ) const
}
QString QgsModelParameterGraphicItem::getLinkedParamDataType( Qt::Edge edge, int index )
QString QgsModelParameterGraphicItem::getLinkedParamDataType( Qt::Edge /* unused in this implementation because parameters only have a bottom edge */, int index )
{
QString unknownType = QString( "unknown" );

View File

@ -137,7 +137,7 @@ class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
*/
void setItemRect( QRectF rect );
QString getLinkedParamDataType( Qt::Edge edge, int index );
virtual QString getLinkedParamDataType( Qt::Edge edge, int index );
#ifndef SIP_RUN
@ -429,7 +429,7 @@ class GUI_EXPORT QgsModelParameterGraphicItem : public QgsModelComponentGraphicI
void contextMenuEvent( QGraphicsSceneContextMenuEvent *event ) override;
bool canDeleteComponent() override;
QString getLinkedParamDataType( Qt::Edge edge, int index );
QString getLinkedParamDataType( Qt::Edge /* unused in this implementation because parameters only have a bottom edge */, int index ) override;
protected:
QColor fillColor( State state ) const override;