From 28326b664c2935e1180f6e3f360eda6525972de8 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 13 Dec 2024 09:15:25 +0100 Subject: [PATCH 01/13] add button and store setting --- src/providers/postgres/qgspgnewconnection.cpp | 2 ++ src/ui/qgspgnewconnectionbase.ui | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/providers/postgres/qgspgnewconnection.cpp b/src/providers/postgres/qgspgnewconnection.cpp index cded70f6b943..6ee0a35f9d19 100644 --- a/src/providers/postgres/qgspgnewconnection.cpp +++ b/src/providers/postgres/qgspgnewconnection.cpp @@ -82,6 +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() ); // Ensure that cb_publicSchemaOnly is set correctly cb_geometryColumnsOnly_clicked(); @@ -177,6 +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() ); QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "postgres" ) ); std::unique_ptr providerConnection( qgis::down_cast( providerMetadata->createConnection( txtName->text() ) ) ); diff --git a/src/ui/qgspgnewconnectionbase.ui b/src/ui/qgspgnewconnectionbase.ui index 943cbf587194..1b1b1d5e509f 100644 --- a/src/ui/qgspgnewconnectionbase.ui +++ b/src/ui/qgspgnewconnectionbase.ui @@ -7,7 +7,7 @@ 0 0 448 - 510 + 573 @@ -236,6 +236,13 @@ + + + + Don't list raster overview tables + + + From 86b64eea78bf383d768d7a13a4509a0dc0624d4d Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 13 Dec 2024 10:27:46 +0100 Subject: [PATCH 02/13] use new setting --- src/providers/postgres/qgspostgresconn.cpp | 8 ++++++++ src/providers/postgres/qgspostgresconn.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index fe87882499dd..988b4c8652be 100644 --- a/src/providers/postgres/qgspostgresconn.cpp +++ b/src/providers/postgres/qgspostgresconn.cpp @@ -2731,6 +2731,12 @@ bool QgsPostgresConn::allowProjectsInDatabase( const QString &connName ) return settings.value( "/PostgreSQL/connections/" + connName + "/projectsInDatabase", false ).toBool(); } +bool QgsPostgresConn::removeRasterOverviewTables( const QString &connName ) +{ + QgsSettings settings; + return settings.value( "/PostgreSQL/connections/" + connName + "/dontShowRasterOverviews", false ).toBool(); +} + void QgsPostgresConn::deleteConnection( const QString &connName ) { QgsSettings settings; @@ -2755,6 +2761,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 ); } @@ -2782,6 +2789,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.sync(); } diff --git a/src/providers/postgres/qgspostgresconn.h b/src/providers/postgres/qgspostgresconn.h index ea38d2806626..acb8634f2631 100644 --- a/src/providers/postgres/qgspostgresconn.h +++ b/src/providers/postgres/qgspostgresconn.h @@ -471,6 +471,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 ); /** * Duplicates \a src connection settings to a new \a dst connection. From d9c7a029518c11ab7e7c2bd53a410c13e0829f18 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 13 Dec 2024 10:28:57 +0100 Subject: [PATCH 03/13] removeRasterOverviews in functions --- src/providers/postgres/qgspostgresconn.cpp | 58 +++++++++++++++++++--- src/providers/postgres/qgspostgresconn.h | 15 ++++-- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index 988b4c8652be..dfc2cfe9517e 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, const QString &schema, const QString &name ) +bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews, const QString &schema, const QString &name ) { QMutexLocker locker( &mLock ); int nColumns = 0; @@ -1054,6 +1054,52 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP } } + if ( removeRasterOverviews ) + { + QString sqlRasterOverviews = QString( "SELECT o_table_schema, o_table_name FROM public.raster_overviews" ); + + QgsPostgresResult resultRasterOverviews; + resultRasterOverviews = LoggedPQexec( "QgsPostgresConn", sqlRasterOverviews ); + + if ( resultRasterOverviews.result() ) + { + QVector overviews; + for ( int idx = 0; idx < resultRasterOverviews.PQntuples(); idx++ ) + { + QgsPostgresRasterOverviewLayerProperty rasterOverviewProperty; + rasterOverviewProperty.schemaName = resultRasterOverviews.PQgetvalue( idx, 0 ); + rasterOverviewProperty.tableName = resultRasterOverviews.PQgetvalue( idx, 1 ); + overviews.append( rasterOverviewProperty ); + } + + QVector layersToKeep; + for ( int i = 0; i < mLayersSupported.count(); i++ ) + { + QgsPostgresLayerProperty property = mLayersSupported.at( i ); + + if ( !property.isRaster ) + { + layersToKeep.append( property ); + } + else + { + bool keepRasterTable = true; + for ( QgsPostgresRasterOverviewLayerProperty overview : overviews ) + { + if ( property.schemaName == overview.schemaName && property.tableName == overview.tableName ) + { + keepRasterTable = false; + } + } + + if ( keepRasterTable ) + layersToKeep.append( property ); + } + } + mLayersSupported = layersToKeep; + } + } + if ( nColumns == 0 && schema.isEmpty() ) { QgsMessageLog::logMessage( tr( "Database connection was successful, but the accessible tables could not be determined." ), tr( "PostGIS" ) ); @@ -1062,14 +1108,14 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP return true; } -bool QgsPostgresConn::supportedLayersPrivate( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, const QString &schema, const QString &table ) +bool QgsPostgresConn::supportedLayersPrivate( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews, const QString &schema, const QString &table ) { QMutexLocker locker( &mLock ); mLayersSupported.clear(); // Get the list of supported tables - if ( !getTableInfo( searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, schema, table ) ) + if ( !getTableInfo( searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, removeRasterOverviews, schema, table ) ) { QgsMessageLog::logMessage( tr( "Unable to get list of spatially enabled tables from the database" ), tr( "PostGIS" ) ); return false; @@ -1458,15 +1504,15 @@ Qgis::PostgresRelKind QgsPostgresConn::relKindFromValue( const QString &value ) return Qgis::PostgresRelKind::Unknown; } -bool QgsPostgresConn::supportedLayers( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, const QString &schema ) +bool QgsPostgresConn::supportedLayers( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews, const QString &schema ) { - return supportedLayersPrivate( layers, searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, schema ); + return supportedLayersPrivate( layers, searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, removeRasterOverviews, schema ); } bool QgsPostgresConn::supportedLayer( QgsPostgresLayerProperty &layerProperty, const QString &schema, const QString &table ) { QVector layers; - if ( !supportedLayersPrivate( layers, false, false, true /* allowGeometrylessTables */, schema, table ) || layers.empty() ) + if ( !supportedLayersPrivate( layers, false, false, true /* allowGeometrylessTables */, false, schema, table ) || layers.empty() ) { return false; } diff --git a/src/providers/postgres/qgspostgresconn.h b/src/providers/postgres/qgspostgresconn.h index acb8634f2631..e5ea7600b4af 100644 --- a/src/providers/postgres/qgspostgresconn.h +++ b/src/providers/postgres/qgspostgresconn.h @@ -68,6 +68,12 @@ struct QgsPostgresSchemaProperty QString owner; }; +//! Raster overview table properties structure +struct QgsPostgresRasterOverviewLayerProperty +{ + QString schemaName; + QString tableName; +}; //! Layer Property structure // TODO: Fill to Postgres/PostGIS specifications @@ -382,10 +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 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, const QString &schema = QString() ); + bool supportedLayers( QVector &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool removeRasterOverviews = false, const QString &schema = QString() ); /** * Get the information about a supported layer @@ -418,11 +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 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, const QString &schema = QString(), const QString &name = QString() ); + bool getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool removeRasterOverviews = false, const QString &schema = QString(), const QString &name = QString() ); qint64 getBinaryInt( QgsPostgresResult &queryResult, int row, int col ); @@ -544,11 +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 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, const QString &schema = QString(), const QString &table = QString() ); + bool supportedLayersPrivate( QVector &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool removeRasterOverviews = false, const QString &schema = QString(), const QString &table = QString() ); //! List of the supported layers QVector mLayersSupported; From 90f436dbb06c5c452161eb1f4db88c8e25105002 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 13 Dec 2024 10:29:40 +0100 Subject: [PATCH 04/13] settings --- src/providers/postgres/qgspostgresdataitems.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/postgres/qgspostgresdataitems.cpp b/src/providers/postgres/qgspostgresdataitems.cpp index 46ec9265c0b6..fc57d5e9c39f 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 ), mName ); + const bool ok = conn->supportedLayers( layerProperties, QgsPostgresConn::geometryColumnsOnly( mConnectionName ), QgsPostgresConn::publicSchemaOnly( mConnectionName ), QgsPostgresConn::allowGeometrylessTables( mConnectionName ), QgsPostgresConn::removeRasterOverviewTables( mConnectionName ), mName ); if ( !ok ) { From ad1beb2be164af6c946f5705235502ece92959fb Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 13 Dec 2024 10:29:57 +0100 Subject: [PATCH 05/13] parameter --- src/providers/postgres/qgspostgresproviderconnection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/providers/postgres/qgspostgresproviderconnection.cpp b/src/providers/postgres/qgspostgresproviderconnection.cpp index e73969ab09cb..1df19ffe9805 100644 --- a/src/providers/postgres/qgspostgresproviderconnection.cpp +++ b/src/providers/postgres/qgspostgresproviderconnection.cpp @@ -45,6 +45,7 @@ const QStringList QgsPostgresProviderConnection::CONFIGURATION_PARAMETERS = { QStringLiteral( "projectsInDatabase" ), QStringLiteral( "metadataInDatabase" ), QStringLiteral( "session_role" ), + QStringLiteral( "dontShowRasterOverviews" ), }; const QString QgsPostgresProviderConnection::SETTINGS_BASE_KEY = QStringLiteral( "/PostgreSQL/connections/" ); From c29ff1987dcb86b5f8cd5a1eb7e0e0a77baffe9b Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 13 Dec 2024 10:30:12 +0100 Subject: [PATCH 06/13] update function --- src/providers/postgres/qgspostgresproviderconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/postgres/qgspostgresproviderconnection.cpp b/src/providers/postgres/qgspostgresproviderconnection.cpp index 1df19ffe9805..3076403cd68b 100644 --- a/src/providers/postgres/qgspostgresproviderconnection.cpp +++ b/src/providers/postgres/qgspostgresproviderconnection.cpp @@ -240,7 +240,7 @@ QList QgsPostgresProviderC } else { - ok = conn->supportedLayers( properties, false, schema == QStringLiteral( "public" ), aspatial, schema ); + ok = conn->supportedLayers( properties, false, schema == QStringLiteral( "public" ), aspatial, false, schema ); } if ( !ok ) From 514a4b5cd12a48c69d0a7465b47b147048811595 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 9 Jan 2025 13:02:12 +0100 Subject: [PATCH 07/13] 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 From dbf5968ab07ad9e84842f8cc41a5a310e0f07f97 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Mon, 13 Jan 2025 17:50:21 +0100 Subject: [PATCH 08/13] only run if there is at least one result --- src/providers/postgres/qgspostgresconn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index 9b8116729d25..1e485570a39d 100644 --- a/src/providers/postgres/qgspostgresconn.cpp +++ b/src/providers/postgres/qgspostgresconn.cpp @@ -1062,7 +1062,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP QgsPostgresResult resultRasterOverviews; resultRasterOverviews = LoggedPQexec( "QgsPostgresConn", sqlRasterOverviews ); - if ( resultRasterOverviews.result() ) + if ( resultRasterOverviews.result() && resultRasterOverviews.PQntuples() > 0 ) { QVector overviews; for ( int idx = 0; idx < resultRasterOverviews.PQntuples(); idx++ ) From ea799720a33b8162fb84e6ff2400e260d5d62407 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Mon, 13 Jan 2025 18:05:37 +0100 Subject: [PATCH 09/13] add explicit check for existence of raster_overviews view --- src/providers/postgres/qgspostgresconn.cpp | 64 +++++++++++++--------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index 1e485570a39d..ba8cb06371c1 100644 --- a/src/providers/postgres/qgspostgresconn.cpp +++ b/src/providers/postgres/qgspostgresconn.cpp @@ -1057,47 +1057,57 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP // remove raster overivews if showRasterOverviews is FALSE if ( !showRasterOverviews ) { - QString sqlRasterOverviews = QString( "SELECT o_table_schema, o_table_name FROM public.raster_overviews" ); + QString sqlRasterOverviewExist = QStringLiteral( "SELECT table_schema, table_name" + " FROM information_schema.views" + " WHERE table_schema = 'public' AND table_name = 'raster_overviews'" ); - QgsPostgresResult resultRasterOverviews; - resultRasterOverviews = LoggedPQexec( "QgsPostgresConn", sqlRasterOverviews ); + QgsPostgresResult resultRasterOverviewsExist; + resultRasterOverviewsExist = LoggedPQexec( "QgsPostgresConn", sqlRasterOverviewExist ); - if ( resultRasterOverviews.result() && resultRasterOverviews.PQntuples() > 0 ) + if ( resultRasterOverviewsExist.result() && resultRasterOverviewsExist.PQntuples() > 0 ) { - QVector overviews; - for ( int idx = 0; idx < resultRasterOverviews.PQntuples(); idx++ ) - { - QgsPostgresRasterOverviewLayerProperty rasterOverviewProperty; - rasterOverviewProperty.schemaName = resultRasterOverviews.PQgetvalue( idx, 0 ); - rasterOverviewProperty.tableName = resultRasterOverviews.PQgetvalue( idx, 1 ); - overviews.append( rasterOverviewProperty ); - } + QString sqlRasterOverviews = QString( "SELECT o_table_schema, o_table_name FROM public.raster_overviews" ); - QVector layersToKeep; - for ( int i = 0; i < mLayersSupported.count(); i++ ) - { - QgsPostgresLayerProperty property = mLayersSupported.at( i ); + QgsPostgresResult resultRasterOverviews; + resultRasterOverviews = LoggedPQexec( "QgsPostgresConn", sqlRasterOverviews ); - if ( !property.isRaster ) + if ( resultRasterOverviews.result() && resultRasterOverviews.PQntuples() > 0 ) + { + QVector overviews; + for ( int idx = 0; idx < resultRasterOverviews.PQntuples(); idx++ ) { - layersToKeep.append( property ); + QgsPostgresRasterOverviewLayerProperty rasterOverviewProperty; + rasterOverviewProperty.schemaName = resultRasterOverviews.PQgetvalue( idx, 0 ); + rasterOverviewProperty.tableName = resultRasterOverviews.PQgetvalue( idx, 1 ); + overviews.append( rasterOverviewProperty ); } - else + + QVector layersToKeep; + for ( int i = 0; i < mLayersSupported.count(); i++ ) { - bool keepRasterTable = true; - for ( QgsPostgresRasterOverviewLayerProperty overview : overviews ) + QgsPostgresLayerProperty property = mLayersSupported.at( i ); + + if ( !property.isRaster ) { - if ( property.schemaName == overview.schemaName && property.tableName == overview.tableName ) + layersToKeep.append( property ); + } + else + { + bool keepRasterTable = true; + for ( QgsPostgresRasterOverviewLayerProperty overview : overviews ) { - keepRasterTable = false; + if ( property.schemaName == overview.schemaName && property.tableName == overview.tableName ) + { + keepRasterTable = false; + } } - } - if ( keepRasterTable ) - layersToKeep.append( property ); + if ( keepRasterTable ) + layersToKeep.append( property ); + } } + mLayersSupported = layersToKeep; } - mLayersSupported = layersToKeep; } } From 7bd6fea01783827de62c425c89966eb5e47a372d Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 16 Jan 2025 17:16:04 +0100 Subject: [PATCH 10/13] change to QStringLiteral Co-authored-by: Stefanos Natsis --- src/providers/postgres/qgspostgresconn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index ba8cb06371c1..c81159861316 100644 --- a/src/providers/postgres/qgspostgresconn.cpp +++ b/src/providers/postgres/qgspostgresconn.cpp @@ -1066,7 +1066,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP if ( resultRasterOverviewsExist.result() && resultRasterOverviewsExist.PQntuples() > 0 ) { - QString sqlRasterOverviews = QString( "SELECT o_table_schema, o_table_name FROM public.raster_overviews" ); + const QString sqlRasterOverviews = QStringLiteral( "SELECT o_table_schema, o_table_name FROM public.raster_overviews" ); QgsPostgresResult resultRasterOverviews; resultRasterOverviews = LoggedPQexec( "QgsPostgresConn", sqlRasterOverviews ); From eb4f10f272b1718dda05efd20a62f221d1af470c Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 16 Jan 2025 17:16:35 +0100 Subject: [PATCH 11/13] make const Co-authored-by: Stefanos Natsis --- src/providers/postgres/qgspostgresconn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index c81159861316..a2aa540b83ad 100644 --- a/src/providers/postgres/qgspostgresconn.cpp +++ b/src/providers/postgres/qgspostgresconn.cpp @@ -1094,7 +1094,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP else { bool keepRasterTable = true; - for ( QgsPostgresRasterOverviewLayerProperty overview : overviews ) + for ( const QgsPostgresRasterOverviewLayerProperty &overview : std::as_const( overviews ) ) { if ( property.schemaName == overview.schemaName && property.tableName == overview.tableName ) { From 5873c05db5bf9960e0091a7adc01355aa0519540 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 16 Jan 2025 17:19:21 +0100 Subject: [PATCH 12/13] default value false --- src/providers/postgres/qgspgnewconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/postgres/qgspgnewconnection.cpp b/src/providers/postgres/qgspgnewconnection.cpp index 813c77e68571..d2aefea4e8e1 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_showRasterOverviews->setChecked( settings.value( key + "/showRasterOverviews", true ).toBool() ); + cb_showRasterOverviews->setChecked( settings.value( key + "/showRasterOverviews", false ).toBool() ); // Ensure that cb_publicSchemaOnly is set correctly cb_geometryColumnsOnly_clicked(); From d3e9d2d54485f9c744179237d50a640642e52b61 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Fri, 17 Jan 2025 09:37:17 +0100 Subject: [PATCH 13/13] make variable name consistent with existing one --- src/providers/postgres/qgspgnewconnection.cpp | 4 ++-- src/providers/postgres/qgspostgresconn.cpp | 22 +++++++++---------- src/providers/postgres/qgspostgresconn.h | 14 ++++++------ .../postgres/qgspostgresdataitems.cpp | 2 +- .../qgspostgresproviderconnection.cpp | 2 +- src/ui/qgspgnewconnectionbase.ui | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/providers/postgres/qgspgnewconnection.cpp b/src/providers/postgres/qgspgnewconnection.cpp index d2aefea4e8e1..68880aec94e0 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_showRasterOverviews->setChecked( settings.value( key + "/showRasterOverviews", false ).toBool() ); + cb_allowRasterOverviewTables->setChecked( settings.value( key + "/allowRasterOverviewTables", false ).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( "showRasterOverviews", cb_showRasterOverviews->isChecked() ); + configuration.insert( "allowRasterOverviewTables", cb_allowRasterOverviewTables->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 a2aa540b83ad..6f086ffc7f8e 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 showRasterOverviews, const QString &schema, const QString &name ) +bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool allowRasterOverviewTables, const QString &schema, const QString &name ) { QMutexLocker locker( &mLock ); int nColumns = 0; @@ -1054,8 +1054,8 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP } } - // remove raster overivews if showRasterOverviews is FALSE - if ( !showRasterOverviews ) + // remove raster overivews if allowRasterOverviewTables is FALSE + if ( !allowRasterOverviewTables ) { QString sqlRasterOverviewExist = QStringLiteral( "SELECT table_schema, table_name" " FROM information_schema.views" @@ -1119,14 +1119,14 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP return true; } -bool QgsPostgresConn::supportedLayersPrivate( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool showRasterOverviews, const QString &schema, const QString &table ) +bool QgsPostgresConn::supportedLayersPrivate( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool allowRasterOverviewTables, const QString &schema, const QString &table ) { QMutexLocker locker( &mLock ); mLayersSupported.clear(); // Get the list of supported tables - if ( !getTableInfo( searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, showRasterOverviews, schema, table ) ) + if ( !getTableInfo( searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, allowRasterOverviewTables, schema, table ) ) { QgsMessageLog::logMessage( tr( "Unable to get list of spatially enabled tables from the database" ), tr( "PostGIS" ) ); return false; @@ -1515,9 +1515,9 @@ Qgis::PostgresRelKind QgsPostgresConn::relKindFromValue( const QString &value ) return Qgis::PostgresRelKind::Unknown; } -bool QgsPostgresConn::supportedLayers( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool showRasterOverviews, const QString &schema ) +bool QgsPostgresConn::supportedLayers( QVector &layers, bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool allowRasterOverviewTables, const QString &schema ) { - return supportedLayersPrivate( layers, searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, showRasterOverviews, schema ); + return supportedLayersPrivate( layers, searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables, allowRasterOverviewTables, schema ); } bool QgsPostgresConn::supportedLayer( QgsPostgresLayerProperty &layerProperty, const QString &schema, const QString &table ) @@ -2788,10 +2788,10 @@ bool QgsPostgresConn::allowProjectsInDatabase( const QString &connName ) return settings.value( "/PostgreSQL/connections/" + connName + "/projectsInDatabase", false ).toBool(); } -bool QgsPostgresConn::showRasterOverviewTables( const QString &connName ) +bool QgsPostgresConn::allowRasterOverviewTables( const QString &connName ) { QgsSettings settings; - return settings.value( "/PostgreSQL/connections/" + connName + "/showRasterOverviews", true ).toBool(); + return settings.value( "/PostgreSQL/connections/" + connName + "/allowRasterOverviewTables", true ).toBool(); } void QgsPostgresConn::deleteConnection( const QString &connName ) @@ -2818,7 +2818,7 @@ void QgsPostgresConn::deleteConnection( const QString &connName ) settings.remove( key + "/metadataInDatabase" ); settings.remove( key + "/dontResolveType" ); settings.remove( key + "/session_role" ); - settings.remove( key + "/showRasterOverviews" ); + settings.remove( key + "/allowRasterOverviewTables" ); settings.remove( key ); } @@ -2846,7 +2846,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( "/showRasterOverviews" ), settings.value( key + QStringLiteral( "/showRasterOverviews" ) ).toString() ); + settings.setValue( newKey + QStringLiteral( "/allowRasterOverviewTables" ), settings.value( key + QStringLiteral( "/allowRasterOverviewTables" ) ).toString() ); settings.sync(); } diff --git a/src/providers/postgres/qgspostgresconn.h b/src/providers/postgres/qgspostgresconn.h index 007caa8d5231..b813a0eb1af9 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 showRasterOverviews list raster layer overviews + * \param allowRasterOverviewTables 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 showRasterOverviews = false, const QString &schema = QString() ); + bool supportedLayers( QVector &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool allowRasterOverviewTables = 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 showRasterOverviews list raster layer overviews + * \param allowRasterOverviewTables 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 showRasterOverviews = false, const QString &schema = QString(), const QString &name = QString() ); + bool getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, bool allowRasterOverviewTables = 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 showRasterOverviewTables( const QString &connName ); + static bool allowRasterOverviewTables( 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 showRasterOverviews list raster layer overviews + * \param allowRasterOverviewTables 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 showRasterOverviews = false, const QString &schema = QString(), const QString &table = QString() ); + bool supportedLayersPrivate( QVector &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, bool allowRasterOverviewTables = 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 0779097201f9..38623712fedc 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::showRasterOverviewTables( mConnectionName ), mName ); + const bool ok = conn->supportedLayers( layerProperties, QgsPostgresConn::geometryColumnsOnly( mConnectionName ), QgsPostgresConn::publicSchemaOnly( mConnectionName ), QgsPostgresConn::allowGeometrylessTables( mConnectionName ), QgsPostgresConn::allowRasterOverviewTables( mConnectionName ), mName ); if ( !ok ) { diff --git a/src/providers/postgres/qgspostgresproviderconnection.cpp b/src/providers/postgres/qgspostgresproviderconnection.cpp index 83d9dffa1187..1dbe381865ca 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( "showRasterOverviews" ), + QStringLiteral( "allowRasterOverviewTables" ), }; const QString QgsPostgresProviderConnection::SETTINGS_BASE_KEY = QStringLiteral( "/PostgreSQL/connections/" ); diff --git a/src/ui/qgspgnewconnectionbase.ui b/src/ui/qgspgnewconnectionbase.ui index e8f7289b497b..30641ca15325 100644 --- a/src/ui/qgspgnewconnectionbase.ui +++ b/src/ui/qgspgnewconnectionbase.ui @@ -237,9 +237,9 @@ - + - List raster overview tables + Also list raster overview tables