Skip to content


[layouts] Add search filter box to 'add layer to legend' dialog
Browse files Browse the repository at this point in the history
Helps with finding specific layers in large projects
  • Loading branch information
nyalldawson committed Aug 22, 2018
1 parent 16b58b9 commit 8c5938a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/app/layout/qgslayoutlegendlayersdialog.cpp
Expand Up @@ -27,12 +27,17 @@ QgsLayoutLegendLayersDialog::QgsLayoutLegendLayersDialog( QWidget *parent )
QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/LayoutLegendLayers/geometry" ) ).toByteArray() );

mFilterLineEdit->setShowClearButton( true );
mFilterLineEdit->setShowSearchIcon( true );

mModel = new QgsMapLayerProxyModel( listMapLayers );
listMapLayers->setModel( mModel );
QModelIndex firstLayer = mModel->index( 0, 0 );
listMapLayers->selectionModel()->select( firstLayer, QItemSelectionModel::Select );

connect( listMapLayers, &QListView::doubleClicked, this, &QgsLayoutLegendLayersDialog::accept );

connect( mFilterLineEdit, &QLineEdit::textChanged, mModel, &QgsMapLayerProxyModel::setFilterString );

Expand Down
25 changes: 23 additions & 2 deletions src/ui/layout/qgslayoutlegendlayersdialogbase.ui
Expand Up @@ -14,7 +14,10 @@
<string>Add Layer to Legend</string>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<property name="spacing">
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
Expand All @@ -24,15 +27,33 @@
<item row="0" column="0">
<item row="1" column="0">
<widget class="QListView" name="listMapLayers">
<property name="selectionMode">
<item row="0" column="0">
<widget class="QgsFilterLineEdit" name="mFilterLineEdit">
<property name="placeholderText">
Expand Down

0 comments on commit 8c5938a

Please sign in to comment.