Skip to content

Commit f80f4ec

Browse files
committed
only selected features
should be exported to sqlite / gpkg
1 parent b1cd2fd commit f80f4ec

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/core/qgsofflineediting.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString &offlineDataPath,
138138
if ( vl )
139139
{
140140
QString origLayerId = vl->id();
141-
QgsVectorLayer *newLayer;
142-
newLayer = copyVectorLayer( vl, database.get(), dbPath, onlySelected, gpkg );
141+
QgsVectorLayer *newLayer = copyVectorLayer( vl, database.get(), dbPath, onlySelected, gpkg );
143142
if ( newLayer )
144143
{
145144
layerIdMapping.insert( origLayerId, newLayer );
@@ -171,6 +170,7 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString &offlineDataPath,
171170
}
172171
}
173172

173+
174174
emit progressStopped();
175175

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

409+
// creating geopackage
409410
if ( gpkg )
410411
{
411412
OGRSFDriverH hGpkgDriver = OGRGetDriverByName( "GPKG" );
@@ -600,13 +601,15 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
600601
rc = sqlExec( db, sqlCreateIndex );
601602
}
602603
}
603-
if ( rc != SQLITE_OK )
604-
{
605-
showWarning( tr( "Filling SpatiaLite for layer %1 failed" ).arg( layer->name() ) );
606-
return nullptr;
607-
}
608604
}
609605

606+
if ( rc != SQLITE_OK )
607+
{
608+
showWarning( tr( "Filling SpatiaLite for layer %1 failed" ).arg( layer->name() ) );
609+
return nullptr;
610+
}
611+
612+
// add new layer
610613
QString connectionString = QStringLiteral( "dbname='%1' table='%2'%3 sql=" )
611614
.arg( offlineDbPath,
612615
tableName, layer->isSpatial() ? "(Geometry)" : "" );
@@ -760,6 +763,7 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
760763
updateLayerOrder( layer, newLayer );
761764

762765

766+
763767
}
764768
return newLayer;
765769
}
@@ -1352,7 +1356,6 @@ void QgsOfflineEditing::committedFeaturesAdded( const QString &qgisLayerId, cons
13521356
// only store feature ids
13531357
QString sql = QStringLiteral( "SELECT ROWID FROM '%1' ORDER BY ROWID DESC LIMIT %2" ).arg( tableName ).arg( addedFeatures.size() );
13541358
QList<int> newFeatureIds = sqlQueryInts( database.get(), sql );
1355-
13561359
for ( int i = newFeatureIds.size() - 1; i >= 0; i-- )
13571360
{
13581361
QString sql = QStringLiteral( "INSERT INTO 'log_added_features' VALUES ( %1, %2 )" )

src/core/qgsofflineediting.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ class CORE_EXPORT QgsOfflineEditing : public QObject
107107

108108
private:
109109
void initializeSpatialMetadata( sqlite3 *sqlite_handle );
110-
bool createSpatialiteDB( const QString &offlineDbPath, bool gpkg );
110+
bool createSpatialiteDB( const QString &offlineDbPath, bool gpkg = false );
111111
void createLoggingTables( sqlite3 *db );
112112

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

116115
void applyAttributesAdded( QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId, int commitNo );

src/plugins/offline_editing/offline_editing_plugin_gui.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ QgsOfflineEditingPluginGui::QgsOfflineEditingPluginGui( QWidget *parent, Qt::Win
106106

107107
restoreState();
108108

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

0 commit comments

Comments
 (0)