mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fix for bug 1090940 Zoom to all on empty map
Added a count function to the maplayer registry singelton git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@2535 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
8f5e6077f0
commit
639d51a827
@ -2443,7 +2443,9 @@ void QgisApp::removeAllLayers()
|
||||
|
||||
void QgisApp::zoomToLayerExtent()
|
||||
{
|
||||
|
||||
// zoom only if one or more layers loaded
|
||||
if(QgsMapLayerRegistry::instance()->count() > 0)
|
||||
{
|
||||
// get the selected item
|
||||
QListViewItem *li = mMapLegend->currentItem();
|
||||
QgsMapLayer *layer = ((QgsLegendItem *) li)->layer();
|
||||
@ -2453,6 +2455,7 @@ void QgisApp::zoomToLayerExtent()
|
||||
|
||||
// notify the project we've made a change
|
||||
QgsProject::instance()->dirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
void QgisApp::rightClickLegendMenu(QListViewItem * lvi, const QPoint & pt, int)
|
||||
|
@ -46,7 +46,11 @@ QgsMapLayerRegistry::QgsMapLayerRegistry(QObject *parent, const char *name) : QO
|
||||
#endif
|
||||
// constructor does nothing
|
||||
}
|
||||
|
||||
// get the layer count (number of registered layers)
|
||||
const int QgsMapLayerRegistry::count()
|
||||
{
|
||||
return mMapLayers.size();
|
||||
}
|
||||
//! Get a vector layer from the registry - the the requested key does not exist or
|
||||
//does not correspond to a vector layer, null returned!
|
||||
QgsVectorLayer * QgsMapLayerRegistry::getVectorLayer(QString theLayerId)
|
||||
|
@ -40,7 +40,11 @@ public:
|
||||
|
||||
//! Returns the instance pointer, creating the object on the first call
|
||||
static QgsMapLayerRegistry * instance();
|
||||
|
||||
/*! Return the number of registered layers.
|
||||
*
|
||||
* */
|
||||
const int count();
|
||||
|
||||
//! Retrieve a pointer to a loaded plugin by id
|
||||
QgsMapLayer * mapLayer(QString theLayerId);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user