QGIS API Documentation  2.99.0-Master (b058df7)
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 : 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 QGSFIELDPROXYMODEL_H
17 #define QGSFIELDPROXYMODEL_H
18 
19 #include <QSortFilterProxyModel>
20 
21 #include "qgis_core.h"
22 
23 #include "qgis.h"
24 
25 class QgsFieldModel;
26 
32 class CORE_EXPORT QgsFieldProxyModel : public QSortFilterProxyModel
33 {
34  Q_OBJECT
35  Q_FLAGS( Filters )
36 
37  public:
38 
40  enum Filter
41  {
42  String = 1,
43  Int = 2,
44  LongLong = 4,
45  Double = 8,
46  Numeric = Int | LongLong | Double,
47  Date = 16,
48  Time = 32,
49  HideReadOnly = 64,
50  AllTypes = Numeric | Date | String | Time,
51  };
52  Q_DECLARE_FLAGS( Filters, Filter )
53 
54 
58  explicit QgsFieldProxyModel( QObject *parent SIP_TRANSFERTHIS = nullptr );
59 
61  QgsFieldModel *sourceFieldModel() { return mModel; }
62 
68  QgsFieldProxyModel *setFilters( QgsFieldProxyModel::Filters filters );
69 
74  const Filters &filters() const { return mFilters; }
75 
76  private:
77  Filters mFilters;
78  QgsFieldModel *mModel = nullptr;
79 
81  bool isReadOnly( const QModelIndex &index ) const;
82 
83  // QSortFilterProxyModel interface
84  public:
85  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
86  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
87 };
88 
89 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFieldProxyModel::Filters )
90 
91 #endif // QGSFIELDPROXYMODEL_H
QgsFieldModel * sourceFieldModel()
Returns the QgsFieldModel used in this QSortFilterProxyModel.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
The QgsFieldModel class is a model to display the list of fields of a layer in widgets.
Definition: qgsfieldmodel.h:37
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer...
Filter
Field type filters.
const Filters & filters() const
Returns the filters controlling displayed fields.