Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a new filter for WritableLayers to QgsMapLayerProxyModel
  • Loading branch information
m-kuhn committed Mar 29, 2016
1 parent 93e73ac commit ae7b657
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions python/gui/qgsmaplayerproxymodel.sip
Expand Up @@ -20,6 +20,7 @@ class QgsMapLayerProxyModel : QSortFilterProxyModel
HasGeometry,
VectorLayer,
PluginLayer,
WritableLayer,
All
};
typedef QFlags<QgsMapLayerProxyModel::Filter> Filters;
Expand Down
6 changes: 5 additions & 1 deletion src/gui/qgsmaplayerproxymodel.cpp
Expand Up @@ -84,6 +84,11 @@ bool QgsMapLayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex
if ( mExceptList.contains( layer ) )
return false;

QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( layer );

if ( mFilters.testFlag( WritableLayer ) && layer->readOnly() )
return false;

// layer type
if (( mFilters.testFlag( RasterLayer ) && layer->type() == QgsMapLayer::RasterLayer ) ||
( mFilters.testFlag( VectorLayer ) && layer->type() == QgsMapLayer::VectorLayer ) ||
Expand All @@ -98,7 +103,6 @@ bool QgsMapLayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex
mFilters.testFlag( HasGeometry );
if ( detectGeometry && layer->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer );
if ( vl )
{
if ( mFilters.testFlag( HasGeometry ) && vl->hasGeometryType() )
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsmaplayerproxymodel.h
Expand Up @@ -46,6 +46,7 @@ class GUI_EXPORT QgsMapLayerProxyModel : public QSortFilterProxyModel
HasGeometry = PointLayer | LineLayer | PolygonLayer,
VectorLayer = NoGeometry | HasGeometry,
PluginLayer = 32,
WritableLayer = 64,
All = RasterLayer | VectorLayer | PluginLayer
};
Q_DECLARE_FLAGS( Filters, Filter )
Expand Down

0 comments on commit ae7b657

Please sign in to comment.