Skip to content

Commit

Permalink
Merge pull request #5097 from nyalldawson/fix_16924
Browse files Browse the repository at this point in the history
Fix missing entries from composer map combo boxes (fixes #16924)
  • Loading branch information
nyalldawson committed Aug 31, 2017
2 parents 4514c69 + 02c095b commit aec8cd3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
1 change: 0 additions & 1 deletion python/core/composer/qgscomposermodel.sip
Expand Up @@ -283,7 +283,6 @@ class QgsComposerProxyModel: QSortFilterProxyModel

protected:
bool filterAcceptsRow( int source_row, const QModelIndex & source_parent ) const;
bool lessThan( const QModelIndex &left, const QModelIndex &right ) const;

};

19 changes: 3 additions & 16 deletions src/core/composer/qgscomposermodel.cpp
Expand Up @@ -961,29 +961,16 @@ QgsComposerProxyModel::QgsComposerProxyModel( QgsComposition *composition, QObje
// WARNING: the below code triggers a Qt bug (tested on Qt 4.8, can't reproduce on Qt5) whenever the QgsComposerModel source model
// calls beginInsertRows - since it's non functional anyway it's now disabled
// PLEASE verify that the Qt issue is fixed before reenabling

setDynamicSortFilter( true );
#if 0
// TODO doesn't seem to work correctly - not updated when item changes
setDynamicSortFilter( true );
setSortLocaleAware( true );
sort( QgsComposerModel::ItemId );
#endif
}

bool QgsComposerProxyModel::lessThan( const QModelIndex &left, const QModelIndex &right ) const
{
//sort by item id
const QgsComposerItem* item1 = itemFromSourceIndex( left );
const QgsComposerItem* item2 = itemFromSourceIndex( right );
if ( !item1 )
return false;

if ( !item2 )
return true;

return QString::localeAwareCompare( item1->displayName(), item2->displayName() ) < 0;
}

QgsComposerItem* QgsComposerProxyModel::itemFromSourceIndex( const QModelIndex &sourceIndex ) const
QgsComposerItem *QgsComposerProxyModel::itemFromSourceIndex( const QModelIndex &sourceIndex ) const
{
if ( !mComposition )
return nullptr;
Expand Down
3 changes: 1 addition & 2 deletions src/core/composer/qgscomposermodel.h
Expand Up @@ -347,8 +347,7 @@ class CORE_EXPORT QgsComposerProxyModel: public QSortFilterProxyModel
QgsComposerItem* itemFromSourceIndex( const QModelIndex& sourceIndex ) const;

protected:
bool filterAcceptsRow( int source_row, const QModelIndex & source_parent ) const override;
bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;

private:
QgsComposition* mComposition;
Expand Down
1 change: 0 additions & 1 deletion src/gui/qgscomposeritemcombobox.cpp
Expand Up @@ -36,7 +36,6 @@ void QgsComposerItemComboBox::setComposition( QgsComposition *composition )
connect( mProxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( rowsChanged() ) );
setModel( mProxyModel );
setModelColumn( QgsComposerModel::ItemId );
mProxyModel->sort( 0, Qt::AscendingOrder );
}

void QgsComposerItemComboBox::setItem( const QgsComposerItem* item )
Expand Down

0 comments on commit aec8cd3

Please sign in to comment.