17 #include <QStandardItem>
21 #include "qgssettings.h"
31 mFilterLineEdit->setShowClearButton(
true );
32 mFilterLineEdit->setShowSearchIcon(
true );
35 listMapLayers->setModel( mModel );
36 QModelIndex firstLayer = mModel->index( 0, 0 );
37 listMapLayers->selectionModel()->select( firstLayer, QItemSelectionModel::Select );
39 connect( listMapLayers, &QListView::doubleClicked,
this, &QgsLayoutLegendLayersDialog::accept );
42 connect( mCheckBoxVisibleLayers, &QCheckBox::toggled,
this, &QgsLayoutLegendLayersDialog::filterVisible );
43 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutLegendLayersDialog::showHelp );
45 mFilterLineEdit->setFocus();
50 mVisibleLayers = layers;
55 QList< QgsMapLayer * > layers;
57 const QModelIndexList selection = listMapLayers->selectionModel()->selectedIndexes();
58 for (
const QModelIndex &index : selection )
60 const QModelIndex sourceIndex = mModel->mapToSource( index );
61 if ( !sourceIndex.isValid() )
73 void QgsLayoutLegendLayersDialog::filterVisible(
bool enabled )
81 void QgsLayoutLegendLayersDialog::showHelp()
83 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...
QgsMapLayerModel * sourceLayerModel() const
layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel
void setFilterString(const QString &filter)
Sets a filter string, such that only layers with names matching the specified string will be shown.
void setLayerAllowlist(const QList< QgsMapLayer * > &layers)
Sets an allowlist of layers to include within the model.
Base class for all map layer types.