void rulesDialog::initGui() { QgsMapLayerRegistry* layerRegistry = QgsMapLayerRegistry::instance(); QList<QString> layerList = layerRegistry->mapLayers().keys(); mLayer1Box->clear(); mLayer1Box->addItem( "No layer" ); mLayer2Box->clear(); mLayer2Box->addItem( "No layer" ); mLayer1Box->blockSignals( true ); for ( int i = 0; i < layerList.size(); ++i ) { QgsVectorLayer* v1 = ( QgsVectorLayer* )layerRegistry->mapLayers()[layerList[i]]; qDebug() << "layerid = " + layerList[i]; // add layer name to the layer combo boxes mLayer1Box->addItem( v1->name(), v1->id() ); } mLayer1Box->blockSignals( false ); }
void rulesDialog::showControls( const QString& testName ) { if ( testName.isEmpty() ) { return; } mLayer2Box->clear(); mLayer2Box->addItem( "No layer" ); TopologyRule topologyRule = mTestConfMap[testName]; QgsMapLayerRegistry* layerRegistry = QgsMapLayerRegistry::instance(); QList<QString> layerList = layerRegistry->mapLayers().keys(); if ( topologyRule.useSecondLayer ) { mLayer2Box->setVisible( true ); for ( int i = 0; i < layerList.count(); ++i ) { QgsVectorLayer* v1 = ( QgsVectorLayer* )layerRegistry->mapLayers()[layerList[i]]; if ( !v1 ) { continue; } if ( v1->name() == mLayer1Box->currentText() ) { continue; } if ( v1->type() == QgsMapLayer::VectorLayer ) { if ( topologyRule.layer2AcceptsType( v1->geometryType() ) ) { mLayer2Box->addItem( v1->name() , v1->id() ); } } } } else { mLayer2Box->setVisible( false ); } if ( topologyRule.useTolerance ) { mToleranceBox->setVisible( true ); mToleranceLabel->setVisible( true ); } else { mToleranceBox->setVisible( false ); mToleranceLabel->setVisible( false ); } }
void rulesDialog::updateRuleItems( const QString &layerName ) { if ( layerName.isEmpty() ) { return; } mRuleBox->clear(); if ( layerName == "No layer" ) { return; } QString layerId = mLayer1Box->itemData( mLayer1Box->currentIndex() ).toString(); QgsMapLayerRegistry* layerRegistry = QgsMapLayerRegistry::instance(); QgsVectorLayer* vlayer = ( QgsVectorLayer* )layerRegistry->mapLayers()[layerId]; if ( !vlayer ) { qDebug() << "not a vector layer"; return; } for ( QMap<QString, TopologyRule>::iterator it = mTestConfMap.begin(); it != mTestConfMap.end(); ++it ) { TopologyRule rule = it.value(); if ( rule.layer1AcceptsType( vlayer->geometryType() ) ) { mRuleBox->addItem( it.key() ); } } }
// Slot called when the menu item is activated void QgsGPSPlugin::run() { // find all GPX layers std::vector<QgsVectorLayer*> gpxLayers; QMap<QString, QgsMapLayer*>::const_iterator iter; QgsMapLayerRegistry* registry = QgsMapLayerRegistry::instance(); for ( iter = registry->mapLayers().begin(); iter != registry->mapLayers().end(); ++iter ) { if ( iter.value()->type() == QgsMapLayer::VectorLayer ) { QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer *>( iter.value() ); if ( vLayer->providerType() == "gpx" ) gpxLayers.push_back( vLayer ); } } QgsGPSPluginGui *myPluginGui = new QgsGPSPluginGui( mImporters, mDevices, gpxLayers, mQGisInterface->mainWindow(), QgisGui::ModalDialogFlags ); myPluginGui->setAttribute( Qt::WA_DeleteOnClose ); //listen for when the layer has been made so we can draw it connect( myPluginGui, SIGNAL( drawVectorLayer( QString, QString, QString ) ), this, SLOT( drawVectorLayer( QString, QString, QString ) ) ); connect( myPluginGui, SIGNAL( loadGPXFile( QString, bool, bool, bool ) ), this, SLOT( loadGPXFile( QString, bool, bool, bool ) ) ); connect( myPluginGui, SIGNAL( importGPSFile( QString, QgsBabelFormat*, bool, bool, bool, QString, QString ) ), this, SLOT( importGPSFile( QString, QgsBabelFormat*, bool, bool, bool, QString, QString ) ) ); connect( myPluginGui, SIGNAL( convertGPSFile( QString, int, QString, QString ) ), this, SLOT( convertGPSFile( QString, int, QString, QString ) ) ); connect( myPluginGui, SIGNAL( downloadFromGPS( QString, QString, bool, bool, bool, QString, QString ) ), this, SLOT( downloadFromGPS( QString, QString, bool, bool, bool, QString, QString ) ) ); connect( myPluginGui, SIGNAL( uploadToGPS( QgsVectorLayer*, QString, QString ) ), this, SLOT( uploadToGPS( QgsVectorLayer*, QString, QString ) ) ); connect( this, SIGNAL( closeGui() ), myPluginGui, SLOT( close() ) ); myPluginGui->show(); }