QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Signals | Public Member Functions | Private Types | Private Slots | Private Member Functions | List of all members
QgsOfflineEditing Class Reference

#include <qgsofflineediting.h>

Classes

struct  AttributeValueChange
struct  GeometryChange

Public Types

enum  ProgressMode {
  CopyFeatures = 0, ProcessFeatures, AddFields, AddFeatures,
  RemoveFeatures, UpdateFeatures, UpdateGeometries
}

Signals

void progressStarted ()
 emit a signal that processing has started
void layerProgressUpdated (int layer, int numLayers)
 emit a signal that the next layer of numLayers has started processing
void progressModeSet (QgsOfflineEditing::ProgressMode mode, int maximum)
 emit a signal that sets the mode for the progress of the current operation
void progressUpdated (int progress)
 emit a signal with the progress of the current mode
void progressStopped ()
 emit a signal that processing of all layers has finished

Public Member Functions

 QgsOfflineEditing ()
 ~QgsOfflineEditing ()
bool convertToOfflineProject (const QString &offlineDataPath, const QString &offlineDbFile, const QStringList &layerIds)
 convert current project for offline editing
bool isOfflineProject ()
 return true if current project is offline
void synchronize ()
 synchronize to remote layers

Private Types

typedef QList
< AttributeValueChange
AttributeValueChanges
typedef QList< GeometryChangeGeometryChanges

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)
void committedAttributeValuesChanges (const QString &qgisLayerId, const QgsChangedAttributesMap &changedAttrsMap)
void committedGeometriesChanges (const QString &qgisLayerId, const QgsGeometryMap &changedGeometries)
void startListenFeatureChanges ()
void stopListenFeatureChanges ()

Private Member Functions

void initializeSpatialMetadata (sqlite3 *sqlite_handle)
bool createSpatialiteDB (const QString &offlineDbPath)
void createLoggingTables (sqlite3 *db)
void copyVectorLayer (QgsVectorLayer *layer, sqlite3 *db, const QString &offlineDbPath)
void applyAttributesAdded (QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId, int commitNo)
void applyFeaturesAdded (QgsVectorLayer *offlineLayer, QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId)
void applyFeaturesRemoved (QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId)
void applyAttributeValueChanges (QgsVectorLayer *offlineLayer, QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId, int commitNo)
void applyGeometryChanges (QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId, int commitNo)
void updateFidLookup (QgsVectorLayer *remoteLayer, sqlite3 *db, int layerId)
void copySymbology (const QgsVectorLayer *sourceLayer, QgsVectorLayer *targetLayer)
QMap< int, int > attributeLookup (QgsVectorLayer *offlineLayer, QgsVectorLayer *remoteLayer)
void showWarning (const QString &message)
sqlite3openLoggingDb ()
int getOrCreateLayerId (sqlite3 *db, const QString &qgisLayerId)
int getCommitNo (sqlite3 *db)
void increaseCommitNo (sqlite3 *db)
void addFidLookup (sqlite3 *db, int layerId, QgsFeatureId offlineFid, QgsFeatureId remoteFid)
QgsFeatureId remoteFid (sqlite3 *db, int layerId, QgsFeatureId offlineFid)
QgsFeatureId offlineFid (sqlite3 *db, int layerId, QgsFeatureId remoteFid)
bool isAddedFeature (sqlite3 *db, int layerId, QgsFeatureId fid)
int sqlExec (sqlite3 *db, const QString &sql)
int sqlQueryInt (sqlite3 *db, const QString &sql, int defaultValue)
QList< int > sqlQueryInts (sqlite3 *db, const QString &sql)
QList< QgsFieldsqlQueryAttributesAdded (sqlite3 *db, const QString &sql)
QgsFeatureIds sqlQueryFeaturesRemoved (sqlite3 *db, const QString &sql)
AttributeValueChanges sqlQueryAttributeValueChanges (sqlite3 *db, const QString &sql)
GeometryChanges sqlQueryGeometryChanges (sqlite3 *db, const QString &sql)

Detailed Description

Definition at line 32 of file qgsofflineediting.h.

Member Typedef Documentation

Definition at line 127 of file qgsofflineediting.h.

Definition at line 135 of file qgsofflineediting.h.

Member Enumeration Documentation

Enumerator:
CopyFeatures 
ProcessFeatures 
AddFields 
AddFeatures 
RemoveFeatures 
UpdateFeatures 
UpdateGeometries 

Definition at line 37 of file qgsofflineediting.h.

Constructor & Destructor Documentation

QgsOfflineEditing::QgsOfflineEditing ( )

Definition at line 52 of file qgsofflineediting.cpp.

References QgsMapLayerRegistry::instance(), and layerAdded().

QgsOfflineEditing::~QgsOfflineEditing ( )

Definition at line 57 of file qgsofflineediting.cpp.

Member Function Documentation

void QgsOfflineEditing::addFidLookup ( sqlite3 db,
int  layerId,
QgsFeatureId  offlineFid,
QgsFeatureId  remoteFid 
)
private

Definition at line 845 of file qgsofflineediting.cpp.

References sqlExec().

Referenced by copyVectorLayer(), and updateFidLookup().

void QgsOfflineEditing::applyAttributesAdded ( QgsVectorLayer remoteLayer,
sqlite3 db,
int  layerId,
int  commitNo 
)
private
void QgsOfflineEditing::applyAttributeValueChanges ( QgsVectorLayer offlineLayer,
QgsVectorLayer remoteLayer,
sqlite3 db,
int  layerId,
int  commitNo 
)
private
void QgsOfflineEditing::applyFeaturesAdded ( QgsVectorLayer offlineLayer,
QgsVectorLayer remoteLayer,
sqlite3 db,
int  layerId 
)
private
void QgsOfflineEditing::applyFeaturesRemoved ( QgsVectorLayer remoteLayer,
sqlite3 db,
int  layerId 
)
private
void QgsOfflineEditing::applyGeometryChanges ( QgsVectorLayer remoteLayer,
sqlite3 db,
int  layerId,
int  commitNo 
)
private
QMap< int, int > QgsOfflineEditing::attributeLookup ( QgsVectorLayer offlineLayer,
QgsVectorLayer remoteLayer 
)
private
void QgsOfflineEditing::committedAttributesAdded ( const QString &  qgisLayerId,
const QList< QgsField > &  addedAttributes 
)
privateslot
void QgsOfflineEditing::committedAttributeValuesChanges ( const QString &  qgisLayerId,
const QgsChangedAttributesMap changedAttrsMap 
)
privateslot
void QgsOfflineEditing::committedFeaturesAdded ( const QString &  qgisLayerId,
const QgsFeatureList addedFeatures 
)
privateslot
void QgsOfflineEditing::committedFeaturesRemoved ( const QString &  qgisLayerId,
const QgsFeatureIds deletedFeatureIds 
)
privateslot
void QgsOfflineEditing::committedGeometriesChanges ( const QString &  qgisLayerId,
const QgsGeometryMap changedGeometries 
)
privateslot
bool QgsOfflineEditing::convertToOfflineProject ( const QString &  offlineDataPath,
const QString &  offlineDbFile,
const QStringList &  layerIds 
)

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

Definition at line 65 of file qgsofflineediting.cpp.

References copyVectorLayer(), createLoggingTables(), createSpatialiteDB(), QgsMapLayerRegistry::instance(), QgsProject::instance(), layerProgressUpdated(), QgsMapLayerRegistry::mapLayer(), progressStarted(), progressStopped(), PROJECT_ENTRY_KEY_OFFLINE_DB_PATH, PROJECT_ENTRY_SCOPE_OFFLINE, showWarning(), QgsProject::title(), tr, and QgsProject::writeEntry().

void QgsOfflineEditing::copySymbology ( const QgsVectorLayer sourceLayer,
QgsVectorLayer targetLayer 
)
private
void QgsOfflineEditing::copyVectorLayer ( QgsVectorLayer layer,
sqlite3 db,
const QString &  offlineDbPath 
)
private
void QgsOfflineEditing::createLoggingTables ( sqlite3 db)
private

Definition at line 343 of file qgsofflineediting.cpp.

References sqlExec().

Referenced by convertToOfflineProject().

bool QgsOfflineEditing::createSpatialiteDB ( const QString &  offlineDbPath)
private

Definition at line 294 of file qgsofflineediting.cpp.

References initializeSpatialMetadata(), showWarning(), and tr.

Referenced by convertToOfflineProject().

int QgsOfflineEditing::getCommitNo ( sqlite3 db)
private
int QgsOfflineEditing::getOrCreateLayerId ( sqlite3 db,
const QString &  qgisLayerId 
)
private
void QgsOfflineEditing::increaseCommitNo ( sqlite3 db)
private
void QgsOfflineEditing::initializeSpatialMetadata ( sqlite3 sqlite_handle)
private

Definition at line 249 of file qgsofflineediting.cpp.

References showWarning(), and tr.

Referenced by createSpatialiteDB().

bool QgsOfflineEditing::isAddedFeature ( sqlite3 db,
int  layerId,
QgsFeatureId  fid 
)
private
bool QgsOfflineEditing::isOfflineProject ( )

return true if current project is offline

Definition at line 130 of file qgsofflineediting.cpp.

References QgsProject::instance(), PROJECT_ENTRY_KEY_OFFLINE_DB_PATH, PROJECT_ENTRY_SCOPE_OFFLINE, and QgsProject::readEntry().

void QgsOfflineEditing::layerAdded ( QgsMapLayer layer)
privateslot
void QgsOfflineEditing::layerProgressUpdated ( int  layer,
int  numLayers 
)
signal

emit a signal that the next layer of numLayers has started processing

Parameters
layercurrent layer index
numLayerstotal number of layers

Referenced by convertToOfflineProject(), and synchronize().

QgsFeatureId QgsOfflineEditing::offlineFid ( sqlite3 db,
int  layerId,
QgsFeatureId  remoteFid 
)
private

Definition at line 857 of file qgsofflineediting.cpp.

References sqlQueryInt().

Referenced by updateFidLookup().

sqlite3 * QgsOfflineEditing::openLoggingDb ( )
private
void QgsOfflineEditing::progressModeSet ( QgsOfflineEditing::ProgressMode  mode,
int  maximum 
)
signal

emit a signal that sets the mode for the progress of the current operation

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

Referenced by applyAttributesAdded(), applyAttributeValueChanges(), applyFeaturesAdded(), applyFeaturesRemoved(), applyGeometryChanges(), copyVectorLayer(), and updateFidLookup().

void QgsOfflineEditing::progressStarted ( )
signal

emit a signal that processing has started

Referenced by convertToOfflineProject(), and synchronize().

void QgsOfflineEditing::progressStopped ( )
signal

emit a signal that processing of all layers has finished

Referenced by convertToOfflineProject(), and synchronize().

void QgsOfflineEditing::progressUpdated ( int  progress)
signal

emit a signal with the progress of the current mode

Parameters
progresscurrent index of processed entities

Referenced by applyAttributesAdded(), applyAttributeValueChanges(), applyFeaturesAdded(), applyFeaturesRemoved(), applyGeometryChanges(), copyVectorLayer(), and updateFidLookup().

QgsFeatureId QgsOfflineEditing::remoteFid ( sqlite3 db,
int  layerId,
QgsFeatureId  offlineFid 
)
private
void QgsOfflineEditing::showWarning ( const QString &  message)
private
int QgsOfflineEditing::sqlExec ( sqlite3 db,
const QString &  sql 
)
private
QList< QgsField > QgsOfflineEditing::sqlQueryAttributesAdded ( sqlite3 db,
const QString &  sql 
)
private

Definition at line 923 of file qgsofflineediting.cpp.

References showWarning().

Referenced by applyAttributesAdded().

QgsOfflineEditing::AttributeValueChanges QgsOfflineEditing::sqlQueryAttributeValueChanges ( sqlite3 db,
const QString &  sql 
)
private
QgsFeatureIds QgsOfflineEditing::sqlQueryFeaturesRemoved ( sqlite3 db,
const QString &  sql 
)
private

Definition at line 952 of file qgsofflineediting.cpp.

References showWarning().

Referenced by applyFeaturesRemoved().

QgsOfflineEditing::GeometryChanges QgsOfflineEditing::sqlQueryGeometryChanges ( sqlite3 db,
const QString &  sql 
)
private
int QgsOfflineEditing::sqlQueryInt ( sqlite3 db,
const QString &  sql,
int  defaultValue 
)
private
QList< int > QgsOfflineEditing::sqlQueryInts ( sqlite3 db,
const QString &  sql 
)
private

Definition at line 900 of file qgsofflineediting.cpp.

References showWarning().

Referenced by applyFeaturesAdded(), committedFeaturesAdded(), and updateFidLookup().

void QgsOfflineEditing::startListenFeatureChanges ( )
privateslot
void QgsOfflineEditing::stopListenFeatureChanges ( )
privateslot
void QgsOfflineEditing::synchronize ( )
void QgsOfflineEditing::updateFidLookup ( QgsVectorLayer remoteLayer,
sqlite3 db,
int  layerId 
)
private

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