25QgsProcessingModelComponent::QgsProcessingModelComponent(
const QString &description )
26 : mDescription( description )
29QString QgsProcessingModelComponent::description()
const
34void QgsProcessingModelComponent::setDescription(
const QString &description )
36 mDescription = description;
39QPointF QgsProcessingModelComponent::position()
const
44void QgsProcessingModelComponent::setPosition( QPointF position )
49QSizeF QgsProcessingModelComponent::size()
const
54void QgsProcessingModelComponent::setSize( QSizeF size )
59QColor QgsProcessingModelComponent::color()
const
64void QgsProcessingModelComponent::setColor(
const QColor &color )
69bool QgsProcessingModelComponent::linksCollapsed( Qt::Edge edge )
const
74 return mTopEdgeLinksCollapsed;
77 return mBottomEdgeLinksCollapsed;
86void QgsProcessingModelComponent::setLinksCollapsed( Qt::Edge edge,
bool collapsed )
91 mTopEdgeLinksCollapsed = collapsed;
95 mBottomEdgeLinksCollapsed = collapsed;
104void QgsProcessingModelComponent::setComment(
const QgsProcessingModelComment & )
109void QgsProcessingModelComponent::saveCommonProperties( QVariantMap &map )
const
111 map.insert( QStringLiteral(
"component_pos_x" ), mPosition.x() );
112 map.insert( QStringLiteral(
"component_pos_y" ), mPosition.y() );
113 map.insert( QStringLiteral(
"component_description" ), mDescription );
114 map.insert( QStringLiteral(
"component_width" ), mSize.width() );
115 map.insert( QStringLiteral(
"component_height" ), mSize.height() );
116 map.insert( QStringLiteral(
"parameters_collapsed" ), mTopEdgeLinksCollapsed );
117 map.insert( QStringLiteral(
"outputs_collapsed" ), mBottomEdgeLinksCollapsed );
119 const QgsProcessingModelComment *thisComment = comment();
121 map.insert( QStringLiteral(
"comment" ), thisComment->toVariant() );
124void QgsProcessingModelComponent::restoreCommonProperties(
const QVariantMap &map )
127 pos.setX( map.value( QStringLiteral(
"component_pos_x" ) ).toDouble() );
128 pos.setY( map.value( QStringLiteral(
"component_pos_y" ) ).toDouble() );
130 mDescription = map.value( QStringLiteral(
"component_description" ) ).toString();
131 mSize.setWidth( map.value( QStringLiteral(
"component_width" ), QString::number( DEFAULT_COMPONENT_WIDTH ) ).toDouble() );
132 mSize.setHeight( map.value( QStringLiteral(
"component_height" ), QString::number( DEFAULT_COMPONENT_HEIGHT ) ).toDouble() );
133 mColor = map.value( QStringLiteral(
"color" ) ).toString().isEmpty() ? QColor() :
QgsColorUtils::colorFromString( map.value( QStringLiteral(
"color" ) ).toString() );
134 mTopEdgeLinksCollapsed = map.value( QStringLiteral(
"parameters_collapsed" ) ).toBool();
135 mBottomEdgeLinksCollapsed = map.value( QStringLiteral(
"outputs_collapsed" ) ).toBool();
136 QgsProcessingModelComment *thisComment = comment();
138 thisComment->loadVariant( map.value( QStringLiteral(
"comment" ) ).toMap() );
141void QgsProcessingModelComponent::copyNonDefinitionProperties(
const QgsProcessingModelComponent &other )
143 setPosition( other.position() );
144 setSize( other.size() );
145 setLinksCollapsed( Qt::TopEdge, other.linksCollapsed( Qt::TopEdge ) );
146 setLinksCollapsed( Qt::BottomEdge, other.linksCollapsed( Qt::BottomEdge ) );
147 QgsProcessingModelComment *thisComment = comment();
148 const QgsProcessingModelComment *otherComment = other.comment();
149 if ( thisComment && otherComment )
151 if ( !otherComment->position().isNull() )
152 thisComment->setPosition( otherComment->position() );
154 thisComment->setPosition( other.position() + QPointF( size().width(), -1.5 * size().height() ) );
155 thisComment->setSize( otherComment->size() );
Contains utility functions for working with colors.
static QString colorToString(const QColor &color)
Encodes a color into a string value.