debug output for QgsRelation::isValid()

This commit is contained in:
Denis Rouzaud 2016-08-11 09:18:18 +02:00
parent a72485cf47
commit 6e86a9a0f7

View File

@ -311,26 +311,46 @@ void QgsRelation::updateRelationStatus()
mValid = true;
if ( mRelationId.isEmpty() )
mValid = false;
if ( !mReferencedLayer || !mReferencingLayer )
{
QgsDebugMsg( "Invalid relation: no ID" );
mValid = false;
}
}
else
{
if ( mFieldPairs.count() < 1 )
if ( !mReferencedLayer )
{
QgsDebugMsg( QString("Invalid relation: referenced layer does not exist. ID: %1").arg(mReferencedLayerId) );
mValid = false;
}
Q_FOREACH ( const FieldPair& fieldPair, mFieldPairs )
else if ( !mReferencingLayer )
{
if ( -1 == mReferencingLayer->fieldNameIndex( fieldPair.first )
|| -1 == mReferencedLayer->fieldNameIndex( fieldPair.second ) )
QgsDebugMsg( QString("Invalid relation: referencing layer does not exist. ID: %2").arg(mReferencingLayerId) );
mValid = false;
}
else
{
if ( mFieldPairs.count() < 1 )
{
QgsDebugMsg( "Invalid relation: no pair of field is specified." );
mValid = false;
}
Q_FOREACH ( const FieldPair& fieldPair, mFieldPairs )
{
if ( -1 == mReferencingLayer->fieldNameIndex( fieldPair.first ))
{
QgsDebugMsg( QString("Invalid relation: field %1 does not exist in referencing layer %2").arg(fieldPair.first, mReferencingLayer->name()) );
mValid = false;
break;
}
else if ( -1 == mReferencedLayer->fieldNameIndex( fieldPair.second ) )
{
QgsDebugMsg( QString("Invalid relation: field %1 does not exist in referencedg layer %2").arg(fieldPair.second, mReferencedLayer->name()) );
mValid = false;
break;
}
}
}
}
}