QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
Classes | Public Types | Signals | Public Member Functions | List of all members
QgsOfflineEditing Class Reference

#include <qgsofflineediting.h>

Inheritance diagram for QgsOfflineEditing:
Inheritance graph
[legend]

Public Types

enum  ContainerType { SpatiaLite , GPKG }
 Type of offline database container file. More...
 
enum  ProgressMode {
  CopyFeatures = 0 , ProcessFeatures , AddFields , AddFeatures ,
  RemoveFeatures , UpdateFeatures , UpdateGeometries
}
 

Signals

void layerProgressUpdated (int layer, int numLayers)
 Emitted whenever a new layer is being processed. More...
 
void progressModeSet (QgsOfflineEditing::ProgressMode mode, long long maximum)
 Emitted when the mode for the progress of the current operation is set. More...
 
void progressStarted ()
 Emitted when the process has started. More...
 
void progressStopped ()
 Emitted when the processing of all layers has finished. More...
 
void progressUpdated (long long progress)
 Emitted with the progress of the current mode. More...
 
void warning (const QString &title, const QString &message)
 Emitted when a warning needs to be displayed. More...
 

Public Member Functions

 QgsOfflineEditing ()
 
bool convertToOfflineProject (const QString &offlineDataPath, const QString &offlineDbFile, const QStringList &layerIds, bool onlySelected=false, ContainerType containerType=SpatiaLite, const QString &layerNameSuffix=QStringLiteral(" (offline)"))
 Convert current project for offline editing. More...
 
bool isOfflineProject () const
 Returns true if current project is offline. More...
 
void synchronize (bool useTransaction=false)
 Synchronize to remote layers. More...
 

Detailed Description

Definition at line 35 of file qgsofflineediting.h.

Member Enumeration Documentation

◆ ContainerType

Type of offline database container file.

Enumerator
SpatiaLite 
GPKG 

Definition at line 52 of file qgsofflineediting.h.

◆ ProgressMode

Enumerator
CopyFeatures 
ProcessFeatures 
AddFields 
AddFeatures 
RemoveFeatures 
UpdateFeatures 
UpdateGeometries 

Definition at line 40 of file qgsofflineediting.h.

Constructor & Destructor Documentation

◆ QgsOfflineEditing()

QgsOfflineEditing::QgsOfflineEditing ( )

Definition at line 66 of file qgsofflineediting.cpp.

Member Function Documentation

◆ convertToOfflineProject()

bool QgsOfflineEditing::convertToOfflineProject ( const QString &  offlineDataPath,
const QString &  offlineDbFile,
const QStringList &  layerIds,
bool  onlySelected = false,
ContainerType  containerType = SpatiaLite,
const QString &  layerNameSuffix = QStringLiteral( " (offline)" ) 
)

Convert current project for offline editing.

convert current project to offline project returns offline project file path

Parameters
offlineDataPathPath to offline db file
offlineDbFileOffline db file name
layerIdsList of layer names to convert
onlySelectedOnly copy selected features from layers where a selection is present
containerTypedefines the SQLite file container type like SpatiaLite or GPKG
layerNameSuffixSuffix string added to the offline layer name

Workflow:

  • create a sqlite database at offlineDataPath
  • copy layers to Geopackage or SpatiaLite offline layers in the above-created database
  • replace remote layers' data source with offline layers from the database
  • mark those layers as offline
  • mark project as offline

Definition at line 83 of file qgsofflineediting.cpp.

◆ isOfflineProject()

bool QgsOfflineEditing::isOfflineProject ( ) const

Returns true if current project is offline.

Definition at line 138 of file qgsofflineediting.cpp.

◆ layerProgressUpdated

void QgsOfflineEditing::layerProgressUpdated ( int  layer,
int  numLayers 
)
signal

Emitted whenever a new layer is being processed.

It is possible to estimate the progress of the complete operation by comparing the index of the current layer to the total amount numLayers.

◆ progressModeSet

void QgsOfflineEditing::progressModeSet ( QgsOfflineEditing::ProgressMode  mode,
long long  maximum 
)
signal

Emitted when the mode for the progress of the current operation is set.

Parameters
modeprogress mode
maximumtotal number of entities to process in the current operation

◆ progressStarted

void QgsOfflineEditing::progressStarted ( )
signal

Emitted when the process has started.

◆ progressStopped

void QgsOfflineEditing::progressStopped ( )
signal

Emitted when the processing of all layers has finished.

◆ progressUpdated

void QgsOfflineEditing::progressUpdated ( long long  progress)
signal

Emitted with the progress of the current mode.

Parameters
progresscurrent index of processed entities

◆ synchronize()

void QgsOfflineEditing::synchronize ( bool  useTransaction = false)

Synchronize to remote layers.

Parameters
useTransactionenforce the remote layer modifications with the same source to be in a transaction group

Definition at line 143 of file qgsofflineediting.cpp.

◆ warning

void QgsOfflineEditing::warning ( const QString &  title,
const QString &  message 
)
signal

Emitted when a warning needs to be displayed.

Parameters
titletitle string for message
messageA descriptive message for the warning

The documentation for this class was generated from the following files: