diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 3640bd1580c1..3df59d9a7061 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -197,6 +197,7 @@ SET(QGIS_GUI_SRCS processing/qgsprocessingalgorithmdialogbase.cpp processing/qgsprocessingconfigurationwidgets.cpp processing/qgsprocessingguiregistry.cpp + processing/qgsprocessingmatrixparameterdialog.cpp processing/qgsprocessingmodelerparameterwidget.cpp processing/qgsprocessingrecentalgorithmlog.cpp processing/qgsprocessingtoolboxmodel.cpp @@ -732,6 +733,7 @@ SET(QGIS_GUI_MOC_HDRS processing/qgsprocessingalgorithmconfigurationwidget.h processing/qgsprocessingalgorithmdialogbase.h processing/qgsprocessingconfigurationwidgets.h + processing/qgsprocessingmatrixparameterdialog.h processing/qgsprocessingmodelerparameterwidget.h processing/qgsprocessingrecentalgorithmlog.h processing/qgsprocessingtoolboxmodel.h diff --git a/src/gui/processing/qgsprocessingguiregistry.cpp b/src/gui/processing/qgsprocessingguiregistry.cpp index fa8f62321635..27c6e1ea771a 100644 --- a/src/gui/processing/qgsprocessingguiregistry.cpp +++ b/src/gui/processing/qgsprocessingguiregistry.cpp @@ -33,6 +33,7 @@ QgsProcessingGuiRegistry::QgsProcessingGuiRegistry() addParameterWidgetFactory( new QgsProcessingNumericWidgetWrapper() ); addParameterWidgetFactory( new QgsProcessingDistanceWidgetWrapper() ); addParameterWidgetFactory( new QgsProcessingRangeWidgetWrapper() ); + addParameterWidgetFactory( new QgsProcessingMatrixWidgetWrapper() ); } QgsProcessingGuiRegistry::~QgsProcessingGuiRegistry() diff --git a/src/gui/processing/qgsprocessingmatrixparameterdialog.cpp b/src/gui/processing/qgsprocessingmatrixparameterdialog.cpp new file mode 100644 index 000000000000..9561db2bf2ee --- /dev/null +++ b/src/gui/processing/qgsprocessingmatrixparameterdialog.cpp @@ -0,0 +1,192 @@ +/*************************************************************************** + qgsprocessingmatrixparameterdialog.cpp + ------------------------------------ + Date : February 2019 + Copyright : (C) 2019 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 "qgsprocessingmatrixparameterdialog.h" +#include "qgsgui.h" +#include +#include +#include +#include +#include + +///@cond NOT_STABLE + +QgsProcessingMatrixParameterDialog::QgsProcessingMatrixParameterDialog( QWidget *parent, Qt::WindowFlags flags, const QgsProcessingParameterMatrix *param, const QVariantList &initialTable ) + : QDialog( parent, flags ) + , mParam( param ) +{ + setupUi( this ); + + QgsGui::enableAutoGeometryRestore( this ); + + mTblView->setSelectionBehavior( QAbstractItemView::SelectRows ); + mTblView->setSelectionMode( QAbstractItemView::ExtendedSelection ); + + mButtonAdd = new QPushButton( tr( "Add Row" ) ); + mButtonBox->addButton( mButtonAdd, QDialogButtonBox::ActionRole ); + + mButtonRemove = new QPushButton( tr( "Remove Row(s)" ) ); + mButtonBox->addButton( mButtonRemove, QDialogButtonBox::ActionRole ); + + mButtonRemoveAll = new QPushButton( tr( "Remove All" ) ); + mButtonBox->addButton( mButtonRemoveAll, QDialogButtonBox::ActionRole ); + + connect( mButtonAdd, &QPushButton::clicked, this, &QgsProcessingMatrixParameterDialog::addRow ); + connect( mButtonRemove, &QPushButton::clicked, this, &QgsProcessingMatrixParameterDialog::deleteRow ); + connect( mButtonRemoveAll, &QPushButton::clicked, this, &QgsProcessingMatrixParameterDialog::deleteAllRows ); + + if ( param && param->hasFixedNumberRows() ) + { + mButtonAdd->setEnabled( false ); + mButtonRemove->setEnabled( false ); + mButtonRemoveAll->setEnabled( false ); + } + + populateTable( initialTable ); +} + +QVariantList QgsProcessingMatrixParameterDialog::table() const +{ + const int cols = mModel->columnCount(); + const int rows = mModel->rowCount(); + // Table MUST BE 1-dimensional to match core QgsProcessingParameterMatrix expectations + QVariantList res; + res.reserve( cols * rows ); + for ( int row = 0; row < rows; ++row ) + { + for ( int col = 0; col < cols; ++col ) + { + res << mModel->item( row, col )->text(); + } + } + return res; +} + +void QgsProcessingMatrixParameterDialog::addRow() +{ + QList< QStandardItem * > items; + for ( int i = 0; i < mTblView->model()->columnCount(); ++i ) + { + items << new QStandardItem( '0' ); + } + mModel->appendRow( items ); +} + +void QgsProcessingMatrixParameterDialog::deleteRow() +{ + QModelIndexList selected = mTblView->selectionModel()->selectedRows(); + QSet< int > rows; + rows.reserve( selected.count() ); + for ( const QModelIndex &i : selected ) + rows << i.row(); + + QList< int > rowsToDelete = rows.toList(); + std::sort( rowsToDelete.begin(), rowsToDelete.end(), std::greater() ); + mTblView->setUpdatesEnabled( false ); + for ( int i : qgis::as_const( rowsToDelete ) ) + mModel->removeRows( i, 1 ); + + mTblView->setUpdatesEnabled( true ); +} + +void QgsProcessingMatrixParameterDialog::deleteAllRows() +{ + mModel->clear(); + if ( mParam ) + mModel->setHorizontalHeaderLabels( mParam->headers() ); +} + +void QgsProcessingMatrixParameterDialog::populateTable( const QVariantList &contents ) +{ + if ( !mParam ) + return; + + const int cols = mParam->headers().count(); + const int rows = contents.length() / cols; + mModel = new QStandardItemModel( rows, cols, this ); + mModel->setHorizontalHeaderLabels( mParam->headers() ); + + for ( int row = 0; row < rows; ++row ) + { + for ( int col = 0; col < cols; ++col ) + { + QStandardItem *item = new QStandardItem( contents.at( row * cols + col ).toString() ); + mModel->setItem( row, col, item ); + } + } + mTblView->setModel( mModel ); +} + +// +// QgsProcessingMatrixParameterPanel +// + +QgsProcessingMatrixParameterPanel::QgsProcessingMatrixParameterPanel( QWidget *parent, const QgsProcessingParameterMatrix *param ) + : QWidget( parent ) + , mParam( param ) +{ + QHBoxLayout *hl = new QHBoxLayout(); + hl->setMargin( 0 ); + hl->setContentsMargins( 0, 0, 0, 0 ); + + mLineEdit = new QLineEdit(); + mLineEdit->setEnabled( false ); + hl->addWidget( mLineEdit, 1 ); + + mToolButton = new QToolButton(); + mToolButton->setText( tr( "…" ) ); + hl->addWidget( mToolButton ); + + setLayout( hl ); + + if ( mParam ) + { + for ( int row = 0; row < mParam->numberRows(); ++row ) + { + for ( int col = 0; col < mParam->headers().count(); ++col ) + { + mTable.append( '0' ); + } + } + mLineEdit->setText( tr( "Fixed table (%1x%2)" ).arg( mParam->numberRows() ).arg( mParam->headers().count() ) ); + } + + connect( mToolButton, &QToolButton::clicked, this, &QgsProcessingMatrixParameterPanel::showDialog ); +} + +void QgsProcessingMatrixParameterPanel::setValue( const QVariantList &value ) +{ + mTable = value; + updateSummaryText(); + emit changed(); +} + +void QgsProcessingMatrixParameterPanel::showDialog() +{ + QgsProcessingMatrixParameterDialog dlg( this, nullptr, mParam, mTable ); + if ( dlg.exec() ) + { + setValue( dlg.table() ); + } +} + +void QgsProcessingMatrixParameterPanel::updateSummaryText() +{ + if ( mParam ) + mLineEdit->setText( tr( "Fixed table (%1x%2)" ).arg( mTable.count() / mParam->headers().count() ).arg( mParam->headers().count() ) ); +} + + +///@endcond diff --git a/src/gui/processing/qgsprocessingmatrixparameterdialog.h b/src/gui/processing/qgsprocessingmatrixparameterdialog.h new file mode 100644 index 000000000000..fd857472ad89 --- /dev/null +++ b/src/gui/processing/qgsprocessingmatrixparameterdialog.h @@ -0,0 +1,115 @@ +/*************************************************************************** + qgsprocessingmatrixparameterdialog.h + ---------------------------------- + Date : February 2019 + Copyright : (C) 2019 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 QGSPROCESSINGMATRIXPARAMETERDIALOG_H +#define QGSPROCESSINGMATRIXPARAMETERDIALOG_H + +#include "qgis.h" +#include "qgis_gui.h" +#include "ui_qgsprocessingmatrixparameterdialogbase.h" +#include "qgsprocessingparameters.h" + +#define SIP_NO_FILE + +class QStandardItemModel; +class QToolButton; + +///@cond NOT_STABLE + +/** + * \ingroup gui + * \brief Dialog for configuration of a matrix (fixed table) parameter. + * \note Not stable API + * \since QGIS 3.6 + */ +class GUI_EXPORT QgsProcessingMatrixParameterDialog : public QDialog, private Ui::QgsProcessingMatrixParameterDialogBase +{ + Q_OBJECT + + public: + + /** + * Constructor for QgsProcessingMatrixParameterDialog. + */ + QgsProcessingMatrixParameterDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = nullptr, const QgsProcessingParameterMatrix *param = nullptr, + const QVariantList &initialTable = QVariantList() ); + + /** + * Returns the table's contents as a 1 dimensional array. + */ + QVariantList table() const; + + private slots: + + void addRow(); + void deleteRow(); + void deleteAllRows(); + + private: + + QPushButton *mButtonAdd = nullptr; + QPushButton *mButtonRemove = nullptr; + QPushButton *mButtonRemoveAll = nullptr; + const QgsProcessingParameterMatrix *mParam = nullptr; + QStandardItemModel *mModel = nullptr; + + void populateTable( const QVariantList &contents ); + + friend class TestProcessingGui; +}; + + +/** + * \ingroup gui + * \brief Widget for configuration of a matrix (fixed table) parameter. + * \note Not stable API + * \since QGIS 3.6 + */ +class GUI_EXPORT QgsProcessingMatrixParameterPanel : public QWidget +{ + Q_OBJECT + + public: + + QgsProcessingMatrixParameterPanel( QWidget *parent = nullptr, const QgsProcessingParameterMatrix *param = nullptr ); + + QVariantList value() const { return mTable; } + + void setValue( const QVariantList &value ); + + signals: + + void changed(); + + private slots: + + void showDialog(); + + private: + + void updateSummaryText(); + + const QgsProcessingParameterMatrix *mParam = nullptr; + QLineEdit *mLineEdit = nullptr; + QToolButton *mToolButton = nullptr; + + QVariantList mTable; + + friend class TestProcessingGui; +}; + +///@endcond + +#endif // QGSPROCESSINGMATRIXPARAMETERDIALOG_H diff --git a/src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp b/src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp index dfa8867daa2a..88a5a021bd60 100644 --- a/src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp +++ b/src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp @@ -19,6 +19,7 @@ #include "qgsprocessingparameters.h" #include "qgsprocessingoutputs.h" #include "qgsprojectionselectionwidget.h" +#include "qgsprocessingmatrixparameterdialog.h" #include "qgsspinbox.h" #include "qgsdoublespinbox.h" #include "qgsprocessingcontext.h" @@ -945,5 +946,85 @@ QgsAbstractProcessingParameterWidgetWrapper *QgsProcessingRangeWidgetWrapper::cr } + +// +// QgsProcessingMatrixWidgetWrapper +// + +QgsProcessingMatrixWidgetWrapper::QgsProcessingMatrixWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type, QWidget *parent ) + : QgsAbstractProcessingParameterWidgetWrapper( parameter, type, parent ) +{ + +} + +QWidget *QgsProcessingMatrixWidgetWrapper::createWidget() +{ + mMatrixWidget = new QgsProcessingMatrixParameterPanel( nullptr, dynamic_cast< const QgsProcessingParameterMatrix *>( parameterDefinition() ) ); + mMatrixWidget->setToolTip( parameterDefinition()->toolTip() ); + + connect( mMatrixWidget, &QgsProcessingMatrixParameterPanel::changed, this, [ = ] + { + emit widgetValueHasChanged( this ); + } ); + + switch ( type() ) + { + case QgsProcessingGui::Standard: + case QgsProcessingGui::Batch: + case QgsProcessingGui::Modeler: + { + return mMatrixWidget; + }; + } + return nullptr; +} + +void QgsProcessingMatrixWidgetWrapper::setWidgetValue( const QVariant &value, QgsProcessingContext &context ) +{ + const QVariantList v = QgsProcessingParameters::parameterAsMatrix( parameterDefinition(), value, context ); + if ( mMatrixWidget ) + mMatrixWidget->setValue( v ); +} + +QVariant QgsProcessingMatrixWidgetWrapper::widgetValue() const +{ + if ( mMatrixWidget ) + return mMatrixWidget->value().isEmpty() ? QVariant() : mMatrixWidget->value(); + else + return QVariant(); +} + +QStringList QgsProcessingMatrixWidgetWrapper::compatibleParameterTypes() const +{ + return QStringList() + << QgsProcessingParameterMatrix::typeName(); +} + +QStringList QgsProcessingMatrixWidgetWrapper::compatibleOutputTypes() const +{ + return QStringList(); +} + +QList QgsProcessingMatrixWidgetWrapper::compatibleDataTypes() const +{ + return QList< int >(); +} + +QString QgsProcessingMatrixWidgetWrapper::modelerExpressionFormatString() const +{ + return tr( "comma delimited string of values, or an array of values" ); +} + +QString QgsProcessingMatrixWidgetWrapper::parameterType() const +{ + return QgsProcessingParameterMatrix::typeName(); +} + +QgsAbstractProcessingParameterWidgetWrapper *QgsProcessingMatrixWidgetWrapper::createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) +{ + return new QgsProcessingMatrixWidgetWrapper( parameter, type ); +} + + ///@endcond PRIVATE diff --git a/src/gui/processing/qgsprocessingwidgetwrapperimpl.h b/src/gui/processing/qgsprocessingwidgetwrapperimpl.h index 6e457cfbe86b..c02d3dcf9d9a 100644 --- a/src/gui/processing/qgsprocessingwidgetwrapperimpl.h +++ b/src/gui/processing/qgsprocessingwidgetwrapperimpl.h @@ -29,7 +29,7 @@ class QPlainTextEdit; class QgsProjectionSelectionWidget; class QgsSpinBox; class QgsDoubleSpinBox; - +class QgsProcessingMatrixParameterPanel; ///@cond PRIVATE @@ -253,6 +253,40 @@ class GUI_EXPORT QgsProcessingRangeWidgetWrapper : public QgsAbstractProcessingP 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; +}; + ///@endcond PRIVATE #endif // QGSPROCESSINGWIDGETWRAPPERIMPL_H diff --git a/src/ui/processing/qgsprocessingmatrixparameterdialogbase.ui b/src/ui/processing/qgsprocessingmatrixparameterdialogbase.ui new file mode 100644 index 000000000000..60b5d1275720 --- /dev/null +++ b/src/ui/processing/qgsprocessingmatrixparameterdialogbase.ui @@ -0,0 +1,86 @@ + + + QgsProcessingMatrixParameterDialogBase + + + + 0 + 0 + 380 + 320 + + + + Fixed table + + + + 6 + + + 9 + + + 9 + + + 9 + + + 9 + + + + + true + + + + + + + Qt::Vertical + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + mButtonBox + accepted() + QgsProcessingMatrixParameterDialogBase + accept() + + + 248 + 254 + + + 157 + 274 + + + + + mButtonBox + rejected() + QgsProcessingMatrixParameterDialogBase + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/tests/src/gui/testprocessinggui.cpp b/tests/src/gui/testprocessinggui.cpp index 5ea51a9a2b7d..aff31c0c40a6 100644 --- a/tests/src/gui/testprocessinggui.cpp +++ b/tests/src/gui/testprocessinggui.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "qgstest.h" @@ -41,6 +42,7 @@ #include "qgsdoublespinbox.h" #include "qgsspinbox.h" #include "qgsmapcanvas.h" +#include "qgsprocessingmatrixparameterdialog.h" #include "models/qgsprocessingmodelalgorithm.h" class TestParamType : public QgsProcessingParameterDefinition @@ -151,6 +153,8 @@ class TestProcessingGui : public QObject void testNumericWrapperInt(); void testDistanceWrapper(); void testRangeWrapper(); + void testMatrixDialog(); + void testMatrixWrapper(); }; void TestProcessingGui::initTestCase() @@ -1477,5 +1481,100 @@ void TestProcessingGui::testRangeWrapper() testWrapper( QgsProcessingGui::Modeler ); } +void TestProcessingGui::testMatrixDialog() +{ + QgsProcessingParameterMatrix matrixParam( QString(), QString(), 3, false, QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); + std::unique_ptr< QgsProcessingMatrixParameterDialog > dlg = qgis::make_unique< QgsProcessingMatrixParameterDialog>( nullptr, nullptr, &matrixParam ); + // variable length table + QVERIFY( dlg->mButtonAdd->isEnabled() ); + QVERIFY( dlg->mButtonRemove->isEnabled() ); + QVERIFY( dlg->mButtonRemoveAll->isEnabled() ); + + QCOMPARE( dlg->table(), QVariantList() ); + + dlg = qgis::make_unique< QgsProcessingMatrixParameterDialog >( nullptr, nullptr, &matrixParam, QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) ); + QCOMPARE( dlg->table(), QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) ); + dlg->addRow(); + QCOMPARE( dlg->table(), QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) << QString() << QString() ); + dlg->deleteAllRows(); + QCOMPARE( dlg->table(), QVariantList() ); + + QgsProcessingParameterMatrix matrixParam2( QString(), QString(), 3, true, QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); + dlg = qgis::make_unique< QgsProcessingMatrixParameterDialog >( nullptr, nullptr, &matrixParam2, QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) ); + QVERIFY( !dlg->mButtonAdd->isEnabled() ); + QVERIFY( !dlg->mButtonRemove->isEnabled() ); + QVERIFY( !dlg->mButtonRemoveAll->isEnabled() ); +} + +void TestProcessingGui::testMatrixWrapper() +{ + auto testWrapper = []( QgsProcessingGui::WidgetType type ) + { + QgsProcessingContext context; + + QgsProcessingParameterMatrix param( QStringLiteral( "matrix" ), QStringLiteral( "matrix" ), 3, false, QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); + param.setDefaultValue( QStringLiteral( "0.0,100.0,150.0,250.0" ) ); + QgsProcessingMatrixWidgetWrapper wrapper( ¶m, type ); + + QWidget *w = wrapper.createWrappedWidget( context ); + QVERIFY( w ); + + // initial value + QCOMPARE( wrapper.parameterValue().toList(), QVariantList() << QStringLiteral( "0.0" ) << QStringLiteral( "100.0" ) << QStringLiteral( "150.0" ) << QStringLiteral( "250.0" ) ); + + QSignalSpy spy( &wrapper, &QgsProcessingMatrixWidgetWrapper::widgetValueHasChanged ); + wrapper.setWidgetValue( QVariantList() << 5 << 7, context ); + QCOMPARE( spy.count(), 1 ); + QCOMPARE( wrapper.widgetValue().toList(), QVariantList() << QStringLiteral( "5" ) << QStringLiteral( "7" ) ); + QCOMPARE( wrapper.mMatrixWidget->value(), QVariantList() << QStringLiteral( "5" ) << QStringLiteral( "7" ) ); + wrapper.setWidgetValue( QStringLiteral( "28.1,36.5,5.5,8.9" ), context ); + QCOMPARE( spy.count(), 2 ); + QCOMPARE( wrapper.widgetValue().toList(), QVariantList() << QStringLiteral( "28.1" ) << QStringLiteral( "36.5" ) << QStringLiteral( "5.5" ) << QStringLiteral( "8.9" ) ); + QCOMPARE( wrapper.mMatrixWidget->value(), QVariantList() << QStringLiteral( "28.1" ) << QStringLiteral( "36.5" ) << QStringLiteral( "5.5" ) << QStringLiteral( "8.9" ) ); + + QLabel *l = wrapper.createWrappedLabel(); + if ( wrapper.type() != QgsProcessingGui::Batch ) + { + QVERIFY( l ); + QCOMPARE( l->text(), QStringLiteral( "matrix" ) ); + QCOMPARE( l->toolTip(), param.toolTip() ); + delete l; + } + else + { + QVERIFY( !l ); + } + + // check signal + wrapper.mMatrixWidget->setValue( QVariantList() << QStringLiteral( "7" ) << QStringLiteral( "9" ) ); + QCOMPARE( spy.count(), 3 ); + QCOMPARE( wrapper.widgetValue().toList(), QVariantList() << QStringLiteral( "7" ) << QStringLiteral( "9" ) ); + + delete w; + }; + + // standard wrapper + testWrapper( QgsProcessingGui::Standard ); + + // batch wrapper + testWrapper( QgsProcessingGui::Batch ); + + // modeler wrapper + testWrapper( QgsProcessingGui::Modeler ); +} + +void TestProcessingGui::cleanupTempDir() +{ + QDir tmpDir = QDir( mTempDir ); + if ( tmpDir.exists() ) + { + Q_FOREACH ( const QString &tf, tmpDir.entryList( QDir::NoDotAndDotDot | QDir::Files ) ) + { + QVERIFY2( tmpDir.remove( mTempDir + '/' + tf ), qPrintable( "Could not remove " + mTempDir + '/' + tf ) ); + } + QVERIFY2( tmpDir.rmdir( mTempDir ), qPrintable( "Could not remove directory " + mTempDir ) ); + } +} + QGSTEST_MAIN( TestProcessingGui ) #include "testprocessinggui.moc"