Skip to content

Commit a1743ab

Browse files
committedJan 15, 2013
Move QgsOfflineEditing to core and add SIP bindings; refactor Offline Editing Plugin
1 parent 831f99a commit a1743ab

File tree

8 files changed

+213
-44
lines changed

8 files changed

+213
-44
lines changed
 

‎python/core/core.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
%Include qgsmessageoutput.sip
4343
%Include qgsmimedatautils.sip
4444
%Include qgsnetworkaccessmanager.sip
45+
%Include qgsofflineediting.sip
4546
%Include qgsoverlayobject.sip
4647
%Include qgsowsconnection.sip
4748
%Include qgspaintenginehack.sip

‎python/core/qgsofflineediting.sip

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/** \class QgsOfflineEditing
2+
* \brief Class for accessing functionality of Offline Editing Plugin.
3+
* This class can be used to access offline editing functionality from plugins.
4+
*/
5+
class QgsOfflineEditing : QObject
6+
{
7+
%TypeHeaderCode
8+
#include <qgsofflineediting.h>
9+
%End
10+
11+
public:
12+
enum ProgressMode {
13+
CopyFeatures = 0,
14+
ProcessFeatures,
15+
AddFields,
16+
AddFeatures,
17+
RemoveFeatures,
18+
UpdateFeatures,
19+
UpdateGeometries
20+
};
21+
22+
QgsOfflineEditing();
23+
~QgsOfflineEditing();
24+
25+
/** convert current project for offline editing
26+
* @param offlineDataPath path to offline db file
27+
* @param offlineDbFile offline db file name
28+
* @param layerIds list of layer names to convert
29+
*/
30+
bool convertToOfflineProject( const QString& offlineDataPath, const QString& offlineDbFile, const QStringList& layerIds );
31+
32+
/** return true if current project is offline */
33+
bool isOfflineProject();
34+
35+
/** synchronize to remote layers */
36+
void synchronize();
37+
38+
signals:
39+
/** emit a signal that processing has started */
40+
void progressStarted();
41+
42+
/** emit a signal that the next layer of numLayers has started processing
43+
* @param layer current layer index
44+
* @param numLayers total number of layers
45+
*/
46+
void layerProgressUpdated( int layer, int numLayers );
47+
48+
/** emit a signal that sets the mode for the progress of the current operation
49+
* @param mode progress mode
50+
* @param maximum total number of entities to process in the current operation
51+
*/
52+
void progressModeSet( QgsOfflineEditing::ProgressMode mode, int maximum );
53+
54+
/** emit a signal with the progress of the current mode
55+
* @param progress current index of processed entities
56+
*/
57+
void progressUpdated( int progress );
58+
59+
/** emit a signal that processing of all layers has finished */
60+
void progressStopped();
61+
};

‎src/core/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ SET(QGIS_CORE_SRCS
8080
qgsmessagelog.cpp
8181
qgsnetworkreplyparser.cpp
8282
qgscredentials.cpp
83+
qgsofflineediting.cpp
8384
qgsoverlayobject.cpp
8485
qgsowsconnection.cpp
8586
qgspalgeometry.cpp
@@ -267,7 +268,7 @@ IF (WITH_INTERNAL_SPATIALITE)
267268
SET_SOURCE_FILES_PROPERTIES(spatialite/sqlite3.c spatialite/spatialite.c PROPERTIES COMPILE_FLAGS -w)
268269
ENDIF(MSVC)
269270

270-
INCLUDE_DIRECTORIES(BEFORE spatialite/headers/spatialite)
271+
INCLUDE_DIRECTORIES(BEFORE spatialite/headers/spatialite spatialite/headers)
271272
ENDIF (WITH_INTERNAL_SPATIALITE)
272273

273274
ADD_FLEX_FILES(QGIS_CORE_SRCS qgsexpressionlexer.ll)
@@ -288,6 +289,7 @@ SET(QGIS_CORE_MOC_HDRS
288289
qgsmessageoutput.h
289290
qgsmessagelog.h
290291
qgsnetworkreplyparser.h
292+
qgsofflineediting.h
291293
qgscredentials.h
292294
qgspluginlayer.h
293295
qgsproject.h
@@ -379,6 +381,7 @@ SET(QGIS_CORE_HDRS
379381
qgsmimedatautils.h
380382
qgsnetworkreplyparser.h
381383
qgscredentials.h
384+
qgsofflineediting.h
382385
qgsoverlayobjectpositionmanager.h
383386
qgsowsconnection.h
384387
qgspallabeling.h

‎src/plugins/offline_editing/offline_editing.cpp renamed to ‎src/core/qgsofflineediting.cpp

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
* *
1717
***************************************************************************/
1818

19-
#include "offline_editing.h"
20-
#include "offline_editing_progress_dialog.h"
2119

2220
#include <qgsapplication.h>
2321
#include <qgsdatasourceuri.h>
2422
#include <qgsgeometry.h>
25-
#include <qgslegendinterface.h>
2623
#include <qgsmaplayer.h>
2724
#include <qgsmaplayerregistry.h>
25+
#include <qgsofflineediting.h>
2826
#include <qgsproject.h>
2927
#include <qgsvectordataprovider.h>
3028

@@ -50,9 +48,8 @@ extern "C"
5048
#define PROJECT_ENTRY_SCOPE_OFFLINE "OfflineEditingPlugin"
5149
#define PROJECT_ENTRY_KEY_OFFLINE_DB_PATH "/OfflineDbPath"
5250

53-
QgsOfflineEditing::QgsOfflineEditing( QgsOfflineEditingProgressDialog* progressDialog )
51+
QgsOfflineEditing::QgsOfflineEditing()
5452
{
55-
mProgressDialog = progressDialog;
5653
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( layerAdded( QgsMapLayer* ) ) );
5754
}
5855

@@ -85,19 +82,18 @@ bool QgsOfflineEditing::convertToOfflineProject( const QString& offlineDataPath,
8582
// create logging tables
8683
createLoggingTables( db );
8784

88-
mProgressDialog->setTitle( "Converting to offline project" );
89-
mProgressDialog->show();
85+
emit progressStarted();
9086

9187
// copy selected vector layers to SpatiaLite
9288
for ( int i = 0; i < layerIds.count(); i++ )
9389
{
94-
mProgressDialog->setCurrentLayer( i + 1, layerIds.count() );
90+
emit layerProgressUpdated( i + 1, layerIds.count() );
9591

9692
QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( layerIds.at( i ) );
9793
copyVectorLayer( qobject_cast<QgsVectorLayer*>( layer ), db, dbPath );
9894
}
9995

100-
mProgressDialog->hide();
96+
emit progressStopped();
10197

10298
sqlite3_close( db );
10399

@@ -135,18 +131,16 @@ bool QgsOfflineEditing::isOfflineProject()
135131
return !QgsProject::instance()->readEntry( PROJECT_ENTRY_SCOPE_OFFLINE, PROJECT_ENTRY_KEY_OFFLINE_DB_PATH ).isEmpty();
136132
}
137133

138-
void QgsOfflineEditing::synchronize( QgsLegendInterface* legendInterface )
134+
void QgsOfflineEditing::synchronize()
139135
{
140-
Q_UNUSED( legendInterface );
141136
// open logging db
142137
sqlite3* db = openLoggingDb();
143138
if ( db == NULL )
144139
{
145140
return;
146141
}
147142

148-
mProgressDialog->setTitle( "Synchronizing to remote layers" );
149-
mProgressDialog->show();
143+
emit progressStarted();
150144

151145
// restore and sync remote layers
152146
QList<QgsMapLayer*> offlineLayers;
@@ -164,7 +158,7 @@ void QgsOfflineEditing::synchronize( QgsLegendInterface* legendInterface )
164158
{
165159
QgsMapLayer* layer = offlineLayers[l];
166160

167-
mProgressDialog->setCurrentLayer( l + 1, offlineLayers.count() );
161+
emit layerProgressUpdated( l + 1, offlineLayers.count() );
168162

169163
QString remoteSource = layer->customProperty( CUSTOM_PROPERTY_REMOTE_SOURCE, "" ).toString();
170164
QString remoteProvider = layer->customProperty( CUSTOM_PROPERTY_REMOTE_PROVIDER, "" ).toString();
@@ -246,7 +240,7 @@ void QgsOfflineEditing::synchronize( QgsLegendInterface* legendInterface )
246240
}
247241
}
248242

249-
mProgressDialog->hide();
243+
emit progressStopped();
250244

251245
sqlite3_close( db );
252246
}
@@ -517,7 +511,7 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con
517511

518512
layer->select( layer->pendingAllAttributesList(), QgsRectangle(), true, false );
519513

520-
mProgressDialog->setupProgressBar( tr( "%v / %m features copied" ), layer->featureCount() );
514+
emit progressModeSet( QgsOfflineEditing::CopyFeatures, layer->featureCount() );
521515
int featureCount = 1;
522516

523517
QList<QgsFeatureId> remoteFeatureIds;
@@ -538,11 +532,11 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con
538532

539533
newLayer->addFeature( f, false );
540534

541-
mProgressDialog->setProgressValue( featureCount++ );
535+
emit progressUpdated( featureCount++ );
542536
}
543537
if ( newLayer->commitChanges() )
544538
{
545-
mProgressDialog->setupProgressBar( tr( "%v / %m features processed" ), layer->featureCount() );
539+
emit progressModeSet( QgsOfflineEditing::ProcessFeatures, layer->featureCount() );
546540
featureCount = 1;
547541

548542
// update feature id lookup
@@ -560,7 +554,7 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con
560554
{
561555
addFidLookup( db, layerId, offlineFeatureIds.at( i ), remoteFeatureIds.at( i ) );
562556

563-
mProgressDialog->setProgressValue( featureCount++ );
557+
emit progressUpdated( featureCount++ );
564558
}
565559
sqlExec( db, "COMMIT" );
566560
}
@@ -592,7 +586,7 @@ void QgsOfflineEditing::applyAttributesAdded( QgsVectorLayer* remoteLayer, sqlit
592586
typeNameLookup[ nativeType.mType ] = nativeType.mTypeName;
593587
}
594588

595-
mProgressDialog->setupProgressBar( tr( "%v / %m fields added" ), fields.size() );
589+
emit progressModeSet( QgsOfflineEditing::AddFields, fields.size() );
596590

597591
for ( int i = 0; i < fields.size(); i++ )
598592
{
@@ -609,7 +603,7 @@ void QgsOfflineEditing::applyAttributesAdded( QgsVectorLayer* remoteLayer, sqlit
609603
showWarning( QString( "Could not add attribute '%1' of type %2" ).arg( field.name() ).arg( field.type() ) );
610604
}
611605

612-
mProgressDialog->setProgressValue( i + 1 );
606+
emit progressUpdated( i + 1 );
613607
}
614608
}
615609

@@ -630,7 +624,7 @@ void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer* offlineLayer, QgsVec
630624
}
631625

632626
// copy features to remote layer
633-
mProgressDialog->setupProgressBar( tr( "%v / %m features added" ), features.size() );
627+
emit progressModeSet( QgsOfflineEditing::AddFeatures, features.size() );
634628

635629
int i = 1;
636630
for ( QgsFeatureList::iterator it = features.begin(); it != features.end(); ++it )
@@ -650,7 +644,7 @@ void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer* offlineLayer, QgsVec
650644

651645
remoteLayer->addFeature( f, false );
652646

653-
mProgressDialog->setProgressValue( i++ );
647+
emit progressUpdated( i++ );
654648
}
655649
}
656650

@@ -659,15 +653,15 @@ void QgsOfflineEditing::applyFeaturesRemoved( QgsVectorLayer* remoteLayer, sqlit
659653
QString sql = QString( "SELECT \"fid\" FROM 'log_removed_features' WHERE \"layer_id\" = %1" ).arg( layerId );
660654
QgsFeatureIds values = sqlQueryFeaturesRemoved( db, sql );
661655

662-
mProgressDialog->setupProgressBar( tr( "%v / %m features removed" ), values.size() );
656+
emit progressModeSet( QgsOfflineEditing::RemoveFeatures, values.size() );
663657

664658
int i = 1;
665659
for ( QgsFeatureIds::const_iterator it = values.begin(); it != values.end(); ++it )
666660
{
667661
QgsFeatureId fid = remoteFid( db, layerId, *it );
668662
remoteLayer->deleteFeature( fid );
669663

670-
mProgressDialog->setProgressValue( i++ );
664+
emit progressUpdated( i++ );
671665
}
672666
}
673667

@@ -676,7 +670,7 @@ void QgsOfflineEditing::applyAttributeValueChanges( QgsVectorLayer* offlineLayer
676670
QString sql = QString( "SELECT \"fid\", \"attr\", \"value\" FROM 'log_feature_updates' WHERE \"layer_id\" = %1 AND \"commit_no\" = %2 " ).arg( layerId ).arg( commitNo );
677671
AttributeValueChanges values = sqlQueryAttributeValueChanges( db, sql );
678672

679-
mProgressDialog->setupProgressBar( tr( "%v / %m feature updates" ), values.size() );
673+
emit progressModeSet( QgsOfflineEditing::UpdateFeatures, values.size() );
680674

681675
QMap<int, int> attrLookup = attributeLookup( offlineLayer, remoteLayer );
682676

@@ -686,7 +680,7 @@ void QgsOfflineEditing::applyAttributeValueChanges( QgsVectorLayer* offlineLayer
686680

687681
remoteLayer->changeAttributeValue( fid, attrLookup[ values.at( i ).attr ], values.at( i ).value, false );
688682

689-
mProgressDialog->setProgressValue( i + 1 );
683+
emit progressUpdated( i + 1 );
690684
}
691685
}
692686

@@ -695,14 +689,14 @@ void QgsOfflineEditing::applyGeometryChanges( QgsVectorLayer* remoteLayer, sqlit
695689
QString sql = QString( "SELECT \"fid\", \"geom_wkt\" FROM 'log_geometry_updates' WHERE \"layer_id\" = %1 AND \"commit_no\" = %2" ).arg( layerId ).arg( commitNo );
696690
GeometryChanges values = sqlQueryGeometryChanges( db, sql );
697691

698-
mProgressDialog->setupProgressBar( tr( "%v / %m feature geometry updates" ), values.size() );
692+
emit progressModeSet( QgsOfflineEditing::UpdateGeometries, values.size() );
699693

700694
for ( int i = 0; i < values.size(); i++ )
701695
{
702696
QgsFeatureId fid = remoteFid( db, layerId, values.at( i ).fid );
703697
remoteLayer->changeGeometry( fid, QgsGeometry::fromWkt( values.at( i ).geom_wkt ) );
704698

705-
mProgressDialog->setProgressValue( i + 1 );
699+
emit progressUpdated( i + 1 );
706700
}
707701
}
708702

@@ -716,7 +710,7 @@ void QgsOfflineEditing::updateFidLookup( QgsVectorLayer* remoteLayer, sqlite3* d
716710
QgsFeature f;
717711
remoteLayer->select( QgsAttributeList(), QgsRectangle(), false, false );
718712

719-
mProgressDialog->setupProgressBar( tr( "%v / %m features processed" ), remoteLayer->featureCount() );
713+
emit progressModeSet( QgsOfflineEditing::ProcessFeatures, remoteLayer->featureCount() );
720714

721715
int i = 1;
722716
while ( remoteLayer->nextFeature( f ) )
@@ -726,7 +720,7 @@ void QgsOfflineEditing::updateFidLookup( QgsVectorLayer* remoteLayer, sqlite3* d
726720
newRemoteFids[ f.id()] = true;
727721
}
728722

729-
mProgressDialog->setProgressValue( i++ );
723+
emit progressUpdated( i++ );
730724
}
731725

732726
// get local added fids

‎src/plugins/offline_editing/offline_editing.h renamed to ‎src/core/qgsofflineediting.h

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
#include <QObject>
2626
#include <QString>
2727

28-
class QgsLegendInterface;
2928
class QgsMapLayer;
30-
class QgsOfflineEditingProgressDialog;
3129
class QgsVectorLayer;
3230
struct sqlite3;
3331

@@ -36,12 +34,55 @@ class QgsOfflineEditing : public QObject
3634
Q_OBJECT
3735

3836
public:
39-
QgsOfflineEditing( QgsOfflineEditingProgressDialog* progressDialog );
37+
enum ProgressMode {
38+
CopyFeatures = 0,
39+
ProcessFeatures,
40+
AddFields,
41+
AddFeatures,
42+
RemoveFeatures,
43+
UpdateFeatures,
44+
UpdateGeometries
45+
};
46+
47+
QgsOfflineEditing();
4048
~QgsOfflineEditing();
4149

50+
/** convert current project for offline editing
51+
* @param offlineDataPath path to offline db file
52+
* @param offlineDbFile offline db file name
53+
* @param layerIds list of layer names to convert
54+
*/
4255
bool convertToOfflineProject( const QString& offlineDataPath, const QString& offlineDbFile, const QStringList& layerIds );
56+
57+
/** return true if current project is offline */
4358
bool isOfflineProject();
44-
void synchronize( QgsLegendInterface* legendInterface );
59+
60+
/** synchronize to remote layers */
61+
void synchronize();
62+
63+
signals:
64+
/** emit a signal that processing has started */
65+
void progressStarted();
66+
67+
/** emit a signal that the next layer of numLayers has started processing
68+
* @param layer current layer index
69+
* @param numLayers total number of layers
70+
*/
71+
void layerProgressUpdated( int layer, int numLayers );
72+
73+
/** emit a signal that sets the mode for the progress of the current operation
74+
* @param mode progress mode
75+
* @param maximum total number of entities to process in the current operation
76+
*/
77+
void progressModeSet( QgsOfflineEditing::ProgressMode mode, int maximum );
78+
79+
/** emit a signal with the progress of the current mode
80+
* @param progress current index of processed entities
81+
*/
82+
void progressUpdated( int progress );
83+
84+
/** emit a signal that processing of all layers has finished */
85+
void progressStopped();
4586

4687
private:
4788
void initializeSpatialMetadata( sqlite3 *sqlite_handle );
@@ -93,8 +134,6 @@ class QgsOfflineEditing : public QObject
93134
typedef QList<GeometryChange> GeometryChanges;
94135
GeometryChanges sqlQueryGeometryChanges( sqlite3* db, const QString& sql );
95136

96-
QgsOfflineEditingProgressDialog* mProgressDialog;
97-
98137
private slots:
99138
void layerAdded( QgsMapLayer* layer );
100139
void committedAttributesAdded( const QString& qgisLayerId, const QList<QgsField>& addedAttributes );

‎src/plugins/offline_editing/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
SET (offline_editing_plugin_SRCS
66
offline_editing_plugin.cpp
77
offline_editing_plugin_gui.cpp
8-
offline_editing.cpp
98
offline_editing_progress_dialog.cpp
109
)
1110

@@ -17,7 +16,6 @@ SET (offline_editing_plugin_UIS
1716
SET (offline_editing_plugin_MOC_HDRS
1817
offline_editing_plugin.h
1918
offline_editing_plugin_gui.h
20-
offline_editing.h
2119
offline_editing_progress_dialog.h
2220
)
2321

‎src/plugins/offline_editing/offline_editing_plugin.cpp

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "offline_editing_plugin.h"
2020
#include "offline_editing_plugin_gui.h"
2121
#include "offline_editing_progress_dialog.h"
22-
#include "offline_editing.h"
2322

2423
#include <qgisinterface.h>
2524
#include <qgisgui.h>
@@ -47,6 +46,7 @@ QgsOfflineEditingPlugin::QgsOfflineEditingPlugin( QgisInterface* theQgisInterfac
4746
QgsOfflineEditingPlugin::~QgsOfflineEditingPlugin()
4847
{
4948
delete mOfflineEditing;
49+
delete mProgressDialog;
5050
}
5151

5252
void QgsOfflineEditingPlugin::initGui()
@@ -69,7 +69,14 @@ void QgsOfflineEditingPlugin::initGui()
6969
mQGisIface->addPluginToDatabaseMenu( tr( "&Offline Editing" ), mActionSynchronize );
7070
mActionSynchronize->setEnabled( false );
7171

72-
mOfflineEditing = new QgsOfflineEditing( new QgsOfflineEditingProgressDialog( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags ) );
72+
mOfflineEditing = new QgsOfflineEditing();
73+
mProgressDialog = new QgsOfflineEditingProgressDialog( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
74+
75+
connect( mOfflineEditing, SIGNAL( progressStarted() ), this, SLOT( showProgress() ) );
76+
connect( mOfflineEditing, SIGNAL( layerProgressUpdated( int, int ) ), this, SLOT( setLayerProgress( int, int ) ) );
77+
connect( mOfflineEditing, SIGNAL( progressModeSet( QgsOfflineEditing::ProgressMode, int ) ), this, SLOT( setProgressMode( QgsOfflineEditing::ProgressMode, int ) ) );
78+
connect( mOfflineEditing, SIGNAL( progressUpdated( int ) ), this, SLOT( updateProgress( int ) ) );
79+
connect( mOfflineEditing, SIGNAL( progressStopped() ), this, SLOT( hideProgress() ) );
7380

7481
connect( mQGisIface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( updateActions() ) );
7582
connect( mQGisIface->mainWindow(), SIGNAL( newProject() ), this, SLOT( updateActions() ) );
@@ -94,6 +101,7 @@ void QgsOfflineEditingPlugin::convertProject()
94101
return;
95102
}
96103

104+
mProgressDialog->setTitle( tr( "Converting to offline project" ) );
97105
if ( mOfflineEditing->convertToOfflineProject( myPluginGui->offlineDataPath(), myPluginGui->offlineDbFile(), selectedLayerIds ) )
98106
{
99107
updateActions();
@@ -105,7 +113,8 @@ void QgsOfflineEditingPlugin::convertProject()
105113

106114
void QgsOfflineEditingPlugin::synchronize()
107115
{
108-
mOfflineEditing->synchronize( mQGisIface->legendInterface() );
116+
mProgressDialog->setTitle( tr( "Synchronizing to remote layers" ) );
117+
mOfflineEditing->synchronize();
109118
updateActions();
110119
}
111120

@@ -137,6 +146,61 @@ void QgsOfflineEditingPlugin::updateActions()
137146
mActionSynchronize->setEnabled( hasLayers && isOfflineProject );
138147
}
139148

149+
void QgsOfflineEditingPlugin::showProgress()
150+
{
151+
mProgressDialog->show();
152+
}
153+
154+
void QgsOfflineEditingPlugin::setLayerProgress( int layer, int numLayers )
155+
{
156+
mProgressDialog->setCurrentLayer( layer, numLayers );
157+
}
158+
159+
void QgsOfflineEditingPlugin::setProgressMode( QgsOfflineEditing::ProgressMode mode, int maximum )
160+
{
161+
QString format = "";
162+
switch ( mode )
163+
{
164+
case QgsOfflineEditing::CopyFeatures:
165+
format = tr( "%v / %m features copied" );
166+
break;
167+
case QgsOfflineEditing::ProcessFeatures:
168+
format = tr( "%v / %m features processed" );
169+
break;
170+
case QgsOfflineEditing::AddFields:
171+
format = tr( "%v / %m fields added" );
172+
break;
173+
case QgsOfflineEditing::AddFeatures:
174+
format = tr( "%v / %m features added" );
175+
break;
176+
case QgsOfflineEditing::RemoveFeatures:
177+
format = tr( "%v / %m features removed" );
178+
break;
179+
case QgsOfflineEditing::UpdateFeatures:
180+
format = tr( "%v / %m feature updates" );
181+
break;
182+
case QgsOfflineEditing::UpdateGeometries:
183+
format = tr( "%v / %m feature geometry updates" );
184+
break;
185+
186+
default:
187+
break;
188+
}
189+
190+
mProgressDialog->setupProgressBar( format, maximum );
191+
}
192+
193+
void QgsOfflineEditingPlugin::updateProgress( int progress )
194+
{
195+
mProgressDialog->setProgressValue( progress );
196+
}
197+
198+
void QgsOfflineEditingPlugin::hideProgress()
199+
{
200+
mProgressDialog->hide();
201+
}
202+
203+
140204
/**
141205
* Required extern functions needed for every plugin
142206
* These functions can be called prior to creating an instance

‎src/plugins/offline_editing/offline_editing_plugin.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
#define QGS_OFFLINE_EDITING_PLUGIN_H
2121

2222
#include "../qgisplugin.h"
23+
#include <qgsofflineediting.h>
2324
#include <QObject>
2425

2526
class QAction;
2627
class QgisInterface;
27-
class QgsOfflineEditing;
28+
class QgsOfflineEditingProgressDialog;
2829

2930
class QgsOfflineEditingPlugin : public QObject, public QgisPlugin
3031
{
@@ -54,9 +55,17 @@ class QgsOfflineEditingPlugin : public QObject, public QgisPlugin
5455
QAction* mActionSynchronize;
5556

5657
QgsOfflineEditing* mOfflineEditing;
58+
QgsOfflineEditingProgressDialog* mProgressDialog;
5759

5860
private slots:
5961
void updateActions();
62+
63+
//! update progress dialog
64+
void showProgress();
65+
void setLayerProgress( int layer, int numLayers );
66+
void setProgressMode( QgsOfflineEditing::ProgressMode mode, int maximum );
67+
void updateProgress( int progress );
68+
void hideProgress();
6069
};
6170

6271
#endif // QGS_OFFLINE_EDITING_PLUGIN_H

0 commit comments

Comments
 (0)
Please sign in to comment.