mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
Make offline editing a Q_FOREACH free zone
This commit is contained in:
parent
525f0f01a2
commit
8f38e86a8e
@ -105,7 +105,7 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString &offlineDataPath,
|
|||||||
QMap<QString, QgsVectorJoinList > joinInfoBuffer;
|
QMap<QString, QgsVectorJoinList > joinInfoBuffer;
|
||||||
QMap<QString, QgsVectorLayer *> layerIdMapping;
|
QMap<QString, QgsVectorLayer *> layerIdMapping;
|
||||||
|
|
||||||
Q_FOREACH ( const QString &layerId, layerIds )
|
for ( const QString &layerId : layerIds )
|
||||||
{
|
{
|
||||||
QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId );
|
QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId );
|
||||||
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
|
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
|
||||||
@ -161,7 +161,8 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString &offlineDataPath,
|
|||||||
|
|
||||||
if ( newLayer )
|
if ( newLayer )
|
||||||
{
|
{
|
||||||
Q_FOREACH ( QgsVectorLayerJoinInfo join, it.value() )
|
const QList<QgsVectorLayerJoinInfo> joins = it.value();
|
||||||
|
for ( QgsVectorLayerJoinInfo join : joins )
|
||||||
{
|
{
|
||||||
QgsVectorLayer *newJoinedLayer = layerIdMapping.value( join.joinLayerId() );
|
QgsVectorLayer *newJoinedLayer = layerIdMapping.value( join.joinLayerId() );
|
||||||
if ( newJoinedLayer )
|
if ( newJoinedLayer )
|
||||||
@ -910,9 +911,9 @@ void QgsOfflineEditing::applyAttributesAdded( QgsVectorLayer *remoteLayer, sqlit
|
|||||||
void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer *offlineLayer, QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId )
|
void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer *offlineLayer, QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId )
|
||||||
{
|
{
|
||||||
QString sql = QStringLiteral( "SELECT \"fid\" FROM 'log_added_features' WHERE \"layer_id\" = %1" ).arg( layerId );
|
QString sql = QStringLiteral( "SELECT \"fid\" FROM 'log_added_features' WHERE \"layer_id\" = %1" ).arg( layerId );
|
||||||
QList<int> featureIdInts = sqlQueryInts( db, sql );
|
const QList<int> featureIdInts = sqlQueryInts( db, sql );
|
||||||
QgsFeatureIds newFeatureIds;
|
QgsFeatureIds newFeatureIds;
|
||||||
Q_FOREACH ( int id, featureIdInts )
|
for ( int id : featureIdInts )
|
||||||
{
|
{
|
||||||
newFeatureIds << id;
|
newFeatureIds << id;
|
||||||
}
|
}
|
||||||
@ -1073,19 +1074,18 @@ void QgsOfflineEditing::copySymbology( QgsVectorLayer *sourceLayer, QgsVectorLay
|
|||||||
void QgsOfflineEditing::updateRelations( QgsVectorLayer *sourceLayer, QgsVectorLayer *targetLayer )
|
void QgsOfflineEditing::updateRelations( QgsVectorLayer *sourceLayer, QgsVectorLayer *targetLayer )
|
||||||
{
|
{
|
||||||
QgsRelationManager *relationManager = QgsProject::instance()->relationManager();
|
QgsRelationManager *relationManager = QgsProject::instance()->relationManager();
|
||||||
QList<QgsRelation> relations;
|
const QList<QgsRelation> referencedRelations = relationManager->referencedRelations( sourceLayer );
|
||||||
relations = relationManager->referencedRelations( sourceLayer );
|
|
||||||
|
|
||||||
Q_FOREACH ( QgsRelation relation, relations )
|
for ( QgsRelation relation : referencedRelations )
|
||||||
{
|
{
|
||||||
relationManager->removeRelation( relation );
|
relationManager->removeRelation( relation );
|
||||||
relation.setReferencedLayer( targetLayer->id() );
|
relation.setReferencedLayer( targetLayer->id() );
|
||||||
relationManager->addRelation( relation );
|
relationManager->addRelation( relation );
|
||||||
}
|
}
|
||||||
|
|
||||||
relations = relationManager->referencingRelations( sourceLayer );
|
const QList<QgsRelation> referencingRelations = relationManager->referencingRelations( sourceLayer );
|
||||||
|
|
||||||
Q_FOREACH ( QgsRelation relation, relations )
|
for ( QgsRelation relation : referencingRelations )
|
||||||
{
|
{
|
||||||
relationManager->removeRelation( relation );
|
relationManager->removeRelation( relation );
|
||||||
relation.setReferencingLayer( targetLayer->id() );
|
relation.setReferencingLayer( targetLayer->id() );
|
||||||
@ -1096,13 +1096,15 @@ void QgsOfflineEditing::updateRelations( QgsVectorLayer *sourceLayer, QgsVectorL
|
|||||||
void QgsOfflineEditing::updateMapThemes( QgsVectorLayer *sourceLayer, QgsVectorLayer *targetLayer )
|
void QgsOfflineEditing::updateMapThemes( QgsVectorLayer *sourceLayer, QgsVectorLayer *targetLayer )
|
||||||
{
|
{
|
||||||
QgsMapThemeCollection *mapThemeCollection = QgsProject::instance()->mapThemeCollection();
|
QgsMapThemeCollection *mapThemeCollection = QgsProject::instance()->mapThemeCollection();
|
||||||
QStringList mapThemeNames = mapThemeCollection->mapThemes();
|
const QStringList mapThemeNames = mapThemeCollection->mapThemes();
|
||||||
|
|
||||||
Q_FOREACH ( const QString &mapThemeName, mapThemeNames )
|
for ( const QString &mapThemeName : mapThemeNames )
|
||||||
{
|
{
|
||||||
QgsMapThemeCollection::MapThemeRecord record = mapThemeCollection->mapThemeState( mapThemeName );
|
QgsMapThemeCollection::MapThemeRecord record = mapThemeCollection->mapThemeState( mapThemeName );
|
||||||
|
|
||||||
Q_FOREACH ( QgsMapThemeCollection::MapThemeLayerRecord layerRecord, record.layerRecords() )
|
const auto layerRecords = record.layerRecords();
|
||||||
|
|
||||||
|
for ( QgsMapThemeCollection::MapThemeLayerRecord layerRecord : layerRecords )
|
||||||
{
|
{
|
||||||
if ( layerRecord.layer() == sourceLayer )
|
if ( layerRecord.layer() == sourceLayer )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user