QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 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 emit widgetValueHasChanged( this );
64 } );
65 return mLineEdit;
66 }
67 }
68
69 return nullptr;
70}
71
72void QgsProcessingRasterOptionsWidgetWrapper::setWidgetValue( const QVariant &value, QgsProcessingContext &context )
73{
74 QString val = QgsProcessingParameters::parameterAsString( parameterDefinition(), value, context );
75
76 if ( mOptionsWidget )
77 {
78 if ( value.isValid() )
79 mOptionsWidget->setOptions( val.replace( '|', ' ' ) );
80 else
81 mOptionsWidget->setOptions( QString() );
82 }
83 else if ( mLineEdit )
84 {
85 if ( value.isValid() )
86 mLineEdit->setText( val );
87 else
88 mLineEdit->clear();
89 }
90}
91
92QVariant QgsProcessingRasterOptionsWidgetWrapper::widgetValue() const
93{
94 if ( mOptionsWidget )
95 {
96 return mOptionsWidget->options().join( '|' );
97 }
98 else if ( mLineEdit )
99 {
100 return mLineEdit->text().isEmpty() ? QVariant() : mLineEdit->text();
101 }
102 else
103 return QVariant();
104}
105
106QStringList QgsProcessingRasterOptionsWidgetWrapper::compatibleParameterTypes() const
107{
108 return QStringList()
122}
123
124QStringList QgsProcessingRasterOptionsWidgetWrapper::compatibleOutputTypes() const
125{
126 return QStringList() << QgsProcessingOutputNumber::typeName()
131}
132
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.