25#include <QStandardItem>
28#include "moc_qgslayoutlegendlayersdialog.cpp"
30using namespace Qt::StringLiterals;
38 mFilterLineEdit->setShowClearButton(
true );
39 mFilterLineEdit->setShowSearchIcon(
true );
42 listMapLayers->setModel( mModel );
43 const QModelIndex firstLayer = mModel->index( 0, 0 );
44 listMapLayers->selectionModel()->select( firstLayer, QItemSelectionModel::Select );
46 connect( listMapLayers, &QListView::doubleClicked,
this, &QgsLayoutLegendLayersDialog::accept );
49 connect( mCheckBoxVisibleLayers, &QCheckBox::toggled,
this, &QgsLayoutLegendLayersDialog::filterVisible );
50 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutLegendLayersDialog::showHelp );
52 mFilterLineEdit->setFocus();
57 mVisibleLayers = layers;
62 QList<QgsMapLayer *> layers;
64 const QModelIndexList selection = listMapLayers->selectionModel()->selectedIndexes();
65 for (
const QModelIndex &index : selection )
67 const QModelIndex sourceIndex = mModel->mapToSource( index );
68 if ( !sourceIndex.isValid() )
73 QgsMapLayer *layer = mModel->sourceLayerModel()->layerFromIndex( sourceIndex );
80void QgsLayoutLegendLayersDialog::filterVisible(
bool enabled )
88void QgsLayoutLegendLayersDialog::showHelp()
90 QgsHelp::openHelp( u
"print_composer/composer_items/composer_legend.html#legend-items"_s );
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, QgsProject *project)
Constructor, taking layers from project.
A proxy model which provides an easy to use model to display the list of layers in widgets.
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.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...