Skip to content
Permalink
Browse files

Filter layers by type in the data source select dialog

  • Loading branch information
elpaso committed Oct 30, 2018
1 parent 3e9d5c7 commit d995eeb0d74d1dbddd920f1f339478af99a5b135
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/app/qgslayertreeviewbadlayerindicator.cpp
@@ -24,6 +24,7 @@
#include "qgisapp.h"
#include "qgsbrowsermodel.h"
#include "qgsbrowsertreeview.h"
#include "qgsbrowserproxymodel.h"

#include <functional>
#include <QDialog>
@@ -55,16 +56,21 @@ void QgsLayerTreeViewBadLayerIndicatorProvider::onIndicatorClicked( const QModel
QString providerType( layer->providerType() );
QgsMapLayer::LayerType layerType( layer->type() );


// Builds the dialog to select a new data source
QgsBrowserModel browserModel;
browserModel.initialize();
QgsBrowserProxyModel proxyModel;
proxyModel.setBrowserModel( &browserModel );
proxyModel.setFilterByLayerType( true );
proxyModel.setLayerType( layerType );
QDialog dlg;
dlg.setWindowTitle( tr( "Select the new data source" ) );
QByteArray dlgGeom( QgsSettings().value( QStringLiteral( "/Windows/selectDataSourceDialog/geometry" ), QVariant(), QgsSettings::Section::App ).toByteArray() );
dlg.restoreGeometry( dlgGeom );
QVBoxLayout lay( &dlg );
QgsBrowserTreeView *browserWidget( new QgsBrowserTreeView( ) );
browserWidget->setModel( &browserModel );
browserWidget->setModel( &proxyModel );
browserWidget->setHeaderHidden( true );
lay.addWidget( browserWidget );
QDialogButtonBox *buttonBox( new QDialogButtonBox( QDialogButtonBox::StandardButton::Ok | QDialogButtonBox::StandardButton::Cancel ) );

0 comments on commit d995eeb

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