|
33 | 33 | #include "qgslogger.h"
|
34 | 34 | #include "qgsvectorlayerutils.h"
|
35 | 35 | #include "qgsrelationmanager.h"
|
| 36 | +#include "qgsmapthemecollection.h" |
36 | 37 |
|
37 | 38 | #include <QDir>
|
38 | 39 | #include <QDomDocument>
|
@@ -256,6 +257,7 @@ void QgsOfflineEditing::synchronize()
|
256 | 257 | // copy style
|
257 | 258 | copySymbology( offlineLayer, remoteLayer );
|
258 | 259 | updateRelations( offlineLayer, remoteLayer );
|
| 260 | + updateMapThemes( offlineLayer, remoteLayer ); |
259 | 261 |
|
260 | 262 | // apply layer edit log
|
261 | 263 | QString qgisLayerId = layer->id();
|
@@ -614,6 +616,7 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
|
614 | 616 | }
|
615 | 617 |
|
616 | 618 | updateRelations( layer, newLayer );
|
| 619 | + updateMapThemes( layer, newLayer ); |
617 | 620 | // copy features
|
618 | 621 | newLayer->startEditing();
|
619 | 622 | QgsFeature f;
|
@@ -924,6 +927,29 @@ void QgsOfflineEditing::updateRelations( QgsVectorLayer* sourceLayer, QgsVectorL
|
924 | 927 | }
|
925 | 928 | }
|
926 | 929 |
|
| 930 | +void QgsOfflineEditing::updateMapThemes( QgsVectorLayer* sourceLayer, QgsVectorLayer* targetLayer ) |
| 931 | +{ |
| 932 | + QgsMapThemeCollection* mapThemeCollection = QgsProject::instance()->mapThemeCollection(); |
| 933 | + QStringList mapThemeNames = mapThemeCollection->mapThemes(); |
| 934 | + |
| 935 | + Q_FOREACH ( const QString& mapThemeName, mapThemeNames ) |
| 936 | + { |
| 937 | + QgsMapThemeCollection::MapThemeRecord record = mapThemeCollection->mapThemeState( mapThemeName ); |
| 938 | + |
| 939 | + Q_FOREACH ( QgsMapThemeCollection::MapThemeLayerRecord layerRecord, record.layerRecords() ) |
| 940 | + { |
| 941 | + if ( layerRecord.layer() == sourceLayer ) |
| 942 | + { |
| 943 | + layerRecord.setLayer( targetLayer ); |
| 944 | + record.removeLayerRecord( sourceLayer ); |
| 945 | + record.addLayerRecord( layerRecord ); |
| 946 | + } |
| 947 | + } |
| 948 | + |
| 949 | + QgsProject::instance()->mapThemeCollection()->update( mapThemeName, record ); |
| 950 | + } |
| 951 | +} |
| 952 | + |
927 | 953 | // NOTE: use this to map column indices in case the remote geometry column is not last
|
928 | 954 | QMap<int, int> QgsOfflineEditing::attributeLookup( QgsVectorLayer* offlineLayer, QgsVectorLayer* remoteLayer )
|
929 | 955 | {
|
|
0 commit comments