QGIS API Documentation
2.0.1-Dufour
|
#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< GeometryChange > | GeometryChanges |
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) |
sqlite3 * | openLoggingDb () |
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< QgsField > | sqlQueryAttributesAdded (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) |
Definition at line 32 of file qgsofflineediting.h.
|
private |
Definition at line 127 of file qgsofflineediting.h.
|
private |
Definition at line 135 of file qgsofflineediting.h.
CopyFeatures | |
ProcessFeatures | |
AddFields | |
AddFeatures | |
RemoveFeatures | |
UpdateFeatures | |
UpdateGeometries |
Definition at line 37 of file qgsofflineediting.h.
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.
|
private |
Definition at line 845 of file qgsofflineediting.cpp.
References sqlExec().
Referenced by copyVectorLayer(), and updateFidLookup().
|
private |
Definition at line 575 of file qgsofflineediting.cpp.
References QgsVectorLayer::addAttribute(), AddFields, QgsVectorLayer::dataProvider(), QgsVectorDataProvider::NativeType::mType, QgsVectorDataProvider::NativeType::mTypeName, QgsField::name(), QgsVectorDataProvider::nativeTypes(), progressModeSet(), progressUpdated(), QgsField::setTypeName(), showWarning(), sqlQueryAttributesAdded(), and QgsField::type().
Referenced by synchronize().
|
private |
Definition at line 671 of file qgsofflineediting.cpp.
References attributeLookup(), QgsVectorLayer::changeAttributeValue(), progressModeSet(), progressUpdated(), remoteFid(), sqlQueryAttributeValueChanges(), and UpdateFeatures.
Referenced by synchronize().
|
private |
Definition at line 612 of file qgsofflineediting.cpp.
References QgsVectorLayer::addFeature(), AddFeatures, attributeLookup(), QgsFeature::attributes(), QgsFields::count(), QgsVectorLayer::getFeatures(), QgsFeatureIterator::nextFeature(), QgsVectorLayer::pendingFields(), progressModeSet(), progressUpdated(), QgsFeature::setAttributes(), and sqlQueryInts().
Referenced by synchronize().
|
private |
Definition at line 654 of file qgsofflineediting.cpp.
References QgsVectorLayer::deleteFeature(), progressModeSet(), progressUpdated(), remoteFid(), RemoveFeatures, and sqlQueryFeaturesRemoved().
Referenced by synchronize().
|
private |
Definition at line 690 of file qgsofflineediting.cpp.
References QgsVectorLayer::changeGeometry(), QgsGeometry::fromWkt(), progressModeSet(), progressUpdated(), remoteFid(), sqlQueryGeometryChanges(), and UpdateGeometries.
Referenced by synchronize().
|
private |
Definition at line 771 of file qgsofflineediting.cpp.
References QgsVectorLayer::pendingAllAttributesList().
Referenced by applyAttributeValueChanges(), and applyFeaturesAdded().
|
privateslot |
Definition at line 1028 of file qgsofflineediting.cpp.
References QgsField::comment(), getCommitNo(), getOrCreateLayerId(), increaseCommitNo(), QgsField::length(), QgsField::name(), openLoggingDb(), QgsField::precision(), sqlExec(), and QgsField::type().
Referenced by startListenFeatureChanges(), and stopListenFeatureChanges().
|
privateslot |
Definition at line 1118 of file qgsofflineediting.cpp.
References getCommitNo(), getOrCreateLayerId(), increaseCommitNo(), isAddedFeature(), openLoggingDb(), and sqlExec().
Referenced by startListenFeatureChanges(), and stopListenFeatureChanges().
|
privateslot |
Definition at line 1058 of file qgsofflineediting.cpp.
References getOrCreateLayerId(), QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayer(), openLoggingDb(), QgsMapLayer::source(), sqlExec(), sqlQueryInts(), and QgsDataSourceURI::table().
Referenced by startListenFeatureChanges(), and stopListenFeatureChanges().
|
privateslot |
Definition at line 1087 of file qgsofflineediting.cpp.
References getOrCreateLayerId(), isAddedFeature(), openLoggingDb(), and sqlExec().
Referenced by startListenFeatureChanges(), and stopListenFeatureChanges().
|
privateslot |
Definition at line 1155 of file qgsofflineediting.cpp.
References QgsGeometry::exportToWkt(), getCommitNo(), getOrCreateLayerId(), increaseCommitNo(), isAddedFeature(), openLoggingDb(), and sqlExec().
Referenced by startListenFeatureChanges(), and stopListenFeatureChanges().
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
offlineDataPath | path to offline db file |
offlineDbFile | offline db file name |
layerIds | list 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().
|
private |
Definition at line 752 of file qgsofflineediting.cpp.
References QgsVectorLayer::readSymbology(), showWarning(), and QgsVectorLayer::writeSymbology().
Referenced by copyVectorLayer(), and synchronize().
|
private |
Definition at line 389 of file qgsofflineediting.cpp.
References QgsVectorLayer::addFeature(), addFidLookup(), QgsMapLayerRegistry::addMapLayers(), QgsFeature::attributes(), QgsCoordinateReferenceSystem::authid(), QgsVectorLayer::commitChanges(), QgsVectorLayer::commitErrors(), CopyFeatures, copySymbology(), QgsFields::count(), QgsMapLayer::crs(), CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, CUSTOM_PROPERTY_REMOTE_PROVIDER, CUSTOM_PROPERTY_REMOTE_SOURCE, QgsVectorLayer::dataProvider(), QgsVectorLayer::featureCount(), QgsVectorDataProvider::fields(), QgsVectorLayer::getFeatures(), getOrCreateLayerId(), QgsVectorLayer::hasLabelsEnabled(), QgsMapLayer::id(), QgsFeature::id(), QgsMapLayerRegistry::instance(), QgsMapLayer::isValid(), QgsMapLayer::name(), QgsFeatureIterator::nextFeature(), QgsFeatureRequest::NoGeometry, ProcessFeatures, progressModeSet(), progressUpdated(), QgsVectorLayer::providerType(), QgsMapLayerRegistry::removeMapLayers(), QgsFeature::setAttributes(), QgsMapLayer::setCustomProperty(), QgsVectorLayer::setSubsetString(), showWarning(), QgsMapLayer::source(), sqlExec(), QgsVectorLayer::startEditing(), tr, QGis::WKBLineString, QGis::WKBMultiLineString, QGis::WKBMultiPoint, QGis::WKBMultiPolygon, QGis::WKBPoint, QGis::WKBPolygon, and QgsVectorLayer::wkbType().
Referenced by convertToOfflineProject().
|
private |
Definition at line 343 of file qgsofflineediting.cpp.
References sqlExec().
Referenced by convertToOfflineProject().
|
private |
Definition at line 294 of file qgsofflineediting.cpp.
References initializeSpatialMetadata(), showWarning(), and tr.
Referenced by convertToOfflineProject().
|
private |
Definition at line 833 of file qgsofflineediting.cpp.
References sqlQueryInt().
Referenced by committedAttributesAdded(), committedAttributeValuesChanges(), committedGeometriesChanges(), increaseCommitNo(), and synchronize().
|
private |
Definition at line 808 of file qgsofflineediting.cpp.
References sqlExec(), and sqlQueryInt().
Referenced by committedAttributesAdded(), committedAttributeValuesChanges(), committedFeaturesAdded(), committedFeaturesRemoved(), committedGeometriesChanges(), and copyVectorLayer().
|
private |
Definition at line 839 of file qgsofflineediting.cpp.
References getCommitNo(), and sqlExec().
Referenced by committedAttributesAdded(), committedAttributeValuesChanges(), and committedGeometriesChanges().
|
private |
Definition at line 249 of file qgsofflineediting.cpp.
References showWarning(), and tr.
Referenced by createSpatialiteDB().
|
private |
Definition at line 863 of file qgsofflineediting.cpp.
References sqlQueryInt().
Referenced by committedAttributeValuesChanges(), committedFeaturesRemoved(), and committedGeometriesChanges().
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().
|
privateslot |
Definition at line 1222 of file qgsofflineediting.cpp.
References CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, QgsMapLayer::customProperty(), startListenFeatureChanges(), and stopListenFeatureChanges().
Referenced by QgsOfflineEditing().
|
signal |
emit a signal that the next layer of numLayers has started processing
layer | current layer index |
numLayers | total number of layers |
Referenced by convertToOfflineProject(), and synchronize().
|
private |
Definition at line 857 of file qgsofflineediting.cpp.
References sqlQueryInt().
Referenced by updateFidLookup().
|
private |
Definition at line 791 of file qgsofflineediting.cpp.
References QgsProject::instance(), PROJECT_ENTRY_KEY_OFFLINE_DB_PATH, PROJECT_ENTRY_SCOPE_OFFLINE, QgsProject::readEntry(), showWarning(), and tr.
Referenced by committedAttributesAdded(), committedAttributeValuesChanges(), committedFeaturesAdded(), committedFeaturesRemoved(), committedGeometriesChanges(), and synchronize().
|
signal |
emit a signal that sets the mode for the progress of the current operation
mode | progress mode |
maximum | total number of entities to process in the current operation |
Referenced by applyAttributesAdded(), applyAttributeValueChanges(), applyFeaturesAdded(), applyFeaturesRemoved(), applyGeometryChanges(), copyVectorLayer(), and updateFidLookup().
|
signal |
emit a signal that processing has started
Referenced by convertToOfflineProject(), and synchronize().
|
signal |
emit a signal that processing of all layers has finished
Referenced by convertToOfflineProject(), and synchronize().
|
signal |
emit a signal with the progress of the current mode
progress | current index of processed entities |
Referenced by applyAttributesAdded(), applyAttributeValueChanges(), applyFeaturesAdded(), applyFeaturesRemoved(), applyGeometryChanges(), copyVectorLayer(), and updateFidLookup().
|
private |
Definition at line 851 of file qgsofflineediting.cpp.
References sqlQueryInt().
Referenced by applyAttributeValueChanges(), applyFeaturesRemoved(), and applyGeometryChanges().
|
private |
Definition at line 786 of file qgsofflineediting.cpp.
References tr.
Referenced by applyAttributesAdded(), convertToOfflineProject(), copySymbology(), copyVectorLayer(), createSpatialiteDB(), initializeSpatialMetadata(), openLoggingDb(), sqlExec(), sqlQueryAttributesAdded(), sqlQueryAttributeValueChanges(), sqlQueryFeaturesRemoved(), sqlQueryGeometryChanges(), sqlQueryInt(), sqlQueryInts(), and synchronize().
|
private |
Definition at line 869 of file qgsofflineediting.cpp.
References showWarning().
Referenced by addFidLookup(), committedAttributesAdded(), committedAttributeValuesChanges(), committedFeaturesAdded(), committedFeaturesRemoved(), committedGeometriesChanges(), copyVectorLayer(), createLoggingTables(), getOrCreateLayerId(), increaseCommitNo(), synchronize(), and updateFidLookup().
|
private |
Definition at line 923 of file qgsofflineediting.cpp.
References showWarning().
Referenced by applyAttributesAdded().
|
private |
Definition at line 975 of file qgsofflineediting.cpp.
References QgsOfflineEditing::AttributeValueChange::attr, QgsOfflineEditing::AttributeValueChange::fid, showWarning(), and QgsOfflineEditing::AttributeValueChange::value.
Referenced by applyAttributeValueChanges().
|
private |
Definition at line 952 of file qgsofflineediting.cpp.
References showWarning().
Referenced by applyFeaturesRemoved().
|
private |
Definition at line 1002 of file qgsofflineediting.cpp.
References QgsOfflineEditing::GeometryChange::fid, QgsOfflineEditing::GeometryChange::geom_wkt, and showWarning().
Referenced by applyGeometryChanges().
|
private |
Definition at line 880 of file qgsofflineediting.cpp.
References showWarning().
Referenced by getCommitNo(), getOrCreateLayerId(), isAddedFeature(), offlineFid(), remoteFid(), and synchronize().
|
private |
Definition at line 900 of file qgsofflineediting.cpp.
References showWarning().
Referenced by applyFeaturesAdded(), committedFeaturesAdded(), and updateFidLookup().
|
privateslot |
Definition at line 1190 of file qgsofflineediting.cpp.
References committedAttributesAdded(), committedAttributeValuesChanges(), committedFeaturesAdded(), committedFeaturesRemoved(), committedGeometriesChanges(), and QgsVectorLayer::editBuffer().
Referenced by layerAdded().
|
privateslot |
Definition at line 1206 of file qgsofflineediting.cpp.
References committedAttributesAdded(), committedAttributeValuesChanges(), committedFeaturesAdded(), committedFeaturesRemoved(), committedGeometriesChanges(), and QgsVectorLayer::editBuffer().
Referenced by layerAdded().
void QgsOfflineEditing::synchronize | ( | ) |
synchronize to remote layers
Definition at line 135 of file qgsofflineediting.cpp.
References QgsMapLayerRegistry::addMapLayers(), applyAttributesAdded(), applyAttributeValueChanges(), applyFeaturesAdded(), applyFeaturesRemoved(), applyGeometryChanges(), QgsVectorLayer::commitChanges(), QgsVectorLayer::commitErrors(), copySymbology(), CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, CUSTOM_PROPERTY_REMOTE_PROVIDER, CUSTOM_PROPERTY_REMOTE_SOURCE, QgsMapLayer::customProperty(), getCommitNo(), QgsMapLayer::id(), QgsMapLayerRegistry::instance(), QgsProject::instance(), QgsMapLayer::isValid(), layerProgressUpdated(), QgsMapLayerRegistry::mapLayers(), QgsMapLayer::name(), openLoggingDb(), progressStarted(), progressStopped(), PROJECT_ENTRY_KEY_OFFLINE_DB_PATH, PROJECT_ENTRY_SCOPE_OFFLINE, QgsVectorLayer::reload(), QgsProject::removeEntry(), QgsMapLayerRegistry::removeMapLayers(), showWarning(), sqlExec(), sqlQueryInt(), QgsVectorLayer::startEditing(), QgsProject::title(), and updateFidLookup().
|
private |
Definition at line 706 of file qgsofflineediting.cpp.
References addFidLookup(), QgsVectorLayer::featureCount(), QgsVectorLayer::getFeatures(), QgsFeature::id(), QgsFeatureIterator::nextFeature(), QgsFeatureRequest::NoGeometry, offlineFid(), ProcessFeatures, progressModeSet(), progressUpdated(), sqlExec(), and sqlQueryInts().
Referenced by synchronize().