Skip to content
Permalink
Browse files
fix #5062 and apply rest of #5041
  • Loading branch information
jef-n committed Feb 21, 2012
1 parent 7cea2f5 commit 927dcbd755d69b571195c321561dba192c0f855e
Showing with 15 additions and 8 deletions.
  1. +6 −4 src/app/qgisapp.cpp
  2. +4 −3 src/app/qgsbrowserdockwidget.cpp
  3. +5 −1 src/providers/gdal/qgsgdaldataitems.cpp
@@ -2258,9 +2258,11 @@ void QgisApp::askUserForGDALSublayers( QgsRasterLayer *layer )

if ( chooseSublayersDialog.exec() )
{
foreach( QString layer, chooseSublayersDialog.getSelection() )
foreach( QString path, chooseSublayersDialog.getSelection() )
{
QgsRasterLayer *rlayer = new QgsRasterLayer( layer, layer );
QString name = path;
name.replace( layer->source(), QFileInfo( layer->source() ).completeBaseName() );
QgsRasterLayer *rlayer = new QgsRasterLayer( path, name );
if ( rlayer && rlayer->isValid() )
{
addRasterLayer( rlayer );
@@ -2272,11 +2274,11 @@ void QgisApp::askUserForGDALSublayers( QgsRasterLayer *layer )
bool QgisApp::shouldAskUserForGDALSublayers( QgsRasterLayer *layer )
{
// return false if layer is empty or raster has no sublayers
if ( !layer || layer->subLayers().size() < 1 )
if ( !layer || layer->providerType() != "gdal" || layer->subLayers().size() < 1 )
return false;

QSettings settings;
int promptLayers = settings.value( "/qgis/promptForRasterSublayers", "if_need" ).toInt();
int promptLayers = settings.value( "/qgis/promptForRasterSublayers", 1 ).toInt();
// 0 = always -> always ask (if there are existing sublayers)
// 1 = if needed -> ask if layer has no bands, but has sublayers
// 2 = never
@@ -126,10 +126,9 @@ void QgsBrowserDockWidget::itemClicked( const QModelIndex& index )
QString providerKey = layerItem->providerKey();

QgsDebugMsg( providerKey + " : " + uri );
QgsMapLayer* layer = NULL;
if ( type == QgsMapLayer::VectorLayer )
{
layer = QgisApp::instance()->addVectorLayer( uri, layerItem->name(), providerKey );
QgisApp::instance()->addVectorLayer( uri, layerItem->name(), providerKey );
}
if ( type == QgsMapLayer::RasterLayer )
{
@@ -159,7 +158,7 @@ void QgsBrowserDockWidget::itemClicked( const QModelIndex& index )
QgsDebugMsg( "rasterLayerPath = " + rasterLayerPath );
QgsDebugMsg( "layers = " + layers.join( " " ) );

layer = QgisApp::instance()->addRasterLayer( rasterLayerPath, layerItem->name(), providerKey, layers, styles, format, crs );
QgisApp::instance()->addRasterLayer( rasterLayerPath, layerItem->name(), providerKey, layers, styles, format, crs );
}
}

@@ -248,7 +247,9 @@ void QgsBrowserDockWidget::removeFavourite()

void QgsBrowserDockWidget::refresh()
{
QApplication::setOverrideCursor( Qt::WaitCursor );
refreshModel( QModelIndex() );
QApplication::restoreOverrideCursor();
}

void QgsBrowserDockWidget::refreshModel( const QModelIndex& index )
@@ -125,7 +125,11 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
{
GDALClose( hChildDS );
QgsDebugMsg( QString( "add child #%1 - %2" ).arg( i ).arg( sublayers[i] ) );
childItem = new QgsGdalLayerItem( item, sublayers[i], thePath + "/" + sublayers[i], sublayers[i] );

QString name = sublayers[i];
name.replace( thePath, QFileInfo( thePath ).completeBaseName() );

childItem = new QgsGdalLayerItem( item, name, thePath + "/" + name, sublayers[i] );
if ( childItem )
item->addChildItem( childItem );
}

0 comments on commit 927dcbd

Please sign in to comment.