QGIS API Documentation  2.9.0-Master
qgsmaplayerproxymodel.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaplayerproxymodel.h
3  --------------------------------------
4  Date : 01.04.2014
5  Copyright : (C) 2014 Denis Rouzaud
6  Email : denis.rouzaud@gmail.com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15 
16 #ifndef QGSMAPLAYERPROXYMODEL_H
17 #define QGSMAPLAYERPROXYMODEL_H
18 
19 #include <QSortFilterProxyModel>
20 
21 class QgsMapLayerModel;
22 class QgsMapLayer;
23 
28 class GUI_EXPORT QgsMapLayerProxyModel : public QSortFilterProxyModel
29 {
30  Q_OBJECT
31  Q_FLAGS( Filters )
32  public:
33  enum Filter
34  {
35  RasterLayer = 1,
36  NoGeometry = 2,
37  PointLayer = 4,
38  LineLayer = 8,
39  PolygonLayer = 16,
40  HasGeometry = PointLayer | LineLayer | PolygonLayer,
41  VectorLayer = NoGeometry | HasGeometry,
42  PluginLayer = 32,
43  All = RasterLayer | PolygonLayer | PluginLayer
44  };
45  Q_DECLARE_FLAGS( Filters, Filter )
46 
47 
51  explicit QgsMapLayerProxyModel( QObject *parent = 0 );
52 
56  QgsMapLayerModel* sourceLayerModel() const { return mModel; }
57 
63  QgsMapLayerProxyModel* setFilters( Filters filters );
64  const Filters& filters() const { return mFilters; }
65 
67  void setExceptedLayerList( QList<QgsMapLayer*> exceptList );
68  QList<QgsMapLayer*> exceptedLayerList() {return mExceptList;}
69 
70  private:
71  Filters mFilters;
72  QList<QgsMapLayer*> mExceptList;
73  QgsMapLayerModel* mModel;
74 
75  // QSortFilterProxyModel interface
76  public:
77  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
78  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
79 };
80 
81 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayerProxyModel::Filters )
82 
83 #endif // QGSMAPLAYERPROXYMODEL_H
QList< QgsMapLayer * > exceptedLayerList()
Base class for all map layer types.
Definition: qgsmaplayer.h:49
The QgsMapLayerModel class is a model to display layers in widgets.
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
const Filters & filters() const