Skip to content
Permalink
Browse files

Add a new filter for WritableLayers to QgsMapLayerProxyModel

  • Loading branch information
m-kuhn committed Mar 29, 2016
1 parent 93e73ac commit ae7b657da35aed2dc8665192f4a13c04e752ca05
Showing with 7 additions and 1 deletion.
  1. +1 −0 python/gui/qgsmaplayerproxymodel.sip
  2. +5 −1 src/gui/qgsmaplayerproxymodel.cpp
  3. +1 −0 src/gui/qgsmaplayerproxymodel.h
@@ -20,6 +20,7 @@ class QgsMapLayerProxyModel : QSortFilterProxyModel
HasGeometry,
VectorLayer,
PluginLayer,
WritableLayer,
All
};
typedef QFlags<QgsMapLayerProxyModel::Filter> Filters;
@@ -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 ) ||
@@ -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() )
@@ -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 )

0 comments on commit ae7b657

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