QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 : [email protected]
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 
27 class GUI_EXPORT QgsMapLayerProxyModel : public QSortFilterProxyModel
28 {
29  Q_OBJECT
30  Q_FLAGS( Filters )
31  public:
32  enum Filter
33  {
34  RasterLayer = 1,
35  NoGeometry = 2,
36  PointLayer = 4,
37  LineLayer = 8,
38  PolygonLayer = 16,
39  HasGeometry = PointLayer | LineLayer | PolygonLayer,
40  VectorLayer = NoGeometry | HasGeometry,
41  PluginLayer = 32,
42  All = RasterLayer | PolygonLayer | PluginLayer
43  };
44  Q_DECLARE_FLAGS( Filters, Filter )
45 
46 
50  explicit QgsMapLayerProxyModel( QObject *parent = 0 );
51 
55  QgsMapLayerModel* sourceLayerModel() const { return mModel; }
56 
62  QgsMapLayerProxyModel* setFilters( Filters filters );
63  const Filters& filters() const { return mFilters; }
64 
65  private:
66  Filters mFilters;
67  QgsMapLayerModel* mModel;
68 
69  // QSortFilterProxyModel interface
70  public:
71  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const;
72  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const;
73 };
74 
75 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayerProxyModel::Filters )
76 
77 #endif // QGSMAPLAYERPROXYMODEL_H