Skip to content

Commit

Permalink
Code layout
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and nyalldawson committed Apr 3, 2020
1 parent 8ac0a3d commit 1ef0c65
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 44 deletions.
5 changes: 2 additions & 3 deletions python/gui/auto_generated/qgsfieldmappingmodel.sip.in
Expand Up @@ -50,9 +50,8 @@ the mapping expression is editable.
Constructs a QgsFieldMappingModel 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.

:param parent: parent object
field name to the corresponding expression. A ``parent`` object
can be also specified.
%End

QgsExpressionContextGenerator *contextGenerator() const;
Expand Down
5 changes: 2 additions & 3 deletions python/gui/auto_generated/qgsfieldmappingwidget.sip.in
Expand Up @@ -31,9 +31,8 @@ for each set of "destination" fields an expression defines how to obtain the val
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.

:param parent: parent object
field name to the corresponding expression. A:param parent: object
can also be specified.
%End

void setDestinationEditable( bool editable );
Expand Down
66 changes: 32 additions & 34 deletions src/gui/qgsfieldmappingmodel.cpp
Expand Up @@ -163,42 +163,40 @@ bool QgsFieldMappingModel::setData( const QModelIndex &index, const QVariant &va
{
if ( role == Qt::EditRole )
{
Field &f { const_cast<Field &>( mMapping.at( index.row() ) ) };
Field &f = mMapping[index.row()];
switch ( index.column() )
{
{
case ColumnDataIndex::SourceExpression:
{
const QgsExpression exp { value.toString() };
f.expression = exp;
break;
}
case ColumnDataIndex::DestinationName:
{
f.field.setName( value.toString() );
break;
}
case ColumnDataIndex::DestinationType:
{
f.field.setType( static_cast<QVariant::Type>( value.toInt( ) ) );
break;
}
case ColumnDataIndex::DestinationLength:
{
bool ok;
const int length { value.toInt( &ok ) };
if ( ok )
f.field.setLength( length );
break;
}
case ColumnDataIndex::DestinationPrecision:
{
bool ok;
const int precision { value.toInt( &ok ) };
if ( ok )
f.field.setPrecision( precision );
break;
}
case ColumnDataIndex::SourceExpression:
{
const QgsExpression exp { value.toString() };
f.expression = exp;
break;
}
case ColumnDataIndex::DestinationName:
{
f.field.setName( value.toString() );
break;
}
case ColumnDataIndex::DestinationType:
{
f.field.setType( static_cast<QVariant::Type>( value.toInt( ) ) );
break;
}
case ColumnDataIndex::DestinationLength:
{
bool ok;
const int length { value.toInt( &ok ) };
if ( ok )
f.field.setLength( length );
break;
}
case ColumnDataIndex::DestinationPrecision:
{
bool ok;
const int precision { value.toInt( &ok ) };
if ( ok )
f.field.setPrecision( precision );
break;
}
}
emit dataChanged( index, index );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsfieldmappingmodel.h
Expand Up @@ -71,8 +71,8 @@ class GUI_EXPORT QgsFieldMappingModel: public QAbstractTableModel
* Constructs a QgsFieldMappingModel from a set of \a sourceFields
* and \a destinationFields, initial values for the expressions can be
* optionally specified through \a expressions which is a map from the original
* field name to the corresponding expression.
* \param parent parent object
* field name to the corresponding expression. A \a parent object
* can be also specified.
*/
QgsFieldMappingModel( const QgsFields &sourceFields = QgsFields(),
const QgsFields &destinationFields = QgsFields(),
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsfieldmappingwidget.h
Expand Up @@ -41,8 +41,8 @@ class GUI_EXPORT QgsFieldMappingWidget : public QWidget, private Ui::QgsFieldMap
* Constructs a QgsFieldMappingWidget from a set of \a sourceFields
* and \a destinationFields, initial values for the expressions can be
* optionally specified through \a expressions which is a map from the original
* field name to the corresponding expression.
* \param parent parent object
* field name to the corresponding expression. A \param parent object
* can also be specified.
*/
explicit QgsFieldMappingWidget( const QgsFields &sourceFields = QgsFields(),
const QgsFields &destinationFields = QgsFields(),
Expand Down

0 comments on commit 1ef0c65

Please sign in to comment.