Skip to content

Commit

Permalink
Offline editing: preserve join field names (layer prefix)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 22, 2015
1 parent 3dbf70f commit 772033d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/core/qgsofflineediting.cpp
Expand Up @@ -95,7 +95,24 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString& offlineDataPath,
{
QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( layerIds.at( i ) );
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( layer );
const QgsVectorJoinList& joins = vl->vectorJoins();
QgsVectorJoinList joins = vl->vectorJoins();

// Layer names will be appended an _offline suffix
// Join fields are prefixed with the layer name and we do not want the
// field name to change so we stabilize the field name by defining a
// custom prefix with the layername without _offline suffix.
QgsVectorJoinList::iterator it = joins.begin();
while ( it != joins.end() )
{
if (( *it ).prefix.isNull() )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer(( *it ).joinLayerId ) );

if ( vl )
( *it ).prefix = vl->name() + "_";
}
++it;
}
joinInfoBuffer.insert( vl->id(), joins );
}

Expand Down

0 comments on commit 772033d

Please sign in to comment.