Skip to content
Permalink
Browse files
more robust fix for #2762 as suggested by Martin
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15727 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
alexbruy committed Apr 16, 2011
1 parent f861f8b commit 9ef6503808f5139ae038b81ee5fcf766488b4541
Showing with 23 additions and 14 deletions.
  1. +1 −12 src/app/legend/qgsapplegendinterface.cpp
  2. +17 −1 src/app/legend/qgslegend.cpp
  3. +5 −1 src/app/legend/qgslegend.h
@@ -119,18 +119,7 @@ bool QgsAppLegendInterface::isLayerVisible( QgsMapLayer * ml )

QList< QgsMapLayer * > QgsAppLegendInterface::layers() const
{
QList< QgsMapLayer * > items;
QTreeWidgetItemIterator it( mLegend );
while ( *it )
{
QgsLegendLayer *llayer = dynamic_cast<QgsLegendLayer *>( *it );
if ( llayer )
items.append( llayer->layer() );

++it;
}

return items;
return mLegend->layers();
}

void QgsAppLegendInterface::refreshLayerSymbology( QgsMapLayer *ml )
@@ -649,7 +649,7 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
updateMapCanvasLayerSet();

// first layer?
if ( QgsMapLayerRegistry::instance()->count() == 1 )
if ( layers().count() == 1 )
{
mMapCanvas->zoomToFullExtent();
mMapCanvas->clearExtentHistory();
@@ -716,6 +716,22 @@ QList<QgsMapLayer *> QgsLegend::selectedLayers()
return layers;
}

QList<QgsMapLayer *> QgsLegend::layers()
{
QList< QgsMapLayer * > items;
QTreeWidgetItemIterator it( this );
while ( *it )
{
QgsLegendLayer *llayer = dynamic_cast<QgsLegendLayer *>( *it );
if ( llayer )
items.append( llayer->layer() );

++it;
}

return items;
}

bool QgsLegend::setCurrentLayer( QgsMapLayer *layer )
{
QgsLegendLayer *ll = findLegendLayer( layer );
@@ -112,6 +112,10 @@ class QgsLegend : public QTreeWidget
Else, an empty list is returned.*/
QList<QgsMapLayer *> selectedLayers();

/*!Returns all layers loaded in QgsMapCanvas.
Else, an empty list is returned.*/
QList<QgsMapLayer *> layers();

/*!set the current layer
returns true if the layer exists, false otherwise*/
bool setCurrentLayer( QgsMapLayer *layer );
@@ -410,7 +414,7 @@ class QgsLegend : public QTreeWidget

/**Pointer to the main canvas. Used for requiring repaints in case of legend changes*/
QgsMapCanvas* mMapCanvas;

/**Stores the width values of the LegendSymbologyItem pixmaps. The purpose of this is that the legend may automatically change
the global IconWidth when items are added or removed*/
std::multiset<int> mPixmapWidthValues;

0 comments on commit 9ef6503

Please sign in to comment.