Skip to content
Permalink
Browse files

Condense separate entries for PDAL/EPT point clouds in data source ma…

…nager

to a single entry

Have just one "Point Cloud" tab in the manager, and make the widget
automatically pick the preferred (correct) provider based on the
file selected in the widget.

This avoids UI clutter and ensures that point clouds follow the
same pattern as vector/raster/mesh layers in the dialog
  • Loading branch information
nyalldawson committed Nov 5, 2020
1 parent 7ef1afc commit 36cdb08ba314647503dede87e2246b10592b27f0
@@ -347,7 +347,7 @@ SET(QGIS_GUI_SRCS
providers/ogr/qgsogritemguiprovider.cpp
providers/ogr/qgsgeopackageprojectstorageguiprovider.cpp

providers/ept/qgseptsourceselect.cpp
providers/ept/qgspointcloudsourceselect.cpp
providers/ept/qgseptproviderguimetadata.cpp
providers/ept/qgseptdataitemguiprovider.cpp

@@ -1108,7 +1108,7 @@ SET(QGIS_GUI_HDRS
providers/ogr/qgsogritemguiprovider.h
providers/ogr/qgsogrsourceselect.h

providers/ept/qgseptsourceselect.h
providers/ept/qgspointcloudsourceselect.h
providers/ept/qgseptproviderguimetadata.h
providers/ept/qgseptdataitemguiprovider.h

@@ -17,7 +17,7 @@

#include "qgsapplication.h"
#include "qgssourceselectprovider.h"
#include "qgseptsourceselect.h"
#include "qgspointcloudsourceselect.h"
#include "qgseptproviderguimetadata.h"
#include "qgseptdataitemguiprovider.h"

@@ -28,12 +28,12 @@ class QgsEptSourceSelectProvider : public QgsSourceSelectProvider
public:

QString providerKey() const override { return QStringLiteral( "ept" ); }
QString text() const override { return QObject::tr( "EPT Point Cloud" ); }
QString text() const override { return QObject::tr( "Point Cloud" ); }
int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 25; }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddEntwineLayer.svg" ) ); }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPointCloudLayer.svg" ) ); }
QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsEptSourceSelect( parent, fl, widgetMode );
return new QgsPointCloudSourceSelect( parent, fl, widgetMode );
}
};

@@ -1,5 +1,5 @@
/***************************************************************************
qgseptsourceselect.cpp
qgspointcloudsourceselect.cpp
--------------------
begin : October 2020
copyright : (C) 2020 by Peter Petrik
@@ -17,16 +17,17 @@

#include <QMessageBox>

#include "qgseptsourceselect.h"
#include "qgspointcloudsourceselect.h"
#include "qgsproviderregistry.h"
#include "qgsprovidermetadata.h"

QgsEptSourceSelect::QgsEptSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ):
QgsPointCloudSourceSelect::QgsPointCloudSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ):
QgsAbstractDataSourceWidget( parent, fl, widgetMode )
{
setupUi( this );
setupButtons( buttonBox );

mFileWidget->setDialogTitle( tr( "Open EPT Point Cloud Supported Dataset" ) );
mFileWidget->setDialogTitle( tr( "Open Point Cloud Dataset" ) );
mFileWidget->setFilter( QgsProviderRegistry::instance()->filePointCloudFilters() );
mFileWidget->setStorageMode( QgsFileWidget::GetMultipleFiles );
connect( mFileWidget, &QgsFileWidget::fileChanged, this, [ = ]( const QString & path )
@@ -36,18 +37,25 @@ QgsEptSourceSelect::QgsEptSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
} );
}

void QgsEptSourceSelect::addButtonClicked()
void QgsPointCloudSourceSelect::addButtonClicked()
{
if ( mPath.isEmpty() )
{
QMessageBox::information( this,
tr( "Add EPT point cloud layers" ),
tr( "Add Point Cloud Layers" ),
tr( "No layers selected." ) );
return;
}

for ( const QString &path : QgsFileWidget::splitFilePaths( mPath ) )
{
emit addPointCloudLayer( path, QFileInfo( path ).baseName(), QStringLiteral( "ept" ) ) ;
// auto determine preferred provider for each path

const QList< QgsProviderMetadata * > preferredProviders = QgsProviderRegistry::instance()->preferredProvidersForUri( mPath );
// maybe we should raise an assert if preferredProviders size is 0 or >1? Play it safe for now...
if ( preferredProviders.empty() )
continue;

emit addPointCloudLayer( path, QFileInfo( path ).baseName(), preferredProviders.at( 0 )->key() ) ;
}
}
@@ -1,5 +1,5 @@
/***************************************************************************
qgseptsourceselect.h
qgspointcloudsourceselect.h
--------------------
begin : October 2020
copyright : (C) 2020 by Peter Petrik
@@ -14,31 +14,31 @@
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSEPTSOURCESELECT_H
#define QGSEPTSOURCESELECT_H
#ifndef QGSPOINTCLOUDSOURCESELECT_H
#define QGSPOINTCLOUDSOURCESELECT_H

///@cond PRIVATE
#include "qgis_sip.h"
#define SIP_NO_FILE

#include "ui_qgseptsourceselectbase.h"
#include "ui_qgspointcloudsourceselectbase.h"
#include "qgsabstractdatasourcewidget.h"
#include "qgis_gui.h"


/**
* \class QgsEptSourceSelect
* \brief Dialog to select EPT point cloud supported sources
* \class QgsPointCloudSourceSelect
* \brief Dialog to select point cloud supported sources
*/
class QgsEptSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsEptSourceSelectBase
class QgsPointCloudSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsPointCloudSourceSelectBase
{
Q_OBJECT

public:
//! Constructor
QgsEptSourceSelect( QWidget *parent = nullptr,
Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags,
QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
QgsPointCloudSourceSelect( QWidget *parent = nullptr,
Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags,
QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );

public slots:
//! Determines the tables the user selected and closes the dialog
@@ -51,4 +51,4 @@ class QgsEptSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsEp

///@endcond
///
#endif // QGSEPTSOURCESELECT_H
#endif // QGSPOINTCLOUDSOURCESELECT_H
@@ -16,14 +16,12 @@ IF (WITH_GUI)
${PDAL_SRCS}
qgspdalprovidergui.cpp
qgspdaldataitemguiprovider.cpp
qgspdalsourceselect.cpp
)

SET(PDAL_HDRS
${PDAL_HDRS}
qgspdalprovidergui.h
qgspdaldataitemguiprovider.h
qgspdalsourceselect.h
)
ENDIF ()

@@ -18,7 +18,6 @@
#include "qgsmanageconnectionsdialog.h"
#include "qgspdaldataitems.h"
#include "qgspdalprovider.h"
#include "qgspdalsourceselect.h"

#include <QFileDialog>
#include <QInputDialog>
@@ -15,27 +15,8 @@

#include "qgsapplication.h"
#include "qgsproviderguimetadata.h"
#include "qgssourceselectprovider.h"

#include "qgspdalprovider.h"
#include "qgspdalsourceselect.h"


//! Provider for pdal source select
class QgsPdalSourceSelectProvider : public QgsSourceSelectProvider
{
public:

QString providerKey() const override { return QStringLiteral( "pdal" ); }
QString text() const override { return QObject::tr( "PDAL Point Clouds" ); }
int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 22; }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPdalLayer.svg" ) ); }
QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget,
QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsPdalSourceSelect( parent, fl, widgetMode );
}
};


class QgsPdalProviderGuiMetadata: public QgsProviderGuiMetadata
@@ -45,13 +26,6 @@ class QgsPdalProviderGuiMetadata: public QgsProviderGuiMetadata
: QgsProviderGuiMetadata( QStringLiteral( "pdal" ) )
{
}

QList<QgsSourceSelectProvider *> sourceSelectProviders() override
{
QList<QgsSourceSelectProvider *> providers;
providers << new QgsPdalSourceSelectProvider;
return providers;
}
};


This file was deleted.

This file was deleted.

0 comments on commit 36cdb08

Please sign in to comment.
You can’t perform that action at this time.