Skip to content
Permalink
Browse files

Fix test

  • Loading branch information
nyalldawson committed Mar 13, 2020
1 parent 8ebfc85 commit 3c11776cb9d14b965d5c841a6b2ca1386edb9c12
@@ -4175,8 +4175,8 @@ void QgsProcessingDatabaseSchemaWidgetWrapper::setParentConnectionWrapperValue(
context = tmpContext.get();
}

QVariant value = parentWrapper->parameterValue();
const QString connection = QgsProcessingParameters::parameterAsConnectionName( parentWrapper->parameterDefinition(), value, *context );
const QVariant value = parentWrapper->parameterValue();
const QString connection = value.isValid() ? QgsProcessingParameters::parameterAsConnectionName( parentWrapper->parameterDefinition(), value, *context ) : QString();

if ( mSchemaComboBox )
mSchemaComboBox->setConnectionName( connection, dynamic_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->parameterDefinition() )->providerId() );
@@ -4433,9 +4433,9 @@ void QgsProcessingDatabaseTableWidgetWrapper::setParentConnectionWrapperValue( c
}

QVariant value = parentWrapper->parameterValue();
mConnection = QgsProcessingParameters::parameterAsConnectionName( parentWrapper->parameterDefinition(), value, *context );
mConnection = value.isValid() ? QgsProcessingParameters::parameterAsConnectionName( parentWrapper->parameterDefinition(), value, *context ) : QString();
mProvider = dynamic_cast< const QgsProcessingParameterProviderConnection * >( parentWrapper->parameterDefinition() )->providerId();
if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
if ( mTableComboBox && !mSchema.isEmpty() )
{
mTableComboBox->setSchema( mSchema );
mTableComboBox->setConnectionName( mConnection, mProvider );
@@ -4461,7 +4461,7 @@ void QgsProcessingDatabaseTableWidgetWrapper::setParentSchemaWrapperValue( const
}

QVariant value = parentWrapper->parameterValue();
mSchema = QgsProcessingParameters::parameterAsSchema( parentWrapper->parameterDefinition(), value, *context );
mSchema = value.isValid() ? QgsProcessingParameters::parameterAsSchema( parentWrapper->parameterDefinition(), value, *context ) : QString();

if ( mTableComboBox && !mSchema.isEmpty() && !mConnection.isEmpty() )
{
@@ -121,9 +121,17 @@ void QgsDatabaseSchemaComboBox::setConnectionName( const QString &connection, co

const QString oldSchema = currentSchema();
QgsDatabaseSchemaModel *oldModel = mModel;
mModel = new QgsDatabaseSchemaModel( mProvider, connection, this );
mModel->setAllowEmptySchema( mAllowEmpty );
mSortModel->setSourceModel( mModel );
if ( !connection.isEmpty() && !mProvider.isEmpty() )
{
mModel = new QgsDatabaseSchemaModel( mProvider, connection, this );
mModel->setAllowEmptySchema( mAllowEmpty );
mSortModel->setSourceModel( mModel );
}
else
{
mModel = nullptr;
mSortModel->setSourceModel( nullptr );
}
if ( oldModel )
oldModel->deleteLater();

@@ -4766,7 +4766,7 @@ void TestProcessingGui::testDatabaseSchemaWrapper()

auto testWrapper = [&schemas]( QgsProcessingGui::WidgetType type )
{
QgsProcessingParameterProviderConnection connParam( QStringLiteral( "conn" ), QStringLiteral( "connection" ), QStringLiteral( "postgres" ), true );
QgsProcessingParameterProviderConnection connParam( QStringLiteral( "conn" ), QStringLiteral( "connection" ), QStringLiteral( "postgres" ), QVariant(), true );
TestLayerWrapper connWrapper( &connParam );

QgsProcessingParameterDatabaseSchema param( QStringLiteral( "schema" ), QStringLiteral( "schema" ), QStringLiteral( "conn" ), QVariant(), false );
@@ -4827,6 +4827,7 @@ void TestProcessingGui::testDatabaseSchemaWrapper()
// make sure things are ok if connection is changed back to nothing
connWrapper.setWidgetValue( QVariant(), context );
wrapper.setParentConnectionWrapperValue( &connWrapper );
QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->comboBox()->count(), 0 );

switch ( type )
{
@@ -4969,9 +4970,9 @@ void TestProcessingGui::testDatabaseTableWrapper()

auto testWrapper = [&tableNames]( QgsProcessingGui::WidgetType type )
{
QgsProcessingParameterProviderConnection connParam( QStringLiteral( "conn" ), QStringLiteral( "connection" ), QStringLiteral( "postgres" ), true );
QgsProcessingParameterProviderConnection connParam( QStringLiteral( "conn" ), QStringLiteral( "connection" ), QStringLiteral( "postgres" ), QVariant(), true );
TestLayerWrapper connWrapper( &connParam );
QgsProcessingParameterDatabaseSchema schemaParam( QStringLiteral( "schema" ), QStringLiteral( "schema" ), QStringLiteral( "connection" ), true );
QgsProcessingParameterDatabaseSchema schemaParam( QStringLiteral( "schema" ), QStringLiteral( "schema" ), QStringLiteral( "connection" ), QVariant(), true );
TestLayerWrapper schemaWrapper( &schemaParam );

QgsProcessingParameterDatabaseTable param( QStringLiteral( "table" ), QStringLiteral( "table" ), QStringLiteral( "conn" ), QStringLiteral( "schema" ), QVariant(), false );
@@ -5034,6 +5035,7 @@ void TestProcessingGui::testDatabaseTableWrapper()
// make sure things are ok if connection is changed back to nothing
connWrapper.setWidgetValue( QVariant(), context );
wrapper.setParentConnectionWrapperValue( &connWrapper );
QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->comboBox()->count(), 0 );

switch ( type )
{

0 comments on commit 3c11776

Please sign in to comment.
You can’t perform that action at this time.