mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-10-31 00:06:02 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			373 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			373 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/core/qgsfields.h                                                 *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | |
|  ************************************************************************/
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| class QgsFields
 | |
| {
 | |
| %Docstring(signature="appended")
 | |
| Container of fields for a vector layer.
 | |
| 
 | |
| In addition to storing a list of :py:class:`QgsField` instances, it also:
 | |
| 
 | |
| - allows quick lookups of field names to index in the list
 | |
| - keeps track of where the field definition comes from (vector data provider, joined layer or newly added from an editing operation)
 | |
| 
 | |
| .. note::
 | |
| 
 | |
|    :py:class:`QgsFields` objects are implicitly shared.
 | |
| %End
 | |
| 
 | |
| %TypeHeaderCode
 | |
| #include "qgsfields.h"
 | |
| %End
 | |
|   public:
 | |
| 
 | |
|     enum FieldOrigin
 | |
|     {
 | |
|       OriginUnknown,
 | |
|       OriginProvider,
 | |
|       OriginJoin,
 | |
|       OriginEdit,
 | |
|       OriginExpression
 | |
|     };
 | |
| 
 | |
| 
 | |
|     QgsFields();
 | |
| %Docstring
 | |
| Constructor for an empty field container
 | |
| %End
 | |
| 
 | |
|     QgsFields( const QgsFields &other );
 | |
| %Docstring
 | |
| Copy constructor
 | |
| %End
 | |
| 
 | |
| 
 | |
|     virtual ~QgsFields();
 | |
| 
 | |
|     void clear();
 | |
| %Docstring
 | |
| Removes all fields
 | |
| %End
 | |
| 
 | |
|     bool append( const QgsField &field, FieldOrigin origin = OriginProvider, int originIndex = -1 );
 | |
| %Docstring
 | |
| Appends a field. The field must have unique name, otherwise it is rejected (returns ``False``)
 | |
| %End
 | |
| 
 | |
|     bool rename( int fieldIdx, const QString &name );
 | |
| %Docstring
 | |
| Renames a name of field. The field must have unique name, otherwise change is rejected (returns ``False``)
 | |
| 
 | |
| .. versionadded:: 3.6
 | |
| %End
 | |
| 
 | |
|     bool appendExpressionField( const QgsField &field, int originIndex );
 | |
| %Docstring
 | |
| Appends an expression field. The field must have unique name, otherwise it is rejected (returns ``False``)
 | |
| %End
 | |
| 
 | |
| 
 | |
|     void remove( int fieldIdx );
 | |
| %Docstring
 | |
| Removes the field with the given index.
 | |
| 
 | |
| :raises KeyError: if no field with the specified index exists
 | |
| %End
 | |
| %MethodCode
 | |
|     if ( a0 < 0 || a0 >= sipCpp->count() )
 | |
|     {
 | |
|       PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
 | |
|       sipIsErr = 1;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       sipCpp->remove( a0 );
 | |
|     }
 | |
| %End
 | |
| 
 | |
|     void extend( const QgsFields &other );
 | |
| %Docstring
 | |
| Extends with fields from another QgsFields container
 | |
| %End
 | |
| 
 | |
|     bool isEmpty() const;
 | |
| %Docstring
 | |
| Checks whether the container is empty
 | |
| %End
 | |
| 
 | |
|     int count() const;
 | |
| %Docstring
 | |
| Returns number of items
 | |
| %End
 | |
| 
 | |
|     int __len__() const;
 | |
| %MethodCode
 | |
|     sipRes = sipCpp->count();
 | |
| %End
 | |
| 
 | |
|     //! Ensures that bool(obj) returns ``True`` (otherwise __len__() would be used)
 | |
|     int __bool__() const;
 | |
| %MethodCode
 | |
|     sipRes = true;
 | |
| %End
 | |
| 
 | |
|     int size() const;
 | |
| %Docstring
 | |
| Returns number of items
 | |
| %End
 | |
| 
 | |
|     QStringList names() const;
 | |
| %Docstring
 | |
| Returns a list with field names
 | |
| 
 | |
| .. versionadded:: 3.0
 | |
| %End
 | |
| 
 | |
|     bool exists( int i ) const;
 | |
| %Docstring
 | |
| Returns if a field index is valid
 | |
| 
 | |
| :param i: Index of the field which needs to be checked
 | |
| 
 | |
| :return: ``True`` if the field exists
 | |
| %End
 | |
| 
 | |
| 
 | |
|     QgsField &operator[]( int i ) /Factory/;
 | |
| %MethodCode
 | |
|     SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->count() );
 | |
|     if ( idx < 0 )
 | |
|       sipIsErr = 1;
 | |
|     else
 | |
|       sipRes = new QgsField( sipCpp->operator[]( idx ) );
 | |
| %End
 | |
| 
 | |
| 
 | |
|     QgsField at( int i ) const /Factory/;
 | |
| %Docstring
 | |
| Returns the field at particular index (must be in range 0..N-1).
 | |
| 
 | |
| :raises KeyError: if no field exists at the specified index
 | |
| %End
 | |
| %MethodCode
 | |
|     if ( a0 < 0 || a0 >= sipCpp->count() )
 | |
|     {
 | |
|       PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
 | |
|       sipIsErr = 1;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       sipRes = new QgsField( sipCpp->at( a0 ) );
 | |
|     }
 | |
| %End
 | |
| 
 | |
| 
 | |
|     QgsField field( int fieldIdx ) const /Factory/;
 | |
| %Docstring
 | |
| Returns the field at particular index (must be in range 0..N-1).
 | |
| 
 | |
| :raises KeyError: if no field exists at the specified index
 | |
| %End
 | |
| %MethodCode
 | |
|     if ( a0 < 0 || a0 >= sipCpp->count() )
 | |
|     {
 | |
|       PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
 | |
|       sipIsErr = 1;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       sipRes = new QgsField( sipCpp->field( a0 ) );
 | |
|     }
 | |
| %End
 | |
| 
 | |
| 
 | |
|     QgsField field( const QString &name ) const /Factory/;
 | |
| %Docstring
 | |
| Returns the field with matching name.
 | |
| 
 | |
| :raises KeyError: if no matching field was found.
 | |
| %End
 | |
| %MethodCode
 | |
|     int fieldIdx = sipCpp->indexFromName( *a0 );
 | |
|     if ( fieldIdx == -1 )
 | |
|     {
 | |
|       PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
 | |
|       sipIsErr = 1;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       sipRes = new QgsField( sipCpp->field( *a0 ) );
 | |
|     }
 | |
| %End
 | |
| 
 | |
| 
 | |
|     FieldOrigin fieldOrigin( int fieldIdx ) const;
 | |
| %Docstring
 | |
| Returns the field's origin (value from an enumeration).
 | |
| 
 | |
| :raises KeyError: if no field exists at the specified index
 | |
| %End
 | |
| %MethodCode
 | |
|     if ( a0 < 0 || a0 >= sipCpp->count() )
 | |
|     {
 | |
|       PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
 | |
|       sipIsErr = 1;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       sipRes = sipCpp->fieldOrigin( a0 );
 | |
|     }
 | |
| %End
 | |
| 
 | |
| 
 | |
|     int fieldOriginIndex( int fieldIdx ) const;
 | |
| %Docstring
 | |
| Returns the field's origin index (its meaning is specific to each type of origin).
 | |
| 
 | |
| :raises KeyError: if no field exists at the specified index
 | |
| %End
 | |
| %MethodCode
 | |
|     if ( a0 < 0 || a0 >= sipCpp->count() )
 | |
|     {
 | |
|       PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
 | |
|       sipIsErr = 1;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       sipRes = sipCpp->fieldOriginIndex( a0 );
 | |
|     }
 | |
| %End
 | |
| 
 | |
|     int indexFromName( const QString &fieldName ) const;
 | |
| %Docstring
 | |
| Gets the field index from the field name.
 | |
| 
 | |
| This method is case sensitive and only matches the data source
 | |
| name of the field.
 | |
| 
 | |
| Alias for indexOf
 | |
| 
 | |
| :param fieldName: The name of the field.
 | |
| 
 | |
| :return: The field index if found or -1 in case it cannot be found.
 | |
| 
 | |
| .. seealso:: :py:func:`lookupField`
 | |
| %End
 | |
| 
 | |
|     int indexOf( const QString &fieldName ) const;
 | |
| %Docstring
 | |
| Gets the field index from the field name.
 | |
| 
 | |
| This method is case sensitive and only matches the data source
 | |
| name of the field.
 | |
| 
 | |
| :param fieldName: The name of the field.
 | |
| 
 | |
| :return: The field index if found or -1 in case it cannot be found.
 | |
| 
 | |
| .. seealso:: :py:func:`lookupField`
 | |
| 
 | |
| .. versionadded:: 3.0
 | |
| %End
 | |
| 
 | |
|     int lookupField( const QString &fieldName ) const;
 | |
| %Docstring
 | |
| Looks up field's index from the field name.
 | |
| This method matches in the following order:
 | |
| 
 | |
| 1. The exact field name taking case sensitivity into account
 | |
| 2. Looks for the field name by case insensitive comparison
 | |
| 3. The field alias (case insensitive)
 | |
| 
 | |
| :param fieldName: The name to look for.
 | |
| 
 | |
| :return: The field index if found or -1 in case it cannot be found.
 | |
| 
 | |
| .. seealso:: :py:func:`indexFromName`
 | |
| 
 | |
| .. versionadded:: 2.4
 | |
| %End
 | |
| 
 | |
|     QgsAttributeList allAttributesList() const;
 | |
| %Docstring
 | |
| Utility function to get list of attribute indexes
 | |
| 
 | |
| .. versionadded:: 2.4
 | |
| %End
 | |
| 
 | |
|     QList<QgsField> toList() const;
 | |
| %Docstring
 | |
| Utility function to return a list of :py:class:`QgsField` instances
 | |
| %End
 | |
| 
 | |
|     bool operator==( const QgsFields &other ) const;
 | |
|     bool operator!=( const QgsFields &other ) const;
 | |
| 
 | |
| 
 | |
|     QIcon iconForField( int fieldIdx, bool considerOrigin = false ) const /Factory/;
 | |
| %Docstring
 | |
| Returns an icon corresponding to a field index, based on the field's type and source
 | |
| 
 | |
| :param fieldIdx: the field index
 | |
| :param considerOrigin: if ``True`` the icon will the origin of the field
 | |
| 
 | |
| :raises KeyError: if no field exists at the specified index
 | |
| 
 | |
| .. versionadded:: 2.14
 | |
| %End
 | |
| %MethodCode
 | |
|     if ( a0 < 0 || a0 >= sipCpp->count() )
 | |
|     {
 | |
|       PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
 | |
|       sipIsErr = 1;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       sipRes = new QIcon( sipCpp->iconForField( a0 ) );
 | |
|     }
 | |
| %End
 | |
| 
 | |
|     static QIcon iconForFieldType( QVariant::Type type, QVariant::Type subType = QVariant::Type::Invalid );
 | |
| %Docstring
 | |
| Returns an icon corresponding to a field ``type``
 | |
| 
 | |
| Since QGIS 3.24, the optional ``subType`` argument can be used to specify the type of variant list or map values.
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     operator QVariant() const;
 | |
| 
 | |
| 
 | |
|     void __setitem__( int key, const QgsField &field );
 | |
| %MethodCode
 | |
|     int idx = ( int )sipConvertFromSequenceIndex( a0, sipCpp->count() );
 | |
|     if ( idx < 0 )
 | |
|       sipIsErr = 1;
 | |
|     else
 | |
|       ( *sipCpp )[idx] = *a1;
 | |
| %End
 | |
| 
 | |
| 
 | |
| 
 | |
| };
 | |
| 
 | |
| 
 | |
| 
 | |
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/core/qgsfields.h                                                 *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | |
|  ************************************************************************/
 |