void SmartIODBox::start() { while( nextCommand() ); if( p->queued_cnt == 1 ) emit progressStarted(); emit progressChanged(progress()); }
void ZProgressManager::connectSignalSlot() { connect(this, SIGNAL(progressStarted()), this, SLOT(startProgress())); connect(this, SIGNAL(progressEnded()), this, SLOT(endProgress())); connect(this, SIGNAL(progressReset()), this, SLOT(resetProgress())); connect(this, SIGNAL(progressStarted(double)), this, SLOT(startProgress(double))); connect(this, SIGNAL(progressEnded(double)), this, SLOT(endProgress(double))); connect(this, SIGNAL(progressAdvanced(double)), this, SLOT(advanceProgress(double))); }
void QgsOfflineEditingPlugin::initGui() { delete mActionConvertProject; // Create the action for tool mActionConvertProject = new QAction( QIcon( ":/offline_editing/offline_editing_copy.png" ), tr( "Convert to offline project" ), this ); mActionConvertProject->setObjectName( "mActionConvertProject" ); // Set the what's this text mActionConvertProject->setWhatsThis( tr( "Create offline copies of selected layers and save as offline project" ) ); // Connect the action to the run connect( mActionConvertProject, SIGNAL( triggered() ), this, SLOT( convertProject() ) ); // Add the icon to the toolbar mQGisIface->addDatabaseToolBarIcon( mActionConvertProject ); mQGisIface->addPluginToDatabaseMenu( tr( "&Offline Editing" ), mActionConvertProject ); mActionConvertProject->setEnabled( false ); mActionSynchronize = new QAction( QIcon( ":/offline_editing/offline_editing_sync.png" ), tr( "Synchronize" ), this ); mActionSynchronize->setObjectName( "mActionSynchronize" ); mActionSynchronize->setWhatsThis( tr( "Synchronize offline project with remote layers" ) ); connect( mActionSynchronize, SIGNAL( triggered() ), this, SLOT( synchronize() ) ); mQGisIface->addDatabaseToolBarIcon( mActionSynchronize ); mQGisIface->addPluginToDatabaseMenu( tr( "&Offline Editing" ), mActionSynchronize ); mActionSynchronize->setEnabled( false ); mOfflineEditing = new QgsOfflineEditing(); mProgressDialog = new QgsOfflineEditingProgressDialog( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags ); connect( mOfflineEditing, SIGNAL( progressStarted() ), this, SLOT( showProgress() ) ); connect( mOfflineEditing, SIGNAL( layerProgressUpdated( int, int ) ), this, SLOT( setLayerProgress( int, int ) ) ); connect( mOfflineEditing, SIGNAL( progressModeSet( QgsOfflineEditing::ProgressMode, int ) ), this, SLOT( setProgressMode( QgsOfflineEditing::ProgressMode, int ) ) ); connect( mOfflineEditing, SIGNAL( progressUpdated( int ) ), this, SLOT( updateProgress( int ) ) ); connect( mOfflineEditing, SIGNAL( progressStopped() ), this, SLOT( hideProgress() ) ); connect( mOfflineEditing, SIGNAL( warning( QString, QString ) ), mQGisIface->messageBar(), SLOT( pushWarning( QString, QString ) ) ); connect( mQGisIface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( updateActions() ) ); connect( mQGisIface->mainWindow(), SIGNAL( newProject() ), this, SLOT( updateActions() ) ); connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument & ) ), this, SLOT( updateActions() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( updateActions() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( updateActions() ) ); updateActions(); }
void PatientManager::readDatabase() { QList<Patient> patients = DatabaseAccess().db()->findPatients(); emit progressStarted(patients.size()); QHash<int, int> oldIds = d->patientIdHash; QList<Patient::Ptr> newPatientList; foreach (Patient data, patients) { int index = d->patientIdHash.value(data.id, -1); oldIds.remove(data.id); if (index == -1) { Patient::Ptr p = createPatient(data); loadData(p); emit patientAdded(d->patients.size()-1, p); } else { loadData(d->patients[index]); } emit progressValue(d->patients.size()); }
void ZProgressManager::notifyProgressStarted(double scale) { emit progressStarted(scale); }
void ZProgressManager::notifyProgressStarted() { emit progressStarted(); }
/** * convert current project to offline project * returns offline project file path */ bool QgsOfflineEditing::convertToOfflineProject( const QString& offlineDataPath, const QString& offlineDbFile, const QStringList& layerIds ) { if ( layerIds.isEmpty() ) { return false; } QString dbPath = QDir( offlineDataPath ).absoluteFilePath( offlineDbFile ); if ( createSpatialiteDB( dbPath ) ) { spatialite_init( 0 ); sqlite3* db; int rc = sqlite3_open( dbPath.toStdString().c_str(), &db ); if ( rc != SQLITE_OK ) { showWarning( tr( "Could not open the spatialite database" ) ); } else { // create logging tables createLoggingTables( db ); emit progressStarted(); // copy selected vector layers to SpatiaLite for ( int i = 0; i < layerIds.count(); i++ ) { emit layerProgressUpdated( i + 1, layerIds.count() ); QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( layerIds.at( i ) ); copyVectorLayer( qobject_cast<QgsVectorLayer*>( layer ), db, dbPath ); } emit progressStopped(); sqlite3_close( db ); // save offline project QString projectTitle = QgsProject::instance()->title(); if ( projectTitle.isEmpty() ) { projectTitle = QFileInfo( QgsProject::instance()->fileName() ).fileName(); } projectTitle += " (offline)"; QgsProject::instance()->title( projectTitle ); QgsProject::instance()->writeEntry( PROJECT_ENTRY_SCOPE_OFFLINE, PROJECT_ENTRY_KEY_OFFLINE_DB_PATH, dbPath ); return true; } } return false; // Workflow: // copy layers to spatialite // create spatialite db at offlineDataPath // create table for each layer // add new spatialite layer // copy features // save as offline project // mark offline layers // remove remote layers // mark as offline project }
void QgsOfflineEditing::synchronize() { // open logging db sqlite3* db = openLoggingDb(); if ( db == NULL ) { return; } emit progressStarted(); // restore and sync remote layers QList<QgsMapLayer*> offlineLayers; QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); for ( QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin() ; layer_it != mapLayers.end(); ++layer_it ) { QgsMapLayer* layer = layer_it.value(); if ( layer->customProperty( CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, false ).toBool() ) { offlineLayers << layer; } } for ( int l = 0; l < offlineLayers.count(); l++ ) { QgsMapLayer* layer = offlineLayers[l]; emit layerProgressUpdated( l + 1, offlineLayers.count() ); QString remoteSource = layer->customProperty( CUSTOM_PROPERTY_REMOTE_SOURCE, "" ).toString(); QString remoteProvider = layer->customProperty( CUSTOM_PROPERTY_REMOTE_PROVIDER, "" ).toString(); QString remoteName = layer->name(); remoteName.remove( QRegExp( " \\(offline\\)$" ) ); QgsVectorLayer* remoteLayer = new QgsVectorLayer( remoteSource, remoteName, remoteProvider ); if ( remoteLayer->isValid() ) { // TODO: only add remote layer if there are log entries? QgsVectorLayer* offlineLayer = qobject_cast<QgsVectorLayer*>( layer ); // copy style copySymbology( offlineLayer, remoteLayer ); // register this layer with the central layers registry QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer *>() << remoteLayer, true ); // apply layer edit log QString qgisLayerId = layer->id(); QString sql = QString( "SELECT \"id\" FROM 'log_layer_ids' WHERE \"qgis_id\" = '%1'" ).arg( qgisLayerId ); int layerId = sqlQueryInt( db, sql, -1 ); if ( layerId != -1 ) { remoteLayer->startEditing(); // TODO: only get commitNos of this layer? int commitNo = getCommitNo( db ); for ( int i = 0; i < commitNo; i++ ) { // apply commits chronologically applyAttributesAdded( remoteLayer, db, layerId, i ); applyAttributeValueChanges( offlineLayer, remoteLayer, db, layerId, i ); applyGeometryChanges( remoteLayer, db, layerId, i ); } applyFeaturesAdded( offlineLayer, remoteLayer, db, layerId ); applyFeaturesRemoved( remoteLayer, db, layerId ); if ( remoteLayer->commitChanges() ) { // update fid lookup updateFidLookup( remoteLayer, db, layerId ); // clear edit log for this layer sql = QString( "DELETE FROM 'log_added_attrs' WHERE \"layer_id\" = %1" ).arg( layerId ); sqlExec( db, sql ); sql = QString( "DELETE FROM 'log_added_features' WHERE \"layer_id\" = %1" ).arg( layerId ); sqlExec( db, sql ); sql = QString( "DELETE FROM 'log_removed_features' WHERE \"layer_id\" = %1" ).arg( layerId ); sqlExec( db, sql ); sql = QString( "DELETE FROM 'log_feature_updates' WHERE \"layer_id\" = %1" ).arg( layerId ); sqlExec( db, sql ); sql = QString( "DELETE FROM 'log_geometry_updates' WHERE \"layer_id\" = %1" ).arg( layerId ); sqlExec( db, sql ); // reset commitNo QString sql = QString( "UPDATE 'log_indices' SET 'last_index' = 0 WHERE \"name\" = 'commit_no'" ); sqlExec( db, sql ); } else { showWarning( remoteLayer->commitErrors().join( "\n" ) ); } } // remove offline layer QgsMapLayerRegistry::instance()->removeMapLayers( ( QStringList() << qgisLayerId ) ); // disable offline project QString projectTitle = QgsProject::instance()->title(); projectTitle.remove( QRegExp( " \\(offline\\)$" ) ); QgsProject::instance()->title( projectTitle ); QgsProject::instance()->removeEntry( PROJECT_ENTRY_SCOPE_OFFLINE, PROJECT_ENTRY_KEY_OFFLINE_DB_PATH ); remoteLayer->reload(); //update with other changes } } emit progressStopped(); sqlite3_close( db ); }