Mods to allow setting of display name of a layer

git-svn-id: http://svn.osgeo.org/qgis/trunk@108 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2002-08-18 17:07:52 +00:00
parent 88a68b3672
commit c93345f49c
5 changed files with 32 additions and 2 deletions

View File

@ -426,12 +426,21 @@ void QgisApp::layerProperties(QListViewItem * lvi)
lyr = ((QgsLegendItem *) li)->layer();
}
QString currentName = lyr->name();
QgsLayerProperties *lp = new QgsLayerProperties(lyr);
if (lp->exec()) {
mapCanvas->freeze();
lyr->setlayerName(lp->displayName());
if(currentName != lp->displayName())
mapLegend->update();
delete lp;
qApp->processEvents();
// apply changes
mapCanvas->freeze(false);
mapCanvas->render2();
}
}
void QgisApp::removeLayer()
{
@ -452,3 +461,4 @@ void QgisApp::rightClickLegendMenu(QListViewItem * lvi, const QPoint & pt, int i
if (lvi)
popMenu->exec(pt);
}

View File

@ -18,6 +18,9 @@
#include <qframe.h>
#include <qcolordialog.h>
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qstring.h>
#include <qlabel.h>
#include "qgsmaplayer.h"
#include "qgssymbol.h"
#include "qgslayerproperties.h"
@ -25,6 +28,12 @@
QgsLayerProperties::QgsLayerProperties(QgsMapLayer * lyr):layer(lyr)
{
// populate the property sheet based on the layer properties
// general info
QString source = lyr->source();
source = source.left(source.find("password"));
lblSource->setText(source);
txtDisplayName->setText(lyr->name());
//symbology
sym = layer->symbol();
btnSetColor->setPaletteBackgroundColor(sym->color());
@ -38,7 +47,7 @@ QgsLayerProperties::~QgsLayerProperties()
}
void QgsLayerProperties::selectFillColor()
{
QColor fc = QColorDialog::getColor(sym->fillColor(), this);
if (fc.isValid()) {
@ -55,3 +64,7 @@ void QgsLayerProperties::selectOutlineColor()
sym->setColor(oc);
}
}
QString QgsLayerProperties::displayName(){
return txtDisplayName->text();
}

View File

@ -20,6 +20,7 @@
#define QGSLAYERPROPERTIES_H
class QgsMapLayer;
class QgsSymbol;
class QString;
#include "qgslayerpropertiesbase.h"
@ -38,6 +39,8 @@ public:
void selectFillColor();
//! Function to display the color selector and choose the outline color
void selectOutlineColor();
//! Name to display in legend
QString displayName();
private:
QgsMapLayer *layer;
QgsSymbol *sym;

View File

@ -48,7 +48,9 @@ const QString QgsMapLayer::name()
{
return layerName;
}
QString QgsMapLayer::source(){
return dataSource;
}
const QgsRect QgsMapLayer::extent()
{
return layerExtent;

View File

@ -86,6 +86,8 @@ class QgsMapLayer:public QObject
bool visible();
//! set visibility
void setVisible(bool vis);
//! Returns the source for the layer
QString source();
/** Write property of int featureType. */
virtual void setFeatureType(const int &_newVal);
/** Read property of int featureType. */