From 514a4b5cd12a48c69d0a7465b47b147048811595 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 9 Jan 2025 13:02:12 +0100 Subject: [PATCH] flip logic to explicitly ask for raster overviews --- src/providers/postgres/qgspgnewconnection.cpp | 4 ++-- src/providers/postgres/qgspostgresconn.cpp | 21 ++++++++++--------- src/providers/postgres/qgspostgresconn.h | 14 ++++++------- .../postgres/qgspostgresdataitems.cpp | 2 +- .../qgspostgresproviderconnection.cpp | 2 +- src/ui/qgspgnewconnectionbase.ui | 4 ++-- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/providers/postgres/qgspgnewconnection.cpp b/src/providers/postgres/qgspgnewconnection.cpp index 6ee0a35f9d19..813c77e68571 100644 --- a/src/providers/postgres/qgspgnewconnection.cpp +++ b/src/providers/postgres/qgspgnewconnection.cpp @@ -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(); @@ -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 providerConnection( qgis::down_cast( providerMetadata->createConnection( txtName->text() ) ) ); diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index dfc2cfe9517e..9b8116729d25 100644 --- a/src/providers/postgres/qgspostgresconn.cpp +++ b/src/providers/postgres/qgspostgresconn.cpp @@ -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; @@ -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" ); @@ -1108,14 +1109,14 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP return true; } -bool QgsPostgresConn::supportedLayersPrivate( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews, const QString &schema, const QString &table ) +bool QgsPostgresConn::supportedLayersPrivate( QVector &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; @@ -1504,9 +1505,9 @@ Qgis::PostgresRelKind QgsPostgresConn::relKindFromValue( const QString &value ) return Qgis::PostgresRelKind::Unknown; } -bool QgsPostgresConn::supportedLayers( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews, const QString &schema ) +bool QgsPostgresConn::supportedLayers( QVector &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 ) @@ -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 ) @@ -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 ); } @@ -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(); } diff --git a/src/providers/postgres/qgspostgresconn.h b/src/providers/postgres/qgspostgresconn.h index e5ea7600b4af..007caa8d5231 100644 --- a/src/providers/postgres/qgspostgresconn.h +++ b/src/providers/postgres/qgspostgresconn.h @@ -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 &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool removeRasterOverviews = false, const QString &schema = QString() ); + bool supportedLayers( QVector &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool showRasterOverviews = false, const QString &schema = QString() ); /** * Get the information about a supported layer @@ -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 ); @@ -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. @@ -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 &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool removeRasterOverviews = false, const QString &schema = QString(), const QString &table = QString() ); + bool supportedLayersPrivate( QVector &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 mLayersSupported; diff --git a/src/providers/postgres/qgspostgresdataitems.cpp b/src/providers/postgres/qgspostgresdataitems.cpp index fc57d5e9c39f..0779097201f9 100644 --- a/src/providers/postgres/qgspostgresdataitems.cpp +++ b/src/providers/postgres/qgspostgresdataitems.cpp @@ -413,7 +413,7 @@ QVector QgsPGSchemaItem::createChildren() } QVector 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 ) { diff --git a/src/providers/postgres/qgspostgresproviderconnection.cpp b/src/providers/postgres/qgspostgresproviderconnection.cpp index 3076403cd68b..83d9dffa1187 100644 --- a/src/providers/postgres/qgspostgresproviderconnection.cpp +++ b/src/providers/postgres/qgspostgresproviderconnection.cpp @@ -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/" ); diff --git a/src/ui/qgspgnewconnectionbase.ui b/src/ui/qgspgnewconnectionbase.ui index 1b1b1d5e509f..e8f7289b497b 100644 --- a/src/ui/qgspgnewconnectionbase.ui +++ b/src/ui/qgspgnewconnectionbase.ui @@ -237,9 +237,9 @@ - + - Don't list raster overview tables + List raster overview tables