Skip to content

Commit

Permalink
flip logic to explicitly ask for raster overviews
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCaha committed Jan 9, 2025
1 parent c29ff19 commit 514a4b5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/providers/postgres/qgspgnewconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ QgsPgNewConnection::QgsPgNewConnection( QWidget *parent, const QString &connName
cb_geometryColumnsOnly->setChecked( settings.value( key + "/geometryColumnsOnly", true ).toBool() );
cb_dontResolveType->setChecked( settings.value( key + "/dontResolveType", false ).toBool() );
cb_allowGeometrylessTables->setChecked( settings.value( key + "/allowGeometrylessTables", false ).toBool() );
cb_dontShowRasterOverviews->setChecked( settings.value( key + "/dontShowRasterOverviews", false ).toBool() );
cb_showRasterOverviews->setChecked( settings.value( key + "/showRasterOverviews", true ).toBool() );
// Ensure that cb_publicSchemaOnly is set correctly
cb_geometryColumnsOnly_clicked();

Expand Down Expand Up @@ -178,7 +178,7 @@ void QgsPgNewConnection::accept()
configuration.insert( "projectsInDatabase", cb_projectsInDatabase->isChecked() );
configuration.insert( "metadataInDatabase", cb_metadataInDatabase->isChecked() );
configuration.insert( "session_role", txtSessionRole->text() );
configuration.insert( "dontShowRasterOverviews", cb_dontShowRasterOverviews->isChecked() );
configuration.insert( "showRasterOverviews", cb_showRasterOverviews->isChecked() );

QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "postgres" ) );
std::unique_ptr<QgsPostgresProviderConnection> providerConnection( qgis::down_cast<QgsPostgresProviderConnection *>( providerMetadata->createConnection( txtName->text() ) ) );
Expand Down
21 changes: 11 additions & 10 deletions src/providers/postgres/qgspostgresconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty &layerProperty, co
}
}

bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews, const QString &schema, const QString &name )
bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool showRasterOverviews, const QString &schema, const QString &name )
{
QMutexLocker locker( &mLock );
int nColumns = 0;
Expand Down Expand Up @@ -1054,7 +1054,8 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
}
}

if ( removeRasterOverviews )
// remove raster overivews if showRasterOverviews is FALSE
if ( !showRasterOverviews )
{
QString sqlRasterOverviews = QString( "SELECT o_table_schema, o_table_name FROM public.raster_overviews" );

Expand Down Expand Up @@ -1108,14 +1109,14 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
return true;
}

bool QgsPostgresConn::supportedLayersPrivate( QVector<QgsPostgresLayerProperty> &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews, const QString &schema, const QString &table )
bool QgsPostgresConn::supportedLayersPrivate( QVector<QgsPostgresLayerProperty> &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool showRasterOverviews, const QString &schema, const QString &table )
{
QMutexLocker locker( &mLock );

mLayersSupported.clear();

// Get the list of supported tables
if ( !getTableInfo( searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, removeRasterOverviews, schema, table ) )
if ( !getTableInfo( searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, showRasterOverviews, schema, table ) )
{
QgsMessageLog::logMessage( tr( "Unable to get list of spatially enabled tables from the database" ), tr( "PostGIS" ) );
return false;
Expand Down Expand Up @@ -1504,9 +1505,9 @@ Qgis::PostgresRelKind QgsPostgresConn::relKindFromValue( const QString &value )
return Qgis::PostgresRelKind::Unknown;
}

bool QgsPostgresConn::supportedLayers( QVector<QgsPostgresLayerProperty> &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews, const QString &schema )
bool QgsPostgresConn::supportedLayers( QVector<QgsPostgresLayerProperty> &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool showRasterOverviews, const QString &schema )
{
return supportedLayersPrivate( layers, searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, removeRasterOverviews, schema );
return supportedLayersPrivate( layers, searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, showRasterOverviews, schema );
}

bool QgsPostgresConn::supportedLayer( QgsPostgresLayerProperty &layerProperty, const QString &schema, const QString &table )
Expand Down Expand Up @@ -2777,10 +2778,10 @@ bool QgsPostgresConn::allowProjectsInDatabase( const QString &connName )
return settings.value( "/PostgreSQL/connections/" + connName + "/projectsInDatabase", false ).toBool();
}

bool QgsPostgresConn::removeRasterOverviewTables( const QString &connName )
bool QgsPostgresConn::showRasterOverviewTables( const QString &connName )
{
QgsSettings settings;
return settings.value( "/PostgreSQL/connections/" + connName + "/dontShowRasterOverviews", false ).toBool();
return settings.value( "/PostgreSQL/connections/" + connName + "/showRasterOverviews", true ).toBool();
}

void QgsPostgresConn::deleteConnection( const QString &connName )
Expand All @@ -2807,7 +2808,7 @@ void QgsPostgresConn::deleteConnection( const QString &connName )
settings.remove( key + "/metadataInDatabase" );
settings.remove( key + "/dontResolveType" );
settings.remove( key + "/session_role" );
settings.remove( key + "/dontShowRasterOverviews" );
settings.remove( key + "/showRasterOverviews" );
settings.remove( key );
}

Expand Down Expand Up @@ -2835,7 +2836,7 @@ void QgsPostgresConn::duplicateConnection( const QString &src, const QString &ds
settings.setValue( newKey + QStringLiteral( "/saveUsername" ), settings.value( key + QStringLiteral( "/saveUsername" ) ).toString() );
settings.setValue( newKey + QStringLiteral( "/savePassword" ), settings.value( key + QStringLiteral( "/savePassword" ) ).toString() );
settings.setValue( newKey + QStringLiteral( "/authcfg" ), settings.value( key + QStringLiteral( "/authcfg" ) ).toString() );
settings.setValue( newKey + QStringLiteral( "/dontShowRasterOverviews" ), settings.value( key + QStringLiteral( "/dontShowRasterOverviews" ) ).toString() );
settings.setValue( newKey + QStringLiteral( "/showRasterOverviews" ), settings.value( key + QStringLiteral( "/showRasterOverviews" ) ).toString() );

settings.sync();
}
Expand Down
14 changes: 7 additions & 7 deletions src/providers/postgres/qgspostgresconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ class QgsPostgresConn : public QObject
* contained in the geometry_columns metatable
* \param searchPublicOnly
* \param allowGeometrylessTables
* \param removeRasterOverviews do not list raster layer overviews
* \param showRasterOverviews list raster layer overviews
* \param schema restrict layers to layers within specified schema
* \returns true if layers were fetched successfully
*/
bool supportedLayers( QVector<QgsPostgresLayerProperty> &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool removeRasterOverviews = false, const QString &schema = QString() );
bool supportedLayers( QVector<QgsPostgresLayerProperty> &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool showRasterOverviews = false, const QString &schema = QString() );

/**
* Get the information about a supported layer
Expand Down Expand Up @@ -425,12 +425,12 @@ class QgsPostgresConn : public QObject
* contained in the geometry_columns metatable
* \param searchPublicOnly
* \param allowGeometrylessTables
* \param removeRasterOverviews do not list raster layer overviews
* \param showRasterOverviews list raster layer overviews
* \param schema restrict tables to those within specified schema
* \param name restrict tables to those with specified name
* \returns true if tables were successfully queried
*/
bool getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews = false, const QString &schema = QString(), const QString &name = QString() );
bool getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool showRasterOverviews = false, const QString &schema = QString(), const QString &name = QString() );

qint64 getBinaryInt( QgsPostgresResult &queryResult, int row, int col );

Expand Down Expand Up @@ -479,7 +479,7 @@ class QgsPostgresConn : public QObject
static bool allowProjectsInDatabase( const QString &connName );
static void deleteConnection( const QString &connName );
static bool allowMetadataInDatabase( const QString &connName );
static bool removeRasterOverviewTables( const QString &connName );
static bool showRasterOverviewTables( const QString &connName );

/**
* Duplicates \a src connection settings to a new \a dst connection.
Expand Down Expand Up @@ -552,12 +552,12 @@ class QgsPostgresConn : public QObject
* contained in the geometry_columns metatable
* \param searchPublicOnly
* \param allowGeometrylessTables
* \param removeRasterOverviews do not list raster layer overviews
* \param showRasterOverviews list raster layer overviews
* \param schema restrict layers to layers within specified schema
* \param table restrict tables to those with specified table
* \returns true if layers were fetched successfully
*/
bool supportedLayersPrivate( QVector<QgsPostgresLayerProperty> &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool removeRasterOverviews = false, const QString &schema = QString(), const QString &table = QString() );
bool supportedLayersPrivate( QVector<QgsPostgresLayerProperty> &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool showRasterOverviews = false, const QString &schema = QString(), const QString &table = QString() );

//! List of the supported layers
QVector<QgsPostgresLayerProperty> mLayersSupported;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ QVector<QgsDataItem *> QgsPGSchemaItem::createChildren()
}

QVector<QgsPostgresLayerProperty> layerProperties;
const bool ok = conn->supportedLayers( layerProperties, QgsPostgresConn::geometryColumnsOnly( mConnectionName ), QgsPostgresConn::publicSchemaOnly( mConnectionName ), QgsPostgresConn::allowGeometrylessTables( mConnectionName ), QgsPostgresConn::removeRasterOverviewTables( mConnectionName ), mName );
const bool ok = conn->supportedLayers( layerProperties, QgsPostgresConn::geometryColumnsOnly( mConnectionName ), QgsPostgresConn::publicSchemaOnly( mConnectionName ), QgsPostgresConn::allowGeometrylessTables( mConnectionName ), QgsPostgresConn::showRasterOverviewTables( mConnectionName ), mName );

if ( !ok )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresproviderconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const QStringList QgsPostgresProviderConnection::CONFIGURATION_PARAMETERS = {
QStringLiteral( "projectsInDatabase" ),
QStringLiteral( "metadataInDatabase" ),
QStringLiteral( "session_role" ),
QStringLiteral( "dontShowRasterOverviews" ),
QStringLiteral( "showRasterOverviews" ),
};

const QString QgsPostgresProviderConnection::SETTINGS_BASE_KEY = QStringLiteral( "/PostgreSQL/connections/" );
Expand Down
4 changes: 2 additions & 2 deletions src/ui/qgspgnewconnectionbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_dontShowRasterOverviews">
<widget class="QCheckBox" name="cb_showRasterOverviews">
<property name="text">
<string>Don't list raster overview tables</string>
<string>List raster overview tables</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 514a4b5

Please sign in to comment.