Skip to content

Commit

Permalink
[gui] Lazy load layer metadata in datasource manager
Browse files Browse the repository at this point in the history
Fix #60018
  • Loading branch information
elpaso authored and nyalldawson committed Jan 28, 2025
1 parent 4a132cb commit 02d46a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gui/qgslayermetadatasearchwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ QgsLayerMetadataSearchWidget::QgsLayerMetadataSearchWidget( QWidget *parent, Qt:
} );

connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsLayerMetadataSearchWidget::showHelp );

// Start loading metadata in the model
mSourceModel->reloadAsync();
mIsLoading = true;
}

void QgsLayerMetadataSearchWidget::setMapCanvas( QgsMapCanvas *newMapCanvas )
Expand Down Expand Up @@ -185,6 +181,7 @@ void QgsLayerMetadataSearchWidget::updateExtentFilter( int index )

void QgsLayerMetadataSearchWidget::refresh()
{
mIsLoading = true;
mSourceModel->reloadAsync();
}

Expand Down Expand Up @@ -261,6 +258,12 @@ void QgsLayerMetadataSearchWidget::showEvent( QShowEvent *event )
{
QgsAbstractDataSourceWidget::showEvent( event );
mSearchFilterLineEdit->setText( mProxyModel->filterString() );
// The first show event triggers the metadata loading
if ( !mIsInitialized )
{
refresh();
mIsInitialized = true;
}
}

void QgsLayerMetadataSearchWidget::showHelp()
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgslayermetadatasearchwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class GUI_EXPORT QgsLayerMetadataSearchWidget : public QgsAbstractDataSourceWidg
private:
QgsLayerMetadataResultsProxyModel *mProxyModel = nullptr;
bool mIsLoading = false;
bool mIsInitialized = false;
QgsLayerMetadataResultsModel *mSourceModel = nullptr;

// QWidget interface
Expand Down

0 comments on commit 02d46a2

Please sign in to comment.