QList<QgsMapLayer *> QgsMapLayerStore::addMapLayers( const QList<QgsMapLayer *> &layers, bool takeOwnership ) { QList<QgsMapLayer *> myResultList; Q_FOREACH ( QgsMapLayer *myLayer, layers ) { if ( !myLayer || !myLayer->isValid() ) { QgsDebugMsg( "Cannot add invalid layers" ); continue; } //check the layer is not already registered! if ( !mMapLayers.contains( myLayer->id() ) ) { mMapLayers[myLayer->id()] = myLayer; myResultList << mMapLayers[myLayer->id()]; if ( takeOwnership ) { myLayer->setParent( this ); } connect( myLayer, &QObject::destroyed, this, &QgsMapLayerStore::onMapLayerDeleted ); emit layerWasAdded( myLayer ); } } if ( !myResultList.isEmpty() ) { emit layersAdded( myResultList ); } return myResultList; }
//introduced in 1.8 QList<QgsMapLayer *> QgsMapLayerRegistry::addMapLayers( QList<QgsMapLayer *> theMapLayers, bool addToLegend, bool takeOwnership ) { QList<QgsMapLayer *> myResultList; for ( int i = 0; i < theMapLayers.size(); ++i ) { QgsMapLayer * myLayer = theMapLayers.at( i ); if ( !myLayer || !myLayer->isValid() ) { QgsDebugMsg( "cannot add invalid layers" ); continue; } //check the layer is not already registered! if ( !mMapLayers.contains( myLayer->id() ) ) { mMapLayers[myLayer->id()] = myLayer; myResultList << mMapLayers[myLayer->id()]; if ( takeOwnership ) mOwnedLayers << myLayer; emit layerWasAdded( myLayer ); } } if ( myResultList.count() > 0 ) { emit layersAdded( myResultList ); if ( addToLegend ) emit legendLayersAdded( myResultList ); } return myResultList; } // QgsMapLayerRegistry::addMapLayers
//introduced in 1.8 QList<QgsMapLayer *> QgsMapLayerRegistry::addMapLayers( QList<QgsMapLayer *> theMapLayers, bool addToLegend ) { QList<QgsMapLayer *> myResultList; for ( int i = 0; i < theMapLayers.size(); ++i ) { QgsMapLayer * myLayer = theMapLayers.at( i ); if ( !myLayer || !myLayer->isValid() ) { QgsDebugMsg( "cannot add invalid layers" ); continue; } //check the layer is not already registered! QMap<QString, QgsMapLayer*>::iterator myIterator = mMapLayers.find( myLayer->id() ); //if myIterator returns mMapLayers.end() then it //does not exist in registry and its safe to add it if ( myIterator == mMapLayers.end() ) { mMapLayers[myLayer->id()] = myLayer; myResultList << mMapLayers[myLayer->id()]; emit layerWasAdded( myLayer ); } } if ( myResultList.count() > 0 ) { emit layersAdded( myResultList ); if ( addToLegend ) emit legendLayersAdded( myResultList ); } return myResultList; } // QgsMapLayerRegistry::addMapLayers
QgsGeometryCheckerSetupTab::QgsGeometryCheckerSetupTab( QgisInterface* iface , QWidget *parent ) : QWidget( parent ), mIface( iface ) { ui.setupUi( this ); ui.progressBar->hide(); ui.labelStatus->hide(); ui.comboBoxInputLayer->setFilters( QgsMapLayerProxyModel::HasGeometry ); mRunButton = ui.buttonBox->addButton( tr( "Run" ), QDialogButtonBox::ActionRole ); mAbortButton = new QPushButton( tr( "Abort" ) ); mRunButton->setEnabled( false ); connect( mRunButton, SIGNAL( clicked() ), this, SLOT( runChecks() ) ); connect( ui.comboBoxInputLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( validateInput() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( updateLayers() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( updateLayers() ) ); connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.lineEditOutput, SLOT( setEnabled( bool ) ) ); connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.pushButtonOutputBrowse, SLOT( setEnabled( bool ) ) ); connect( ui.buttonGroupOutput, SIGNAL( buttonClicked( int ) ), this, SLOT( validateInput() ) ); connect( ui.pushButtonOutputBrowse, SIGNAL( clicked() ), this, SLOT( selectOutputFile() ) ); connect( ui.lineEditOutput, SIGNAL( textChanged( QString ) ), this, SLOT( validateInput() ) ); connect( ui.checkBoxSliverPolygons, SIGNAL( toggled( bool ) ), ui.widgetSliverThreshold, SLOT( setEnabled( bool ) ) ); connect( ui.checkBoxSliverArea, SIGNAL( toggled( bool ) ), ui.doubleSpinBoxSliverArea, SLOT( setEnabled( bool ) ) ); updateLayers(); Q_FOREACH ( const QgsGeometryCheckFactory* factory, QgsGeometryCheckFactoryRegistry::getCheckFactories() ) { factory->restorePrevious( ui ); }
QgsMapLayerModel::QgsMapLayerModel( QObject *parent ) : QAbstractItemModel( parent ) , mLayersChecked( QMap<QString, Qt::CheckState>() ) , mItemCheckable( false ) { connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( addLayers( QList<QgsMapLayer*> ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( removeLayers( QStringList ) ) ); addLayers( QgsMapLayerRegistry::instance()->mapLayers().values() ); }
foreach ( QgsMapLayer* l, layers ) { if ( l->id() == mLayerId ) { mLayer = l; disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( registryLayersAdded( QList<QgsMapLayer*> ) ) ); emit layerLoaded(); break; } }
Q_FOREACH ( QgsMapLayer* l, layers ) { if ( l->id() == mLayerId ) { disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( registryLayersAdded( QList<QgsMapLayer*> ) ) ); attachToLayer(); emit layerLoaded(); break; } }
QgsLayerTreeRegistryBridge::QgsLayerTreeRegistryBridge( QgsLayerTreeGroup *root, QObject *parent ) : QObject( parent ) , mRoot( root ) , mEnabled( true ) , mInsertionPointGroup( root ) , mInsertionPointIndex( 0 ) { connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( layersAdded( QList<QgsMapLayer*> ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( layersWillBeRemoved( QStringList ) ) ); connect( mRoot, SIGNAL( willRemoveChildren( QgsLayerTreeNode*, int, int ) ), this, SLOT( groupWillRemoveChildren( QgsLayerTreeNode*, int, int ) ) ); connect( mRoot, SIGNAL( removedChildren( QgsLayerTreeNode*, int, int ) ), this, SLOT( groupRemovedChildren() ) ); }
QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ) : QDialog( parent ) , mMapCanvas( canvas ) , mDock( 0 ) { setupUi( this ); QSettings myQsettings; bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool(); if ( myDockFlag ) { mDock = new QgsSnappingDock( tr( "Snapping and Digitizing Options" ), QgisApp::instance() ); mDock->setAllowedAreas( Qt::BottomDockWidgetArea | Qt::TopDockWidgetArea ); mDock->setWidget( this ); connect( this, SIGNAL( destroyed() ), mDock, SLOT( close() ) ); QgisApp::instance()->addDockWidget( Qt::BottomDockWidgetArea, mDock ); mButtonBox->setVisible( false ); } else { connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( apply() ) ); connect( mButtonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); } connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer * > ) ), this, SLOT( addLayers( QList<QgsMapLayer * > ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( layersWillBeRemoved( QStringList ) ) ); connect( cbxEnableTopologicalEditingCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( on_cbxEnableTopologicalEditingCheckBox_stateChanged( int ) ) ); connect( cbxEnableIntersectionSnappingCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( on_cbxEnableIntersectionSnappingCheckBox_stateChanged( int ) ) ); reload(); QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); QMap< QString, QgsMapLayer *>::iterator it; for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it ) { addLayer( it.value() ); } mLayerTreeWidget->setHeaderLabels( QStringList() << "" ); mLayerTreeWidget->resizeColumnToContents( 0 ); mLayerTreeWidget->setColumnWidth( 1, 200 ); //hardcoded for now mLayerTreeWidget->setColumnWidth( 2, 200 ); //hardcoded for now mLayerTreeWidget->resizeColumnToContents( 3 ); mLayerTreeWidget->resizeColumnToContents( 4 ); mLayerTreeWidget->setSortingEnabled( true ); connect( QgsProject::instance(), SIGNAL( snapSettingsChanged() ), this, SLOT( reload() ) ); }
void QgsLayerTreeLayer::attachToLayer() { // layer is not necessarily already loaded QgsMapLayer* l = QgsMapLayerRegistry::instance()->mapLayer( mLayerId ); if ( l ) { mLayer = l; mLayerName = l->name(); } else { if ( mLayerName.isEmpty() ) mLayerName = "(?)"; // wait for the layer to be eventually loaded connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( registryLayersAdded( QList<QgsMapLayer*> ) ) ); } }
QgsBullsEyeWidget::QgsBullsEyeWidget( QgsMapCanvas *canvas, QgsLayerTreeView* layerTreeView ) : QgsBottomBar( canvas ), mLayerTreeView( layerTreeView ) { setLayout( new QHBoxLayout ); layout()->setSpacing( 10 ); QWidget* base = new QWidget(); ui.setupUi( base ); layout()->addWidget( base ); QPushButton* closeButton = new QPushButton(); closeButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); closeButton->setIcon( QIcon( ":/images/themes/default/mIconClose.png" ) ); closeButton->setToolTip( tr( "Close" ) ); connect( closeButton, SIGNAL( clicked( bool ) ), this, SIGNAL( close() ) ); layout()->addWidget( closeButton ); layout()->setAlignment( closeButton, Qt::AlignTop ); ui.comboBoxLabels->addItem( tr( "Disabled" ), static_cast<int>( QgsBullsEyeLayer::NO_LABELS ) ); ui.comboBoxLabels->addItem( tr( "Axes" ), static_cast<int>( QgsBullsEyeLayer::LABEL_AXES ) ); ui.comboBoxLabels->addItem( tr( "Rings" ), static_cast<int>( QgsBullsEyeLayer::LABEL_RINGS ) ); ui.comboBoxLabels->addItem( tr( "Axes and rings" ), static_cast<int>( QgsBullsEyeLayer::LABEL_AXES_RINGS ) ); connect( ui.toolButtonAddLayer, SIGNAL( clicked( bool ) ), this, SLOT( createLayer() ) ); connect( ui.inputCenter, SIGNAL( coordinateChanged() ), this, SLOT( updateLayer() ) ); connect( ui.toolButtonPickCenter, SIGNAL( clicked( bool ) ), this, SIGNAL( requestPickCenter() ) ); connect( ui.spinBoxRings, SIGNAL( valueChanged( int ) ), this, SLOT( updateLayer() ) ); connect( ui.spinBoxRingInterval, SIGNAL( valueChanged( double ) ), this, SLOT( updateLayer() ) ); connect( ui.spinBoxAxesInterval, SIGNAL( valueChanged( double ) ), this, SLOT( updateLayer() ) ); connect( ui.toolButtonColor, SIGNAL( colorChanged( QColor ) ), this, SLOT( updateColor( QColor ) ) ); connect( ui.spinBoxFontSize, SIGNAL( valueChanged( int ) ), this, SLOT( updateFontSize( int ) ) ); connect( ui.comboBoxLabels, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateLabeling( int ) ) ); connect( ui.spinBoxLineWidth, SIGNAL( valueChanged( int ) ), this, SLOT( updateLineWidth( int ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( repopulateLayers() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layersRemoved( QStringList ) ), this, SLOT( repopulateLayers() ) ); connect( mCanvas, SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( updateSelectedLayer( QgsMapLayer* ) ) ); repopulateLayers(); connect( ui.comboBoxLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( currentLayerChanged( int ) ) ); }
QgsGeometrySnapperDialog::QgsGeometrySnapperDialog( QgisInterface* iface ): mIface( iface ) { ui.setupUi( this ); mRunButton = ui.buttonBox->addButton( tr( "Run" ), QDialogButtonBox::ActionRole ); ui.buttonBox->button( QDialogButtonBox::Abort )->hide(); mRunButton->setEnabled( false ); ui.progressBar->hide(); setFixedSize( sizeHint() ); setWindowModality( Qt::ApplicationModal ); connect( mRunButton, SIGNAL( clicked() ), this, SLOT( run() ) ); connect( ui.comboBoxInputLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( validateInput() ) ); connect( ui.comboBoxReferenceLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( validateInput() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( updateLayers() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( updateLayers() ) ); connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.lineEditOutput, SLOT( setEnabled( bool ) ) ); connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.pushButtonOutputBrowse, SLOT( setEnabled( bool ) ) ); connect( ui.buttonGroupOutput, SIGNAL( buttonClicked( int ) ), this, SLOT( validateInput() ) ); connect( ui.pushButtonOutputBrowse, SIGNAL( clicked() ), this, SLOT( selectOutputFile() ) ); connect( ui.lineEditOutput, SIGNAL( textChanged( QString ) ), this, SLOT( validateInput() ) ); updateLayers(); }