16#include "moc_qgslayoutlegendlayersdialog.cpp"
18#include <QStandardItem>
32 mFilterLineEdit->setShowClearButton(
true );
33 mFilterLineEdit->setShowSearchIcon(
true );
36 listMapLayers->setModel( mModel );
37 const QModelIndex firstLayer = mModel->index( 0, 0 );
38 listMapLayers->selectionModel()->select( firstLayer, QItemSelectionModel::Select );
40 connect( listMapLayers, &QListView::doubleClicked,
this, &QgsLayoutLegendLayersDialog::accept );
43 connect( mCheckBoxVisibleLayers, &QCheckBox::toggled,
this, &QgsLayoutLegendLayersDialog::filterVisible );
44 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutLegendLayersDialog::showHelp );
46 mFilterLineEdit->setFocus();
51 mVisibleLayers = layers;
56 QList< QgsMapLayer * > layers;
58 const QModelIndexList selection = listMapLayers->selectionModel()->selectedIndexes();
59 for (
const QModelIndex &index : selection )
61 const QModelIndex sourceIndex = mModel->mapToSource( index );
62 if ( !sourceIndex.isValid() )
74void QgsLayoutLegendLayersDialog::filterVisible(
bool enabled )
82void QgsLayoutLegendLayersDialog::showHelp()
84 QgsHelp::openHelp( QStringLiteral(
"print_composer/composer_items/composer_legend.html#legend-items" ) );
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
void setVisibleLayers(const QList< QgsMapLayer * > &layers)
Sets a list of visible layers, to use for filtering within the dialog.
QList< QgsMapLayer * > selectedLayers() const
Returns the list of selected layers.
QgsLayoutLegendLayersDialog(QWidget *parent=nullptr)
constructor
QgsMapLayer * layerFromIndex(const QModelIndex &index) const
Returns the map layer corresponding to the specified index.
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
void setFilterString(const QString &filter)
Sets a filter string, such that only layers with names matching the specified string will be shown.
QgsMapLayerModel * sourceLayerModel() const
layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel
void setLayerAllowlist(const QList< QgsMapLayer * > &layers)
Sets an allowlist of layers to include within the model.
Base class for all map layer types.