Skip to content
Permalink
Browse files
[feature] Add a check box in the sublayer selection dialog to control
whether system and internal tables should be shown

Off by default, but useful when users have a particular need to
load a system table into qgis for view/manipulation
  • Loading branch information
nyalldawson committed Aug 26, 2021
1 parent 10287f0 commit 37dc64fdf8bfe2c485fbe374e6f1ebb51efc159d
Showing with 34 additions and 25 deletions.
  1. +4 −4 src/app/qgisapp.cpp
  2. +1 −0 src/app/qgsprovidersublayersdialog.cpp
  3. +29 −21 src/ui/qgsprovidersublayersdialogbase.ui
@@ -5516,7 +5516,7 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layers, const QString &
qApp->processEvents();
}

QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) )->querySublayers( uri );
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) )->querySublayers( uri, Qgis::SublayerQueryFlag::IncludeSystemTables );
// filter out non-vector sublayers
sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails & sublayer )
{
@@ -5901,7 +5901,7 @@ QgsPointCloudLayer *QgisApp::addPointCloudLayerPrivate( const QString &uri, cons
bool QgisApp::askUserForZipItemLayers( const QString &path, const QList< QgsMapLayerType > &acceptableTypes )
{
// query sublayers
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->querySublayers( path );
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->querySublayers( path, Qgis::SublayerQueryFlag::IncludeSystemTables );

// filter out non-matching sublayers
sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails & sublayer )
@@ -7478,7 +7478,7 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
}

// query sublayers
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->querySublayers( fileName );
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->querySublayers( fileName, Qgis::SublayerQueryFlag::IncludeSystemTables );

if ( !sublayers.empty() || !nonLayerItems.empty() )
{
@@ -13222,7 +13222,7 @@ T *QgisApp::addLayerPrivate( QgsMapLayerType type, const QString &uri, const QSt
{
// query sublayers
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->providerMetadata( providerKey ) ?
QgsProviderRegistry::instance()->providerMetadata( providerKey )->querySublayers( updatedUri )
QgsProviderRegistry::instance()->providerMetadata( providerKey )->querySublayers( updatedUri, Qgis::SublayerQueryFlag::IncludeSystemTables )
: QgsProviderRegistry::instance()->querySublayers( updatedUri );

// filter out non-matching sublayers
@@ -184,6 +184,7 @@ QgsProviderSublayersDialog::QgsProviderSublayersDialog( const QString &uri, cons
connect( mBtnDeselectAll, &QAbstractButton::pressed, this, [ = ] { mLayersTree->selectionModel()->clear(); } );
connect( mLayersTree->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsProviderSublayersDialog::treeSelectionChanged );
connect( mSearchLineEdit, &QgsFilterLineEdit::textChanged, mProxyModel, &QgsProviderSublayerProxyModel::setFilterString );
connect( mCheckShowSystem, &QCheckBox::toggled, mProxyModel, &QgsProviderSublayerProxyModel::setIncludeSystemTables );
connect( mLayersTree, &QTreeView::doubleClicked, this, [ = ]( const QModelIndex & index )
{
mLayersTree->selectionModel()->select( QItemSelection( mLayersTree->model()->index( index.row(), 0, index.parent() ),
@@ -29,20 +29,7 @@
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="mLblFilePath">
<property name="toolTip">
<string>Current file source</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -68,13 +55,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mCbxAddToGroup">
<property name="text">
<string>Add layers to a group</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@@ -90,6 +70,26 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mLblFilePath">
<property name="toolTip">
<string>Current file source</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="mCheckShowSystem">
<property name="text">
<string>Show system and internal tables</string>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
@@ -120,6 +120,13 @@
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="mCbxAddToGroup">
<property name="text">
<string>Add layers to a group</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
@@ -136,6 +143,7 @@
<tabstop>mBtnSelectAll</tabstop>
<tabstop>mBtnDeselectAll</tabstop>
<tabstop>mCbxAddToGroup</tabstop>
<tabstop>mCheckShowSystem</tabstop>
</tabstops>
<resources/>
<connections/>

0 comments on commit 37dc64f

Please sign in to comment.