void QgsProjectBadLayerGuiHandler::handleBadLayers( QList<QDomNode> layers, QDomDocument projectDom ) { Q_UNUSED( projectDom ); QgsDebugMsg( QString( "%1 bad layers found" ).arg( layers.size() ) ); // make sure we have arrow cursor (and not a wait cursor) QApplication::setOverrideCursor( Qt::ArrowCursor ); QMessageBox messageBox; QAbstractButton *ignoreButton = messageBox.addButton( tr( "Ignore" ), QMessageBox::ActionRole ); QAbstractButton *okButton = messageBox.addButton( QMessageBox :: Ok ); messageBox.addButton( QMessageBox :: Cancel ); messageBox.setWindowTitle( tr( "QGIS Project Read Error" ) ); messageBox.setText( tr( "Unable to open one or more project layers.\nChoose " "ignore to continue loading without the missing layers. Choose cancel to " "return to your pre-project load state. Choose OK to try to find the " "missing layers." ) ); messageBox.setIcon( QMessageBox::Critical ); messageBox.exec(); QgsProjectBadLayerGuiHandler::mIgnore = false; if ( messageBox.clickedButton() == okButton ) { QgsDebugMsg( "want to find missing layers is true" ); // attempt to find the new locations for missing layers // XXX vector file hard-coded -- but what if it's raster? QString filter = QgsProviderRegistry::instance()->fileVectorFilters(); findLayers( filter, layers ); } else if ( messageBox.clickedButton() == ignoreButton ) { QgsProjectBadLayerGuiHandler::mIgnore = true; } else { // Do nothing } QApplication::restoreOverrideCursor(); }
QList<QgsMapLayer *> QgsLayerTree::layerOrder() const { if ( mHasCustomLayerOrder ) { return customLayerOrder(); } else { QList<QgsMapLayer *> layers; const QList< QgsLayerTreeLayer * > foundLayers = findLayers(); for ( const auto &treeLayer : foundLayers ) { QgsMapLayer *layer = treeLayer->layer(); if ( !layer || !layer->isSpatial() ) { continue; } layers.append( layer ); } return layers; } }
void KMLVector::findLayers(KMLNode* poNode, int bKeepEmptyContainers) { bool bEmpty = true; // Start with the trunk if( nullptr == poNode ) { nNumLayers_ = 0; poNode = poTrunk_; } if( isFeature(poNode->getName()) || isFeatureContainer(poNode->getName()) || ( isRest(poNode->getName()) && poNode->getName().compare("kml") != 0 ) ) { return; } else if( isContainer(poNode->getName()) ) { for( int z = 0; z < (int) poNode->countChildren(); z++ ) { if( isContainer(poNode->getChild(z)->getName()) ) { findLayers(poNode->getChild(z), bKeepEmptyContainers); } else if( isFeatureContainer(poNode->getChild(z)->getName()) ) { bEmpty = false; } } if( bKeepEmptyContainers && poNode->getName() == "Folder" ) { if (!bEmpty) poNode->eliminateEmpty(this); } else if(bEmpty) { return; } Nodetype nodeType = poNode->getType(); if( bKeepEmptyContainers || isFeature(Nodetype2String(nodeType)) || nodeType == Mixed || nodeType == MultiGeometry || nodeType == MultiPoint || nodeType == MultiLineString || nodeType == MultiPolygon) { poNode->setLayerNumber(nNumLayers_++); papoLayers_ = static_cast<KMLNode**>( CPLRealloc(papoLayers_, nNumLayers_ * sizeof(KMLNode*)) ); papoLayers_[nNumLayers_ - 1] = poNode; } else { CPLDebug( "KML", "We have a strange type here for node %s: %s", poNode->getName().c_str(), Nodetype2String(poNode->getType()).c_str() ); } } else { CPLDebug( "KML", "There is something wrong! Define KML_DEBUG to see details"); if( CPLGetConfigOption("KML_DEBUG", nullptr) != nullptr ) print(); } }