QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
processing
models
qgsprocessingmodeloutput.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsprocessingmodeloutput.cpp
3
----------------------------
4
begin : June 2017
5
copyright : (C) 2017 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#include "
qgsprocessingmodeloutput.h
"
19
20
#include <QString>
21
22
using namespace
Qt::StringLiterals;
23
25
26
QgsProcessingModelOutput::QgsProcessingModelOutput(
const
QString &name,
const
QString &description )
27
: QgsProcessingModelComponent( description )
28
, mName( name )
29
{}
30
31
QgsProcessingModelOutput *QgsProcessingModelOutput::clone()
const
32
{
33
return
new
QgsProcessingModelOutput( *
this
);
34
}
35
36
QVariant QgsProcessingModelOutput::toVariant()
const
37
{
38
QVariantMap map;
39
map.insert( u
"name"
_s, mName );
40
41
if
( mDefaultValue.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
42
{
43
QVariantMap defaultMap = mDefaultValue.value<
QgsProcessingOutputLayerDefinition
>().toVariant().toMap();
44
defaultMap.insert( u
"class"
_s, u
"QgsProcessingOutputLayerDefinition"
_s );
45
map.insert( u
"default_value"
_s, defaultMap );
46
}
47
else
48
{
49
map.insert( u
"default_value"
_s, mDefaultValue );
50
}
51
52
map.insert( u
"child_id"
_s, mChildId );
53
map.insert( u
"output_name"
_s, mOutputName );
54
map.insert( u
"mandatory"
_s, mMandatory );
55
saveCommonProperties( map );
56
return
map;
57
}
58
59
bool
QgsProcessingModelOutput::loadVariant(
const
QVariantMap &map )
60
{
61
mName = map.value( u
"name"
_s ).toString();
62
63
const
QVariant defaultValue = map.value( u
"default_value"
_s );
64
if
( defaultValue.userType() == QMetaType::Type::QVariantMap )
65
{
66
QVariantMap defaultMap = defaultValue.toMap();
67
if
( defaultMap[
"class"
] ==
"QgsProcessingOutputLayerDefinition"
_L1 )
68
{
69
QgsProcessingOutputLayerDefinition
value;
70
value.
loadVariant
( defaultMap );
71
mDefaultValue = QVariant( value );
72
}
73
else
74
{
75
mDefaultValue = QVariant();
76
}
77
}
78
else
79
{
80
mDefaultValue = map.value( u
"default_value"
_s );
81
}
82
83
mChildId = map.value( u
"child_id"
_s ).toString();
84
mOutputName = map.value( u
"output_name"
_s ).toString();
85
mMandatory = map.value( u
"mandatory"
_s,
false
).toBool();
86
restoreCommonProperties( map );
87
return
true
;
88
}
89
90
QgsProcessingOutputLayerDefinition
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
Definition
qgsprocessingparameters.h:294
QgsProcessingOutputLayerDefinition::loadVariant
bool loadVariant(const QVariantMap &map)
Loads this output layer definition from a QVariantMap, wrapped in a QVariant.
Definition
qgsprocessingparameters.cpp:118
qgsprocessingmodeloutput.h
Generated on
for QGIS API Documentation by
1.17.0