Skip to content
Permalink
Browse files
Start depreating
  • Loading branch information
nyalldawson committed Jul 12, 2021
1 parent 9796aa3 commit d44f31000da67eeb842bb32e382d9f16b535f22c
Showing with 62 additions and 13 deletions.
  1. +13 −5 python/gui/auto_generated/qgssublayersdialog.sip.in
  2. +41 −3 src/app/qgisapp.cpp
  3. +8 −5 src/gui/qgssublayersdialog.h
@@ -10,6 +10,11 @@

class QgsSublayersDialog : QDialog
{
%Docstring(signature="appended")

.. deprecated::
Will be removed in QGIS 4.0
%End

%TypeHeaderCode
#include "qgssublayersdialog.h"
@@ -48,11 +53,11 @@ class QgsSublayersDialog : QDialog
typedef QList<QgsSublayersDialog::LayerDefinition> LayerDefinitionList;


QgsSublayersDialog( ProviderType providerType,
const QString &name,
QWidget *parent /TransferThis/ = 0,
Qt::WindowFlags fl = Qt::WindowFlags(),
const QString &dataSourceUri = QString() );
QgsSublayersDialog( ProviderType providerType,
const QString &name,
QWidget *parent /TransferThis/ = 0,
Qt::WindowFlags fl = Qt::WindowFlags(),
const QString &dataSourceUri = QString() ) /Deprecated/;
%Docstring
Construct a new QgsSublayersDialog object - a dialog to select which sub layers to be imported from a data source (e.g. from geopackage or zipfile)

@@ -61,6 +66,9 @@ Construct a new QgsSublayersDialog object - a dialog to select which sub layers
:param parent: parent widget of the dialog
:param fl: window flags
:param dataSourceUri: data source URI

.. deprecated::
Will be removed in QGIS 4.0
%End

~QgsSublayersDialog();
@@ -98,6 +98,9 @@
#include "qgsvectorlayersavestyledialog.h"
#include "maptools/qgsappmaptools.h"
#include "qgsexpressioncontextutils.h"
#include "qgsprovidersublayerdetails.h"
#include "qgsproviderutils.h"
#include "qgsprovidersublayersdialog.h"

#include "qgsanalysis.h"
#include "qgsgeometrycheckregistry.h"
@@ -7675,6 +7678,41 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
}
}

// query sublayers
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->querySublayers( fileName );
if ( !sublayers.empty() )
{
bool detailsAreIncomplete = QgsProviderUtils::sublayerDetailsAreIncomplete( sublayers, false );
const bool singleSublayerOnly = sublayers.size() == 1;
if ( singleSublayerOnly && !detailsAreIncomplete )
{
// nice and easy -- we only have one sublayer, so load that
}
else if ( allowInteractive )
{
// prompt user for sublayers
QgsProviderSublayersDialog dlg( fileName, sublayers, this );

dlg.exec();
}
else // non-interactive
{
// in non-interactive mode we don't care if feature counts are missing, so re-test if
// details are incomplete with ignoring unknown feature counts
detailsAreIncomplete = QgsProviderUtils::sublayerDetailsAreIncomplete( sublayers, true );
if ( detailsAreIncomplete )
{
// requery sublayers, resolving geometry types
sublayers = QgsProviderRegistry::instance()->querySublayers( fileName, Qgis::SublayerQueryFlag::ResolveGeometryType );
}

// add all sublayers

}
ok = true;
}

#if 0
// try to load it as raster
if ( QgsRasterLayer::isValidRasterFileName( fileName ) )
{
@@ -7701,14 +7739,14 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
}
}


CPLPopErrorHandler();

// Try to load as mesh layer after raster & vector
if ( !ok )
{
ok = static_cast< bool >( addMeshLayerPrivate( fileName, fileInfo.completeBaseName(), QStringLiteral( "mdal" ), false ) );
}
#endif

CPLPopErrorHandler();

if ( !ok )
{
@@ -25,6 +25,7 @@
/**
* \ingroup gui
* \class QgsSublayersDialog
* \deprecated Will be removed in QGIS 4.0
*/
class GUI_EXPORT QgsSublayersDialog : public QDialog, private Ui::QgsSublayersDialogBase
{
@@ -97,12 +98,14 @@ class GUI_EXPORT QgsSublayersDialog : public QDialog, private Ui::QgsSublayersDi
* \param parent parent widget of the dialog
* \param fl window flags
* \param dataSourceUri data source URI
*
* \deprecated Will be removed in QGIS 4.0
*/
QgsSublayersDialog( ProviderType providerType,
const QString &name,
QWidget *parent SIP_TRANSFERTHIS = nullptr,
Qt::WindowFlags fl = Qt::WindowFlags(),
const QString &dataSourceUri = QString() );
Q_DECL_DEPRECATED QgsSublayersDialog( ProviderType providerType,
const QString &name,
QWidget *parent SIP_TRANSFERTHIS = nullptr,
Qt::WindowFlags fl = Qt::WindowFlags(),
const QString &dataSourceUri = QString() ) SIP_DEPRECATED;

~QgsSublayersDialog() override;

0 comments on commit d44f310

Please sign in to comment.