Fix for ticket #72

git-svn-id: http://svn.osgeo.org/qgis/trunk@5273 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
g_j_m 2006-04-13 22:58:42 +00:00
parent 21a92b5fa9
commit 4109517233
3 changed files with 25 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#include "qgsproject.h" #include "qgsproject.h"
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgsmaplayer.h" #include "qgsmaplayer.h"
#include "qgslegend.h"
#include "qgslegendlayerfile.h" #include "qgslegendlayerfile.h"
@ -105,6 +106,9 @@ void QgsMapLayer::setLayerName(const QString & _newVal)
{ {
QgsDebugMsg("QgsMapLayer::setLayerName: new name is '" + _newVal); QgsDebugMsg("QgsMapLayer::setLayerName: new name is '" + _newVal);
layerName = _newVal; layerName = _newVal;
// And update the legend if one exists
if (mLegend)
mLegend->setName(mLegendLayerFile, layerName);
} }
/** Read property of QString layerName. */ /** Read property of QString layerName. */

View File

@ -1281,6 +1281,22 @@ void QgsLegend::changeSymbologySettings(const QString& key, const std::list< std
setCurrentItem(theCurrentItem); 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) void QgsLegend::handleItemChange(QTreeWidgetItem* item, int row)
{ {
if(!item) if(!item)

View File

@ -26,6 +26,7 @@
class QgisApp; class QgisApp;
class QgsLegendLayer; class QgsLegendLayer;
class QgsLegendLayerFile;
class QgsLegendItem; class QgsLegendItem;
class QgsMapLayer; class QgsMapLayer;
class QgsMapCanvas; class QgsMapCanvas;
@ -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*/ 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); 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: public slots:
/*!Adds a new layer group with the maplayer to the canvas*/ /*!Adds a new layer group with the maplayer to the canvas*/