17#include "moc_qgslayermetadatasearchwidget.cpp" 
   36  mSourceModel = 
new QgsLayerMetadataResultsModel( searchContext, 
this );
 
   38  mProxyModel->setSourceModel( mSourceModel );
 
   39  mMetadataTableView->setModel( mProxyModel );
 
   40  mMetadataTableView->setSortingEnabled( 
true );
 
   41  mMetadataTableView->sortByColumn( 0, Qt::SortOrder::AscendingOrder );
 
   42  mMetadataTableView->horizontalHeader()->setSectionResizeMode( QgsLayerMetadataResultsModel::Sections::Identifier, QHeaderView::ResizeMode::Stretch );
 
   43  mMetadataTableView->horizontalHeader()->setSectionResizeMode( QgsLayerMetadataResultsModel::Sections::Title, QHeaderView::ResizeMode::Stretch );
 
   44  mMetadataTableView->horizontalHeader()->setSectionResizeMode( QgsLayerMetadataResultsModel::Sections::Abstract, QHeaderView::ResizeMode::Stretch );
 
   45  mMetadataTableView->horizontalHeader()->setSectionResizeMode( QgsLayerMetadataResultsModel::Sections::DataProviderName, QHeaderView::ResizeMode::ResizeToContents );
 
   46  mMetadataTableView->horizontalHeader()->setSectionResizeMode( QgsLayerMetadataResultsModel::Sections::GeometryType, QHeaderView::ResizeMode::ResizeToContents );
 
   47  mMetadataTableView->setSelectionBehavior( QAbstractItemView::SelectRows );
 
   49  mExtentFilterComboBox->addItem( QString() );
 
   50  mExtentFilterComboBox->addItem( QStringLiteral( 
"Map Canvas Extent" ) );
 
   51  mExtentFilterComboBox->addItem( QStringLiteral( 
"Current Project Extent" ) );
 
   52  mExtentFilterComboBox->setCurrentIndex( 0 );
 
   53  mExtentFilterComboBox->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToContents );
 
   54  mExtentFilterComboBox->adjustSize();
 
   56  mGeometryTypeComboBox->addItem( QString(), QVariant() );
 
   63  mGeometryTypeComboBox->setCurrentIndex( 0 );
 
   64  mGeometryTypeComboBox->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToContents );
 
   65  mGeometryTypeComboBox->adjustSize();
 
   67  auto updateLoadBtn = [
this] {
 
   70      mAbortPushButton->setText( tr( 
"Abort" ) );
 
   75      mAbortPushButton->setText( tr( 
"Refresh" ) );
 
   80  connect( mSourceModel, &QgsLayerMetadataResultsModel::progressChanged, mProgressBar, &QProgressBar::setValue );
 
   81  connect( mSourceModel, &QgsLayerMetadataResultsModel::progressChanged, 
this, [
this, updateLoadBtn]( 
int progress ) {
 
   85      mReloadRequired = 
false;
 
   91  connect( mAbortPushButton, &QPushButton::clicked, mSourceModel, [
this, updateLoadBtn]( 
bool ) {
 
   95      mReloadRequired = 
true;
 
  100      mProgressBar->hide();
 
  101      mSourceModel->cancel();
 
  103      mReloadRequired = 
false;
 
  108  connect( mMetadataTableView->selectionModel(), &QItemSelectionModel::selectionChanged, 
this, [
this]( 
const QItemSelection &, 
const QItemSelection & ) {
 
  109    emit enableButtons( mMetadataTableView->selectionModel()->hasSelection() );
 
  116  connect( mGeometryTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [
this]( 
int index ) {
 
  124      const QVariant geomTypeFilterValue( mGeometryTypeComboBox->currentData() );
 
  125      if ( geomTypeFilterValue.isValid() ) 
 
  149  connect( mButtonBox, &QDialogButtonBox::helpRequested, 
this, &QgsLayerMetadataSearchWidget::showHelp );
 
 
  154  if ( newMapCanvas && 
mapCanvas() != newMapCanvas )
 
 
  171  else if ( index == 2 )
 
 
  187  mReloadRequired = 
true;
 
 
  193  const QModelIndexList &selectedIndexes { mMetadataTableView->selectionModel()->selectedRows() };
 
  194  if ( !selectedIndexes.isEmpty() )
 
  196    for ( 
const auto &selectedIndex : std::as_const( selectedIndexes ) )
 
  200      QString layerName = metadataResult.
title();
 
  201      if ( layerName.isEmpty() )
 
  204        if ( components.contains( QStringLiteral( 
"layerName" ) ) )
 
  206          layerName = components.value( QStringLiteral( 
"layerName" ) ).toString();
 
  208        else if ( components.contains( QStringLiteral( 
"table" ) ) )
 
  210          layerName = components.value( QStringLiteral( 
"table" ) ).toString();
 
  214          layerName = metadataResult.identifier();
 
  218      switch ( metadataResult.layerType() )
 
  223          emit 
addRasterLayer( metadataResult.uri(), layerName, metadataResult.dataProviderName() );
 
  225          emit 
addLayer( metadataResult.layerType(), metadataResult.uri(), layerName, metadataResult.dataProviderName() );
 
  231          emit 
addVectorLayer( metadataResult.uri(), layerName, metadataResult.dataProviderName() );
 
  233          emit 
addLayer( metadataResult.layerType(), metadataResult.uri(), layerName, metadataResult.dataProviderName() );
 
  239          emit 
addMeshLayer( metadataResult.uri(), layerName, metadataResult.dataProviderName() );
 
  241          emit 
addLayer( metadataResult.layerType(), metadataResult.uri(), layerName, metadataResult.dataProviderName() );
 
 
  256  mSearchFilterLineEdit->clear();
 
  257  mExtentFilterComboBox->setCurrentIndex( 0 );
 
 
  262  QgsAbstractDataSourceWidget::showEvent( event );
 
  263  mSearchFilterLineEdit->setText( mProxyModel->
filterString() );
 
 
  267void QgsLayerMetadataSearchWidget::showHelp()
 
  269  QgsHelp::openHelp( QStringLiteral( 
"managing_data_source/opening_data.html#the-layer-metadata-search-panel" ) );
 
  272void QgsLayerMetadataSearchWidget::refreshInternal()
 
  274  if ( mReloadRequired && isVisible() )
 
  277    mSourceModel->reloadAsync();
 
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
 
@ Mesh
Mesh layer. Added in QGIS 3.2.
 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
 
static Q_INVOKABLE QgsCoordinateReferenceSystem fromEpsgId(long epsg)
Creates a CRS from a given EPSG ID.
 
void cleared()
Emitted when the widget is cleared.
 
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
 
static QIcon iconForGeometryType(Qgis::GeometryType typeGroup)
Returns the icon for a vector layer whose geometry typeGroup is provided.
 
Map canvas is a class for displaying all GIS data types on a canvas.
 
void extentsChanged()
Emitted when the extents of the map change.
 
QgsReferencedRectangle fullExtent() const
Returns the full extent of the project, which represents the maximal limits of the project.
 
void layersRemoved(const QStringList &layerIds)
Emitted after one or more layers were removed from the registry.
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
QgsCoordinateTransformContext transformContext
 
const QgsProjectViewSettings * viewSettings() const
Returns the project's view settings, which contains settings and properties relating to how a QgsProj...
 
void layersAdded(const QList< QgsMapLayer * > &layers)
Emitted when one or more layers were added to the registry.
 
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
 
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
 
WidgetMode
Different ways a source select dialog can be used.
 
A rectangle specified with double values.
 
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
 
A QgsRectangle with associated coordinate reference system.
 
static Q_INVOKABLE QString geometryDisplayString(Qgis::GeometryType type)
Returns a display string for a geometry type.
 
#define Q_NOWARN_DEPRECATED_POP
 
#define Q_NOWARN_DEPRECATED_PUSH
 
QgsCoordinateTransformContext transformContext
Coordinate transform context.