/*************************************************************************** qgsprocessingwidgetwrapper.cpp --------------------- 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. * * * ***************************************************************************/ #include "qgsprocessingwidgetwrapper.h" #include "qgsprocessingparameters.h" #include QgsAbstractProcessingParameterWidgetWrapper::QgsAbstractProcessingParameterWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsAbstractProcessingParameterWidgetWrapper::WidgetType type, QObject *parent ) : QObject( parent ) , mType( type ) , mParameterDefinition( parameter ) { } QgsAbstractProcessingParameterWidgetWrapper::WidgetType QgsAbstractProcessingParameterWidgetWrapper::type() const { return mType; } QWidget *QgsAbstractProcessingParameterWidgetWrapper::createWrappedWidget( const QgsProcessingContext &context ) { if ( mWidget ) return mWidget; mWidget = createWidget(); setWidgetValue( mParameterDefinition->defaultValue(), context ); return mWidget; } QLabel *QgsAbstractProcessingParameterWidgetWrapper::createWrappedLabel() { if ( mLabel ) return mLabel; mLabel = createLabel(); return mLabel; } QWidget *QgsAbstractProcessingParameterWidgetWrapper::wrappedWidget() { return mWidget; } QLabel *QgsAbstractProcessingParameterWidgetWrapper::wrappedLabel() { return mLabel; } const QgsProcessingParameterDefinition *QgsAbstractProcessingParameterWidgetWrapper::parameterDefinition() const { return mParameterDefinition; } QLabel *QgsAbstractProcessingParameterWidgetWrapper::createLabel() { switch ( mType ) { case Batch: return nullptr; case Standard: case Modeler: { std::unique_ptr< QLabel > label = qgis::make_unique< QLabel >( mParameterDefinition->description() ); label->setToolTip( mParameterDefinition->name() ); return label.release(); } } return nullptr; } void QgsAbstractProcessingParameterWidgetWrapper::postInitialize( const QList & ) { }