25 connect(
this,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutComboBox::indexChanged );
31 mModel->deleteLater();
33 mProxyModel->deleteLater();
37 mProxyModel->setSourceModel( mModel );
39 connect( mProxyModel, &QAbstractItemModel::rowsInserted,
this, &QgsLayoutComboBox::rowsChanged );
40 connect( mProxyModel, &QAbstractItemModel::rowsRemoved,
this, &QgsLayoutComboBox::rowsChanged );
41 setModel( mProxyModel );
42 mProxyModel->sort( 0, Qt::AscendingOrder );
73 QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
74 if ( proxyIdx.isValid() )
76 setCurrentIndex( proxyIdx.row() );
85 return layout( currentIndex() );
88 void QgsLayoutComboBox::indexChanged(
int i )
94 void QgsLayoutComboBox::rowsChanged()
101 else if ( count() == 0 )
109 const QModelIndex proxyIndex = mProxyModel->index( index, 0 );
110 if ( !proxyIndex.isValid() )
115 QModelIndex sourceIndex = mProxyModel->mapToSource( proxyIndex );
116 if ( !sourceIndex.isValid() )
bool allowEmptyLayout() const
Returns true if the combobox includes the empty layout ("not set") choice.
void setLayoutManager(QgsLayoutManager *manager)
Sets the layout manager containing the layouts to list in the combo box.
void layoutChanged(QgsMasterLayoutInterface *layout)
Emitted whenever the currently selected layout changes.
QgsMasterLayoutInterface * currentLayout() const
Returns the layout currently selected in the combo box.
QgsLayoutComboBox(QWidget *parent=nullptr, QgsLayoutManager *manager=nullptr)
QgsLayoutComboBox creates a combo box to display a list of items in a layout manager.
void setCurrentLayout(QgsMasterLayoutInterface *layout)
Sets the currently selected layout in the combo box.
void setAllowEmptyLayout(bool allowEmpty)
Sets whether an optional empty layout ("not set") option is present in the combobox.
QgsLayoutManagerProxyModel::Filters filters() const
Returns the current filters used for filtering available layouts.
void setFilters(QgsLayoutManagerProxyModel::Filters filters)
Sets the current filters used for filtering available layouts.
QgsMasterLayoutInterface * layout(int index) const
Returns the layout at the specified index.
List model representing the print layouts and reports available in a layout manager.
QModelIndex indexFromLayout(QgsMasterLayoutInterface *layout) const
Returns the model index corresponding to a layout.
QgsMasterLayoutInterface * layoutFromIndex(const QModelIndex &index) const
Returns the layout at the corresponding index.
void setAllowEmptyLayout(bool allowEmpty)
Sets whether an optional empty layout ("not set") option is present in the model.
bool allowEmptyLayout() const
Returns true if the model allows the empty layout ("not set") choice.
QSortFilterProxyModel subclass for QgsLayoutManagerModel.
void setFilters(QgsLayoutManagerProxyModel::Filters filters)
Sets the current filters used for filtering available layouts.
QgsLayoutManagerProxyModel::Filters filters() const
Returns the current filters used for filtering available layouts.
Manages storage of a set of layouts.
Interface for master layout type objects, such as print layouts and reports.