QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
QgsFieldMappingWidget Class Reference

Creates a mapping from one set of QgsFields to another, for each set of "destination" fields an expression defines how to obtain the values of the "destination" fields. More...

#include <qgsfieldmappingwidget.h>

Inheritance diagram for QgsFieldMappingWidget:

Public Slots

void appendField (const QgsField &field, const QString &expression=QString())
 Appends a new field to the model, with an optional expression.
void invertSelection ()
 Invert the field selection state.
bool moveSelectedFieldsDown ()
 Moves down the currently selected field.
bool moveSelectedFieldsUp ()
 Moves up currently selected field.
bool removeSelectedFields ()
 Removes the currently selected field from the model.
Public Slots inherited from QgsPanelWidget
void acceptPanel ()
 Accept the panel.
void openPanel (QgsPanelWidget *panel)
 Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the showPanel signal for connected slots to handle the open event.

Signals

void changed ()
 Emitted when the fields defined in the widget are changed.
Signals inherited from QgsPanelWidget
void panelAccepted (QgsPanelWidget *panel)
 Emitted when the panel is accepted by the user.
void showPanel (QgsPanelWidget *panel)
 Emit when you require a panel to be show in the interface.
void widgetChanged ()
 Emitted when the widget state changes.

Public Member Functions

 QgsFieldMappingWidget (QWidget *parent=nullptr, const QgsFields &sourceFields=QgsFields(), const QgsFields &destinationFields=QgsFields(), const QMap< QString, QString > &expressions=QMap< QString, QString >(), const QList< QgsVectorDataProvider::NativeType > &nativeTypes=QList< QgsVectorDataProvider::NativeType >())
 Constructs a QgsFieldMappingWidget from a set of sourceFields and destinationFields, initial values for the expressions can be optionally specified through expressions which is a map from the original field name to the corresponding expression.
bool destinationEditable () const
 Returns true if the destination fields are editable in the model.
QMap< QString, QgsPropertyfieldPropertyMap () const
 Returns a map of destination field name to QgsProperty definition for field value, representing the current status of the widget.
QList< QgsFieldMappingModel::Fieldmapping () const
 Returns a list of Field objects representing the current status of the underlying mapping model.
QgsFieldMappingModelmodel () const
 Returns the underlying mapping model.
void registerExpressionContextGenerator (const QgsExpressionContextGenerator *generator)
 Register an expression context generator class that will be used to retrieve an expression context for the widget.
void scrollTo (const QModelIndex &index) const
 Scroll the fields view to index.
QItemSelectionModel * selectionModel ()
 Returns the selection model.
void setDestinationEditable (bool editable)
 Sets the destination fields editable state to editable.
void setDestinationFields (const QgsFields &destinationFields, const QMap< QString, QString > &expressions=QMap< QString, QString >())
 Set destination fields to destinationFields in the underlying model, initial values for the expressions can be optionally specified through expressions which is a map from the original field name to the corresponding expression.
void setFieldPropertyMap (const QMap< QString, QgsProperty > &map)
 Sets a map of destination field name to QgsProperty definition for field value.
void setNativeTypes (const QList< QgsVectorDataProvider::NativeType > &nativeTypes)
 Sets the list of nativeTypes supported by a data provider.
void setSourceFields (const QgsFields &sourceFields)
 Set source fields of the underlying mapping model to sourceFields.
void setSourceLayer (QgsVectorLayer *layer)
 Sets a source layer to use when generating expression previews in the widget.
QgsVectorLayersourceLayer ()
 Returns the source layer for use when generating expression previews.
Public Member Functions inherited from QgsPanelWidget
 QgsPanelWidget (QWidget *parent=nullptr)
 Base class for any widget that can be shown as an inline panel.
virtual bool applySizeConstraintsToStack () const
 Returns true if the size constraints and hints for the panel widget should be applied to the parent QgsPanelWidgetStack which this panel is shown in.
bool autoDelete () const
 The the auto delete property on the widget.
void connectChildPanel (QgsPanelWidget *panel)
 Connect the given sub panel widgets showPanel signals to this current panels main showPanel event to bubble up to the user.
void connectChildPanels (const QList< QgsPanelWidget * > &panels)
 Connect the given sub panel widgets showPanel signals to this current panels main showPanel event to bubble up to the user.
bool dockMode () const
 Returns the dock mode state.
virtual QMenu * menuButtonMenu ()
 Returns the menu to use for the menu button for this panel, or nullptr if no menu button is required.
virtual QString menuButtonTooltip () const
 Returns the (translated) tooltip text to use for the menu button for this panel.
QString panelTitle () const
 The title of the panel.
void setAutoDelete (bool autoDelete)
 The the auto delete property on the widget.
virtual void setDockMode (bool dockMode)
 Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
void setPanelTitle (const QString &panelTitle)
 Set the title of the panel when shown in the interface.

Friends

class QgsAggregateMappingWidget

Additional Inherited Members

Static Public Member Functions inherited from QgsPanelWidget
static QgsPanelWidgetfindParentPanel (QWidget *widget)
 Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
Protected Member Functions inherited from QgsPanelWidget
void keyPressEvent (QKeyEvent *event) override
 Overridden key press event to handle the esc event on the widget.

Detailed Description

Creates a mapping from one set of QgsFields to another, for each set of "destination" fields an expression defines how to obtain the values of the "destination" fields.

Since
QGIS 3.14

Definition at line 39 of file qgsfieldmappingwidget.h.

Constructor & Destructor Documentation

◆ QgsFieldMappingWidget()

QgsFieldMappingWidget::QgsFieldMappingWidget ( QWidget * parent = nullptr,
const QgsFields & sourceFields = QgsFields(),
const QgsFields & destinationFields = QgsFields(),
const QMap< QString, QString > & expressions = QMap<QString, QString>(),
const QList< QgsVectorDataProvider::NativeType > & nativeTypes = QList< QgsVectorDataProvider::NativeType >() )
explicit

Constructs a QgsFieldMappingWidget from a set of sourceFields and destinationFields, initial values for the expressions can be optionally specified through expressions which is a map from the original field name to the corresponding expression.

A parent object can also be specified.

Since QGIS 3.44, the nativeTypes argument can be used to specify the list of field types natively supported by a data provider. If this list is non-empty, then the destination field types will be populated accordingly. If the list is empty, then a set of default native types will be used instead.

Definition at line 35 of file qgsfieldmappingwidget.cpp.

Member Function Documentation

◆ appendField

void QgsFieldMappingWidget::appendField ( const QgsField & field,
const QString & expression = QString() )
slot

Appends a new field to the model, with an optional expression.

Definition at line 143 of file qgsfieldmappingwidget.cpp.

◆ changed

void QgsFieldMappingWidget::changed ( )
signal

Emitted when the fields defined in the widget are changed.

◆ destinationEditable()

bool QgsFieldMappingWidget::destinationEditable ( ) const

Returns true if the destination fields are editable in the model.

Definition at line 77 of file qgsfieldmappingwidget.cpp.

◆ fieldPropertyMap()

QMap< QString, QgsProperty > QgsFieldMappingWidget::fieldPropertyMap ( ) const

Returns a map of destination field name to QgsProperty definition for field value, representing the current status of the widget.

See also
setFieldPropertyMap()

Definition at line 92 of file qgsfieldmappingwidget.cpp.

◆ invertSelection

void QgsFieldMappingWidget::invertSelection ( )
slot

Invert the field selection state.

Since
QGIS 3.32

Definition at line 165 of file qgsfieldmappingwidget.cpp.

◆ mapping()

QList< QgsFieldMappingModel::Field > QgsFieldMappingWidget::mapping ( ) const

Returns a list of Field objects representing the current status of the underlying mapping model.

Definition at line 87 of file qgsfieldmappingwidget.cpp.

◆ model()

QgsFieldMappingModel * QgsFieldMappingWidget::model ( ) const

Returns the underlying mapping model.

Definition at line 82 of file qgsfieldmappingwidget.cpp.

◆ moveSelectedFieldsDown

bool QgsFieldMappingWidget::moveSelectedFieldsDown ( )
slot

Moves down the currently selected field.

Definition at line 193 of file qgsfieldmappingwidget.cpp.

◆ moveSelectedFieldsUp

bool QgsFieldMappingWidget::moveSelectedFieldsUp ( )
slot

Moves up currently selected field.

Definition at line 177 of file qgsfieldmappingwidget.cpp.

◆ registerExpressionContextGenerator()

void QgsFieldMappingWidget::registerExpressionContextGenerator ( const QgsExpressionContextGenerator * generator)

Register an expression context generator class that will be used to retrieve an expression context for the widget.

Definition at line 138 of file qgsfieldmappingwidget.cpp.

◆ removeSelectedFields

bool QgsFieldMappingWidget::removeSelectedFields ( )
slot

Removes the currently selected field from the model.

Definition at line 148 of file qgsfieldmappingwidget.cpp.

◆ scrollTo()

void QgsFieldMappingWidget::scrollTo ( const QModelIndex & index) const

Scroll the fields view to index.

Definition at line 133 of file qgsfieldmappingwidget.cpp.

◆ selectionModel()

QItemSelectionModel * QgsFieldMappingWidget::selectionModel ( )

Returns the selection model.

Definition at line 102 of file qgsfieldmappingwidget.cpp.

◆ setDestinationEditable()

void QgsFieldMappingWidget::setDestinationEditable ( bool editable)

Sets the destination fields editable state to editable.

Definition at line 71 of file qgsfieldmappingwidget.cpp.

◆ setDestinationFields()

void QgsFieldMappingWidget::setDestinationFields ( const QgsFields & destinationFields,
const QMap< QString, QString > & expressions = QMap<QString, QString>() )

Set destination fields to destinationFields in the underlying model, initial values for the expressions can be optionally specified through expressions which is a map from the original field name to the corresponding expression.

Definition at line 122 of file qgsfieldmappingwidget.cpp.

◆ setFieldPropertyMap()

void QgsFieldMappingWidget::setFieldPropertyMap ( const QMap< QString, QgsProperty > & map)

Sets a map of destination field name to QgsProperty definition for field value.

See also
fieldPropertyMap()

Definition at line 97 of file qgsfieldmappingwidget.cpp.

◆ setNativeTypes()

void QgsFieldMappingWidget::setNativeTypes ( const QList< QgsVectorDataProvider::NativeType > & nativeTypes)

Sets the list of nativeTypes supported by a data provider.

If this list is non-empty, then the destination field types will be populated accordingly. If the list is empty, then a set of default native types will be used instead.

Since
QGIS 3.44

Definition at line 127 of file qgsfieldmappingwidget.cpp.

◆ setSourceFields()

void QgsFieldMappingWidget::setSourceFields ( const QgsFields & sourceFields)

Set source fields of the underlying mapping model to sourceFields.

Definition at line 107 of file qgsfieldmappingwidget.cpp.

◆ setSourceLayer()

void QgsFieldMappingWidget::setSourceLayer ( QgsVectorLayer * layer)

Sets a source layer to use when generating expression previews in the widget.

Since
QGIS 3.16

Definition at line 112 of file qgsfieldmappingwidget.cpp.

◆ sourceLayer()

QgsVectorLayer * QgsFieldMappingWidget::sourceLayer ( )

Returns the source layer for use when generating expression previews.

Returned value may be nullptr.

Since
QGIS 3.16

Definition at line 117 of file qgsfieldmappingwidget.cpp.

◆ QgsAggregateMappingWidget

friend class QgsAggregateMappingWidget
friend

Definition at line 183 of file qgsfieldmappingwidget.h.


The documentation for this class was generated from the following files: