QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
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 "qgis_core.h"
22 
23 #include "qgis_sip.h"
24 
25 class QgsFieldModel;
26 
31 class CORE_EXPORT QgsFieldProxyModel : public QSortFilterProxyModel
32 {
33  Q_OBJECT
34 
35  public:
36 
38  enum Filter SIP_ENUM_BASETYPE( IntFlag )
39  {
40  String = 1 << 0,
41  Int = 1 << 1,
42  LongLong = 1 << 2,
43  Double = 1 << 3,
44  Numeric = Int | LongLong | Double,
45  Date = 1 << 4,
46  Time = 1 << 5,
47  HideReadOnly = 1 << 6,
48  DateTime = 1 << 7,
49  Binary = 1 << 8,
50  Boolean = 1 << 9,
51  OriginProvider = 1 << 10,
52  AllTypes = Numeric | Date | String | Time | DateTime | Binary | Boolean,
53  };
54  Q_DECLARE_FLAGS( Filters, Filter )
55  Q_FLAG( Filters )
56 
57 
61  explicit QgsFieldProxyModel( QObject *parent SIP_TRANSFERTHIS = nullptr );
62 
64  QgsFieldModel *sourceFieldModel() { return mModel; }
65 
71  QgsFieldProxyModel *setFilters( QgsFieldProxyModel::Filters filters );
72 
77  const Filters &filters() const { return mFilters; }
78 
79  private:
80  Filters mFilters;
81  QgsFieldModel *mModel = nullptr;
82 
84  bool isReadOnly( const QModelIndex &index ) const;
85 
86  // QSortFilterProxyModel interface
87  public:
88  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
89  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
90 };
91 
93 
94 #endif // QGSFIELDPROXYMODEL_H
The QgsFieldModel class is a model to display the list of fields in widgets (optionally associated wi...
Definition: qgsfieldmodel.h:38
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer.
const Filters & filters() const
Returns the filters controlling displayed fields.
Filter
Field type filters.
QgsFieldModel * sourceFieldModel()
Returns the QgsFieldModel used in this QSortFilterProxyModel.
QFlags< Filter > Filters
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_ENUM_BASETYPE(type)
Definition: qgis_sip.h:278
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)