checkDock::checkDock( QgisInterface* qIface, QWidget* parent ) : QDockWidget( parent ), Ui::checkDock() { mTest = new topolTest( qIface ); setupUi( this ); // hide the fix-related stuff, needs more work qgsInterface = qIface; mFixButton->hide(); mFixBox->hide(); mErrorListModel = new DockModel( mErrorList, parent ); mErrorTableView->setModel( mErrorListModel ); mErrorTableView->setSelectionBehavior( QAbstractItemView::SelectRows ); mErrorTableView->verticalHeader()->setDefaultSectionSize( 20 ); mLayerRegistry = QgsMapLayerRegistry::instance(); mConfigureDialog = new rulesDialog( mLayerRegistry->mapLayers().keys(), mTest->testMap(), qIface, parent ); mTestTable = mConfigureDialog->testTable(); mValidateExtentButton->setIcon( QIcon( ":/topology/validateExtent.png" ) ); mValidateAllButton->setIcon( QIcon( ":/topology/validateAll.png" ) ); mConfigureButton->setIcon( QIcon( ":/topology/configureRules.png" ) ); // mQgisApp = QgisApp::instance(); QgsMapCanvas* canvas = qIface->mapCanvas();// mQgisApp->mapCanvas(); mRBFeature1 = new QgsRubberBand( canvas ); mRBFeature2 = new QgsRubberBand( canvas ); mRBConflict = new QgsRubberBand( canvas ); mRBFeature1->setColor( "blue" ); mRBFeature2->setColor( "green" ); mRBConflict->setColor( "red" ); mRBFeature1->setWidth( 5 ); mRBFeature2->setWidth( 5 ); mRBConflict->setWidth( 5 ); mVMConflict = 0; mVMFeature1 = 0; mVMFeature2 = 0; connect( mConfigureButton, SIGNAL( clicked() ), this, SLOT( configure() ) ); connect( mValidateAllButton, SIGNAL( clicked() ), this, SLOT( validateAll() ) ); //connect( mValidateSelectedButton, SIGNAL( clicked() ), this, SLOT( validateSelected() ) ); connect( mValidateExtentButton, SIGNAL( clicked() ), this, SLOT( validateExtent() ) ); connect( mToggleRubberbands, SIGNAL( clicked() ), this, SLOT( toggleErrorMarkers() ) ); connect( mFixButton, SIGNAL( clicked() ), this, SLOT( fix() ) ); connect( mErrorTableView, SIGNAL( clicked( const QModelIndex & ) ), this, SLOT( errorListClicked( const QModelIndex & ) ) ); connect( mLayerRegistry, SIGNAL( layerWasAdded( QgsMapLayer* ) ), mConfigureDialog, SLOT( addLayer( QgsMapLayer* ) ) ); connect( mLayerRegistry, SIGNAL( layerWillBeRemoved( QString ) ), mConfigureDialog, SLOT( removeLayer( QString ) ) ); connect( mLayerRegistry, SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( parseErrorListByLayer( QString ) ) ); connect( this, SIGNAL( visibilityChanged( bool ) ), this, SLOT( updateRubberBands( bool ) ) ); }
// Start vector editing void QgsGrassPlugin::edit() { if ( QgsGrassEdit::isRunning() ) { QMessageBox::warning( 0, tr( "Warning" ), tr( "GRASS Edit is already running." ) ); return; } mEditAction->setEnabled( false ); mEdit = new QgsGrassEdit( qGisInterface, qGisInterface->activeLayer(), false, qGisInterface->mainWindow(), Qt::Dialog ); if ( mEdit->isValid() ) { mEdit->show(); mCanvas->refresh(); connect( mEdit, SIGNAL( finished() ), this, SLOT( setEditAction() ) ); connect( mEdit, SIGNAL( finished() ), this, SLOT( cleanUp() ) ); connect( mEdit, SIGNAL( destroyed() ), this, SLOT( editClosed() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( closeEdit( QString ) ) ); } else { delete mEdit; mEdit = NULL; mEditAction->setEnabled( true ); } }
//introduced in 1.8 void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds ) { if ( theLayerIds.isEmpty() ) { return; } emit layersWillBeRemoved( theLayerIds ); foreach ( const QString &myId, theLayerIds ) { QgsMapLayer* lyr = mMapLayers[myId]; if ( mOwnedLayers.contains( lyr ) ) { emit layerWillBeRemoved( myId ); if ( lyr == mRedliningLayer ) { mRedliningLayer = nullptr; } else if ( lyr == mGpsRoutesLayer ) { mGpsRoutesLayer = nullptr; } delete lyr; mOwnedLayers.remove( lyr ); } mMapLayers.remove( myId ); emit layerRemoved( myId ); }
void QgsMapLayerRegistry::removeMapLayer( QString theLayerId, bool theEmitSignal ) { if ( theEmitSignal ) emit layerWillBeRemoved( theLayerId ); delete mMapLayers[theLayerId]; mMapLayers.remove( theLayerId ); }
void QgsSpatialQueryDialog::connectAll() { connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( signal_qgis_layerWasAdded( QgsMapLayer* ) ) ) ; connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( signal_qgis_layerWillBeRemoved( QString ) ) ); connect( ckbLogProcessing, SIGNAL( clicked( bool ) ), this, SLOT( on_ckbLogProcessing_clicked( bool ) ) ); } // QgsSpatialQueryDialog::connectAll()
//introduced in 1.8 void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds ) { emit layersWillBeRemoved( theLayerIds ); foreach ( const QString &myId, theLayerIds ) { emit layerWillBeRemoved( myId ); delete mMapLayers[myId]; mMapLayers.remove( myId ); }
QgsLegendModel::QgsLegendModel(): QStandardItemModel(), mAutoUpdate( true ) { if ( QgsMapLayerRegistry::instance() ) { connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayer( QgsMapLayer* ) ) ); } setItemPrototype( new QgsComposerSymbolItem() ); QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); mHasTopLevelWindow = ( topLevelWidgets.size() > 0 ); }
QgsLegendModel::QgsLegendModel(): QStandardItemModel(), mAutoUpdate( true ) { setColumnCount( 2 ); if ( QgsMapLayerRegistry::instance() ) { connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayer( QgsMapLayer* ) ) ); } QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); mHasTopLevelWindow = ( !topLevelWidgets.isEmpty() ); }
//introduced in 1.8 void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds ) { emit layersWillBeRemoved( theLayerIds ); foreach ( const QString &myId, theLayerIds ) { QgsMapLayer* lyr = mMapLayers[myId]; emit layerWillBeRemoved( myId ); if ( mOwnedLayers.contains( lyr ) ) { delete lyr; mOwnedLayers.remove( lyr ); } mMapLayers.remove( myId ); emit layerRemoved( myId ); }
QgsComposerAttributeTableV2::QgsComposerAttributeTableV2( QgsComposition* composition, bool createUndoCommands ) : QgsComposerTableV2( composition, createUndoCommands ) , mSource( LayerAttributes ) , mVectorLayer( nullptr ) , mCurrentAtlasLayer( nullptr ) , mComposerMap( nullptr ) , mMaximumNumberOfFeatures( 30 ) , mShowUniqueRowsOnly( false ) , mShowOnlyVisibleFeatures( false ) , mFilterToAtlasIntersection( false ) , mFilterFeatures( false ) , mFeatureFilter( QLatin1String( "" ) ) { //set first vector layer from layer registry as default one QMap<QString, QgsMapLayer*> layerMap = mComposition->project()->mapLayers(); QMap<QString, QgsMapLayer*>::const_iterator mapIt = layerMap.constBegin(); for ( ; mapIt != layerMap.constEnd(); ++mapIt ) { QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mapIt.value() ); if ( vl ) { mVectorLayer = vl; break; } } if ( mVectorLayer ) { resetColumns(); //listen for modifications to layer and refresh table when they occur connect( mVectorLayer, SIGNAL( layerModified() ), this, SLOT( refreshAttributes() ) ); } if ( mComposition ) { connect( mComposition->project(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); //refresh table attributes when composition is refreshed connect( mComposition, SIGNAL( refreshItemsTriggered() ), this, SLOT( refreshAttributes() ) ); //connect to atlas feature changes to update table rows connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshAttributes() ) ); //atlas coverage layer change = regenerate columns connect( &mComposition->atlasComposition(), SIGNAL( coverageLayerChanged( QgsVectorLayer* ) ), this, SLOT( atlasLayerChanged( QgsVectorLayer* ) ) ); } refreshAttributes(); }
QgsBullsEyeTool::QgsBullsEyeTool( QgsMapCanvas* canvas, QgsLayerTreeView* layerTreeView ) : QgsMapTool( canvas ), mLayerTreeView( layerTreeView ) { mWidget = new QgsBullsEyeWidget( canvas, mLayerTreeView ); mWidget->setVisible( false ); connect( mWidget, SIGNAL( requestPickCenter( bool ) ), this, SLOT( setPicking( bool ) ) ); connect( mWidget, SIGNAL( close() ), this, SLOT( close() ) ); mActionEditLayer = new QAction( tr( "Edit" ), this ); mActionEditLayer->setIcon( QIcon( ":/images/themes/default/mIconEditable.png" ) ); connect( mActionEditLayer, SIGNAL( triggered( bool ) ), this, SLOT( editCurrentLayer( ) ) ); mLayerTreeView->menuProvider()->addLegendLayerAction( mActionEditLayer, "", "edit_bulleye_layer", QgsMapLayer::PluginLayer, false ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayerTreeMenuAction( QgsMapLayer* ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayerTreeMenuAction( QString ) ) ); }
void QgsMapLayerRegistry::removeAllMapLayers() { // moved before physically removing the layers emit removedAll(); // now let all canvas observers know to clear themselves, // and then consequently any of their map legends while ( mMapLayers.size() > 0 ) { QString id = mMapLayers.begin().key(); emit layerWillBeRemoved( id ); delete mMapLayers[ id ]; // delete the map layer mMapLayers.remove( id ); } mMapLayers.clear(); } // QgsMapLayerRegistry::removeAllMapLayers()
QgsComposerAttributeTable::QgsComposerAttributeTable( QgsComposition* composition ) : QgsComposerTable( composition ), mVectorLayer( 0 ), mComposerMap( 0 ), mMaximumNumberOfFeatures( 5 ), mShowOnlyVisibleFeatures( true ) { //set first vector layer from layer registry as default one QMap<QString, QgsMapLayer*> layerMap = QgsMapLayerRegistry::instance()->mapLayers(); QMap<QString, QgsMapLayer*>::const_iterator mapIt = layerMap.constBegin(); for ( ; mapIt != layerMap.constEnd(); ++mapIt ) { QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mapIt.value() ); if ( vl ) { mVectorLayer = vl; break; } } connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); }
void QgsLegendModel::setAutoUpdate( bool autoUpdate ) { if ( mAutoUpdate == autoUpdate ) //prevent multiple signal/slot connections { return; } mAutoUpdate = autoUpdate; if ( autoUpdate ) { if ( QgsMapLayerRegistry::instance() ) { connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayer( QgsMapLayer* ) ) ); } } else { if ( QgsMapLayerRegistry::instance() )
void QgsSpatialQueryDialog::disconnectAll() { disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( signal_qgis_layerWasAdded( QgsMapLayer* ) ) ) ; disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( signal_qgis_layerWillBeRemoved( QString ) ) ); if ( mLayerTarget ) { disconnect( mLayerTarget, SIGNAL( selectionChanged() ), this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) ); } if ( mLayerReference ) { disconnect( mLayerReference, SIGNAL( selectionChanged() ), this, SLOT( signal_layerReference_selectionFeaturesChanged() ) ); } } // QgsSpatialQueryDialog::disconnectAll()
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(); }
QgsComposerAttributeTable::QgsComposerAttributeTable( QgsComposition* composition ) : QgsComposerTable( composition ) , mVectorLayer( nullptr ) , mComposerMap( nullptr ) , mMaximumNumberOfFeatures( 5 ) , mShowOnlyVisibleFeatures( false ) , mFilterFeatures( false ) , mFeatureFilter( "" ) { //set first vector layer from layer registry as default one QMap<QString, QgsMapLayer*> layerMap = QgsMapLayerRegistry::instance()->mapLayers(); QMap<QString, QgsMapLayer*>::const_iterator mapIt = layerMap.constBegin(); for ( ; mapIt != layerMap.constEnd(); ++mapIt ) { QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mapIt.value() ); if ( vl ) { mVectorLayer = vl; break; } } if ( mVectorLayer ) { resetColumns(); } connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); if ( mComposition ) { //refresh table attributes when composition is refreshed connect( mComposition, SIGNAL( refreshItemsTriggered() ), this, SLOT( refreshAttributes() ) ); //connect to atlas feature changes to update table rows connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshAttributes() ) ); } }
void QgsGrassPlugin::cleanUp() { disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( closeEdit( QString ) ) ); }
} emit layersChanged(); return true; } void QgsLegendModel::setAutoUpdate( bool autoUpdate ) { if ( mAutoUpdate == autoUpdate ) //prevent multiple signal/slot connections { return; } mAutoUpdate = autoUpdate; if ( autoUpdate ) { if ( QgsMapLayerRegistry::instance() ) { connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayer( QgsMapLayer* ) ) ); } } else { if ( QgsMapLayerRegistry::instance() ) { disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayer( QgsMapLayer* ) ) ); } } }