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:
gsherman 2004-12-30 01:07:22 +00:00
parent 8f5e6077f0
commit 639d51a827
3 changed files with 14 additions and 3 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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);