Skip to content

Commit

Permalink
Fix loss of layout item combo box filters
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 11, 2019
1 parent 41d8a9c commit d890084
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/gui/layout/qgslayoutitemcombobox.cpp
Expand Up @@ -28,13 +28,16 @@ QgsLayoutItemComboBox::QgsLayoutItemComboBox( QWidget *parent, QgsLayout *layout
void QgsLayoutItemComboBox::setCurrentLayout( QgsLayout *layout )
{
const bool prevAllowEmpty = mProxyModel && mProxyModel->allowEmptyItem();
int itemType = mProxyModel ? mProxyModel->filterType() : -1;
mProxyModel = qgis::make_unique< QgsLayoutProxyModel >( layout, this );
connect( mProxyModel.get(), &QAbstractItemModel::rowsInserted, this, &QgsLayoutItemComboBox::rowsChanged );
connect( mProxyModel.get(), &QAbstractItemModel::rowsRemoved, this, &QgsLayoutItemComboBox::rowsChanged );
setModel( mProxyModel.get() );
setModelColumn( QgsLayoutModel::ItemId );
mProxyModel->sort( QgsLayoutModel::ItemId, Qt::AscendingOrder );
mProxyModel->setAllowEmptyItem( prevAllowEmpty );
if ( itemType >= 0 )
mProxyModel->setFilterType( static_cast< QgsLayoutItemRegistry::ItemType >( itemType ) );
}

QgsLayout *QgsLayoutItemComboBox::currentLayout()
Expand Down

0 comments on commit d890084

Please sign in to comment.