QGIS API Documentation  2.17.0-Master (872e6d2)
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 
35  enum Filter
36  {
37  String = 1,
38  Int = 2,
39  LongLong = 4,
40  Double = 8,
41  Numeric = Int | LongLong | Double,
42  Date = 16,
43  Time = 32,
44  HideReadOnly = 64,
45  All = Numeric | Date | String | Time, //TODO QGIS 3 - rename to AllTypes
46  };
47  Q_DECLARE_FLAGS( Filters, Filter )
48 
49 
53  explicit QgsFieldProxyModel( QObject *parent = nullptr );
54 
56  QgsFieldModel* sourceFieldModel() { return mModel; }
57 
63  QgsFieldProxyModel* setFilters( const QgsFieldProxyModel::Filters& filters );
64 
68  const Filters& filters() const { return mFilters; }
69 
70  private:
71  Filters mFilters;
72  QgsFieldModel* mModel;
73 
75  bool isReadOnly( const QModelIndex& index ) const;
76 
77  // QSortFilterProxyModel interface
78  public:
79  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
80  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
81 };
82 
83 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFieldProxyModel::Filters )
84 
85 #endif // QGSFIELDPROXYMODEL_H
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
static unsigned index
const Filters & filters() const
Returns the filters controlling displayed fields.
The QgsFieldModel class is a model to display the list of fields of a layer in widgets.
Definition: qgsfieldmodel.h:31
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer...
Filter
Field type filters.
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const