QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsfieldmappingmodel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfieldmappingmodel.cpp - QgsFieldMappingModel
3 
4  ---------------------
5  begin : 17.3.2020
6  copyright : (C) 2020 by Alessandro Pasotti
7  email : elpaso at itopen dot it
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgsfieldmappingmodel.h"
19 #include "qgsexpressionnodeimpl.h"
20 
22  const QgsFields &destinationFields,
23  const QMap<QString, QString> &expressions,
24  QObject *parent )
25  : QAbstractTableModel( parent )
26  , mSourceFields( sourceFields )
27  , mExpressionContextGenerator( new ExpressionContextGenerator( &mSourceFields ) )
28 {
29  setDestinationFields( destinationFields, expressions );
30 }
31 
32 QVariant QgsFieldMappingModel::headerData( int section, Qt::Orientation orientation, int role ) const
33 {
34  if ( role == Qt::DisplayRole )
35  {
36  switch ( orientation )
37  {
38  case Qt::Horizontal:
39  {
40  switch ( static_cast<ColumnDataIndex>( section ) )
41  {
43  {
44  return tr( "Source Expression" );
45  }
47  {
48  return tr( "Name" );
49  }
51  {
52  return tr( "Type" );
53  }
55  {
56  return tr( "Length" );
57  }
59  {
60  return tr( "Precision" );
61  }
63  {
64  return tr( "Constraints" );
65  }
66  }
67  break;
68  }
69  case Qt::Vertical:
70  {
71  return section;
72  }
73  }
74  }
75  return QVariant();
76 }
77 
79 {
80  return mSourceFields;
81 }
82 
83 int QgsFieldMappingModel::rowCount( const QModelIndex &parent ) const
84 {
85  if ( parent.isValid() )
86  return 0;
87  return mMapping.count();
88 }
89 
90 int QgsFieldMappingModel::columnCount( const QModelIndex &parent ) const
91 {
92  if ( parent.isValid() )
93  return 0;
94  return 6;
95 }
96 
97 QVariant QgsFieldMappingModel::data( const QModelIndex &index, int role ) const
98 {
99  if ( index.isValid() )
100  {
101  const ColumnDataIndex col { static_cast<ColumnDataIndex>( index.column() ) };
102  const Field &f { mMapping.at( index.row() ) };
103 
104  const QgsFieldConstraints::Constraints constraints { fieldConstraints( f.field ) };
105 
106  switch ( role )
107  {
108  case Qt::DisplayRole:
109  case Qt::EditRole:
110  {
111  switch ( col )
112  {
114  {
115  return f.expression;
116  }
118  {
119  return f.field.displayName();
120  }
122  {
123  return static_cast<int>( f.field.type() );
124  }
126  {
127  return f.field.length();
128  }
130  {
131  return f.field.precision();
132  }
134  {
135  return constraints != 0 ? tr( "Constraints active" ) : QString();
136  }
137  }
138  break;
139  }
140  case Qt::ToolTipRole:
141  {
143  constraints != 0 )
144  {
145  QStringList constraintDescription;
146  if ( constraints.testFlag( QgsFieldConstraints::Constraint::ConstraintUnique ) )
147  {
148  constraintDescription.push_back( tr( "Unique" ) );
149  }
150  if ( constraints.testFlag( QgsFieldConstraints::Constraint::ConstraintNotNull ) )
151  {
152  constraintDescription.push_back( tr( "Not null" ) );
153  }
154  if ( constraints.testFlag( QgsFieldConstraints::Constraint::ConstraintExpression ) )
155  {
156  constraintDescription.push_back( tr( "Expression" ) );
157  }
158  return constraintDescription.join( QStringLiteral( "<br>" ) );
159  }
160  break;
161  }
162  case Qt::BackgroundRole:
163  {
164  if ( constraints != 0 )
165  {
166  return QBrush( QColor( 255, 224, 178 ) );
167  }
168  break;
169  }
170  }
171  }
172  return QVariant();
173 }
174 
175 Qt::ItemFlags QgsFieldMappingModel::flags( const QModelIndex &index ) const
176 {
177  if ( index.isValid() &&
178  index.column() != static_cast<int>( ColumnDataIndex::DestinationConstraints ) &&
179  ( index.column() == static_cast<int>( ColumnDataIndex::SourceExpression ) || destinationEditable() ) )
180  {
181  return Qt::ItemFlags( Qt::ItemIsSelectable |
182  Qt::ItemIsEditable |
183  Qt::ItemIsEnabled );
184  }
185  return Qt::ItemFlags();
186 }
187 
188 bool QgsFieldMappingModel::setData( const QModelIndex &index, const QVariant &value, int role )
189 {
190  if ( index.isValid() )
191  {
192  if ( role == Qt::EditRole )
193  {
194  Field &f = mMapping[index.row()];
195  switch ( static_cast<ColumnDataIndex>( index.column() ) )
196  {
198  {
199  const QgsExpression exp { value.toString() };
200  f.expression = exp;
201  break;
202  }
204  {
205  f.field.setName( value.toString() );
206  break;
207  }
209  {
210  f.field.setType( static_cast<QVariant::Type>( value.toInt( ) ) );
211  break;
212  }
214  {
215  bool ok;
216  const int length { value.toInt( &ok ) };
217  if ( ok )
218  f.field.setLength( length );
219  break;
220  }
222  {
223  bool ok;
224  const int precision { value.toInt( &ok ) };
225  if ( ok )
227  break;
228  }
230  {
231  // Not editable: do nothing
232  }
233  }
234  emit dataChanged( index, index );
235  }
236  return true;
237  }
238  else
239  {
240  return false;
241  }
242 }
243 
244 QgsFieldConstraints::Constraints QgsFieldMappingModel::fieldConstraints( const QgsField &field ) const
245 {
246  QgsFieldConstraints::Constraints constraints;
247 
248  const QgsFieldConstraints fieldConstraints { field.constraints() };
249 
250  if ( fieldConstraints.constraints() & QgsFieldConstraints::ConstraintNotNull &&
252  constraints.setFlag( QgsFieldConstraints::ConstraintNotNull );
253 
254  if ( fieldConstraints.constraints() & QgsFieldConstraints::ConstraintUnique &&
256  constraints.setFlag( QgsFieldConstraints::ConstraintUnique );
257 
258  if ( fieldConstraints.constraints() & QgsFieldConstraints::ConstraintExpression &&
260  constraints.setFlag( QgsFieldConstraints::ConstraintExpression );
261 
262  return constraints;
263 }
264 
265 bool QgsFieldMappingModel::moveUpOrDown( const QModelIndex &index, bool up )
266 {
267  if ( ! index.isValid() && index.model() == this )
268  return false;
269 
270  // Always swap down
271  const int row { up ? index.row() - 1 : index.row() };
272  // Range checking
273  if ( row < 0 || row + 1 >= rowCount( QModelIndex() ) )
274  {
275  return false;
276  }
277  beginMoveRows( QModelIndex( ), row, row, QModelIndex(), row + 2 );
278 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
279  mMapping.swap( row, row + 1 );
280 #else
281  mMapping.swapItemsAt( row, row + 1 );
282 #endif
283  endMoveRows();
284  return true;
285 }
286 
287 QString QgsFieldMappingModel::findExpressionForDestinationField( const QgsFieldMappingModel::Field &f, QStringList &excludedFieldNames )
288 {
289  // Search for fields in the source
290  // 1. match by name
291  for ( const QgsField &sf : qgis::as_const( mSourceFields ) )
292  {
293  if ( sf.name() == f.field.name() )
294  {
295  excludedFieldNames.push_back( sf.name() );
296  return QgsExpression::quotedColumnRef( sf.name() );
297  }
298  }
299  // 2. match by type
300  for ( const QgsField &sf : qgis::as_const( mSourceFields ) )
301  {
302  if ( excludedFieldNames.contains( sf.name() ) || sf.type() != f.field.type() )
303  continue;
304  excludedFieldNames.push_back( sf.name() );
305  return QgsExpression::quotedColumnRef( sf.name() );
306  }
307  return QString();
308 }
309 
311 {
312  mSourceFields = sourceFields;
313  QStringList usedFields;
314  beginResetModel();
315  for ( const Field &f : qgis::as_const( mMapping ) )
316  {
317  if ( QgsExpression( f.expression ).isField() )
318  {
319  usedFields.push_back( f.expression.mid( 1, f.expression.length() - 2 ) );
320  }
321  }
322  for ( auto it = mMapping.begin(); it != mMapping.end(); ++it )
323  {
324  if ( it->expression.isEmpty() )
325  {
326  const QString expression { findExpressionForDestinationField( *it, usedFields ) };
327  if ( ! expression.isEmpty() )
328  it->expression = expression;
329  }
330  }
331  endResetModel();
332 }
333 
335 {
336  return mExpressionContextGenerator.get();
337 }
338 
340 {
341  mExpressionContextGenerator->setBaseExpressionContextGenerator( generator );
342 }
343 
345  const QMap<QString, QString> &expressions )
346 {
347  beginResetModel();
348  mMapping.clear();
349  // Prepare the model data
350  QStringList usedFields;
351  for ( const QgsField &df : destinationFields )
352  {
353  Field f;
354  f.field = df;
355  f.originalName = df.name();
356  if ( expressions.contains( f.field.name() ) )
357  {
358  f.expression = expressions.value( f.field.name() );
359  const QgsExpression exp { f.expression };
360  // if it's source field
361  if ( exp.isField() &&
362  mSourceFields.names().contains( qgis::setToList( exp.referencedColumns() ).first() ) )
363  {
364  usedFields.push_back( qgis::setToList( exp.referencedColumns() ).first() );
365  }
366  }
367  else
368  {
369  const QString expression { findExpressionForDestinationField( f, usedFields ) };
370  if ( ! expression.isEmpty() )
371  f.expression = expression;
372  }
373  mMapping.push_back( f );
374  }
375  endResetModel();
376 }
377 
379 {
380  return mDestinationEditable;
381 }
382 
383 void QgsFieldMappingModel::setDestinationEditable( bool destinationEditable )
384 {
385  mDestinationEditable = destinationEditable;
386 }
387 
388 const QMap<QVariant::Type, QString> QgsFieldMappingModel::dataTypes()
389 {
390  static const QMap<QVariant::Type, QString> sDataTypes
391  {
392  { QVariant::Type::Int, tr( "Whole number (integer - 32bit)" ) },
393  { QVariant::Type::LongLong, tr( "Whole number (integer - 64bit)" ) },
394  { QVariant::Type::Double, tr( "Decimal number (double)" ) },
395  { QVariant::Type::String, tr( "Text (string)" ) },
396  { QVariant::Type::Date, tr( "Date" ) },
397  { QVariant::Type::Time, tr( "Time" ) },
398  { QVariant::Type::DateTime, tr( "Date & Time" ) },
399  { QVariant::Type::Bool, tr( "Boolean" ) },
400  { QVariant::Type::ByteArray, tr( "Binary object (BLOB)" ) },
401  };
402  return sDataTypes;
403 }
404 
405 QList<QgsFieldMappingModel::Field> QgsFieldMappingModel::mapping() const
406 {
407  return mMapping;
408 }
409 
410 QMap<QString, QgsProperty> QgsFieldMappingModel::fieldPropertyMap() const
411 {
412  QMap< QString, QgsProperty > fieldMap;
413  for ( const QgsFieldMappingModel::Field &field : mMapping )
414  {
415  const QgsExpression exp( field.expression );
416  const bool isField = exp.isField();
417  fieldMap.insert( field.originalName, isField
418  ? QgsProperty::fromField( static_cast<const QgsExpressionNodeColumnRef *>( exp.rootNode() )->name() )
419  : QgsProperty::fromExpression( field.expression ) );
420  }
421  return fieldMap;
422 }
423 
424 void QgsFieldMappingModel::setFieldPropertyMap( const QMap<QString, QgsProperty> &map )
425 {
426  beginResetModel();
427  for ( int i = 0; i < mMapping.count(); ++i )
428  {
429  Field &f = mMapping[i];
430  if ( map.contains( f.field.name() ) )
431  {
432  const QgsProperty prop = map.value( f.field.name() );
433  switch ( prop.propertyType() )
434  {
437  break;
438 
440  f.expression = prop.field();
441  break;
442 
444  f.expression = prop.expressionString();
445  break;
446 
448  f.expression.clear();
449  break;
450  }
451  }
452  else
453  {
454  f.expression.clear();
455  }
456  }
457  endResetModel();
458 }
459 
460 void QgsFieldMappingModel::appendField( const QgsField &field, const QString &expression )
461 {
462  const int lastRow { rowCount( QModelIndex( ) ) };
463  beginInsertRows( QModelIndex(), lastRow, lastRow );
464  Field f;
465  f.field = field;
466  f.expression = expression;
467  f.originalName = field.name();
468  mMapping.push_back( f );
469  endInsertRows( );
470 }
471 
472 bool QgsFieldMappingModel::removeField( const QModelIndex &index )
473 {
474  if ( index.isValid() && index.model() == this && index.row() < rowCount( QModelIndex() ) )
475  {
476  beginRemoveRows( QModelIndex(), index.row(), index.row() );
477  mMapping.removeAt( index.row() );
478  endRemoveRows();
479  return true;
480  }
481  else
482  {
483  return false;
484  }
485 }
486 
487 bool QgsFieldMappingModel::moveUp( const QModelIndex &index )
488 {
489  return moveUpOrDown( index );
490 }
491 
492 bool QgsFieldMappingModel::moveDown( const QModelIndex &index )
493 {
494  return moveUpOrDown( index, false );
495 }
496 
497 QgsFieldMappingModel::ExpressionContextGenerator::ExpressionContextGenerator( const QgsFields *sourceFields )
498  : mSourceFields( sourceFields )
499 {
500 }
501 
502 QgsExpressionContext QgsFieldMappingModel::ExpressionContextGenerator::createExpressionContext() const
503 {
504  if ( mBaseGenerator )
505  {
506  QgsExpressionContext ctx = mBaseGenerator->createExpressionContext();
507  std::unique_ptr< QgsExpressionContextScope > fieldMappingScope = qgis::make_unique< QgsExpressionContextScope >( tr( "Field Mapping" ) );
508  fieldMappingScope->setFields( *mSourceFields );
509  ctx.appendScope( fieldMappingScope.release() );
510  return ctx;
511  }
512  else
513  {
516  ctx.setFields( *mSourceFields );
517  QgsFeature feature { *mSourceFields };
518  feature.setValid( true );
519  ctx.setFeature( feature );
520  return ctx;
521  }
522 }
523 
524 void QgsFieldMappingModel::ExpressionContextGenerator::setBaseExpressionContextGenerator( const QgsExpressionContextGenerator *generator )
525 {
526  mBaseGenerator = generator;
527 }
QgsFieldMappingModel::setDestinationFields
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...
Definition: qgsfieldmappingmodel.cpp:344
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:369
QgsFieldMappingModel::contextGenerator
QgsExpressionContextGenerator * contextGenerator() const
Returns the context generator with the source fields.
Definition: qgsfieldmappingmodel.cpp:334
qgsexpressioncontextutils.h
QgsFieldMappingModel::QgsFieldMappingModel
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,...
Definition: qgsfieldmappingmodel.cpp:21
QgsProperty::fromField
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name.
Definition: qgsproperty.cpp:220
QgsProperty
A store for object properties.
Definition: qgsproperty.h:231
QgsExpressionContextUtils::globalScope
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Definition: qgsexpressioncontextutils.cpp:33
QgsFieldMappingModel::Field::originalName
QString originalName
The original name of the field.
Definition: qgsfieldmappingmodel.h:81
QgsFieldMappingModel::removeField
bool removeField(const QModelIndex &index)
Removes the field at index from the model, returns true on success.
Definition: qgsfieldmappingmodel.cpp:472
QgsFieldConstraints
Definition: qgsfieldconstraints.h:32
QgsExpression::rootNode
const QgsExpressionNode * rootNode() const
Returns the root node of the expression.
Definition: qgsexpression.cpp:1074
QgsExpressionNodeColumnRef
An expression node which takes it value from a feature's field.
Definition: qgsexpressionnodeimpl.h:400
QgsProperty::FieldBasedProperty
@ FieldBasedProperty
Field based property (QgsFieldBasedProperty)
Definition: qgsproperty.h:240
QgsFieldMappingModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: qgsfieldmappingmodel.cpp:90
QgsFields
Definition: qgsfields.h:44
QgsFieldMappingModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: qgsfieldmappingmodel.cpp:83
QgsFieldMappingModel::ColumnDataIndex
ColumnDataIndex
The ColumnDataIndex enum represents the column index for the view.
Definition: qgsfieldmappingmodel.h:63
QgsFeature::setValid
void setValid(bool validity)
Sets the validity of the feature.
Definition: qgsfeature.cpp:188
QgsExpressionContext::setFields
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the context.
Definition: qgsexpressioncontext.cpp:553
QgsFieldMappingModel::sourceFields
QgsFields sourceFields() const
Returns a list of source fields.
Definition: qgsfieldmappingmodel.cpp:78
QgsProperty::fromExpression
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
Definition: qgsproperty.cpp:212
QgsProperty::propertyType
Type propertyType() const
Returns the property type.
Definition: qgsproperty.cpp:261
QgsFieldMappingModel::dataTypes
static const QMap< QVariant::Type, QString > dataTypes()
Returns a static map of supported data types.
Definition: qgsfieldmappingmodel.cpp:388
QgsField::name
QString name
Definition: qgsfield.h:59
QgsFieldConstraints::ConstraintNotNull
@ ConstraintNotNull
Field may not be null.
Definition: qgsfieldconstraints.h:45
QgsFieldMappingModel::destinationEditable
bool destinationEditable() const
Returns true if the destination fields are editable.
Definition: qgsfieldmappingmodel.cpp:378
QgsProperty::value
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
Definition: qgsproperty.cpp:519
QgsFieldMappingModel::moveUp
bool moveUp(const QModelIndex &index)
Moves down the field at index.
Definition: qgsfieldmappingmodel.cpp:487
QgsProperty::expressionString
QString expressionString() const
Returns the expression used for the property value.
Definition: qgsproperty.cpp:323
QgsFieldMappingModel::setDestinationEditable
void setDestinationEditable(bool editable)
Sets the destination fields editable state to editable.
Definition: qgsfieldmappingmodel.cpp:383
QgsExpression::quotedValue
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
Definition: qgsexpression.cpp:79
QgsFieldMappingModel::mapping
QList< QgsFieldMappingModel::Field > mapping() const
Returns a list of Field objects representing the current status of the model.
Definition: qgsfieldmappingmodel.cpp:405
QgsFieldMappingModel::appendField
void appendField(const QgsField &field, const QString &expression=QString())
Appends a new field to the model, with an optional expression.
Definition: qgsfieldmappingmodel.cpp:460
QgsFieldMappingModel::setBaseExpressionContextGenerator
void setBaseExpressionContextGenerator(const QgsExpressionContextGenerator *generator)
Sets the base expression context generator, which will generate the expression contexts for expressio...
Definition: qgsfieldmappingmodel.cpp:339
precision
int precision
Definition: qgswfsgetfeature.cpp:103
QgsProperty::ExpressionBasedProperty
@ ExpressionBasedProperty
Expression based property (QgsExpressionBasedProperty)
Definition: qgsproperty.h:241
QgsFieldMappingModel::Field::field
QgsField field
The field in its current status (it might have been renamed)
Definition: qgsfieldmappingmodel.h:83
QgsFieldMappingModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: qgsfieldmappingmodel.cpp:175
QgsFieldConstraints::ConstraintUnique
@ ConstraintUnique
Field must have a unique value.
Definition: qgsfieldconstraints.h:46
QgsField::setLength
void setLength(int len)
Set the field length.
Definition: qgsfield.cpp:195
QgsFieldMappingModel::setFieldPropertyMap
void setFieldPropertyMap(const QMap< QString, QgsProperty > &map)
Sets a map of destination field name to QgsProperty definition for field value.
Definition: qgsfieldmappingmodel.cpp:424
QgsFieldConstraints::ConstraintStrengthHard
@ ConstraintStrengthHard
Constraint must be honored before feature can be accepted.
Definition: qgsfieldconstraints.h:67
QgsExpressionContext::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Definition: qgsexpressioncontext.cpp:490
QgsFieldMappingModel::ColumnDataIndex::DestinationPrecision
@ DestinationPrecision
Destination field precision.
QgsFieldMappingModel::Field
The Field struct holds information about a mapped field.
Definition: qgsfieldmappingmodel.h:78
qgsexpressionnodeimpl.h
QgsExpressionNodeColumnRef::name
QString name() const
The name of the column.
Definition: qgsexpressionnodeimpl.h:414
QgsField::setPrecision
void setPrecision(int precision)
Set the field precision.
Definition: qgsfield.cpp:199
QgsFieldMappingModel::ColumnDataIndex::SourceExpression
@ SourceExpression
Expression.
QgsFieldMappingModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Definition: qgsfieldmappingmodel.cpp:188
QgsFieldMappingModel::ColumnDataIndex::DestinationConstraints
@ DestinationConstraints
Destination field constraints.
QgsProperty::field
QString field() const
Returns the current field name the property references.
Definition: qgsproperty.cpp:300
QgsFieldConstraints::ConstraintExpression
@ ConstraintExpression
Field has an expression constraint set. See constraintExpression().
Definition: qgsfieldconstraints.h:47
QgsFieldMappingModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: qgsfieldmappingmodel.cpp:97
QgsExpression::quotedColumnRef
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
Definition: qgsexpression.cpp:65
QgsField::constraints
QgsFieldConstraints constraints
Definition: qgsfield.h:62
QgsField::setType
void setType(QVariant::Type type)
Set variant type.
Definition: qgsfield.cpp:180
QgsFeature
Definition: qgsfeature.h:55
QgsProperty::staticValue
QVariant staticValue() const
Returns the current static value for the property.
Definition: qgsproperty.cpp:284
QgsExpression::isField
bool isField() const
Checks whether an expression consists only of a single field reference.
Definition: qgsexpression.cpp:1079
QgsFieldMappingModel::fieldPropertyMap
QMap< QString, QgsProperty > fieldPropertyMap() const
Returns a map of destination field name to QgsProperty definition for field value,...
Definition: qgsfieldmappingmodel.cpp:410
QgsFieldMappingModel::setSourceFields
void setSourceFields(const QgsFields &sourceFields)
Set source fields to sourceFields.
Definition: qgsfieldmappingmodel.cpp:310
QgsFieldMappingModel::Field::expression
QString expression
The expression for the mapped field from the source fields.
Definition: qgsfieldmappingmodel.h:85
QgsExpression
Definition: qgsexpression.h:113
QgsProperty::StaticProperty
@ StaticProperty
Static property (QgsStaticProperty)
Definition: qgsproperty.h:239
QgsFieldMappingModel::ColumnDataIndex::DestinationName
@ DestinationName
Destination field name.
QgsFieldMappingModel::moveDown
bool moveDown(const QModelIndex &index)
Moves up the field at index.
Definition: qgsfieldmappingmodel.cpp:492
QgsExpressionContextGenerator
Definition: qgsexpressioncontextgenerator.h:36
QgsFieldMappingModel::ColumnDataIndex::DestinationLength
@ DestinationLength
Destination field length.
QgsFieldMappingModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: qgsfieldmappingmodel.cpp:32
QgsField::type
QVariant::Type type
Definition: qgsfield.h:57
QgsField::setName
void setName(const QString &name)
Set the field name.
Definition: qgsfield.cpp:175
qgsfieldmappingmodel.h
QgsProperty::InvalidProperty
@ InvalidProperty
Invalid (not set) property.
Definition: qgsproperty.h:238
QgsFields::names
QStringList names() const
Returns a list with field names.
Definition: qgsfields.cpp:143
QgsFieldMappingModel::ColumnDataIndex::DestinationType
@ DestinationType
Destination field QVariant::Type casted to (int)
QgsExpressionContext::setFeature
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Definition: qgsexpressioncontext.cpp:521
QgsField
Definition: qgsfield.h:49