18#include "moc_qgslayoutcombobox.cpp"
26 connect(
this,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutComboBox::indexChanged );
32 mModel->deleteLater();
34 mProxyModel->deleteLater();
38 mProxyModel->setSourceModel( mModel );
40 connect( mProxyModel, &QAbstractItemModel::rowsInserted,
this, &QgsLayoutComboBox::rowsChanged );
41 connect( mProxyModel, &QAbstractItemModel::rowsRemoved,
this, &QgsLayoutComboBox::rowsChanged );
42 setModel( mProxyModel );
43 mProxyModel->sort( 0, Qt::AscendingOrder );
74 const QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
75 if ( proxyIdx.isValid() )
77 setCurrentIndex( proxyIdx.row() );
86 return layout( currentIndex() );
89void QgsLayoutComboBox::indexChanged(
int i )
95void QgsLayoutComboBox::rowsChanged()
102 else if ( count() == 0 )
110 const QModelIndex proxyIndex = mProxyModel->index( index, 0 );
111 if ( !proxyIndex.isValid() )
116 const QModelIndex sourceIndex = mProxyModel->mapToSource( proxyIndex );
117 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.