QGIS API Documentation  2.99.0-Master (9ed189e)
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 #include "qgis_gui.h"
21 
22 class QgsFieldModel;
23 
28 class GUI_EXPORT QgsFieldProxyModel : public QSortFilterProxyModel
29 {
30  Q_OBJECT
31  Q_FLAGS( Filters )
32 
33  public:
34 
36  enum Filter
37  {
38  String = 1,
39  Int = 2,
40  LongLong = 4,
41  Double = 8,
42  Numeric = Int | LongLong | Double,
43  Date = 16,
44  Time = 32,
45  HideReadOnly = 64,
46  AllTypes = Numeric | Date | String | Time,
47  };
48  Q_DECLARE_FLAGS( Filters, Filter )
49 
50 
54  explicit QgsFieldProxyModel( QObject *parent = nullptr );
55 
57  QgsFieldModel* sourceFieldModel() { return mModel; }
58 
64  QgsFieldProxyModel* setFilters( QgsFieldProxyModel::Filters filters );
65 
69  const Filters& filters() const { return mFilters; }
70 
71  private:
72  Filters mFilters;
73  QgsFieldModel* mModel = nullptr;
74 
76  bool isReadOnly( const QModelIndex& index ) const;
77 
78  // QSortFilterProxyModel interface
79  public:
80  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
81  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
82 };
83 
84 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFieldProxyModel::Filters )
85 
86 #endif // QGSFIELDPROXYMODEL_H
static unsigned index
QgsFieldModel * sourceFieldModel()
Returns the QgsFieldModel used in this QSortFilterProxyModel.
The QgsFieldModel class is a model to display the list of fields of a layer in widgets.
Definition: qgsfieldmodel.h:34
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.