QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgsprocessingrasteroptionswidgetwrapper.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingrasteroptionswidgetwrapper.cpp
3 ---------------------
4 begin : November 2020
5 copyright : (C) 2020 by Alexander Bruy
6 email : alexander dot bruy 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
19#include "moc_qgsprocessingrasteroptionswidgetwrapper.cpp"
23
24#include <QComboBox>
25#include <QLineEdit>
26
28
29QgsProcessingRasterOptionsWidgetWrapper::QgsProcessingRasterOptionsWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type, QWidget *parent )
30 : QgsAbstractProcessingParameterWidgetWrapper( parameter, type, parent )
31{
32}
33
34QString QgsProcessingRasterOptionsWidgetWrapper::parameterType() const
35{
36 return QStringLiteral( "rasteroptions" );
37}
38
39QgsAbstractProcessingParameterWidgetWrapper *QgsProcessingRasterOptionsWidgetWrapper::createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type )
40{
41 return new QgsProcessingRasterOptionsWidgetWrapper( parameter, type );
42}
43
44QWidget *QgsProcessingRasterOptionsWidgetWrapper::createWidget()
45{
46 switch ( type() )
47 {
49 {
50 mOptionsWidget = new QgsRasterFormatSaveOptionsWidget();
51 mOptionsWidget->setToolTip( parameterDefinition()->toolTip() );
52 connect( mOptionsWidget, &QgsRasterFormatSaveOptionsWidget::optionsChanged, this, [ = ]
53 {
54 emit widgetValueHasChanged( this );
55 } );
56 return mOptionsWidget;
57 }
60 {
61 mLineEdit = new QLineEdit();
62 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
63 connect( mLineEdit, &QLineEdit::textChanged, this, [ = ]
64 {
65 emit widgetValueHasChanged( this );
66 } );
67 return mLineEdit;
68 }
69 }
70
71 return nullptr;
72}
73
74void QgsProcessingRasterOptionsWidgetWrapper::setWidgetValue( const QVariant &value, QgsProcessingContext &context )
75{
76 QString val = QgsProcessingParameters::parameterAsString( parameterDefinition(), value, context );
77
78 if ( mOptionsWidget )
79 {
80 if ( value.isValid() )
81 mOptionsWidget->setOptions( val.replace( '|', ' ' ) );
82 else
83 mOptionsWidget->setOptions( QString() );
84 }
85 else if ( mLineEdit )
86 {
87 if ( value.isValid() )
88 mLineEdit->setText( val );
89 else
90 mLineEdit->clear();
91 }
92}
93
94QVariant QgsProcessingRasterOptionsWidgetWrapper::widgetValue() const
95{
96 if ( mOptionsWidget )
97 {
98 return mOptionsWidget->options().join( '|' );
99 }
100 else if ( mLineEdit )
101 {
102 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
103 }
104 else
105 return QVariant();
106}
107
108QStringList QgsProcessingRasterOptionsWidgetWrapper::compatibleParameterTypes() const
109{
110 return QStringList()
124}
125
126QStringList QgsProcessingRasterOptionsWidgetWrapper::compatibleOutputTypes() const
127{
128 return QStringList() << QgsProcessingOutputNumber::typeName()
133}
134
A widget wrapper for Processing parameter value widgets.
Contains information about the context in which a processing algorithm is executed.
WidgetType
Types of dialogs which Processing widgets can be created for.
@ Modeler
Modeler dialog.
@ Standard
Standard algorithm dialog.
@ Batch
Batch processing dialog.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
Base class for the definition of processing parameters.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
A widget to select format-specific raster saving options.
void optionsChanged()
Emitted when the options configured in the widget are changed.