Skip to content

Commit 6323525

Browse files
author
mcoletti
committed
Yet more more superfluous checks for OGR plug-in removed since that's now handled elsewhere.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4286 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7b9ee7f commit 6323525

File tree

1 file changed

+56
-63
lines changed

1 file changed

+56
-63
lines changed

src/qgisapp.cpp

Lines changed: 56 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5159,96 +5159,89 @@ void QgisApp::addRasterLayer(QString const & rasterLayerPath,
51595159
{
51605160

51615161
#ifdef QGISDEBUG
5162-
std::cout << "QgisApp::addRasterLayer: about to get library for " << providerKey.toLocal8Bit().data() << std::endl;
5162+
std::cout << "QgisApp::addRasterLayer: about to get library for " << providerKey.toLocal8Bit().data() << std::endl;
51635163
#endif
51645164

5165-
// check to see if the appropriate provider is available
5166-
QString providerName;
5167-
5168-
QString pProvider = mProviderRegistry->library(providerKey);
5169-
5170-
if ( ! pProvider.isNull() )
5171-
{
5172-
mMapCanvas->freeze();
5173-
QApplication::setOverrideCursor(Qt::WaitCursor);
5174-
// create the layer
5175-
QgsRasterLayer *layer;
5176-
/* Eliminate the need to instantiate the layer based on provider type.
5177-
The caller is responsible for cobbling together the needed information to
5178-
open the layer
5179-
*/
5165+
mMapCanvas->freeze();
5166+
QApplication::setOverrideCursor(Qt::WaitCursor);
5167+
// create the layer
5168+
QgsRasterLayer *layer;
5169+
/* Eliminate the need to instantiate the layer based on provider type.
5170+
The caller is responsible for cobbling together the needed information to
5171+
open the layer
5172+
*/
51805173
#ifdef QGISDEBUG
51815174

5182-
std::cout << "QgisApp::addRasterLayer: Creating new raster layer using " <<
5175+
std::cout << "QgisApp::addRasterLayer: Creating new raster layer using " <<
51835176
rasterLayerPath.toLocal8Bit().data() << " with baseName of " << baseName.toLocal8Bit().data() <<
51845177
" and layer list of " << layers.join(", ").toLocal8Bit().data() <<
51855178
" and style list of " << styles.join(", ").toLocal8Bit().data() <<
51865179
" and format of " << format.toLocal8Bit().data() <<
51875180
" and providerKey of " << providerKey.toLocal8Bit().data() << std::endl;
51885181
#endif
51895182

5190-
// TODO: Remove the 0 when the raster layer becomes a full provider gateway.
5191-
layer = new QgsRasterLayer(0, rasterLayerPath, baseName, providerKey, layers, styles, format);
5183+
// TODO: Remove the 0 when the raster layer becomes a full provider gateway.
5184+
layer = new QgsRasterLayer(0, rasterLayerPath, baseName, providerKey, layers, styles, format);
51925185

51935186
#ifdef QGISDEBUG
5194-
std::cout << "QgisApp::addRasterLayer: Constructed new layer." << std::endl;
5187+
std::cout << "QgisApp::addRasterLayer: Constructed new layer." << std::endl;
51955188
#endif
51965189

5197-
if( layer && layer->isValid() )
5198-
{
5199-
// Register this layer with the layers registry
5200-
QgsMapLayerRegistry::instance()->addMapLayer(layer);
5201-
// init the context menu so it can connect to slots in main app
5202-
// now taken care of in legend layer->initContextMenu(this);
5190+
if( layer && layer->isValid() )
5191+
{
5192+
// Register this layer with the layers registry
5193+
QgsMapLayerRegistry::instance()->addMapLayer(layer);
5194+
// init the context menu so it can connect to slots in main app
5195+
// now taken care of in legend layer->initContextMenu(this);
52035196

5204-
// connect up any request the raster may make to update the app progress
5205-
QObject::connect(layer,
5206-
SIGNAL(setProgress(int,int)),
5207-
this,
5208-
SLOT(showProgress(int,int)));
5209-
// connect up any request the raster may make to update the statusbar message
5210-
QObject::connect(layer,
5211-
SIGNAL(setStatus(QString)),
5212-
this,
5213-
SLOT(showStatusMessage(QString)));
5197+
// connect up any request the raster may make to update the app progress
5198+
QObject::connect(layer,
5199+
SIGNAL(setProgress(int,int)),
5200+
this,
5201+
SLOT(showProgress(int,int)));
5202+
// connect up any request the raster may make to update the statusbar message
5203+
QObject::connect(layer,
5204+
SIGNAL(setStatus(QString)),
5205+
this,
5206+
SLOT(showStatusMessage(QString)));
52145207

5215-
// connect up any keypresses to be passed tot he layer (e.g. so esc can stop rendering)
5208+
// connect up any keypresses to be passed tot he layer (e.g. so esc can stop rendering)
52165209
#ifdef QGISDEBUG
5217-
std::cout << " Connecting up maplayers keyPressed event to the QgisApp keyPress signal" << std::endl;
5210+
std::cout << " Connecting up maplayers keyPressed event to the QgisApp keyPress signal" << std::endl;
52185211
#endif
5219-
QObject::connect(this,
5220-
SIGNAL(keyPressed(QKeyEvent * )),
5221-
layer,
5222-
SLOT(keyPressed(QKeyEvent* )));
5212+
QObject::connect(this,
5213+
SIGNAL(keyPressed(QKeyEvent * )),
5214+
layer,
5215+
SLOT(keyPressed(QKeyEvent* )));
52235216

52245217

5225-
//add hooks for letting layer know canvas needs to recalc the layer extents
5226-
QObject::connect(layer,
5227-
SIGNAL(recalculateExtents()),
5228-
mMapCanvas,
5229-
SLOT(recalculateExtents()));
5218+
//add hooks for letting layer know canvas needs to recalc the layer extents
5219+
QObject::connect(layer,
5220+
SIGNAL(recalculateExtents()),
5221+
mMapCanvas,
5222+
SLOT(recalculateExtents()));
52305223

5231-
QObject::connect(layer,
5232-
SIGNAL(recalculateExtents()),
5233-
mOverviewCanvas,
5234-
SLOT(recalculateExtents()));
5224+
QObject::connect(layer,
5225+
SIGNAL(recalculateExtents()),
5226+
mOverviewCanvas,
5227+
SLOT(recalculateExtents()));
52355228

52365229

5237-
QgsProject::instance()->dirty(false); // XXX this might be redundant
5230+
QgsProject::instance()->dirty(false); // XXX this might be redundant
52385231

5239-
statusBar()->message(mMapCanvas->extent().stringRep(2));
5232+
statusBar()->message(mMapCanvas->extent().stringRep(2));
52405233

5241-
}
5242-
else
5243-
{
5244-
QMessageBox::critical(this,"Layer is not valid",
5245-
"The layer is not a valid layer and can not be added to the map");
5246-
}
5247-
qApp->processEvents();
5248-
mMapCanvas->freeze(false);
5249-
mMapCanvas->render();
5250-
QApplication::restoreOverrideCursor();
52515234
}
5235+
else
5236+
{
5237+
QMessageBox::critical(this,"Layer is not valid",
5238+
"The layer is not a valid layer and can not be added to the map");
5239+
}
5240+
5241+
qApp->processEvents();
5242+
mMapCanvas->freeze(false);
5243+
mMapCanvas->render();
5244+
QApplication::restoreOverrideCursor();
52525245

52535246
} // QgisApp::addRasterLayer
52545247

0 commit comments

Comments
 (0)