1/************************************************************************ 2 * This file has been generated automatically from * 3 * * 4 * src/core/qgsfieldmodel.h * 5 * * 6 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 7 ************************************************************************/ 8 9 10 11 12 13 14class QgsFieldModel : QAbstractItemModel 15{ 16%Docstring(signature="appended") 17The :py:class:`QgsFieldModel` class is a model to display the list of fields in widgets 18(optionally associated with a vector layer). 19If allowed, expressions might be added to the end of the model. 20It can be associated with a :py:class:`QgsMapLayerModel` to dynamically display a layer and its fields. 21 22.. versionadded:: 2.3 23%End 24 25%TypeHeaderCode 26#include "qgsfieldmodel.h" 27%End 28 public: 29 30 enum FieldRoles 31 { 32 FieldNameRole, 33 FieldIndexRole, 34 ExpressionRole, 35 IsExpressionRole, 36 ExpressionValidityRole, 37 FieldTypeRole, 38 FieldOriginRole, 39 IsEmptyRole, 40 EditorWidgetType, 41 JoinedFieldIsEditable, 42 FieldIsWidgetEditable, 43 }; 44 45 explicit QgsFieldModel( QObject *parent /TransferThis/ = 0 ); 46%Docstring 47Constructor for QgsFieldModel - creates a model to display the fields of a given layer. 48%End 49 50 QModelIndex indexFromName( const QString &fieldName ); 51%Docstring 52Returns the index corresponding to a given fieldName. 53%End 54 55 void setAllowExpression( bool allowExpression ); 56%Docstring 57Sets whether custom expressions are accepted and displayed in the model. 58 59.. seealso:: :py:func:`allowExpression` 60 61.. seealso:: :py:func:`setExpression` 62%End 63 64 bool allowExpression(); 65%Docstring 66Returns ``True`` if the model allows custom expressions to be created and displayed. 67 68.. seealso:: :py:func:`setAllowExpression` 69%End 70 71 void setAllowEmptyFieldName( bool allowEmpty ); 72%Docstring 73Sets whether an optional empty field ("not set") option is present in the model. 74 75.. seealso:: :py:func:`allowEmptyFieldName` 76 77.. versionadded:: 3.0 78%End 79 80 bool allowEmptyFieldName() const; 81%Docstring 82Returns ``True`` if the model allows the empty field ("not set") choice. 83 84.. seealso:: :py:func:`setAllowEmptyFieldName` 85 86.. versionadded:: 3.0 87%End 88 89 bool isField( const QString &expression ) const; 90%Docstring 91Returns ``True`` if a string represents a field reference, or ``False`` if it is an 92expression consisting of more than direct field reference. 93%End 94 95 void setExpression( const QString &expression ); 96%Docstring 97Sets a single expression to be added after the fields at the end of the model. 98 99.. seealso:: :py:func:`setAllowExpression` 100 101.. seealso:: :py:func:`allowExpression` 102 103.. seealso:: :py:func:`removeExpression` 104%End 105 106 void removeExpression(); 107%Docstring 108Removes any custom expression from the model. 109 110.. seealso:: :py:func:`setExpression` 111 112.. seealso:: :py:func:`allowExpression` 113%End 114 115 QgsVectorLayer *layer(); 116%Docstring 117Returns the layer associated with the model. 118 119.. seealso:: :py:func:`setLayer` 120%End 121 122 virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const; 123 124 virtual QModelIndex parent( const QModelIndex &child ) const; 125 126 virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; 127 128 virtual int columnCount( const QModelIndex &parent ) const; 129 130 virtual QVariant data( const QModelIndex &index, int role ) const; 131 132 133 static QString fieldToolTip( const QgsField &field ); 134%Docstring 135Returns a HTML formatted tooltip string for a ``field``, containing details 136like the field name, alias and type. 137 138.. versionadded:: 3.0 139%End 140 141 static QString fieldToolTipExtended( const QgsField &field, const QgsVectorLayer *layer ); 142%Docstring 143Returns a HTML formatted tooltip string for a ``field``, containing details 144like the field name, alias, type and expression. 145 146.. versionadded:: 3.14 147%End 148 149 void setFields( const QgsFields &fields ); 150%Docstring 151Manually sets the ``fields`` to use for the model. 152 153This method should only be used when the model ISN'T associated with a :py:func:`~QgsFieldModel.layer` 154and needs to show the fields from an arbitrary field collection instead. Calling 155:py:func:`~QgsFieldModel.setFields` will automatically clear any existing :py:func:`~QgsFieldModel.layer`. 156 157.. seealso:: :py:func:`fields` 158 159.. versionadded:: 3.14 160%End 161 162 QgsFields fields() const; 163%Docstring 164Returns the fields currently shown in the model. 165 166This will either be fields from the associated :py:func:`~QgsFieldModel.layer` or the fields 167manually set by a call to :py:func:`~QgsFieldModel.setFields`. 168 169.. versionadded:: 3.14 170%End 171 172 public slots: 173 174 void setLayer( QgsVectorLayer *layer ); 175%Docstring 176Set the layer from which fields are displayed. 177 178.. seealso:: :py:func:`layer` 179%End 180 181 protected slots: 182 183 virtual void updateModel(); 184%Docstring 185Called when the model must be updated. 186%End 187 188 protected: 189 190 191}; 192 193/************************************************************************ 194 * This file has been generated automatically from * 195 * * 196 * src/core/qgsfieldmodel.h * 197 * * 198 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 199 ************************************************************************/ 200