Skip to content

Commit

Permalink
fix photo in relation preview #2058
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Oct 16, 2023
1 parent 16cc7eb commit 4259cf2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/relationfeaturesmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,24 @@ QgsRelation RelationFeaturesModel::relation() const

QVariant RelationFeaturesModel::relationPhotoPath( const FeatureLayerPair &featurePair ) const
{
// Feature title used to get path of the referenced image.
QString path = featureTitle( featurePair ).toString();

int fieldIndex = photoFieldIndex( featurePair.layer() );
QgsEditorWidgetSetup setup = featurePair.layer()->editorWidgetSetup( fieldIndex );
QVariantMap config = setup.config();

const QgsFeature feature = featurePair.feature();
QString path = feature.attribute( fieldIndex ).toString();

QString finalPath = InputUtils::resolvePath( path, homePath(), config, featurePair, QgsProject::instance() );

return QVariant( finalPath );
}

int RelationFeaturesModel::photoFieldIndex( QgsVectorLayer *layer ) const
{
if ( !layer )
{
return -1;
}

QgsFields fields = layer->fields();
for ( int i = 0; i < fields.size(); i++ )
Expand Down

1 comment on commit 4259cf2

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 23.10.470211 just submitted!

Please sign in to comment.