Skip to content
Permalink
Browse files

Add hasChildren to browser proxy model

this to allow filtering out layers
  • Loading branch information
elpaso committed Mar 10, 2020
1 parent 867d0f6 commit d1404ac5ae53764c956179e7970e5f21bbad106a
@@ -174,6 +174,9 @@ Sets show layers to ``showLayers``
virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const;


public:
virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;

};

/************************************************************************
@@ -284,3 +284,15 @@ void QgsBrowserProxyModel::setDataItemProviderKeyFilter( const QStringList &filt
mHiddenDataItemsKeys = filter;
invalidateFilter();
}


bool QgsBrowserProxyModel::hasChildren( const QModelIndex &parent ) const
{
bool isFertile { QSortFilterProxyModel::hasChildren( parent ) };
if ( isFertile && ! mShowLayers && parent.isValid() )
{
QgsDataItem *item = dataItem( parent );
return ! item->layerCollection();
}
return isFertile;
}
@@ -216,6 +216,10 @@ class CORE_EXPORT QgsBrowserProxyModel : public QSortFilterProxyModel
bool filterRootAcceptsProviderKey( const QModelIndex &sourceIndex ) const;



// QAbstractItemModel interface
public:
bool hasChildren( const QModelIndex &parent = QModelIndex() ) const override;
};

#endif // QGSBROWSERPROXYMODEL_H

0 comments on commit d1404ac

Please sign in to comment.
You can’t perform that action at this time.