mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
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:
parent
88a68b3672
commit
c93345f49c
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
@ -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;
|
||||
|
@ -48,7 +48,9 @@ const QString QgsMapLayer::name()
|
||||
{
|
||||
return layerName;
|
||||
}
|
||||
|
||||
QString QgsMapLayer::source(){
|
||||
return dataSource;
|
||||
}
|
||||
const QgsRect QgsMapLayer::extent()
|
||||
{
|
||||
return layerExtent;
|
||||
|
@ -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. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user