17 #include <QStandardItem> 30 mFilterLineEdit->setShowClearButton(
true );
31 mFilterLineEdit->setShowSearchIcon(
true );
34 listMapLayers->setModel( mModel );
35 QModelIndex firstLayer = mModel->index( 0, 0 );
36 listMapLayers->selectionModel()->select( firstLayer, QItemSelectionModel::Select );
38 connect( listMapLayers, &QListView::doubleClicked,
this, &QgsLayoutLegendLayersDialog::accept );
41 connect( mCheckBoxVisibleLayers, &QCheckBox::toggled,
this, &QgsLayoutLegendLayersDialog::filterVisible );
46 mVisibleLayers = layers;
51 QList< QgsMapLayer * > layers;
53 const QModelIndexList selection = listMapLayers->selectionModel()->selectedIndexes();
54 for (
const QModelIndex &index : selection )
56 const QModelIndex sourceIndex = mModel->mapToSource( index );
57 if ( !sourceIndex.isValid() )
69 void QgsLayoutLegendLayersDialog::filterVisible(
bool enabled )
QgsLayoutLegendLayersDialog(QWidget *parent=nullptr)
constructor
QgsMapLayer * layerFromIndex(const QModelIndex &index) const
Returns the map layer corresponding to the specified index.
Base class for all map layer types.
QList< QgsMapLayer *> selectedLayers() const
Returns the list of selected layers.
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 setVisibleLayers(const QList< QgsMapLayer *> &layers)
Sets a list of visible layers, to use for filtering within the dialog.
void setLayerWhitelist(const QList< QgsMapLayer *> &layers)
Sets a whitelist of layers to include within the model.
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...
void setFilterString(const QString &filter)
Sets a filter string, such that only layers with names matching the specified string will be shown...