Skip to content

Commit 7626e27

Browse files
author
mcoletti
committed
Merged render() fix and reformatted to addVectorLayer to follow project formatting guidelines.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4292 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 098db17 commit 7626e27

File tree

1 file changed

+60
-68
lines changed

1 file changed

+60
-68
lines changed

src/qgisapp.cpp

Lines changed: 60 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4275,91 +4275,83 @@ way.
42754275
*/
42764276
void QgisApp::addVectorLayer(QString vectorLayerPath, QString baseName, QString providerKey)
42774277
{
4278-
// check to see if the appropriate provider is available
4279-
QString providerName;
4280-
4281-
QString pProvider = mProviderRegistry->library(providerKey);
4282-
4283-
if ( ! pProvider.isNull() )
4284-
{
4285-
mMapCanvas->freeze();
4286-
QApplication::setOverrideCursor(Qt::WaitCursor);
4287-
// create the layer
4288-
QgsVectorLayer *layer;
4289-
/* Eliminate the need to instantiate the layer based on provider type.
4290-
The caller is responsible for cobbling together the needed information to
4291-
open the layer
4292-
*/
4278+
mMapCanvas->freeze();
4279+
QApplication::setOverrideCursor(Qt::WaitCursor);
4280+
// create the layer
4281+
QgsVectorLayer *layer;
4282+
/* Eliminate the need to instantiate the layer based on provider type.
4283+
The caller is responsible for cobbling together the needed information to
4284+
open the layer
4285+
*/
42934286
#ifdef QGISDEBUG
42944287

4295-
std::cout << "Creating new vector layer using " <<
4296-
vectorLayerPath.toLocal8Bit().data() << " with baseName of " << baseName.toLocal8Bit().data() <<
4297-
" and providerKey of " << providerKey.toLocal8Bit().data() << std::endl;
4288+
std::cout << "Creating new vector layer using " <<
4289+
vectorLayerPath.toLocal8Bit().data() << " with baseName of " << baseName.toLocal8Bit().data() <<
4290+
" and providerKey of " << providerKey.toLocal8Bit().data() << std::endl;
42984291
#endif
42994292

4300-
layer = new QgsVectorLayer(vectorLayerPath, baseName, providerKey);
4301-
QObject::connect(layer, SIGNAL(editingStopped(bool)), mMapCanvas, SLOT(removeDigitizingLines(bool)));
4293+
layer = new QgsVectorLayer(vectorLayerPath, baseName, providerKey);
4294+
QObject::connect(layer, SIGNAL(editingStopped(bool)), mMapCanvas, SLOT(removeDigitizingLines(bool)));
43024295

4303-
if( layer && layer->isValid() )
4304-
{
4305-
// Register this layer with the layers registry
4306-
QgsMapLayerRegistry::instance()->addMapLayer(layer);
4307-
// init the context menu so it can connect to slots in main app
4308-
// now taken care of in legend layer->initContextMenu(this);
4309-
4310-
// give it a random color
4311-
QgsSingleSymRenderer *renderer = new QgsSingleSymRenderer(layer->vectorType()); //add single symbol renderer as default
4312-
layer->setRenderer(renderer);
4313-
// add it to the mapcanvas collection
4314-
// mMapCanvas->addLayer(layer); No longer necessary since adding to registry will add to canvas
4315-
4316-
//connect up a request from the raster layer to show in overview map
4317-
// XXX some day will no longer necessary since adding to registry will add to overview layer
4318-
// QObject::connect(layer,
4319-
// SIGNAL(showInOverview(QString,bool)),
4320-
// this,
4321-
// SLOT(setLayerOverviewStatus(QString,bool)));
4322-
4323-
// connect up any keypresses to be passed tot he layer (e.g. so esc can stop rendering)
4296+
if( layer && layer->isValid() )
4297+
{
4298+
// Register this layer with the layers registry
4299+
QgsMapLayerRegistry::instance()->addMapLayer(layer);
4300+
// init the context menu so it can connect to slots in main app
4301+
// now taken care of in legend layer->initContextMenu(this);
4302+
4303+
// give it a random color
4304+
QgsSingleSymRenderer *renderer = new QgsSingleSymRenderer(layer->vectorType()); //add single symbol renderer as default
4305+
layer->setRenderer(renderer);
4306+
// add it to the mapcanvas collection
4307+
// mMapCanvas->addLayer(layer); No longer necessary since adding to registry will add to canvas
4308+
4309+
//connect up a request from the raster layer to show in overview map
4310+
// XXX some day will no longer necessary since adding to registry will add to overview layer
4311+
// QObject::connect(layer,
4312+
// SIGNAL(showInOverview(QString,bool)),
4313+
// this,
4314+
// SLOT(setLayerOverviewStatus(QString,bool)));
4315+
4316+
// connect up any keypresses to be passed tot he layer (e.g. so esc can stop rendering)
43244317
#ifdef QGISDEBUG
4325-
std::cout << " Connecting up maplayers keyPressed event to the QgisApp keyPress signal" << std::endl;
4318+
std::cout << " Connecting up maplayers keyPressed event to the QgisApp keyPress signal" << std::endl;
43264319
#endif
4327-
QObject::connect(this,
4328-
SIGNAL(keyPressed(QKeyEvent * )),
4329-
layer,
4330-
SLOT(keyPressed(QKeyEvent* )));
4320+
QObject::connect(this,
4321+
SIGNAL(keyPressed(QKeyEvent * )),
4322+
layer,
4323+
SLOT(keyPressed(QKeyEvent* )));
43314324

43324325

4333-
//add hooks for letting layer know canvas needs to recalc the layer extents
4334-
QObject::connect(layer,
4335-
SIGNAL(recalculateExtents()),
4336-
mMapCanvas,
4337-
SLOT(recalculateExtents()));
4326+
//add hooks for letting layer know canvas needs to recalc the layer extents
4327+
QObject::connect(layer,
4328+
SIGNAL(recalculateExtents()),
4329+
mMapCanvas,
4330+
SLOT(recalculateExtents()));
43384331

4339-
QObject::connect(layer,
4340-
SIGNAL(recalculateExtents()),
4341-
mOverviewCanvas,
4342-
SLOT(recalculateExtents()));
4332+
QObject::connect(layer,
4333+
SIGNAL(recalculateExtents()),
4334+
mOverviewCanvas,
4335+
SLOT(recalculateExtents()));
43434336

43444337

4345-
QgsProject::instance()->dirty(false); // XXX this might be redundant
4338+
QgsProject::instance()->dirty(false); // XXX this might be redundant
43464339

4347-
statusBar()->message(mMapCanvas->extent().stringRep(2));
4340+
statusBar()->message(mMapCanvas->extent().stringRep(2));
43484341

4349-
}
4350-
else
4351-
{
4352-
QMessageBox::critical(this,tr("Layer is not valid"),
4353-
tr("The layer is not a valid layer and can not be added to the map"));
4354-
}
4355-
qApp->processEvents();
4356-
mMapCanvas->freeze(false);
4342+
}
4343+
else
4344+
{
4345+
QMessageBox::critical(this,tr("Layer is not valid"),
4346+
tr("The layer is not a valid layer and can not be added to the map"));
4347+
}
4348+
qApp->processEvents();
4349+
mMapCanvas->freeze(false);
43574350
// For Qt4, deprecate direct calling of render(). Let render() be called by the
43584351
// paint event loop of the map canvas widget.
43594352
// mMapCanvas->render();
4360-
mMapCanvas->update();
4361-
QApplication::restoreOverrideCursor();
4362-
}
4353+
mMapCanvas->update();
4354+
QApplication::restoreOverrideCursor();
43634355

43644356
} // QgisApp::addVectorLayer
43654357

0 commit comments

Comments
 (0)