Skip to content

Commit

Permalink
bring layerAdded signal back to fix synchronize
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayan committed May 13, 2013
1 parent 778f223 commit 0dcd9eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -51,6 +51,7 @@ extern "C"

QgsOfflineEditing::QgsOfflineEditing()
{
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( layerAdded( QgsMapLayer* ) ) );
}

QgsOfflineEditing::~QgsOfflineEditing()
Expand Down Expand Up @@ -558,7 +559,6 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con
emit progressUpdated( featureCount++ );
}
sqlExec( db, "COMMIT" );
listenStartStopEdits( newLayer );
}
else
{
Expand Down Expand Up @@ -1219,8 +1219,15 @@ void QgsOfflineEditing::stopListenFeatureChanges()
this, SLOT( committedGeometriesChanges( const QString&, const QgsGeometryMap& ) ) );
}

void QgsOfflineEditing::listenStartStopEdits( QgsVectorLayer *vLayer )
void QgsOfflineEditing::layerAdded( QgsMapLayer* layer )
{
connect( vLayer, SIGNAL( editingStarted() ), this, SLOT( startListenFeatureChanges() ) );
connect( vLayer, SIGNAL( editingStopped() ), this, SLOT( stopListenFeatureChanges() ) );
// detect offline layer
if ( layer->customProperty( CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, false ).toBool() )
{
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer *>( layer );
connect( vLayer, SIGNAL( editingStarted() ), this, SLOT( startListenFeatureChanges() ) );
connect( vLayer, SIGNAL( editingStopped() ), this, SLOT( stopListenFeatureChanges() ) );
}
}


2 changes: 1 addition & 1 deletion src/core/qgsofflineediting.h
Expand Up @@ -134,9 +134,9 @@ class CORE_EXPORT QgsOfflineEditing : public QObject
};
typedef QList<GeometryChange> GeometryChanges;
GeometryChanges sqlQueryGeometryChanges( sqlite3* db, const QString& sql );
void listenStartStopEdits( QgsVectorLayer* vLayer );

private slots:
void layerAdded( QgsMapLayer* layer );
void committedAttributesAdded( const QString& qgisLayerId, const QList<QgsField>& addedAttributes );
void committedFeaturesAdded( const QString& qgisLayerId, const QgsFeatureList& addedFeatures );
void committedFeaturesRemoved( const QString& qgisLayerId, const QgsFeatureIds& deletedFeatureIds );
Expand Down

0 comments on commit 0dcd9eb

Please sign in to comment.