Skip to content
Permalink
Browse files

[layouts] Add search filter box to 'add layer to legend' dialog

Helps with finding specific layers in large projects
  • Loading branch information
nyalldawson committed Aug 22, 2018
1 parent 16b58b9 commit 8c5938a96743758b5f07ea8fb3491cdad9344f1f
Showing with 28 additions and 2 deletions.
  1. +5 −0 src/app/layout/qgslayoutlegendlayersdialog.cpp
  2. +23 −2 src/ui/layout/qgslayoutlegendlayersdialogbase.ui
@@ -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 );
}

QgsLayoutLegendLayersDialog::~QgsLayoutLegendLayersDialog()
@@ -14,7 +14,10 @@
<string>Add Layer to Legend</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<property name="spacing">
<number>6</number>
</property>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -24,15 +27,33 @@
</property>
</widget>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QListView" name="listMapLayers">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QgsFilterLineEdit" name="mFilterLineEdit">
<property name="placeholderText">
<string>Search</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsFilterLineEdit</class>
<extends>QLineEdit</extends>
<header>qgsfilterlineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mFilterLineEdit</tabstop>
<tabstop>listMapLayers</tabstop>
</tabstops>
<resources/>
<connections>
<connection>

0 comments on commit 8c5938a

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