QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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
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
25class QgsFieldModel;
26
32class CORE_EXPORT QgsFieldProxyModel : public QSortFilterProxyModel
33{
34 Q_OBJECT
35
36 public:
37
39 enum Filter
40 {
41 String = 1,
42 Int = 2,
43 LongLong = 4,
44 Double = 8,
45 Numeric = Int | LongLong | Double,
46 Date = 16,
47 Time = 32,
48 HideReadOnly = 64,
49 DateTime = 128,
50 AllTypes = Numeric | Date | String | Time,
51 };
52 Q_DECLARE_FLAGS( Filters, Filter )
53 Q_FLAG( Filters )
54
55
59 explicit QgsFieldProxyModel( QObject *parent SIP_TRANSFERTHIS = nullptr );
60
62 QgsFieldModel *sourceFieldModel() { return mModel; }
63
69 QgsFieldProxyModel *setFilters( QgsFieldProxyModel::Filters filters );
70
75 const Filters &filters() const { return mFilters; }
76
77 private:
78 Filters mFilters;
79 QgsFieldModel *mModel = nullptr;
80
82 bool isReadOnly( const QModelIndex &index ) const;
83
84 // QSortFilterProxyModel interface
85 public:
86 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
87 bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
88};
89
90Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFieldProxyModel::Filters )
91
92#endif // QGSFIELDPROXYMODEL_H
The QgsFieldModel class is a model to display the list of fields in widgets (optionally associated wi...
Definition: qgsfieldmodel.h:39
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer.
QgsFieldModel * sourceFieldModel()
Returns the QgsFieldModel used in this QSortFilterProxyModel.
Filter
Field type filters.
const Filters & filters() const
Returns the filters controlling displayed fields.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.