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 & )
113void QgsProcessingModelComponent::saveCommonProperties( QVariantMap &map )
const
115 map.insert( u
"component_pos_x"_s, mPosition.x() );
116 map.insert( u
"component_pos_y"_s, mPosition.y() );
117 map.insert( u
"component_description"_s, mDescription );
118 map.insert( u
"component_width"_s, mSize.width() );
119 map.insert( u
"component_height"_s, mSize.height() );
120 map.insert( u
"parameters_collapsed"_s, mTopEdgeLinksCollapsed );
121 map.insert( u
"outputs_collapsed"_s, mBottomEdgeLinksCollapsed );
123 const QgsProcessingModelComment *thisComment = comment();
125 map.insert( u
"comment"_s, thisComment->toVariant() );
128void QgsProcessingModelComponent::restoreCommonProperties(
const QVariantMap &map )
131 pos.setX( map.value( u
"component_pos_x"_s ).toDouble() );
132 pos.setY( map.value( u
"component_pos_y"_s ).toDouble() );
134 mDescription = map.value( u
"component_description"_s ).toString();
135 mSize.setWidth( map.value( u
"component_width"_s, QString::number( DEFAULT_COMPONENT_WIDTH ) ).toDouble() );
136 mSize.setHeight( map.value( u
"component_height"_s, QString::number( DEFAULT_COMPONENT_HEIGHT ) ).toDouble() );
137 mColor = map.value( u
"color"_s ).toString().isEmpty() ? QColor() :
QgsColorUtils::colorFromString( map.value( u
"color"_s ).toString() );
138 mTopEdgeLinksCollapsed = map.value( u
"parameters_collapsed"_s ).toBool();
139 mBottomEdgeLinksCollapsed = map.value( u
"outputs_collapsed"_s ).toBool();
140 QgsProcessingModelComment *thisComment = comment();
142 thisComment->loadVariant( map.value( u
"comment"_s ).toMap() );
145void QgsProcessingModelComponent::copyNonDefinitionProperties(
const QgsProcessingModelComponent &other )
147 setPosition( other.position() );
148 setSize( other.size() );
149 setLinksCollapsed( Qt::TopEdge, other.linksCollapsed( Qt::TopEdge ) );
150 setLinksCollapsed( Qt::BottomEdge, other.linksCollapsed( Qt::BottomEdge ) );
151 QgsProcessingModelComment *thisComment = comment();
152 const QgsProcessingModelComment *otherComment = other.comment();
153 if ( thisComment && otherComment )
155 if ( !otherComment->position().isNull() )
156 thisComment->setPosition( otherComment->position() );
158 thisComment->setPosition( other.position() + QPointF( size().width(), -1.5 * size().height() ) );
159 thisComment->setSize( otherComment->size() );
Contains utility functions for working with colors.
static QString colorToString(const QColor &color)
Encodes a color into a string value.