16#ifndef QGSFIELDMAPPINGMODEL_H
17#define QGSFIELDMAPPINGMODEL_H
26#include <QAbstractTableModel>
27#include <QStyledItemDelegate>
56 DestinationConstraints,
94 void setNativeTypes(
const QList< QgsVectorDataProvider::NativeType > &nativeTypes );
106 Q_DECL_DEPRECATED
static const QMap<QMetaType::Type, QString>
dataTypes();
118 QList<QgsFieldMappingModel::Field>
mapping()
const;
142 bool moveUp(
const QModelIndex &index );
145 bool moveDown(
const QModelIndex &index );
168 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
169 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
170 QVariant
data(
const QModelIndex &index,
int role )
const override;
171 QVariant
headerData(
int section, Qt::Orientation orientation,
int role )
const override;
172 Qt::ItemFlags
flags(
const QModelIndex &index )
const override;
173 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
199 QString qgsFieldToTypeName(
const QgsField &field )
const;
205 void setFieldTypeFromName(
QgsField &field,
const QString &name )
const;
207 bool moveUpOrDown(
const QModelIndex &index,
bool up =
true );
220 QList< QgsVectorDataProvider::NativeType > mNativeTypes;
222 QList<Field> mMapping;
223 bool mDestinationEditable =
false;
225 std::unique_ptr<ExpressionContextGenerator> mExpressionContextGenerator;
Abstract interface for generating an expression context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QFlags< Constraint > Constraints
void setDestinationEditable(bool editable)
Sets the destination fields editable state to editable.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
ColumnDataIndex
The ColumnDataIndex enum represents the column index for the view.
Qt::ItemFlags flags(const QModelIndex &index) const override
QgsFields sourceFields() const
Returns a list of source fields.
void setNativeTypes(const QList< QgsVectorDataProvider::NativeType > &nativeTypes)
Sets the list of nativeTypes supported by a data provider.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
bool removeField(const QModelIndex &index)
Removes the field at index from the model, returns true on success.
void appendField(const QgsField &field, const QString &expression=QString())
Appends a new field to the model, with an optional expression.
friend class QgsAggregateMappingModel
QMap< QString, QgsProperty > fieldPropertyMap() const
Returns a map of destination field name to QgsProperty definition for field value,...
QList< QgsFieldMappingModel::Field > mapping() const
Returns a list of Field objects representing the current status of the model.
QgsFieldMappingModel(const QgsFields &sourceFields=QgsFields(), const QgsFields &destinationFields=QgsFields(), const QMap< QString, QString > &expressions=QMap< QString, QString >(), QObject *parent=nullptr)
Constructs a QgsFieldMappingModel from a set of sourceFields and destinationFields,...
bool moveDown(const QModelIndex &index)
Moves up the field at index.
bool moveUp(const QModelIndex &index)
Moves down the field at index.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
static Q_DECL_DEPRECATED const QMap< QMetaType::Type, QString > dataTypes()
Returns a static map of supported data types.
void setBaseExpressionContextGenerator(const QgsExpressionContextGenerator *generator)
Sets the base expression context generator, which will generate the expression contexts for expressio...
static const QList< QgsVectorDataProvider::NativeType > supportedDataTypes()
Returns a static list of supported data types.
QgsExpressionContextGenerator * contextGenerator() const
Returns the context generator with the source fields.
void setDestinationFields(const QgsFields &destinationFields, const QMap< QString, QString > &expressions=QMap< QString, QString >())
Set destination fields to destinationFields, initial values for the expressions can be optionally spe...
void setSourceFields(const QgsFields &sourceFields)
Set source fields to sourceFields.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
bool destinationEditable() const
Returns true if the destination fields are editable.
void setFieldPropertyMap(const QMap< QString, QgsProperty > &map)
Sets a map of destination field name to QgsProperty definition for field value.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
The Field struct holds information about a mapped field.
QgsField field
The field in its current status (it might have been renamed).
QString expression
The expression for the mapped field from the source fields.
QString originalName
The original name of the field.