21 : QSortFilterProxyModel( parent )
22 , mFilters( AllTypes )
25 setSourceModel( mModel );
35bool QgsFieldProxyModel::isReadOnly(
const QModelIndex &index )
const
83 const QModelIndex index = sourceModel()->index( source_row, 0, source_parent );
85 if ( mFilters.testFlag(
HideReadOnly ) && isReadOnly( index ) )
104 if ( mFilters.testFlag(
AllTypes ) )
114 const QMetaType::Type type =
static_cast<QMetaType::Type
>( typeVar.toInt( &ok ) );
118 if ( ( mFilters.testFlag(
String ) && type == QMetaType::Type::QString ) ||
119 ( mFilters.testFlag(
LongLong ) && type == QMetaType::Type::LongLong ) ||
120 ( mFilters.testFlag(
Int ) && type == QMetaType::Type::Int ) ||
121 ( mFilters.testFlag(
Double ) && type == QMetaType::Type::Double ) ||
122 ( mFilters.testFlag(
Date ) && type == QMetaType::Type::QDate ) ||
123 ( mFilters.testFlag(
Date ) && type == QMetaType::Type::QDateTime ) ||
124 ( mFilters.testFlag(
DateTime ) && type == QMetaType::Type::QDateTime ) ||
125 ( mFilters.testFlag(
Time ) && type == QMetaType::Type::QTime ) ||
126 ( mFilters.testFlag(
Binary ) && type == QMetaType::Type::QByteArray ) ||
127 ( mFilters.testFlag(
Boolean ) && type == QMetaType::Type::Bool ) )
151 return leftId < rightId;
@ Provider
Field originates from the underlying data provider of the vector layer.
@ Edit
Field has been temporarily added in editing mode.
@ Unknown
The field origin has not been specified.
@ Expression
Field is calculated from an expression.
@ Join
Field originates from a joined layer.
The QgsFieldModel class is a model to display the list of fields in widgets (optionally associated wi...
@ FieldIsWidgetEditable
true if a is editable from the widget
@ FieldOrigin
Return the field origin (if a field, returns QVariant if expression)
@ IsEmpty
Return if the index corresponds to the empty value.
@ FieldIndex
Return field index if index corresponds to a field.
@ EditorWidgetType
Editor widget type.
@ FieldType
Return the field type (if a field, return QVariant if expression)
@ JoinedFieldIsEditable
true if a joined field is editable (returns QVariant if not a joined field)
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer.
@ DateTime
Datetime fields.
@ HideReadOnly
Hide read-only fields.
@ LongLong
Longlong fields.
@ AllTypes
All field types.
@ Date
Date or datetime fields.
@ Binary
Binary fields, since QGIS 3.34.
@ Boolean
Boolean fields, since QGIS 3.34.
@ OriginProvider
Fields with a provider origin, since QGIS 3.38.
const Filters & filters() const
Returns the filters controlling displayed fields.
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
QgsFieldProxyModel(QObject *parent=nullptr)
QgsFieldProxModel creates a proxy model with a QgsFieldModel as source model.
QgsFieldProxyModel * setFilters(QgsFieldProxyModel::Filters filters)
Set flags that affect how fields are filtered in the model.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.