Skip to content
Permalink
Browse files

only selected features

should be exported to sqlite / gpkg
  • Loading branch information
signedav committed May 22, 2018
1 parent b1cd2fd commit f80f4ecb13b078ec93be11de4a78628a13030b49
@@ -138,8 +138,7 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString &offlineDataPath,
if ( vl )
{
QString origLayerId = vl->id();
QgsVectorLayer *newLayer;
newLayer = copyVectorLayer( vl, database.get(), dbPath, onlySelected, gpkg );
QgsVectorLayer *newLayer = copyVectorLayer( vl, database.get(), dbPath, onlySelected, gpkg );
if ( newLayer )
{
layerIdMapping.insert( origLayerId, newLayer );
@@ -171,6 +170,7 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString &offlineDataPath,
}
}


emit progressStopped();

// save offline project
@@ -406,6 +406,7 @@ bool QgsOfflineEditing::createSpatialiteDB( const QString &offlineDbPath, bool g
// creating/opening the new database
QString dbPath = newDb.fileName();

// creating geopackage
if ( gpkg )
{
OGRSFDriverH hGpkgDriver = OGRGetDriverByName( "GPKG" );
@@ -600,13 +601,15 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
rc = sqlExec( db, sqlCreateIndex );
}
}
if ( rc != SQLITE_OK )
{
showWarning( tr( "Filling SpatiaLite for layer %1 failed" ).arg( layer->name() ) );
return nullptr;
}
}

if ( rc != SQLITE_OK )
{
showWarning( tr( "Filling SpatiaLite for layer %1 failed" ).arg( layer->name() ) );
return nullptr;
}

// add new layer
QString connectionString = QStringLiteral( "dbname='%1' table='%2'%3 sql=" )
.arg( offlineDbPath,
tableName, layer->isSpatial() ? "(Geometry)" : "" );
@@ -760,6 +763,7 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
updateLayerOrder( layer, newLayer );



}
return newLayer;
}
@@ -1352,7 +1356,6 @@ void QgsOfflineEditing::committedFeaturesAdded( const QString &qgisLayerId, cons
// only store feature ids
QString sql = QStringLiteral( "SELECT ROWID FROM '%1' ORDER BY ROWID DESC LIMIT %2" ).arg( tableName ).arg( addedFeatures.size() );
QList<int> newFeatureIds = sqlQueryInts( database.get(), sql );

for ( int i = newFeatureIds.size() - 1; i >= 0; i-- )
{
QString sql = QStringLiteral( "INSERT INTO 'log_added_features' VALUES ( %1, %2 )" )
@@ -107,10 +107,9 @@ class CORE_EXPORT QgsOfflineEditing : public QObject

private:
void initializeSpatialMetadata( sqlite3 *sqlite_handle );
bool createSpatialiteDB( const QString &offlineDbPath, bool gpkg );
bool createSpatialiteDB( const QString &offlineDbPath, bool gpkg = false );
void createLoggingTables( sqlite3 *db );

QgsVectorLayer *copyVectorLayerGpkg( QgsVectorLayer *layer, sqlite3 *db, const QString &offlineDbPath );
QgsVectorLayer *copyVectorLayer( QgsVectorLayer *layer, sqlite3 *db, const QString &offlineDbPath, bool onlySelected, bool gpkg );

void applyAttributesAdded( QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId, int commitNo );
@@ -106,7 +106,6 @@ QgsOfflineEditingPluginGui::QgsOfflineEditingPluginGui( QWidget *parent, Qt::Win

restoreState();

mOnlySelectedCheckBox->setDisabled( true );
mOfflineDbFile = QStringLiteral( "offline.gpkg" );
mOfflineDataPathLineEdit->setText( QDir( mOfflineDataPath ).absoluteFilePath( mOfflineDbFile ) );

0 comments on commit f80f4ec

Please sign in to comment.
You can’t perform that action at this time.