QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsfieldproxymodel.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfieldproxymodel.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 QGSFIELDPROXYMODEL_H
17 #define QGSFIELDPROXYMODEL_H
18 
19 #include <QSortFilterProxyModel>
20 
21 #include "qgsfieldmodel.h"
22 
27 class GUI_EXPORT QgsFieldProxyModel : public QSortFilterProxyModel
28 {
29  Q_OBJECT
30  Q_FLAGS( Filters )
31 
32  public:
33  enum Filter
34  {
35  String = 1,
36  Int = 2,
37  LongLong = 4,
38  Double = 8,
39  Numeric = Int | LongLong | Double,
40  Date = 16,
41  All = Numeric | Date | String
42  };
43  Q_DECLARE_FLAGS( Filters, Filter )
44 
45 
49  explicit QgsFieldProxyModel( QObject *parent = 0 );
50 
52  QgsFieldModel* sourceFieldModel() { return mModel; }
53 
59  QgsFieldProxyModel* setFilters( Filters filters );
60  const Filters& filters() const { return mFilters; }
61 
62  private:
63  Filters mFilters;
64  QgsFieldModel* mModel;
65 
66  // QSortFilterProxyModel interface
67  public:
68  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const;
69  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const;
70 };
71 
72 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFieldProxyModel::Filters )
73 
74 #endif // QGSFIELDPROXYMODEL_H