25using namespace Qt::StringLiterals;
29QgsProcessingModelComponent::QgsProcessingModelComponent(
const QString &description )
30 : mDescription( description )
33QString QgsProcessingModelComponent::description()
const
38void QgsProcessingModelComponent::setDescription(
const QString &description )
40 mDescription = description;
43QPointF QgsProcessingModelComponent::position()
const
48void QgsProcessingModelComponent::setPosition( QPointF position )
53QSizeF QgsProcessingModelComponent::size()
const
58void QgsProcessingModelComponent::setSize( QSizeF size )
63QColor QgsProcessingModelComponent::color()
const
68void QgsProcessingModelComponent::setColor(
const QColor &color )
73bool QgsProcessingModelComponent::linksCollapsed( Qt::Edge edge )
const
78 return mTopEdgeLinksCollapsed;
81 return mBottomEdgeLinksCollapsed;
90void QgsProcessingModelComponent::setLinksCollapsed( Qt::Edge edge,
bool collapsed )
95 mTopEdgeLinksCollapsed = collapsed;
99 mBottomEdgeLinksCollapsed = collapsed;
108void QgsProcessingModelComponent::setComment(
const QgsProcessingModelComment & )
111void QgsProcessingModelComponent::saveCommonProperties( QVariantMap &map )
const
113 map.insert( u
"component_pos_x"_s, mPosition.x() );
114 map.insert( u
"component_pos_y"_s, mPosition.y() );
115 map.insert( u
"component_description"_s, mDescription );
116 map.insert( u
"component_width"_s, mSize.width() );
117 map.insert( u
"component_height"_s, mSize.height() );
118 map.insert( u
"parameters_collapsed"_s, mTopEdgeLinksCollapsed );
119 map.insert( u
"outputs_collapsed"_s, mBottomEdgeLinksCollapsed );
121 const QgsProcessingModelComment *thisComment = comment();
123 map.insert( u
"comment"_s, thisComment->toVariant() );
126void QgsProcessingModelComponent::restoreCommonProperties(
const QVariantMap &map )
129 pos.setX( map.value( u
"component_pos_x"_s ).toDouble() );
130 pos.setY( map.value( u
"component_pos_y"_s ).toDouble() );
132 mDescription = map.value( u
"component_description"_s ).toString();
133 mSize.setWidth( map.value( u
"component_width"_s, QString::number( DEFAULT_COMPONENT_WIDTH ) ).toDouble() );
134 mSize.setHeight( map.value( u
"component_height"_s, QString::number( DEFAULT_COMPONENT_HEIGHT ) ).toDouble() );
135 mColor = map.value( u
"color"_s ).toString().isEmpty() ? QColor() :
QgsColorUtils::colorFromString( map.value( u
"color"_s ).toString() );
136 mTopEdgeLinksCollapsed = map.value( u
"parameters_collapsed"_s ).toBool();
137 mBottomEdgeLinksCollapsed = map.value( u
"outputs_collapsed"_s ).toBool();
138 QgsProcessingModelComment *thisComment = comment();
140 thisComment->loadVariant( map.value( u
"comment"_s ).toMap() );
143void QgsProcessingModelComponent::copyNonDefinitionProperties(
const QgsProcessingModelComponent &other )
145 setPosition( other.position() );
146 setSize( other.size() );
147 setLinksCollapsed( Qt::TopEdge, other.linksCollapsed( Qt::TopEdge ) );
148 setLinksCollapsed( Qt::BottomEdge, other.linksCollapsed( Qt::BottomEdge ) );
149 QgsProcessingModelComment *thisComment = comment();
150 const QgsProcessingModelComment *otherComment = other.comment();
151 if ( thisComment && otherComment )
153 if ( !otherComment->position().isNull() )
154 thisComment->setPosition( otherComment->position() );
156 thisComment->setPosition( other.position() + QPointF( size().width(), -1.5 * size().height() ) );
157 thisComment->setSize( otherComment->size() );
Contains utility functions for working with colors.
static QString colorToString(const QColor &color)
Encodes a color into a string value.