Skip to content

Commit

Permalink
Fix for ticket #72
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@5273 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Apr 13, 2006
1 parent 21a92b5 commit 4109517
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/gui/qgsmaplayer.cpp
Expand Up @@ -37,6 +37,7 @@
#include "qgsproject.h"
#include "qgssymbol.h"
#include "qgsmaplayer.h"
#include "qgslegend.h"
#include "qgslegendlayerfile.h"


Expand Down Expand Up @@ -105,6 +106,9 @@ void QgsMapLayer::setLayerName(const QString & _newVal)
{
QgsDebugMsg("QgsMapLayer::setLayerName: new name is '" + _newVal);
layerName = _newVal;
// And update the legend if one exists
if (mLegend)
mLegend->setName(mLegendLayerFile, layerName);
}

/** Read property of QString layerName. */
Expand Down
16 changes: 16 additions & 0 deletions src/legend/qgslegend.cpp
Expand Up @@ -1281,6 +1281,22 @@ void QgsLegend::changeSymbologySettings(const QString& key, const std::list< std
setCurrentItem(theCurrentItem);
}

void QgsLegend::setName(QgsLegendLayerFile* legendLayerFile,
QString layerName)
{
if (legendLayerFile)
{
QTreeWidgetItem* p = legendLayerFile->parent();
if (p)
{
p = p->parent();
if (p)
p->setText(0, layerName);
}
}

}

void QgsLegend::handleItemChange(QTreeWidgetItem* item, int row)
{
if(!item)
Expand Down
5 changes: 5 additions & 0 deletions src/legend/qgslegend.h
Expand Up @@ -26,6 +26,7 @@

class QgisApp;
class QgsLegendLayer;
class QgsLegendLayerFile;
class QgsLegendItem;
class QgsMapLayer;
class QgsMapCanvas;
Expand Down Expand Up @@ -145,6 +146,10 @@ class QgsLegend : public QTreeWidget
Note: the QIcon* are deleted and therefore need to be allocated by calling functions using operator new*/
void changeSymbologySettings(const QString& key, const std::list< std::pair<QString, QIcon*> >* newSymbologyItems);

/** Sets the name of the QgsLegendLayer that is the parent of
the given QgsLegendLayerFile */
void setName(QgsLegendLayerFile* w, QString layerName);

public slots:

/*!Adds a new layer group with the maplayer to the canvas*/
Expand Down

0 comments on commit 4109517

Please sign in to comment.