QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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
22
23#include <QComboBox>
24#include <QLineEdit>
25
27
28QgsProcessingRasterOptionsWidgetWrapper::QgsProcessingRasterOptionsWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type, QWidget *parent )
29 : QgsAbstractProcessingParameterWidgetWrapper( parameter, type, parent )
30{
31}
32
33QString QgsProcessingRasterOptionsWidgetWrapper::parameterType() const
34{
35 return QStringLiteral( "rasteroptions" );
36}
37
38QgsAbstractProcessingParameterWidgetWrapper *QgsProcessingRasterOptionsWidgetWrapper::createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type )
39{
40 return new QgsProcessingRasterOptionsWidgetWrapper( parameter, type );
41}
42
43QWidget *QgsProcessingRasterOptionsWidgetWrapper::createWidget()
44{
45 switch ( type() )
46 {
48 {
49 mOptionsWidget = new QgsRasterFormatSaveOptionsWidget();
50 mOptionsWidget->setToolTip( parameterDefinition()->toolTip() );
51 connect( mOptionsWidget, &QgsRasterFormatSaveOptionsWidget::optionsChanged, this, [ = ]
52 {
53 emit widgetValueHasChanged( this );
54 } );
55 return mOptionsWidget;
56 }
59 {
60 mLineEdit = new QLineEdit();
61 mLineEdit->setToolTip( parameterDefinition()->toolTip() );
62 connect( mLineEdit, &QLineEdit::textChanged, this, [ = ]
63 {
64 emit widgetValueHasChanged( this );
65 } );
66 return mLineEdit;
67 }
68 }
69
70 return nullptr;
71}
72
73void QgsProcessingRasterOptionsWidgetWrapper::setWidgetValue( const QVariant &value, QgsProcessingContext &context )
74{
75 QString val = QgsProcessingParameters::parameterAsString( parameterDefinition(), value, context );
76
77 if ( mOptionsWidget )
78 {
79 if ( value.isValid() )
80 mOptionsWidget->setOptions( val.replace( '|', ' ' ) );
81 else
82 mOptionsWidget->setOptions( QString() );
83 }
84 else if ( mLineEdit )
85 {
86 if ( value.isValid() )
87 mLineEdit->setText( val );
88 else
89 mLineEdit->clear();
90 }
91}
92
93QVariant QgsProcessingRasterOptionsWidgetWrapper::widgetValue() const
94{
95 if ( mOptionsWidget )
96 {
97 return mOptionsWidget->options().join( '|' );
98 }
99 else if ( mLineEdit )
100 {
101 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
102 }
103 else
104 return QVariant();
105}
106
107QStringList QgsProcessingRasterOptionsWidgetWrapper::compatibleParameterTypes() const
108{
109 return QStringList()
123}
124
125QStringList QgsProcessingRasterOptionsWidgetWrapper::compatibleOutputTypes() const
126{
127 return QStringList() << QgsProcessingOutputNumber::typeName()
132}
133
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.