void QgsMapLayer::setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal ) { *mCRS = srs; if ( !mCRS->isValid() ) { mCRS->setValidationHint( tr( "Specify CRS for layer %1" ).arg( name() ) ); mCRS->validate(); } if ( emitSignal ) emit layerCrsChanged(); }
void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeature &f, const QMap<QString, QString> &derivedAttributes ) { QTreeWidgetItem *layItem = layerItem( vlayer ); if ( layItem == 0 ) { layItem = new QTreeWidgetItem( QStringList() << QString::number( lstResults->topLevelItemCount() ) << vlayer->name() ); layItem->setData( 0, Qt::UserRole, QVariant::fromValue( qobject_cast<QObject *>( vlayer ) ) ); lstResults->addTopLevelItem( layItem ); connect( vlayer, SIGNAL( layerDeleted() ), this, SLOT( layerDestroyed() ) ); connect( vlayer, SIGNAL( layerCrsChanged() ), this, SLOT( layerDestroyed() ) ); connect( vlayer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( featureDeleted( QgsFeatureId ) ) ); connect( vlayer, SIGNAL( attributeValueChanged( QgsFeatureId, int, const QVariant & ) ), this, SLOT( attributeValueChanged( QgsFeatureId, int, const QVariant & ) ) ); connect( vlayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) ); connect( vlayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) ); }
void QgsMapLayer::setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal ) { *mCRS = srs; if ( emitSignal ) emit layerCrsChanged(); }
void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers ) { // create layer set QStringList layerSet, layerSetOverview; int i; for ( i = 0; i < layers.size(); i++ ) { QgsMapCanvasLayer &lyr = layers[i]; if ( !lyr.layer() ) { continue; } if ( lyr.isVisible() ) { layerSet.push_back( lyr.layer()->id() ); } if ( lyr.isInOverview() ) { layerSetOverview.push_back( lyr.layer()->id() ); } } const QStringList& layerSetOld = mapSettings().layers(); bool layerSetChanged = layerSetOld != layerSet; // update only if needed if ( layerSetChanged ) { QgsDebugMsg( "Layers changed to: " + layerSet.join( ", " ) ); for ( i = 0; i < layerCount(); i++ ) { // Add check if vector layer when disconnecting from selectionChanged slot // Ticket #811 - racicot QgsMapLayer *currentLayer = layer( i ); if ( !currentLayer ) continue; disconnect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) ); disconnect( currentLayer, SIGNAL( layerCrsChanged() ), this, SLOT( layerCrsChange() ) ); QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer ); if ( isVectLyr ) { disconnect( currentLayer, SIGNAL( selectionChanged() ), this, SLOT( selectionChangedSlot() ) ); } } mSettings.setLayers( layerSet ); for ( i = 0; i < layerCount(); i++ ) { // Add check if vector layer when connecting to selectionChanged slot // Ticket #811 - racicot QgsMapLayer *currentLayer = layer( i ); connect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) ); connect( currentLayer, SIGNAL( layerCrsChanged() ), this, SLOT( layerCrsChange() ) ); QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer ); if ( isVectLyr ) { connect( currentLayer, SIGNAL( selectionChanged() ), this, SLOT( selectionChangedSlot() ) ); } } updateDatumTransformEntries(); QgsDebugMsg( "Layers have changed, refreshing" ); emit layersChanged(); refresh(); } if ( mMapOverview ) { const QStringList& layerSetOvOld = mMapOverview->layerSet(); if ( layerSetOvOld != layerSetOverview ) { mMapOverview->setLayerSet( layerSetOverview ); } // refresh overview maplayers even if layer set is the same // because full extent might have changed updateOverview(); } } // setLayerSet