mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-27 00:03:38 -04:00
Fixes: - enum parameters set to "allow multiple" only allow a single value selection when used in modeler - optional enum parameters cannot be set to no value when used outside of modeler Fixes #20406
512 lines
17 KiB
C++
512 lines
17 KiB
C++
/***************************************************************************
|
|
qgsprocessingwidgetwrapperimpl.h
|
|
---------------------
|
|
begin : August 2018
|
|
copyright : (C) 2018 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. *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
|
|
#ifndef QGSPROCESSINGWIDGETWRAPPERIMPL_H
|
|
#define QGSPROCESSINGWIDGETWRAPPERIMPL_H
|
|
|
|
#define SIP_NO_FILE
|
|
#include "qgsprocessingwidgetwrapper.h"
|
|
#include <QAbstractButton>
|
|
|
|
class QCheckBox;
|
|
class QComboBox;
|
|
class QLineEdit;
|
|
class QPlainTextEdit;
|
|
class QToolButton;
|
|
class QButtonGroup;
|
|
class QgsProjectionSelectionWidget;
|
|
class QgsSpinBox;
|
|
class QgsDoubleSpinBox;
|
|
class QgsAuthConfigSelect;
|
|
class QgsProcessingMatrixParameterPanel;
|
|
class QgsFileWidget;
|
|
class QgsFieldExpressionWidget;
|
|
class QgsExpressionLineEdit;
|
|
class QgsProcessingParameterEnum;
|
|
|
|
///@cond PRIVATE
|
|
|
|
class GUI_EXPORT QgsProcessingBooleanWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingBooleanWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
QLabel *createLabel() override SIP_FACTORY;
|
|
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
|
|
QStringList compatibleParameterTypes() const override;
|
|
|
|
QStringList compatibleOutputTypes() const override;
|
|
|
|
QList< int > compatibleDataTypes() const override;
|
|
|
|
private:
|
|
|
|
QCheckBox *mCheckBox = nullptr;
|
|
QComboBox *mComboBox = nullptr;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
class GUI_EXPORT QgsProcessingCrsWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingCrsWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
|
|
QStringList compatibleParameterTypes() const override;
|
|
QStringList compatibleOutputTypes() const override;
|
|
QList< int > compatibleDataTypes() const override;
|
|
QString modelerExpressionFormatString() const override;
|
|
|
|
private:
|
|
|
|
QgsProjectionSelectionWidget *mProjectionSelectionWidget = nullptr;
|
|
QCheckBox *mUseProjectCrsCheckBox = nullptr;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
class GUI_EXPORT QgsProcessingStringWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingStringWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
|
|
QStringList compatibleParameterTypes() const override;
|
|
|
|
QStringList compatibleOutputTypes() const override;
|
|
|
|
QList< int > compatibleDataTypes() const override;
|
|
|
|
private:
|
|
|
|
QLineEdit *mLineEdit = nullptr;
|
|
QPlainTextEdit *mPlainTextEdit = nullptr;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
|
|
class GUI_EXPORT QgsProcessingAuthConfigWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingAuthConfigWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
|
|
QStringList compatibleParameterTypes() const override;
|
|
|
|
QStringList compatibleOutputTypes() const override;
|
|
|
|
QList< int > compatibleDataTypes() const override;
|
|
|
|
private:
|
|
|
|
QgsAuthConfigSelect *mAuthConfigSelect = nullptr;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
|
|
class GUI_EXPORT QgsProcessingNumericWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingNumericWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
|
|
QStringList compatibleParameterTypes() const override;
|
|
|
|
QStringList compatibleOutputTypes() const override;
|
|
|
|
QList< int > compatibleDataTypes() const override;
|
|
|
|
protected:
|
|
|
|
QgsSpinBox *mSpinBox = nullptr;
|
|
QgsDoubleSpinBox *mDoubleSpinBox = nullptr;
|
|
|
|
private:
|
|
|
|
static double calculateStep( double minimum, double maximum );
|
|
|
|
bool mAllowingNull = false;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
|
|
class GUI_EXPORT QgsProcessingDistanceWidgetWrapper : public QgsProcessingNumericWidgetWrapper
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingDistanceWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
void postInitialize( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers ) override;
|
|
|
|
public slots:
|
|
void setUnitParameterValue( const QVariant &value );
|
|
void setUnits( QgsUnitTypes::DistanceUnit unit );
|
|
|
|
protected:
|
|
|
|
QVariant widgetValue() const override;
|
|
|
|
private:
|
|
|
|
QgsUnitTypes::DistanceUnit mBaseUnit = QgsUnitTypes::DistanceUnknownUnit;
|
|
QLabel *mLabel = nullptr;
|
|
QWidget *mWarningLabel = nullptr;
|
|
QComboBox *mUnitsCombo = nullptr;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
|
|
class GUI_EXPORT QgsProcessingRangeWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingRangeWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
QStringList compatibleParameterTypes() const override;
|
|
QStringList compatibleOutputTypes() const override;
|
|
QList< int > compatibleDataTypes() const override;
|
|
QString modelerExpressionFormatString() const override;
|
|
|
|
protected:
|
|
|
|
QgsDoubleSpinBox *mMinSpinBox = nullptr;
|
|
QgsDoubleSpinBox *mMaxSpinBox = nullptr;
|
|
|
|
private:
|
|
|
|
int mBlockChangedSignal = 0;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
|
|
class GUI_EXPORT QgsProcessingMatrixWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingMatrixWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
|
|
QStringList compatibleParameterTypes() const override;
|
|
QStringList compatibleOutputTypes() const override;
|
|
QList< int > compatibleDataTypes() const override;
|
|
QString modelerExpressionFormatString() const override;
|
|
|
|
private:
|
|
|
|
QgsProcessingMatrixParameterPanel *mMatrixWidget = nullptr;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
class GUI_EXPORT QgsProcessingFileWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingFileWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
|
|
QStringList compatibleParameterTypes() const override;
|
|
|
|
QStringList compatibleOutputTypes() const override;
|
|
|
|
QList< int > compatibleDataTypes() const override;
|
|
QString modelerExpressionFormatString() const override;
|
|
|
|
private:
|
|
|
|
QgsFileWidget *mFileWidget = nullptr;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
class GUI_EXPORT QgsProcessingExpressionWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingExpressionWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
void postInitialize( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers ) override;
|
|
public slots:
|
|
void setParentLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *parentWrapper );
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
|
|
QStringList compatibleParameterTypes() const override;
|
|
|
|
QStringList compatibleOutputTypes() const override;
|
|
|
|
QList< int > compatibleDataTypes() const override;
|
|
QString modelerExpressionFormatString() const override;
|
|
const QgsVectorLayer *linkedVectorLayer() const override;
|
|
private:
|
|
|
|
QgsFieldExpressionWidget *mFieldExpWidget = nullptr;
|
|
QgsExpressionLineEdit *mExpLineEdit = nullptr;
|
|
std::unique_ptr< QgsVectorLayer > mParentLayer;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
|
|
class GUI_EXPORT QgsProcessingEnumCheckboxPanelWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingEnumCheckboxPanelWidget( QWidget *parent = nullptr, const QgsProcessingParameterEnum *param = nullptr, int columns = 2 );
|
|
QVariant value() const;
|
|
void setValue( const QVariant &value );
|
|
|
|
signals:
|
|
|
|
void changed();
|
|
|
|
private slots:
|
|
|
|
void showPopupMenu();
|
|
void selectAll();
|
|
void deselectAll();
|
|
|
|
private:
|
|
|
|
const QgsProcessingParameterEnum *mParam = nullptr;
|
|
QMap< QVariant, QAbstractButton * > mButtons;
|
|
QButtonGroup *mButtonGroup = nullptr;
|
|
int mColumns = 2;
|
|
bool mBlockChangedSignal = false;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
class GUI_EXPORT QgsProcessingEnumPanelWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingEnumPanelWidget( QWidget *parent = nullptr, const QgsProcessingParameterEnum *param = nullptr );
|
|
QVariant value() const { return mValue; }
|
|
void setValue( const QVariant &value );
|
|
|
|
signals:
|
|
|
|
void changed();
|
|
|
|
private slots:
|
|
|
|
void showDialog();
|
|
|
|
private:
|
|
|
|
void updateSummaryText();
|
|
|
|
const QgsProcessingParameterEnum *mParam = nullptr;
|
|
QLineEdit *mLineEdit = nullptr;
|
|
QToolButton *mToolButton = nullptr;
|
|
|
|
QVariantList mValue;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
|
|
class GUI_EXPORT QgsProcessingEnumWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QgsProcessingEnumWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
|
|
QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
|
|
|
|
// QgsProcessingParameterWidgetFactoryInterface
|
|
QString parameterType() const override;
|
|
QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
|
|
|
|
// QgsProcessingParameterWidgetWrapper interface
|
|
QWidget *createWidget() override SIP_FACTORY;
|
|
|
|
protected:
|
|
|
|
void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
|
|
QVariant widgetValue() const override;
|
|
|
|
QStringList compatibleParameterTypes() const override;
|
|
|
|
QStringList compatibleOutputTypes() const override;
|
|
|
|
QList< int > compatibleDataTypes() const override;
|
|
QString modelerExpressionFormatString() const override;
|
|
private:
|
|
|
|
QComboBox *mComboBox = nullptr;
|
|
QgsProcessingEnumPanelWidget *mPanel = nullptr;
|
|
QgsProcessingEnumCheckboxPanelWidget *mCheckboxPanel = nullptr;
|
|
|
|
friend class TestProcessingGui;
|
|
};
|
|
|
|
|
|
///@endcond PRIVATE
|
|
|
|
#endif // QGSPROCESSINGWIDGETWRAPPERIMPL_H
|