Skip to content

Commit 0dcd9eb

Browse files
committedMay 13, 2013
bring layerAdded signal back to fix synchronize
1 parent 778f223 commit 0dcd9eb

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed
 

‎src/core/qgsofflineediting.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ extern "C"
5151

5252
QgsOfflineEditing::QgsOfflineEditing()
5353
{
54+
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( layerAdded( QgsMapLayer* ) ) );
5455
}
5556

5657
QgsOfflineEditing::~QgsOfflineEditing()
@@ -558,7 +559,6 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con
558559
emit progressUpdated( featureCount++ );
559560
}
560561
sqlExec( db, "COMMIT" );
561-
listenStartStopEdits( newLayer );
562562
}
563563
else
564564
{
@@ -1219,8 +1219,15 @@ void QgsOfflineEditing::stopListenFeatureChanges()
12191219
this, SLOT( committedGeometriesChanges( const QString&, const QgsGeometryMap& ) ) );
12201220
}
12211221

1222-
void QgsOfflineEditing::listenStartStopEdits( QgsVectorLayer *vLayer )
1222+
void QgsOfflineEditing::layerAdded( QgsMapLayer* layer )
12231223
{
1224-
connect( vLayer, SIGNAL( editingStarted() ), this, SLOT( startListenFeatureChanges() ) );
1225-
connect( vLayer, SIGNAL( editingStopped() ), this, SLOT( stopListenFeatureChanges() ) );
1224+
// detect offline layer
1225+
if ( layer->customProperty( CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, false ).toBool() )
1226+
{
1227+
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer *>( layer );
1228+
connect( vLayer, SIGNAL( editingStarted() ), this, SLOT( startListenFeatureChanges() ) );
1229+
connect( vLayer, SIGNAL( editingStopped() ), this, SLOT( stopListenFeatureChanges() ) );
1230+
}
12261231
}
1232+
1233+

‎src/core/qgsofflineediting.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ class CORE_EXPORT QgsOfflineEditing : public QObject
134134
};
135135
typedef QList<GeometryChange> GeometryChanges;
136136
GeometryChanges sqlQueryGeometryChanges( sqlite3* db, const QString& sql );
137-
void listenStartStopEdits( QgsVectorLayer* vLayer );
138137

139138
private slots:
139+
void layerAdded( QgsMapLayer* layer );
140140
void committedAttributesAdded( const QString& qgisLayerId, const QList<QgsField>& addedAttributes );
141141
void committedFeaturesAdded( const QString& qgisLayerId, const QgsFeatureList& addedFeatures );
142142
void committedFeaturesRemoved( const QString& qgisLayerId, const QgsFeatureIds& deletedFeatureIds );

0 commit comments

Comments
 (0)
Please sign in to comment.