24QgsProcessingModelComponent::QgsProcessingModelComponent(
const QString &description )
25 : mDescription( description )
28QString QgsProcessingModelComponent::description()
const
33void QgsProcessingModelComponent::setDescription(
const QString &description )
35 mDescription = description;
38QPointF QgsProcessingModelComponent::position()
const
43void QgsProcessingModelComponent::setPosition( QPointF position )
48QSizeF QgsProcessingModelComponent::size()
const
53void QgsProcessingModelComponent::setSize( QSizeF size )
58QColor QgsProcessingModelComponent::color()
const
63void QgsProcessingModelComponent::setColor(
const QColor &color )
68bool QgsProcessingModelComponent::linksCollapsed( Qt::Edge edge )
const
73 return mTopEdgeLinksCollapsed;
76 return mBottomEdgeLinksCollapsed;
85void QgsProcessingModelComponent::setLinksCollapsed( Qt::Edge edge,
bool collapsed )
90 mTopEdgeLinksCollapsed = collapsed;
94 mBottomEdgeLinksCollapsed = collapsed;
103void QgsProcessingModelComponent::setComment(
const QgsProcessingModelComment & )
108void QgsProcessingModelComponent::saveCommonProperties( QVariantMap &map )
const
110 map.insert( QStringLiteral(
"component_pos_x" ), mPosition.x() );
111 map.insert( QStringLiteral(
"component_pos_y" ), mPosition.y() );
112 map.insert( QStringLiteral(
"component_description" ), mDescription );
113 map.insert( QStringLiteral(
"component_width" ), mSize.width() );
114 map.insert( QStringLiteral(
"component_height" ), mSize.height() );
115 map.insert( QStringLiteral(
"parameters_collapsed" ), mTopEdgeLinksCollapsed );
116 map.insert( QStringLiteral(
"outputs_collapsed" ), mBottomEdgeLinksCollapsed );
118 const QgsProcessingModelComment *thisComment = comment();
120 map.insert( QStringLiteral(
"comment" ), thisComment->toVariant() );
123void QgsProcessingModelComponent::restoreCommonProperties(
const QVariantMap &map )
126 pos.setX( map.value( QStringLiteral(
"component_pos_x" ) ).toDouble() );
127 pos.setY( map.value( QStringLiteral(
"component_pos_y" ) ).toDouble() );
129 mDescription = map.value( QStringLiteral(
"component_description" ) ).toString();
130 mSize.setWidth( map.value( QStringLiteral(
"component_width" ), QString::number( DEFAULT_COMPONENT_WIDTH ) ).toDouble() );
131 mSize.setHeight( map.value( QStringLiteral(
"component_height" ), QString::number( DEFAULT_COMPONENT_HEIGHT ) ).toDouble() );
132 mColor = map.value( QStringLiteral(
"color" ) ).toString().isEmpty() ? QColor() :
QgsSymbolLayerUtils::decodeColor( map.value( QStringLiteral(
"color" ) ).toString() );
133 mTopEdgeLinksCollapsed = map.value( QStringLiteral(
"parameters_collapsed" ) ).toBool();
134 mBottomEdgeLinksCollapsed = map.value( QStringLiteral(
"outputs_collapsed" ) ).toBool();
135 QgsProcessingModelComment *thisComment = comment();
137 thisComment->loadVariant( map.value( QStringLiteral(
"comment" ) ).toMap() );
140void QgsProcessingModelComponent::copyNonDefinitionProperties(
const QgsProcessingModelComponent &other )
142 setPosition( other.position() );
143 setSize( other.size() );
144 setLinksCollapsed( Qt::TopEdge, other.linksCollapsed( Qt::TopEdge ) );
145 setLinksCollapsed( Qt::BottomEdge, other.linksCollapsed( Qt::BottomEdge ) );
146 QgsProcessingModelComment *thisComment = comment();
147 const QgsProcessingModelComment *otherComment = other.comment();
148 if ( thisComment && otherComment )
150 if ( !otherComment->position().isNull() )
151 thisComment->setPosition( otherComment->position() );
153 thisComment->setPosition( other.position() + QPointF( size().width(), -1.5 * size().height() ) );
154 thisComment->setSize( otherComment->size() );
static QString encodeColor(const QColor &color)