mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-03 00:04:47 -04:00
auto-fix pre-commit issues
This commit is contained in:
parent
99613254d1
commit
192298a388
@ -13,6 +13,7 @@ try:
|
||||
except (NameError, AttributeError):
|
||||
pass
|
||||
try:
|
||||
QgsModelDesignerSocketGraphicItem.typeToColorLookup = staticmethod(QgsModelDesignerSocketGraphicItem.typeToColorLookup)
|
||||
QgsModelDesignerSocketGraphicItem.__overridden_methods__ = ['paint']
|
||||
QgsModelDesignerSocketGraphicItem.__group__ = ['processing', 'models']
|
||||
except (NameError, AttributeError):
|
||||
|
@ -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
|
||||
|
||||
QString getLinkedParamDataType( Qt::Edge edge, int index );
|
||||
|
||||
virtual void mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event );
|
||||
|
||||
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent *event );
|
||||
@ -362,6 +364,8 @@ Ownership of ``parameter`` is transferred to the item.
|
||||
virtual bool canDeleteComponent();
|
||||
|
||||
|
||||
QString getLinkedParamDataType( Qt::Edge edge, int index );
|
||||
|
||||
protected:
|
||||
virtual QColor fillColor( State state ) const;
|
||||
|
||||
|
@ -140,6 +140,8 @@ A socket allowing linking component together.
|
||||
#include "qgsmodelgraphicitem.h"
|
||||
%End
|
||||
public:
|
||||
static QColor typeToColorLookup( QString dataType );
|
||||
|
||||
QgsModelDesignerSocketGraphicItem( QgsModelComponentGraphicItem *parent /TransferThis/, QgsProcessingModelComponent *component, int index, const QPointF &position, Qt::Edge edge, const QSizeF &size = QSizeF( 11, 11 ) );
|
||||
%Docstring
|
||||
Constructor for QgsModelDesignerSocketGraphicItem, with the specified
|
||||
@ -178,6 +180,16 @@ Return the component associated to the socket */
|
||||
QgsModelComponentGraphicItem *componentItem();
|
||||
%Docstring
|
||||
Return the parent graphic item associated to the socket */
|
||||
%End
|
||||
QColor getColor();
|
||||
%Docstring
|
||||
Returns the color of the socket based on the type of data the param
|
||||
corresponds to */
|
||||
%End
|
||||
|
||||
bool isDefaultParamValue();
|
||||
%Docstring
|
||||
Returns whether the param value bear the default param value */
|
||||
%End
|
||||
signals:
|
||||
|
||||
|
@ -13,6 +13,7 @@ try:
|
||||
except (NameError, AttributeError):
|
||||
pass
|
||||
try:
|
||||
QgsModelDesignerSocketGraphicItem.typeToColorLookup = staticmethod(QgsModelDesignerSocketGraphicItem.typeToColorLookup)
|
||||
QgsModelDesignerSocketGraphicItem.__overridden_methods__ = ['paint']
|
||||
QgsModelDesignerSocketGraphicItem.__group__ = ['processing', 'models']
|
||||
except (NameError, AttributeError):
|
||||
|
@ -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
|
||||
|
||||
QString getLinkedParamDataType( Qt::Edge edge, int index );
|
||||
|
||||
virtual void mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event );
|
||||
|
||||
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent *event );
|
||||
@ -362,6 +364,8 @@ Ownership of ``parameter`` is transferred to the item.
|
||||
virtual bool canDeleteComponent();
|
||||
|
||||
|
||||
QString getLinkedParamDataType( Qt::Edge edge, int index );
|
||||
|
||||
protected:
|
||||
virtual QColor fillColor( State state ) const;
|
||||
|
||||
|
@ -140,6 +140,8 @@ A socket allowing linking component together.
|
||||
#include "qgsmodelgraphicitem.h"
|
||||
%End
|
||||
public:
|
||||
static QColor typeToColorLookup( QString dataType );
|
||||
|
||||
QgsModelDesignerSocketGraphicItem( QgsModelComponentGraphicItem *parent /TransferThis/, QgsProcessingModelComponent *component, int index, const QPointF &position, Qt::Edge edge, const QSizeF &size = QSizeF( 11, 11 ) );
|
||||
%Docstring
|
||||
Constructor for QgsModelDesignerSocketGraphicItem, with the specified
|
||||
@ -178,6 +180,16 @@ Return the component associated to the socket */
|
||||
QgsModelComponentGraphicItem *componentItem();
|
||||
%Docstring
|
||||
Return the parent graphic item associated to the socket */
|
||||
%End
|
||||
QColor getColor();
|
||||
%Docstring
|
||||
Returns the color of the socket based on the type of data the param
|
||||
corresponds to */
|
||||
%End
|
||||
|
||||
bool isDefaultParamValue();
|
||||
%Docstring
|
||||
Returns whether the param value bear the default param value */
|
||||
%End
|
||||
signals:
|
||||
|
||||
|
@ -77,15 +77,16 @@ void QgsModelArrowItem::paint( QPainter *painter, const QStyleOptionGraphicsItem
|
||||
|
||||
// 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);
|
||||
if ( QgsModelParameterGraphicItem *paramItem = dynamic_cast<QgsModelParameterGraphicItem *>( mStartItem ) )
|
||||
{
|
||||
dataType = paramItem->getLinkedParamDataType( mStartEdge, mStartIndex );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataType = mStartItem->getLinkedParamDataType(mStartEdge, mStartIndex);
|
||||
dataType = mStartItem->getLinkedParamDataType( mStartEdge, mStartIndex );
|
||||
}
|
||||
|
||||
QColor color = QgsModelDesignerSocketGraphicItem::typeToColorLookup(dataType);
|
||||
QColor color = QgsModelDesignerSocketGraphicItem::typeToColorLookup( dataType );
|
||||
|
||||
if ( mStartItem->state() == QgsModelComponentGraphicItem::Selected || mEndItem->state() == QgsModelComponentGraphicItem::Selected )
|
||||
color.setAlpha( 220 );
|
||||
|
@ -499,11 +499,12 @@ QPixmap QgsModelComponentGraphicItem::iconPixmap() const
|
||||
|
||||
void QgsModelComponentGraphicItem::updateButtonPositions()
|
||||
{
|
||||
bool isParameter = dynamic_cast<QgsProcessingModelParameter *>(mComponent.get()) != nullptr;
|
||||
bool isParameter = dynamic_cast<QgsProcessingModelParameter *>( mComponent.get() ) != nullptr;
|
||||
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 (isParameter) {
|
||||
if ( isParameter )
|
||||
{
|
||||
if ( mExpandBottomButton )
|
||||
{
|
||||
const QPointF pt = linkPoint( Qt::BottomEdge, -1, false );
|
||||
@ -517,7 +518,9 @@ void QgsModelComponentGraphicItem::updateButtonPositions()
|
||||
socket->setPosition( pt );
|
||||
socket->setVisible( !collapsed );
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mExpandTopButton )
|
||||
{
|
||||
const QPointF pt = linkPoint( Qt::TopEdge, -1, true );
|
||||
@ -579,13 +582,18 @@ void QgsModelComponentGraphicItem::fold( Qt::Edge edge, bool folded )
|
||||
// also need to update the model's stored component
|
||||
|
||||
// TODO - this is not so nice, consider moving this to model class
|
||||
if ( QgsProcessingModelChildAlgorithm *child = dynamic_cast<QgsProcessingModelChildAlgorithm *>( mComponent.get() ) ){
|
||||
if ( QgsProcessingModelChildAlgorithm *child = dynamic_cast<QgsProcessingModelChildAlgorithm *>( mComponent.get() ) )
|
||||
{
|
||||
mModel->childAlgorithm( child->childId() ).setLinksCollapsed( edge, folded );
|
||||
} else if ( QgsProcessingModelParameter *param = dynamic_cast<QgsProcessingModelParameter *>( mComponent.get() ) ) {
|
||||
}
|
||||
else if ( QgsProcessingModelParameter *param = dynamic_cast<QgsProcessingModelParameter *>( mComponent.get() ) )
|
||||
{
|
||||
QString paramName = param->parameterName();
|
||||
QgsProcessingModelParameter paramComp = mModel->parameterComponent( paramName );
|
||||
paramComp.setLinksCollapsed( edge, folded );
|
||||
} else if ( QgsProcessingModelOutput *output = dynamic_cast<QgsProcessingModelOutput *>( mComponent.get() ) ){
|
||||
}
|
||||
else if ( QgsProcessingModelOutput *output = dynamic_cast<QgsProcessingModelOutput *>( mComponent.get() ) )
|
||||
{
|
||||
mModel->childAlgorithm( output->childId() ).modelOutput( output->name() ).setLinksCollapsed( edge, folded );
|
||||
}
|
||||
|
||||
@ -862,11 +870,11 @@ QString QgsModelParameterGraphicItem::linkPointText( Qt::Edge, int index ) const
|
||||
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()))
|
||||
if ( const QgsProcessingParameterDefinition *paramDef = this->model()->parameterDefinition( parameter->parameterName() ) )
|
||||
{
|
||||
QVariant paramValue = paramDef->defaultValue();
|
||||
|
||||
if (paramValue.isValid() && !paramValue.toString().isEmpty())
|
||||
if ( paramValue.isValid() && !paramValue.toString().isEmpty() )
|
||||
{
|
||||
text += ": " + paramValue.toString();
|
||||
}
|
||||
@ -880,10 +888,9 @@ QString QgsModelParameterGraphicItem::linkPointText( Qt::Edge, int index ) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString QgsModelParameterGraphicItem::getLinkedParamDataType(Qt::Edge edge, int index)
|
||||
QString QgsModelParameterGraphicItem::getLinkedParamDataType( Qt::Edge edge, int index )
|
||||
{
|
||||
QString unknownType = QString("unknown");
|
||||
QString unknownType = QString( "unknown" );
|
||||
|
||||
if ( index < 0 )
|
||||
{
|
||||
@ -1138,13 +1145,14 @@ int QgsModelChildAlgorithmGraphicItem::linkPointCount( Qt::Edge edge ) const
|
||||
}
|
||||
|
||||
|
||||
QString QgsModelComponentGraphicItem::getLinkedParamDataType(Qt::Edge edge, int index)
|
||||
QString QgsModelComponentGraphicItem::getLinkedParamDataType( Qt::Edge edge, int index )
|
||||
{
|
||||
QString unknownType = QString("unknown");
|
||||
QString unknownType = QString( "unknown" );
|
||||
|
||||
if ( const QgsProcessingModelChildAlgorithm *child = dynamic_cast<const QgsProcessingModelChildAlgorithm *>( component() ) )
|
||||
{
|
||||
if ( !child->algorithm() ) {
|
||||
if ( !child->algorithm() )
|
||||
{
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@ -1152,8 +1160,9 @@ QString QgsModelComponentGraphicItem::getLinkedParamDataType(Qt::Edge edge, int
|
||||
{
|
||||
case Qt::BottomEdge:
|
||||
{
|
||||
if (index <= child->algorithm()->outputDefinitions().size() - 1) {
|
||||
return child->algorithm()->outputDefinitions().at(index)->type();
|
||||
if ( index <= child->algorithm()->outputDefinitions().size() - 1 )
|
||||
{
|
||||
return child->algorithm()->outputDefinitions().at( index )->type();
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
@ -1161,8 +1170,9 @@ QString QgsModelComponentGraphicItem::getLinkedParamDataType(Qt::Edge edge, int
|
||||
{
|
||||
QgsProcessingParameterDefinitions params = child->algorithm()->parameterDefinitions();
|
||||
|
||||
if (index <= params.size() - 1) {
|
||||
return params.at(index)->type();
|
||||
if ( index <= params.size() - 1 )
|
||||
{
|
||||
return params.at( index )->type();
|
||||
}
|
||||
|
||||
return unknownType;
|
||||
@ -1178,7 +1188,6 @@ QString QgsModelComponentGraphicItem::getLinkedParamDataType(Qt::Edge edge, int
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString QgsModelChildAlgorithmGraphicItem::linkPointText( Qt::Edge edge, int index ) const
|
||||
{
|
||||
if ( index < 0 )
|
||||
@ -1229,55 +1238,55 @@ QString QgsModelChildAlgorithmGraphicItem::linkPointText( Qt::Edge edge, int ind
|
||||
return QString();
|
||||
}
|
||||
|
||||
const QgsProcessingParameterDefinition* param = params.at( index );
|
||||
const QgsProcessingParameterDefinition *param = params.at( index );
|
||||
QString name = param->name();
|
||||
QString title = param->description();
|
||||
|
||||
|
||||
QgsProcessingModelChildParameterSources paramSources = child->parameterSources().value(name);
|
||||
QgsProcessingModelChildParameterSources paramSources = child->parameterSources().value( name );
|
||||
QString paramValueAsStr = "";
|
||||
|
||||
if (paramSources.size() > 0) {
|
||||
if ( paramSources.size() > 0 )
|
||||
{
|
||||
QgsProcessingModelChildParameterSource firstParamSource = paramSources[0];
|
||||
|
||||
switch(firstParamSource.getSourceType()) {
|
||||
|
||||
switch ( firstParamSource.getSourceType() )
|
||||
{
|
||||
case Qgis::ProcessingModelChildParameterSource::ChildOutput:
|
||||
paramValueAsStr = QStringLiteral( ": %1" ).arg(
|
||||
firstParamSource.friendlyIdentifier(const_cast<QgsProcessingModelAlgorithm *>(model()))
|
||||
firstParamSource.friendlyIdentifier( const_cast<QgsProcessingModelAlgorithm *>( model() ) )
|
||||
);
|
||||
break;
|
||||
|
||||
case Qgis::ProcessingModelChildParameterSource::Expression:
|
||||
paramValueAsStr = QStringLiteral( ": %1" ).arg(firstParamSource.expression());
|
||||
paramValueAsStr = QStringLiteral( ": %1" ).arg( firstParamSource.expression() );
|
||||
break;
|
||||
|
||||
case Qgis::ProcessingModelChildParameterSource::ExpressionText:
|
||||
paramValueAsStr = QStringLiteral( ": %1" ).arg(firstParamSource.expressionText());
|
||||
paramValueAsStr = QStringLiteral( ": %1" ).arg( firstParamSource.expressionText() );
|
||||
break;
|
||||
|
||||
case Qgis::ProcessingModelChildParameterSource::ModelOutput:
|
||||
paramValueAsStr = QStringLiteral( ": output from '%1'" ).arg(
|
||||
firstParamSource.friendlyIdentifier(const_cast<QgsProcessingModelAlgorithm *>(model()))
|
||||
);
|
||||
paramValueAsStr = QStringLiteral( ": output from '%1'" ).arg( firstParamSource.friendlyIdentifier( const_cast<QgsProcessingModelAlgorithm *>( model() ) ) );
|
||||
break;
|
||||
|
||||
case Qgis::ProcessingModelChildParameterSource::ModelParameter:
|
||||
{
|
||||
QString friendlyName = firstParamSource.friendlyIdentifier(const_cast<QgsProcessingModelAlgorithm *>(model()));
|
||||
paramValueAsStr = friendlyName.isEmpty() ? QStringLiteral( ":" ) : QStringLiteral( ": value from '%1'" ).arg(friendlyName);
|
||||
QString friendlyName = firstParamSource.friendlyIdentifier( const_cast<QgsProcessingModelAlgorithm *>( model() ) );
|
||||
paramValueAsStr = friendlyName.isEmpty() ? QStringLiteral( ":" ) : QStringLiteral( ": value from '%1'" ).arg( friendlyName );
|
||||
break;
|
||||
}
|
||||
|
||||
case Qgis::ProcessingModelChildParameterSource::StaticValue:
|
||||
default:
|
||||
QVariant paramValue = paramSources[0].staticValue();
|
||||
paramValueAsStr = QStringLiteral( ": %1" ).arg(paramValue.toString());
|
||||
paramValueAsStr = QStringLiteral( ": %1" ).arg( paramValue.toString() );
|
||||
|
||||
// In case of an enum, we want to display the label of the enum value (and not just its index as an int)
|
||||
if (param->type() == QgsProcessingParameterEnum::typeName()) {
|
||||
const QgsProcessingParameterEnum* paramAsEnumParam = dynamic_cast<const QgsProcessingParameterEnum *>(param);
|
||||
paramValueAsStr = QStringLiteral( ": %1" ).arg(paramAsEnumParam->options().at(paramValue.toInt()));
|
||||
if ( param->type() == QgsProcessingParameterEnum::typeName() )
|
||||
{
|
||||
const QgsProcessingParameterEnum *paramAsEnumParam = dynamic_cast<const QgsProcessingParameterEnum *>( param );
|
||||
paramValueAsStr = QStringLiteral( ": %1" ).arg( paramAsEnumParam->options().at( paramValue.toInt() ) );
|
||||
}
|
||||
}
|
||||
title += paramValueAsStr;
|
||||
@ -1312,7 +1321,7 @@ bool QgsModelChildAlgorithmGraphicItem::canDeleteComponent()
|
||||
return false;
|
||||
}
|
||||
|
||||
void QgsModelChildAlgorithmGraphicItem::setResults( const QgsProcessingModelChildAlgorithmResult &results)
|
||||
void QgsModelChildAlgorithmGraphicItem::setResults( const QgsProcessingModelChildAlgorithmResult &results )
|
||||
{
|
||||
if ( mResults == results )
|
||||
return;
|
||||
|
@ -137,7 +137,7 @@ class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
|
||||
*/
|
||||
void setItemRect( QRectF rect );
|
||||
|
||||
QString getLinkedParamDataType(Qt::Edge edge, int index);
|
||||
QString getLinkedParamDataType( Qt::Edge edge, int index );
|
||||
|
||||
#ifndef SIP_RUN
|
||||
|
||||
|
@ -185,13 +185,12 @@ QgsModelDesignerSocketGraphicItem::QgsModelDesignerSocketGraphicItem( QgsModelCo
|
||||
|
||||
void QgsModelDesignerSocketGraphicItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * )
|
||||
{
|
||||
|
||||
QColor outlineColor = getColor();
|
||||
QColor fillColor = QColor(outlineColor);
|
||||
fillColor.setAlpha(isDefaultParamValue() ? 30 : 255);
|
||||
QColor fillColor = QColor( outlineColor );
|
||||
fillColor.setAlpha( isDefaultParamValue() ? 30 : 255 );
|
||||
|
||||
// Outline style
|
||||
painter->setPen(QPen(outlineColor, mHoverState ? mSocketOutlineWidth * 2 : mSocketOutlineWidth));
|
||||
painter->setPen( QPen( outlineColor, mHoverState ? mSocketOutlineWidth * 2 : mSocketOutlineWidth ) );
|
||||
|
||||
// Fill style
|
||||
painter->setBrush( QBrush( fillColor, Qt::SolidPattern ) );
|
||||
@ -211,161 +210,149 @@ void QgsModelDesignerSocketGraphicItem::paint( QPainter *painter, const QStyleOp
|
||||
}
|
||||
|
||||
|
||||
QColor QgsModelDesignerSocketGraphicItem::getColor() {
|
||||
QColor QgsModelDesignerSocketGraphicItem::getColor()
|
||||
{
|
||||
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 *>(componentItem()))
|
||||
if ( QgsModelParameterGraphicItem *paramItem = dynamic_cast<QgsModelParameterGraphicItem *>( componentItem() ) )
|
||||
{
|
||||
dataType = paramItem->getLinkedParamDataType(mEdge, mIndex);
|
||||
dataType = paramItem->getLinkedParamDataType( mEdge, mIndex );
|
||||
}
|
||||
else
|
||||
{
|
||||
dataType = componentItem()->getLinkedParamDataType(mEdge, mIndex);
|
||||
dataType = componentItem()->getLinkedParamDataType( mEdge, mIndex );
|
||||
}
|
||||
|
||||
return QgsModelDesignerSocketGraphicItem::typeToColorLookup(dataType);
|
||||
|
||||
return QgsModelDesignerSocketGraphicItem::typeToColorLookup( dataType );
|
||||
}
|
||||
|
||||
|
||||
QColor QgsModelDesignerSocketGraphicItem::typeToColorLookup(QString dataType) {
|
||||
|
||||
QColor QgsModelDesignerSocketGraphicItem::typeToColorLookup( QString dataType )
|
||||
{
|
||||
// Numerical types
|
||||
if(
|
||||
dataType == QgsProcessingParameterMatrix::typeName() ||
|
||||
dataType == QgsProcessingParameterNumber::typeName() ||
|
||||
dataType == QgsProcessingParameterRange::typeName() ||
|
||||
dataType == QgsProcessingParameterColor::typeName() ||
|
||||
dataType == QgsProcessingOutputNumber::typeName() ||
|
||||
dataType == QgsProcessingParameterDistance::typeName() ||
|
||||
dataType == QgsProcessingParameterDuration::typeName() ||
|
||||
dataType == QgsProcessingParameterScale::typeName()
|
||||
if (
|
||||
dataType == QgsProcessingParameterMatrix::typeName() || dataType == QgsProcessingParameterNumber::typeName() || dataType == QgsProcessingParameterRange::typeName() || dataType == QgsProcessingParameterColor::typeName() || dataType == QgsProcessingOutputNumber::typeName() || dataType == QgsProcessingParameterDistance::typeName() || dataType == QgsProcessingParameterDuration::typeName() || dataType == QgsProcessingParameterScale::typeName()
|
||||
|
||||
) {
|
||||
return QColor(34, 157, 214);
|
||||
} else
|
||||
|
||||
// Boolean type
|
||||
if(
|
||||
dataType == QgsProcessingParameterBoolean::typeName() ||
|
||||
dataType == QgsProcessingOutputBoolean::typeName()
|
||||
) {
|
||||
return QColor(51, 201, 28);
|
||||
} else
|
||||
|
||||
// Vector types
|
||||
if(
|
||||
dataType == QgsProcessingParameterPoint::typeName() ||
|
||||
dataType == QgsProcessingParameterGeometry::typeName() ||
|
||||
dataType == QgsProcessingParameterVectorLayer::typeName() ||
|
||||
dataType == QgsProcessingParameterMeshLayer::typeName() ||
|
||||
dataType == QgsProcessingParameterPointCloudLayer::typeName() ||
|
||||
dataType == QgsProcessingOutputVectorLayer::typeName() ||
|
||||
dataType == QgsProcessingOutputPointCloudLayer::typeName() ||
|
||||
dataType == QgsProcessingParameterExtent::typeName() ||
|
||||
dataType == QgsProcessingOutputVectorTileLayer::typeName() ||
|
||||
dataType == QgsProcessingParameterPointCloudDestination::typeName() ||
|
||||
dataType == QgsProcessingParameterVectorTileDestination::typeName() ||
|
||||
dataType == QgsProcessingParameterVectorDestination::typeName() ||
|
||||
dataType == QgsProcessingParameterFeatureSource::typeName()
|
||||
) {
|
||||
return QColor(180, 180, 0);
|
||||
} else
|
||||
|
||||
// Raster type
|
||||
if(
|
||||
dataType == QgsProcessingParameterRasterLayer::typeName() ||
|
||||
dataType == QgsProcessingOutputRasterLayer::typeName()
|
||||
|
||||
) {
|
||||
return QColor(0, 180, 180);
|
||||
} else
|
||||
|
||||
// enum
|
||||
if(
|
||||
dataType == QgsProcessingParameterEnum::typeName()
|
||||
) {
|
||||
return QColor(128, 68, 201);
|
||||
} else
|
||||
|
||||
// String and datetime types
|
||||
if(
|
||||
dataType == QgsProcessingParameterString::typeName() ||
|
||||
dataType == QgsProcessingParameterDateTime::typeName() ||
|
||||
dataType == QgsProcessingParameterCrs::typeName() ||
|
||||
dataType == QgsProcessingOutputHtml::typeName() ||
|
||||
dataType == QgsProcessingOutputString::typeName()
|
||||
|
||||
) {
|
||||
return QColor(100, 100, 255);
|
||||
} else
|
||||
|
||||
// filesystem types
|
||||
if(
|
||||
dataType == QgsProcessingParameterFile::typeName() ||
|
||||
dataType == QgsProcessingOutputFolder::typeName() ||
|
||||
dataType == QgsProcessingOutputFile::typeName() ||
|
||||
dataType == QgsProcessingParameterFolderDestination::typeName() ||
|
||||
dataType == QgsProcessingParameterFeatureSink::typeName() ||
|
||||
dataType == QgsProcessingParameterRasterDestination::typeName() ||
|
||||
dataType == QgsProcessingParameterFileDestination::typeName()
|
||||
) {
|
||||
return QColor(80, 80, 80);
|
||||
} else
|
||||
|
||||
// Expression type
|
||||
if(dataType == QgsProcessingParameterExpression::typeName()) {
|
||||
return QColor(180, 80, 180);
|
||||
} else
|
||||
|
||||
// Other Layer types
|
||||
if(
|
||||
dataType == QgsProcessingParameterMultipleLayers::typeName() ||
|
||||
dataType == QgsProcessingParameterMapLayer::typeName() ||
|
||||
dataType == QgsProcessingParameterAnnotationLayer::typeName() ||
|
||||
dataType == QgsProcessingOutputMultipleLayers::typeName()
|
||||
|
||||
) {
|
||||
return QColor(128, 128, 0);
|
||||
} else
|
||||
|
||||
// Default color, applies for:
|
||||
// QgsProcessingParameterField
|
||||
// QgsProcessingParameterMapTheme
|
||||
// QgsProcessingParameterBand
|
||||
// QgsProcessingParameterLayout
|
||||
// QgsProcessingParameterLayoutItem
|
||||
// QgsProcessingParameterCoordinateOperation
|
||||
// QgsProcessingParameterAuthConfig // config
|
||||
// QgsProcessingParameterDatabaseSchema
|
||||
// QgsProcessingParameterDatabaseTable
|
||||
// QgsProcessingParameterProviderConnection
|
||||
// QgsProcessingParameterPointCloudAttribute
|
||||
// QgsProcessingOutputVariant
|
||||
// QgsProcessingOutputConditionalBranch
|
||||
)
|
||||
{
|
||||
return QColor(128, 128, 128);
|
||||
return QColor( 34, 157, 214 );
|
||||
}
|
||||
else
|
||||
|
||||
// Boolean type
|
||||
if (
|
||||
dataType == QgsProcessingParameterBoolean::typeName() || dataType == QgsProcessingOutputBoolean::typeName()
|
||||
)
|
||||
{
|
||||
return QColor( 51, 201, 28 );
|
||||
}
|
||||
else
|
||||
|
||||
// Vector types
|
||||
if (
|
||||
dataType == QgsProcessingParameterPoint::typeName() || dataType == QgsProcessingParameterGeometry::typeName() || dataType == QgsProcessingParameterVectorLayer::typeName() || dataType == QgsProcessingParameterMeshLayer::typeName() || dataType == QgsProcessingParameterPointCloudLayer::typeName() || dataType == QgsProcessingOutputVectorLayer::typeName() || dataType == QgsProcessingOutputPointCloudLayer::typeName() || dataType == QgsProcessingParameterExtent::typeName() || dataType == QgsProcessingOutputVectorTileLayer::typeName() || dataType == QgsProcessingParameterPointCloudDestination::typeName() || dataType == QgsProcessingParameterVectorTileDestination::typeName() || dataType == QgsProcessingParameterVectorDestination::typeName() || dataType == QgsProcessingParameterFeatureSource::typeName()
|
||||
)
|
||||
{
|
||||
return QColor( 180, 180, 0 );
|
||||
}
|
||||
else
|
||||
|
||||
// Raster type
|
||||
if (
|
||||
dataType == QgsProcessingParameterRasterLayer::typeName() || dataType == QgsProcessingOutputRasterLayer::typeName()
|
||||
|
||||
)
|
||||
{
|
||||
return QColor( 0, 180, 180 );
|
||||
}
|
||||
else
|
||||
|
||||
// enum
|
||||
if (
|
||||
dataType == QgsProcessingParameterEnum::typeName()
|
||||
)
|
||||
{
|
||||
return QColor( 128, 68, 201 );
|
||||
}
|
||||
else
|
||||
|
||||
// String and datetime types
|
||||
if (
|
||||
dataType == QgsProcessingParameterString::typeName() || dataType == QgsProcessingParameterDateTime::typeName() || dataType == QgsProcessingParameterCrs::typeName() || dataType == QgsProcessingOutputHtml::typeName() || dataType == QgsProcessingOutputString::typeName()
|
||||
|
||||
)
|
||||
{
|
||||
return QColor( 100, 100, 255 );
|
||||
}
|
||||
else
|
||||
|
||||
// filesystem types
|
||||
if (
|
||||
dataType == QgsProcessingParameterFile::typeName() || dataType == QgsProcessingOutputFolder::typeName() || dataType == QgsProcessingOutputFile::typeName() || dataType == QgsProcessingParameterFolderDestination::typeName() || dataType == QgsProcessingParameterFeatureSink::typeName() || dataType == QgsProcessingParameterRasterDestination::typeName() || dataType == QgsProcessingParameterFileDestination::typeName()
|
||||
)
|
||||
{
|
||||
return QColor( 80, 80, 80 );
|
||||
}
|
||||
else
|
||||
|
||||
// Expression type
|
||||
if ( dataType == QgsProcessingParameterExpression::typeName() )
|
||||
{
|
||||
return QColor( 180, 80, 180 );
|
||||
}
|
||||
else
|
||||
|
||||
// Other Layer types
|
||||
if (
|
||||
dataType == QgsProcessingParameterMultipleLayers::typeName() || dataType == QgsProcessingParameterMapLayer::typeName() || dataType == QgsProcessingParameterAnnotationLayer::typeName() || dataType == QgsProcessingOutputMultipleLayers::typeName()
|
||||
|
||||
)
|
||||
{
|
||||
return QColor( 128, 128, 0 );
|
||||
}
|
||||
else
|
||||
|
||||
// Default color, applies for:
|
||||
// QgsProcessingParameterField
|
||||
// QgsProcessingParameterMapTheme
|
||||
// QgsProcessingParameterBand
|
||||
// QgsProcessingParameterLayout
|
||||
// QgsProcessingParameterLayoutItem
|
||||
// QgsProcessingParameterCoordinateOperation
|
||||
// QgsProcessingParameterAuthConfig // config
|
||||
// QgsProcessingParameterDatabaseSchema
|
||||
// QgsProcessingParameterDatabaseTable
|
||||
// QgsProcessingParameterProviderConnection
|
||||
// QgsProcessingParameterPointCloudAttribute
|
||||
// QgsProcessingOutputVariant
|
||||
// QgsProcessingOutputConditionalBranch
|
||||
{
|
||||
return QColor( 128, 128, 128 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool QgsModelDesignerSocketGraphicItem::isDefaultParamValue() {
|
||||
if (!mComponent) {
|
||||
bool QgsModelDesignerSocketGraphicItem::isDefaultParamValue()
|
||||
{
|
||||
if ( !mComponent )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const QgsProcessingModelChildAlgorithm *child = dynamic_cast<const QgsProcessingModelChildAlgorithm *>( mComponent );
|
||||
|
||||
if (!child) {
|
||||
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()) {
|
||||
if ( child->algorithm() )
|
||||
{
|
||||
switch ( mEdge )
|
||||
{
|
||||
// Input params
|
||||
@ -373,20 +360,23 @@ bool QgsModelDesignerSocketGraphicItem::isDefaultParamValue() {
|
||||
{
|
||||
QgsProcessingParameterDefinitions params = child->algorithm()->parameterDefinitions();
|
||||
|
||||
if ( mIndex > (params.length() - 1) ) {
|
||||
if ( mIndex > ( params.length() - 1 ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
const QgsProcessingParameterDefinition* param = params.at( mIndex );
|
||||
const QgsProcessingParameterDefinition *param = params.at( mIndex );
|
||||
QString name = param->name();
|
||||
|
||||
QgsProcessingModelChildParameterSources paramSources = child->parameterSources().value(name);
|
||||
if (paramSources.size() == 0) {
|
||||
QgsProcessingModelChildParameterSources paramSources = child->parameterSources().value( name );
|
||||
if ( paramSources.size() == 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// The default value can only happen in the case of the parameter uses a static value
|
||||
if (paramSources[0].getSourceType() != Qgis::ProcessingModelChildParameterSource::StaticValue) {
|
||||
if ( paramSources[0].getSourceType() != Qgis::ProcessingModelChildParameterSource::StaticValue )
|
||||
{
|
||||
isDefaultValue = false;
|
||||
break;
|
||||
}
|
||||
@ -398,7 +388,6 @@ bool QgsModelDesignerSocketGraphicItem::isDefaultParamValue() {
|
||||
// Ouputs
|
||||
case Qt::BottomEdge:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
case Qt::LeftEdge:
|
||||
|
@ -158,7 +158,7 @@ class GUI_EXPORT QgsModelDesignerSocketGraphicItem : public QgsModelDesignerFlat
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static QColor typeToColorLookup(QString dataType);
|
||||
static QColor typeToColorLookup( QString dataType );
|
||||
|
||||
/**
|
||||
* Constructor for QgsModelDesignerSocketGraphicItem, with the specified \a parent item.
|
||||
|
Loading…
x
Reference in New Issue
Block a user