16#ifndef QGSFIELDMAPPINGMODEL_H
17#define QGSFIELDMAPPINGMODEL_H
26#include <QAbstractTableModel>
27#include <QStyledItemDelegate>
56 DestinationConstraints,
96 void setNativeTypes(
const QList< QgsVectorDataProvider::NativeType > &nativeTypes );
108 Q_DECL_DEPRECATED
static const QMap<QMetaType::Type, QString>
dataTypes();
120 QList<QgsFieldMappingModel::Field>
mapping()
const;
144 bool moveUp(
const QModelIndex &index );
147 bool moveDown(
const QModelIndex &index );
170 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
171 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
172 QVariant
data(
const QModelIndex &index,
int role )
const override;
173 QVariant
headerData(
int section, Qt::Orientation orientation,
int role )
const override;
174 Qt::ItemFlags
flags(
const QModelIndex &index )
const override;
175 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
201 QString qgsFieldToTypeName(
const QgsField &field )
const;
207 void setFieldTypeFromName(
QgsField &field,
const QString &name )
const;
209 bool moveUpOrDown(
const QModelIndex &index,
bool up =
true );
222 QList< QgsVectorDataProvider::NativeType > mNativeTypes;
224 QList<Field> mMapping;
225 bool mDestinationEditable =
false;
227 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.