@@ -746,7 +746,7 @@ void QgisApp::dropEvent( QDropEvent *event )
746746 }
747747 else if ( u.layerType == " raster" )
748748 {
749- addRasterLayer ( u.uri , u.name , u.providerKey );
749+ addRasterLayer ( u.uri , u.name , u.providerKey , QStringList (), QStringList (), QString (), QString () );
750750 }
751751 }
752752 }
@@ -2631,8 +2631,10 @@ void QgisApp::addWmsLayer()
26312631 QMessageBox::warning ( this , tr ( " WMS" ), tr ( " Cannot get WMS select dialog from provider." ) );
26322632 return ;
26332633 }
2634- connect ( wmss , SIGNAL ( addRasterLayer ( QString const &, QString const &, QString const & ) ),
2635- this , SLOT ( addRasterLayer ( QString const &, QString const &, QString const & ) ) );
2634+ connect ( wmss , SIGNAL ( addRasterLayer ( QString const &, QString const &, QString const &, QStringList const &, QStringList const &, QString const &,
2635+ QString const & ) ),
2636+ this , SLOT ( addRasterLayer ( QString const &, QString const &, QString const &, QStringList const &, QStringList const &, QString const &,
2637+ QString const & ) ) );
26362638 wmss->exec ();
26372639 delete wmss;
26382640}
@@ -6803,17 +6805,22 @@ QgsRasterLayer* QgisApp::addRasterLayer( QString const & rasterFile, QString con
68036805
68046806/* * Add a raster layer directly without prompting user for location
68056807 The caller must provide information compatible with the provider plugin
6806- using the uri and baseName. The provider can use these
6808+ using the rasterLayerPath and baseName. The provider can use these
68076809 parameters in any way necessary to initialize the layer. The baseName
68086810 parameter is used in the Map Legend so it should be formed in a meaningful
68096811 way.
68106812
68116813 \note Copied from the equivalent addVectorLayer function in this file
6814+ TODO Make it work for rasters specifically.
68126815 */
68136816QgsRasterLayer* QgisApp::addRasterLayer (
6814- QString const &uri ,
6817+ QString const &rasterLayerPath ,
68156818 QString const &baseName,
6816- QString const &providerKey )
6819+ QString const &providerKey,
6820+ QStringList const & layers,
6821+ QStringList const & styles,
6822+ QString const &format,
6823+ QString const &crs )
68176824{
68186825 QgsDebugMsg ( " about to get library for " + providerKey );
68196826
@@ -6824,21 +6831,42 @@ QgsRasterLayer* QgisApp::addRasterLayer(
68246831
68256832 mMapCanvas ->freeze ();
68266833
6834+ // Let render() do its own cursor management
6835+ // QApplication::setOverrideCursor(Qt::WaitCursor);
6836+
68276837 // create the layer
68286838 QgsRasterLayer *layer;
6829- QgsDebugMsg ( " Creating new raster layer using " + uri
6830- + " with baseName of " + baseName );
6839+ /* Eliminate the need to instantiate the layer based on provider type.
6840+ The caller is responsible for cobbling together the needed information to
6841+ open the layer
6842+ */
6843+ QgsDebugMsg ( " Creating new raster layer using " + rasterLayerPath
6844+ + " with baseName of " + baseName
6845+ + " and layer list of " + layers.join ( " , " )
6846+ + " and style list of " + styles.join ( " , " )
6847+ + " and format of " + format
6848+ + " and providerKey of " + providerKey
6849+ + " and CRS of " + crs );
68316850
68326851 // TODO: Remove the 0 when the raster layer becomes a full provider gateway.
6833- layer = new QgsRasterLayer ( uri, baseName, providerKey );
6852+ layer = new QgsRasterLayer ( 0 , rasterLayerPath, baseName, providerKey, layers, styles, format, crs );
68346853
68356854 QgsDebugMsg ( " Constructed new layer." );
68366855
6837- if ( layer && layer->isValid () )
6856+ if ( layer && shouldAskUserForGDALSublayers ( layer ) )
6857+ {
6858+ askUserForGDALSublayers ( layer );
6859+
6860+ // The first layer loaded is not useful in that case. The user can select it in
6861+ // the list if he wants to load it.
6862+ delete layer;
6863+ }
6864+ else if ( layer && layer->isValid () )
68386865 {
68396866 addRasterLayer ( layer );
68406867
68416868 statusBar ()->showMessage ( mMapCanvas ->extent ().toString ( 2 ) );
6869+
68426870 }
68436871 else
68446872 {
@@ -6853,6 +6881,10 @@ QgsRasterLayer* QgisApp::addRasterLayer(
68536881 mMapCanvas ->refresh ();
68546882
68556883 return layer;
6884+
6885+ // Let render() do its own cursor management
6886+ // QApplication::restoreOverrideCursor();
6887+
68566888} // QgisApp::addRasterLayer
68576889
68586890
0 commit comments