mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			306 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			306 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/gui/attributetable/qgsattributetablemodel.h                      *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
class QgsAttributeTableModel : QAbstractTableModel
 | 
						|
{
 | 
						|
%Docstring(signature="appended")
 | 
						|
A model backed by a :py:class:`QgsVectorLayerCache` which is able to provide
 | 
						|
feature/attribute information to a QAbstractItemView.
 | 
						|
 | 
						|
Is able to generate editor widgets for its QModelIndexes as well.
 | 
						|
Is mostly referred to as "master model" within this doc and the source.
 | 
						|
 | 
						|
\see <a href="http://doc.qt.digia.com/qt/model-view-programming.html">Qt Model View Programming</a>
 | 
						|
%End
 | 
						|
 | 
						|
%TypeHeaderCode
 | 
						|
#include "qgsattributetablemodel.h"
 | 
						|
%End
 | 
						|
  public:
 | 
						|
 | 
						|
    enum class CustomRole
 | 
						|
    {
 | 
						|
      FeatureId,
 | 
						|
      FieldIndex,
 | 
						|
      User,
 | 
						|
      // Insert new values here, SortRole needs to be the last one
 | 
						|
      Sort,
 | 
						|
    };
 | 
						|
 | 
						|
  public:
 | 
						|
    QgsAttributeTableModel( QgsVectorLayerCache *layerCache, QObject *parent = 0 );
 | 
						|
%Docstring
 | 
						|
Constructor
 | 
						|
 | 
						|
:param layerCache: A layer cache to use as backend
 | 
						|
:param parent: The parent QObject (owner)
 | 
						|
%End
 | 
						|
 | 
						|
    virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
 | 
						|
 | 
						|
%Docstring
 | 
						|
Returns the number of rows
 | 
						|
 | 
						|
:param parent: parent index
 | 
						|
%End
 | 
						|
 | 
						|
    virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
 | 
						|
 | 
						|
%Docstring
 | 
						|
Returns the number of columns
 | 
						|
 | 
						|
:param parent: parent index
 | 
						|
%End
 | 
						|
 | 
						|
    virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
 | 
						|
 | 
						|
%Docstring
 | 
						|
Returns header data
 | 
						|
 | 
						|
:param section: required section
 | 
						|
:param orientation: horizontal or vertical orientation
 | 
						|
:param role: data role
 | 
						|
%End
 | 
						|
 | 
						|
    virtual QVariant data( const QModelIndex &index, int role ) const;
 | 
						|
 | 
						|
%Docstring
 | 
						|
Returns data on the given index
 | 
						|
 | 
						|
:param index: model index
 | 
						|
:param role: data role
 | 
						|
%End
 | 
						|
 | 
						|
    virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
 | 
						|
 | 
						|
%Docstring
 | 
						|
Updates data on given index
 | 
						|
 | 
						|
:param index: model index
 | 
						|
:param value: new data value
 | 
						|
:param role: data role
 | 
						|
%End
 | 
						|
 | 
						|
    virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
 | 
						|
 | 
						|
%Docstring
 | 
						|
Returns item flags for the index
 | 
						|
 | 
						|
:param index: model index
 | 
						|
%End
 | 
						|
 | 
						|
    void reload( const QModelIndex &index1, const QModelIndex &index2 );
 | 
						|
%Docstring
 | 
						|
Reloads the model data between indices
 | 
						|
 | 
						|
:param index1: start index
 | 
						|
:param index2: end index
 | 
						|
%End
 | 
						|
 | 
						|
    virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
 | 
						|
 | 
						|
%Docstring
 | 
						|
Remove rows
 | 
						|
%End
 | 
						|
 | 
						|
    void resetModel();
 | 
						|
%Docstring
 | 
						|
Resets the model
 | 
						|
 | 
						|
Alias to :py:func:`~QgsAttributeTableModel.loadLayer`
 | 
						|
%End
 | 
						|
 | 
						|
    int idToRow( QgsFeatureId id ) const;
 | 
						|
%Docstring
 | 
						|
Maps feature id to table row
 | 
						|
 | 
						|
:param id: feature id
 | 
						|
%End
 | 
						|
 | 
						|
    QModelIndex idToIndex( QgsFeatureId id ) const;
 | 
						|
 | 
						|
    QModelIndexList idToIndexList( QgsFeatureId id ) const;
 | 
						|
 | 
						|
    int fieldIdx( int col ) const;
 | 
						|
%Docstring
 | 
						|
Gets field index from column
 | 
						|
%End
 | 
						|
 | 
						|
    int fieldCol( int idx ) const;
 | 
						|
%Docstring
 | 
						|
Gets column from field index
 | 
						|
%End
 | 
						|
 | 
						|
    QgsFeatureId rowToId( int row ) const;
 | 
						|
%Docstring
 | 
						|
Maps row to feature id
 | 
						|
 | 
						|
:param row: row number
 | 
						|
%End
 | 
						|
 | 
						|
    void swapRows( QgsFeatureId a, QgsFeatureId b );
 | 
						|
%Docstring
 | 
						|
Swaps two rows
 | 
						|
 | 
						|
:param a: first row
 | 
						|
:param b: second row
 | 
						|
%End
 | 
						|
 | 
						|
    QgsVectorLayer *layer() const;
 | 
						|
%Docstring
 | 
						|
Returns the layer this model uses as backend. Retrieved from the layer cache.
 | 
						|
%End
 | 
						|
 | 
						|
    QgsVectorLayerCache *layerCache() const;
 | 
						|
%Docstring
 | 
						|
Returns the layer cache this model uses as backend.
 | 
						|
%End
 | 
						|
 | 
						|
    void executeAction( QUuid action, const QModelIndex &idx ) const;
 | 
						|
%Docstring
 | 
						|
Execute an action
 | 
						|
%End
 | 
						|
 | 
						|
    void executeMapLayerAction( QgsMapLayerAction *action, const QModelIndex &idx, const QgsMapLayerActionContext &context = QgsMapLayerActionContext() ) const;
 | 
						|
%Docstring
 | 
						|
Execute a :py:class:`QgsMapLayerAction`
 | 
						|
%End
 | 
						|
 | 
						|
    QgsFeature feature( const QModelIndex &idx ) const;
 | 
						|
%Docstring
 | 
						|
Returns the feature attributes at given model index
 | 
						|
 | 
						|
:return: feature attributes at given model index
 | 
						|
%End
 | 
						|
 | 
						|
    void prefetchColumnData( int column );
 | 
						|
%Docstring
 | 
						|
Caches the entire data for one column. This should be called prior to sorting,
 | 
						|
so the data does not have to be fetched for every single comparison.
 | 
						|
Specify -1 as column to invalidate the cache
 | 
						|
 | 
						|
:param column: The column index of the field to catch
 | 
						|
%End
 | 
						|
 | 
						|
    void prefetchSortData( const QString &expression, unsigned long cacheIndex = 0 );
 | 
						|
%Docstring
 | 
						|
Prefetches the entire data for an ``expression``. Based on this cached information
 | 
						|
the sorting can later be done in a performant way. A ``cacheIndex`` can be specified
 | 
						|
if multiple caches should be filled. In this case, the caches will be available
 | 
						|
as ``QgsAttributeTableModel.SortRole + cacheIndex``.
 | 
						|
%End
 | 
						|
 | 
						|
    QString sortCacheExpression( unsigned long cacheIndex = 0 ) const;
 | 
						|
%Docstring
 | 
						|
The expression which was used to fill the sorting cache at index ``cacheIndex``.
 | 
						|
 | 
						|
.. seealso:: :py:func:`prefetchSortData`
 | 
						|
%End
 | 
						|
 | 
						|
    void setRequest( const QgsFeatureRequest &request );
 | 
						|
%Docstring
 | 
						|
Set a request that will be used to fill this attribute table model.
 | 
						|
In contrast to a filter, the request will constrain the data shown without the possibility
 | 
						|
to dynamically adjust it.
 | 
						|
 | 
						|
:param request: The request to use to fill this table model.
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
    const QgsFeatureRequest &request() const;
 | 
						|
%Docstring
 | 
						|
Gets the the feature request
 | 
						|
%End
 | 
						|
 | 
						|
    void setEditorContext( const QgsAttributeEditorContext &context );
 | 
						|
%Docstring
 | 
						|
Sets the context in which this table is shown.
 | 
						|
Will be forwarded to any editor widget created when editing data on this model.
 | 
						|
 | 
						|
:param context: The context
 | 
						|
%End
 | 
						|
 | 
						|
    const QgsAttributeEditorContext &editorContext() const;
 | 
						|
%Docstring
 | 
						|
Returns the context in which this table is shown.
 | 
						|
Will be forwarded to any editor widget created when editing data on this model.
 | 
						|
 | 
						|
:return: The context
 | 
						|
%End
 | 
						|
 | 
						|
    int extraColumns() const;
 | 
						|
%Docstring
 | 
						|
Empty extra columns to announce from this model.
 | 
						|
Any extra columns need to be implemented by proxy models in front of this model.
 | 
						|
%End
 | 
						|
 | 
						|
    void setExtraColumns( int extraColumns );
 | 
						|
%Docstring
 | 
						|
Empty extra columns to announce from this model.
 | 
						|
Any extra columns need to be implemented by proxy models in front of this model.
 | 
						|
%End
 | 
						|
 | 
						|
    bool showValidityState() const;
 | 
						|
%Docstring
 | 
						|
Returns whether the attribute table will add a visual feedback to cells when an attribute
 | 
						|
constraint is not met.
 | 
						|
 | 
						|
.. versionadded:: 3.30
 | 
						|
%End
 | 
						|
 | 
						|
    void setShowValidityState( bool show );
 | 
						|
%Docstring
 | 
						|
Sets whether the attribute table will add a visual feedback to cells when an attribute constraint
 | 
						|
is not met.
 | 
						|
 | 
						|
.. versionadded:: 3.30
 | 
						|
%End
 | 
						|
 | 
						|
  public slots:
 | 
						|
 | 
						|
    virtual void loadLayer();
 | 
						|
%Docstring
 | 
						|
Loads the layer into the model
 | 
						|
Preferably to be called, before using this model as source for any other proxy model
 | 
						|
%End
 | 
						|
 | 
						|
    void fieldConditionalStyleChanged( const QString &fieldName );
 | 
						|
%Docstring
 | 
						|
Handles updating the model when the conditional style for a field changes.
 | 
						|
 | 
						|
:param fieldName: name of field whose conditional style has changed
 | 
						|
%End
 | 
						|
 | 
						|
  signals:
 | 
						|
 | 
						|
    void modelChanged();
 | 
						|
%Docstring
 | 
						|
Emitted when the model has been changed.
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
    void finished();
 | 
						|
%Docstring
 | 
						|
Emitted when the model has completely loaded all features.
 | 
						|
%End
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/gui/attributetable/qgsattributetablemodel.h                      *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 |