Skip to content

Commit

Permalink
Start depreating
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 12, 2021
1 parent 9796aa3 commit d44f310
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 13 deletions.
18 changes: 13 additions & 5 deletions python/gui/auto_generated/qgssublayersdialog.sip.in
Expand Up @@ -10,6 +10,11 @@

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

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

%TypeHeaderCode
#include "qgssublayersdialog.h"
Expand Down Expand Up @@ -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)

Expand All @@ -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();
Expand Down
44 changes: 41 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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 ) )
{
Expand All @@ -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 )
{
Expand Down
13 changes: 8 additions & 5 deletions src/gui/qgssublayersdialog.h
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit d44f310

Please sign in to comment.