mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
This allows users to create comments attached to model components (inputs, algorithms or outputs). Comments are shown linked to the associated component, and can be freely moved around the model.
121 lines
3.8 KiB
C++
121 lines
3.8 KiB
C++
/***************************************************************************
|
|
qgsprocessingmodelcomponent.cpp
|
|
-------------------------------
|
|
begin : June 2017
|
|
copyright : (C) 2017 by Nyall Dawson
|
|
email : nyall dot dawson at gmail dot com
|
|
***************************************************************************/
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
#include "qgsprocessingmodelcomponent.h"
|
|
|
|
///@cond NOT_STABLE
|
|
|
|
QgsProcessingModelComponent::QgsProcessingModelComponent( const QString &description )
|
|
: mDescription( description )
|
|
{}
|
|
|
|
QString QgsProcessingModelComponent::description() const
|
|
{
|
|
return mDescription;
|
|
}
|
|
|
|
void QgsProcessingModelComponent::setDescription( const QString &description )
|
|
{
|
|
mDescription = description;
|
|
}
|
|
|
|
QPointF QgsProcessingModelComponent::position() const
|
|
{
|
|
return mPosition;
|
|
}
|
|
|
|
void QgsProcessingModelComponent::setPosition( QPointF position )
|
|
{
|
|
mPosition = position;
|
|
}
|
|
|
|
QSizeF QgsProcessingModelComponent::size() const
|
|
{
|
|
return mSize;
|
|
}
|
|
|
|
void QgsProcessingModelComponent::setSize( QSizeF size )
|
|
{
|
|
mSize = size;
|
|
}
|
|
|
|
bool QgsProcessingModelComponent::linksCollapsed( Qt::Edge edge ) const
|
|
{
|
|
switch ( edge )
|
|
{
|
|
case Qt::TopEdge:
|
|
return mTopEdgeLinksCollapsed;
|
|
|
|
case Qt::BottomEdge:
|
|
return mBottomEdgeLinksCollapsed;
|
|
|
|
case Qt::LeftEdge:
|
|
case Qt::RightEdge:
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void QgsProcessingModelComponent::setLinksCollapsed( Qt::Edge edge, bool collapsed )
|
|
{
|
|
switch ( edge )
|
|
{
|
|
case Qt::TopEdge:
|
|
mTopEdgeLinksCollapsed = collapsed;
|
|
break;
|
|
|
|
case Qt::BottomEdge:
|
|
mBottomEdgeLinksCollapsed = collapsed;
|
|
break;
|
|
|
|
case Qt::LeftEdge:
|
|
case Qt::RightEdge:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void QgsProcessingModelComponent::setComment( const QgsProcessingModelComment & )
|
|
{
|
|
|
|
}
|
|
|
|
void QgsProcessingModelComponent::saveCommonProperties( QVariantMap &map ) const
|
|
{
|
|
map.insert( QStringLiteral( "component_pos_x" ), mPosition.x() );
|
|
map.insert( QStringLiteral( "component_pos_y" ), mPosition.y() );
|
|
map.insert( QStringLiteral( "component_description" ), mDescription );
|
|
map.insert( QStringLiteral( "component_width" ), mSize.width() );
|
|
map.insert( QStringLiteral( "component_height" ), mSize.height() );
|
|
map.insert( QStringLiteral( "parameters_collapsed" ), mTopEdgeLinksCollapsed );
|
|
map.insert( QStringLiteral( "outputs_collapsed" ), mBottomEdgeLinksCollapsed );
|
|
}
|
|
|
|
void QgsProcessingModelComponent::restoreCommonProperties( const QVariantMap &map )
|
|
{
|
|
QPointF pos;
|
|
pos.setX( map.value( QStringLiteral( "component_pos_x" ) ).toDouble() );
|
|
pos.setY( map.value( QStringLiteral( "component_pos_y" ) ).toDouble() );
|
|
mPosition = pos;
|
|
mDescription = map.value( QStringLiteral( "component_description" ) ).toString();
|
|
mSize.setWidth( map.value( QStringLiteral( "component_width" ), QString::number( DEFAULT_COMPONENT_WIDTH ) ).toDouble() );
|
|
mSize.setHeight( map.value( QStringLiteral( "component_height" ), QString::number( DEFAULT_COMPONENT_HEIGHT ) ).toDouble() );
|
|
mTopEdgeLinksCollapsed = map.value( QStringLiteral( "parameters_collapsed" ) ).toBool();
|
|
mBottomEdgeLinksCollapsed = map.value( QStringLiteral( "outputs_collapsed" ) ).toBool();
|
|
}
|
|
|
|
///@endcond
|