Skip to content

Commit

Permalink
rename filters in map layer proxy model
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 12, 2014
1 parent afc2e05 commit 6765a7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
17 changes: 9 additions & 8 deletions python/gui/qgsmaplayerproxymodel.sip
Expand Up @@ -12,14 +12,15 @@ class QgsMapLayerProxyModel : QSortFilterProxyModel
public:
enum Filter
{
NoFilter = 1,
RasterLayer = 2,
NoGeometry = 4,
PointLayer = 8,
LineLayer = 16,
PolygonLayer = 32,
HasGeometry = 56,
VectorLayer = 60
RasterLayer = 1,
NoGeometry = 2,
PointLayer = 4,
LineLayer = 8,
PolygonLayer = 16,
HasGeometry = 28,
VectorLayer = 30,
PluginLayer = 32,
All = 63
};
typedef QFlags<QgsMapLayerProxyModel::Filter> Filters;

Expand Down
7 changes: 4 additions & 3 deletions src/gui/qgsmaplayerproxymodel.cpp
Expand Up @@ -20,7 +20,7 @@

QgsMapLayerProxyModel::QgsMapLayerProxyModel( QObject *parent )
: QSortFilterProxyModel( parent )
, mFilters( NoFilter )
, mFilters( All )
, mModel( new QgsMapLayerModel( this ) )
{
setSourceModel( mModel );
Expand All @@ -34,7 +34,7 @@ QgsMapLayerProxyModel *QgsMapLayerProxyModel::setFilters( Filters filters )

bool QgsMapLayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
{
if ( mFilters.testFlag( NoFilter ) )
if ( mFilters.testFlag( All ) )
return true;

QModelIndex index = sourceModel()->index( source_row, 0, source_parent );
Expand All @@ -44,7 +44,8 @@ bool QgsMapLayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex

// layer type
if (( mFilters.testFlag( RasterLayer ) && layer->type() == QgsMapLayer::RasterLayer ) ||
( mFilters.testFlag( VectorLayer ) && layer->type() == QgsMapLayer::VectorLayer ) )
( mFilters.testFlag( VectorLayer ) && layer->type() == QgsMapLayer::VectorLayer ) ||
( mFilters.testFlag( PluginLayer ) && layer->type() == QgsMapLayer::PluginLayer ) )
return true;

// geometry type
Expand Down
15 changes: 8 additions & 7 deletions src/gui/qgsmaplayerproxymodel.h
Expand Up @@ -30,14 +30,15 @@ class GUI_EXPORT QgsMapLayerProxyModel : public QSortFilterProxyModel
public:
enum Filter
{
NoFilter = 1,
RasterLayer = 2,
NoGeometry = 4,
PointLayer = 8,
LineLayer = 16,
PolygonLayer = 32,
RasterLayer = 1,
NoGeometry = 2,
PointLayer = 4,
LineLayer = 8,
PolygonLayer = 16,
HasGeometry = PointLayer | LineLayer | PolygonLayer,
VectorLayer = NoGeometry | HasGeometry
VectorLayer = NoGeometry | HasGeometry,
PluginLayer = 32,
All = RasterLayer | PolygonLayer | PluginLayer
};
Q_DECLARE_FLAGS( Filters, Filter )

Expand Down

0 comments on commit 6765a7c

Please sign in to comment.