mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-25 00:03:06 -04:00
- Add abstract base class for Processing widget wrappers to c++ - Add wrapper factory interface to c++ - Make QgsProcessingGuiRegistry also register widget wrapper factories, and be responsible for creation of new c++ processing widget wrapper instances - Start on private c++ implementation of boolean widget wrapper, including unit tests
93 lines
2.8 KiB
C++
93 lines
2.8 KiB
C++
/***************************************************************************
|
|
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 <QLabel>
|
|
|
|
|
|
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<QgsAbstractProcessingParameterWidgetWrapper *> & )
|
|
{
|
|
|
|
}
|