Skip to content
Permalink
Browse files

Convert some Q_FOREACHes to for-in

  • Loading branch information
m-kuhn committed Oct 26, 2017
1 parent 3eefe0d commit 93395950b3b8f07f52778fcd0732641bc1278b71
Showing with 24 additions and 15 deletions.
  1. +24 −15 src/gui/qgsattributeform.cpp
@@ -717,9 +717,9 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww )
updateConstraint( ft, eww );

// update eww dependencies constraint
QList<QgsEditorWidgetWrapper *> deps = constraintDependencies( eww );
const QList<QgsEditorWidgetWrapper *> deps = constraintDependencies( eww );

Q_FOREACH ( QgsEditorWidgetWrapper *depsEww, deps )
for ( QgsEditorWidgetWrapper *depsEww : deps )
updateConstraint( ft, depsEww );

// sync OK button status
@@ -728,7 +728,8 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww )
mExpressionContext.setFeature( ft );

// Recheck visibility for all containers which are controlled by this value
Q_FOREACH ( ContainerInformation *info, mContainerInformationDependency.value( eww->field().name() ) )
const QVector<ContainerInformation *> infos = mContainerInformationDependency.value( eww->field().name() );
for ( ContainerInformation *info : infos )
{
info->apply( &mExpressionContext );
}
@@ -767,10 +768,9 @@ bool QgsAttributeForm::currentFormFeature( QgsFeature &feature )
{
bool rc = true;
feature = QgsFeature( mFeature );
QgsAttributes src = feature.attributes();
QgsAttributes dst = feature.attributes();

Q_FOREACH ( QgsWidgetWrapper *ww, mWidgets )
for ( QgsWidgetWrapper *ww : qgis::as_const( mWidgets ) )
{
QgsEditorWidgetWrapper *eww = qobject_cast<QgsEditorWidgetWrapper *>( ww );

@@ -802,18 +802,20 @@ bool QgsAttributeForm::currentFormFeature( QgsFeature &feature )
void QgsAttributeForm::registerContainerInformation( QgsAttributeForm::ContainerInformation *info )
{
mContainerVisibilityInformation.append( info );
Q_FOREACH ( const QString &col, info->expression.referencedColumns() )

const QSet<QString> referencedColumns = info->expression.referencedColumns();

for ( const QString &col : referencedColumns )
{
mContainerInformationDependency[ col ].append( info );
}
}

bool QgsAttributeForm::currentFormValidConstraints( QStringList &invalidFields,
QStringList &descriptions )
bool QgsAttributeForm::currentFormValidConstraints( QStringList &invalidFields, QStringList &descriptions )
{
bool valid( true );

Q_FOREACH ( QgsWidgetWrapper *ww, mWidgets )
for ( QgsWidgetWrapper *ww : qgis::as_const( mWidgets ) )
{
QgsEditorWidgetWrapper *eww = qobject_cast<QgsEditorWidgetWrapper *>( ww );
if ( eww )
@@ -907,7 +909,7 @@ QList<QgsEditorWidgetWrapper *> QgsAttributeForm::constraintDependencies( QgsEdi
QString name = w->field().name();

// for each widget in the current form
Q_FOREACH ( QgsWidgetWrapper *ww, mWidgets )
for ( QgsWidgetWrapper *ww : qgis::as_const( mWidgets ) )
{
// get the wrapper
QgsEditorWidgetWrapper *eww = qobject_cast<QgsEditorWidgetWrapper *>( ww );
@@ -920,7 +922,9 @@ QList<QgsEditorWidgetWrapper *> QgsAttributeForm::constraintDependencies( QgsEdi
// get expression and referencedColumns
QgsExpression expr = eww->layer()->fields().at( eww->fieldIdx() ).constraints().constraintExpression();

Q_FOREACH ( const QString &colName, expr.referencedColumns() )
const auto referencedColumns = expr.referencedColumns();

for ( const QString &colName : referencedColumns )
{
if ( name == colName )
{
@@ -960,7 +964,7 @@ void QgsAttributeForm::synchronizeEnabledState()
|| mMode == AddFeatureMode
|| mMode == MultiEditMode ) && mLayer->isEditable();

Q_FOREACH ( QgsWidgetWrapper *ww, mWidgets )
for ( QgsWidgetWrapper *ww : qgis::as_const( mWidgets ) )
{
QgsEditorWidgetWrapper *eww = qobject_cast<QgsEditorWidgetWrapper *>( ww );
if ( eww )
@@ -1070,7 +1074,9 @@ void QgsAttributeForm::init()
int column = 0;
int columnCount = 1;

Q_FOREACH ( QgsAttributeEditorElement *widgDef, mLayer->editFormConfig().tabs() )
const QList<QgsAttributeEditorElement *> tabs = mLayer->editFormConfig().tabs();

for ( QgsAttributeEditorElement *widgDef : tabs )
{
if ( widgDef->type() == QgsAttributeEditorElement::AeTypeContainer )
{
@@ -1182,9 +1188,12 @@ void QgsAttributeForm::init()
}

int row = 0;
Q_FOREACH ( const QgsField &field, mLayer->fields().toList() )

const QgsFields fields = mLayer->fields();

for ( const QgsField &field : fields )
{
int idx = mLayer->fields().lookupField( field.name() );
int idx = fields.lookupField( field.name() );
if ( idx < 0 )
continue;

0 comments on commit 9339595

Please sign in to comment.
You can’t perform that action at this time.