23 changes: 11 additions & 12 deletions src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@ QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
mTransparencyLevel( 255 ), // 0 is completely transparent
mValid( false ), // assume the layer is invalid
mDataSource( source ),
mLayerOrigName( lyrname ), // store the original name
mID( "" ),
mLayerType( type )

{
QgsDebugMsg( "lyrname is '" + lyrname + "'" );

mCRS = new QgsCoordinateReferenceSystem();

// Set the display name = internal name
mLayerName = capitaliseLayerName( lyrname );
QgsDebugMsg( "layerName is '" + mLayerName + "'" );
QgsDebugMsg( "original name: '" + mLayerOrigName + "'" );
mLayerName = capitaliseLayerName( mLayerOrigName );
QgsDebugMsg( "display name: '" + mLayerName + "'" );

// Generate the unique ID of this layer
QDateTime dt = QDateTime::currentDateTime();
Expand All @@ -77,8 +76,6 @@ QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
mpCacheImage = 0;
}



QgsMapLayer::~QgsMapLayer()
{
delete mCRS;
Expand All @@ -102,9 +99,11 @@ QString QgsMapLayer::id() const
/** Write property of QString layerName. */
void QgsMapLayer::setLayerName( const QString & name )
{
QgsDebugMsg( "new name is '" + name + "'" );
QgsDebugMsg( "new original name: '" + name + "'" );
QString newName = capitaliseLayerName( name );
if ( newName == mLayerName ) return;
QgsDebugMsg( "new display name: '" + name + "'" );
if ( name == mLayerOrigName && newName == mLayerName ) return;
mLayerOrigName = name; // store the new original name
mLayerName = newName;
emit layerNameChanged();
}
Expand Down Expand Up @@ -432,7 +431,7 @@ bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )

// layer name
QDomElement layerName = document.createElement( "layername" );
QDomText layerNameText = document.createTextNode( name() );
QDomText layerNameText = document.createTextNode( originalName() );
layerName.appendChild( layerNameText );

// layer title
Expand Down Expand Up @@ -608,12 +607,12 @@ void QgsMapLayer::setTransparency( unsigned int theInt )
mTransparencyLevel = theInt;
}

QString QgsMapLayer::capitaliseLayerName( const QString name )
QString QgsMapLayer::capitaliseLayerName( const QString& name )
{
// Capitalise the first letter of the layer name if requested
QSettings settings;
bool capitaliseLayerName =
settings.value( "qgis/capitaliseLayerName", QVariant( false ) ).toBool();
settings.value( "/qgis/capitaliseLayerName", QVariant( false ) ).toBool();

QString layerName( name );

Expand Down
14 changes: 12 additions & 2 deletions src/core/qgsmaplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
const QString & name() const;

/** Get the original name of the layer
* @note added in 1.9
*/
const QString & originalName() const { return mLayerOrigName; }

void setTitle( const QString& title ) { mTitle = title; }
const QString& title() const { return mTitle; }

Expand Down Expand Up @@ -223,8 +228,8 @@ class CORE_EXPORT QgsMapLayer : public QObject
@note emitSignal added in 1.4 */
void setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal = true );

/** A convenience function to capitalise the layer name */
static QString capitaliseLayerName( const QString name );
/** A convenience function to (un)capitalise the layer name */
static QString capitaliseLayerName( const QString& name );

/** Retrieve the style URI for this layer
* (either as a .qml file on disk or as a
Expand Down Expand Up @@ -428,6 +433,11 @@ class CORE_EXPORT QgsMapLayer : public QObject
/** Name of the layer - used for display */
QString mLayerName;

/** Original name of the layer
* @note added in 1.9
*/
QString mLayerOrigName;

QString mTitle;

/**Description of the layer*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ QString QgsProject::layerIsEmbedded( const QString& id ) const
return QString();
}
return it.value().first;
};
}

bool QgsProject::createEmbeddedLayer( const QString& layerId, const QString& projectFilePath, QList<QDomNode>& brokenNodes,
QList< QPair< QgsVectorLayer*, QDomElement > >& vectorLayerList, bool saveFlag )
Expand Down
122 changes: 97 additions & 25 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<width>654</width>
<height>808</height>
</rect>
</property>
Expand Down Expand Up @@ -1137,8 +1137,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<height>417</height>
<width>669</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
Expand Down Expand Up @@ -1456,7 +1456,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>615</width>
<width>654</width>
<height>681</height>
</rect>
</property>
Expand Down Expand Up @@ -1944,8 +1944,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>498</width>
<height>332</height>
<width>669</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
Expand Down Expand Up @@ -2074,25 +2074,97 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="capitaliseCheckBox">
<property name="text">
<string>Capitalise layer names</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxLegendClassifiers">
<property name="text">
<string>Display classification attribute names</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxCreateRasterLegendIcons">
<property name="text">
<string>Create raster icons</string>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="2">
<widget class="Line" name="line_4">
<property name="minimumSize">
<size>
<width>12</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_34">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="capitaliseCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Capitalise layer names</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="mLegendLayersBoldChkBx">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bold layer names</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QCheckBox" name="cbxLegendClassifiers">
<property name="text">
<string>Display classification attribute names</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QCheckBox" name="mLegendGroupsBoldChkBx">
<property name="text">
<string>Bold group names</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QCheckBox" name="cbxCreateRasterLegendIcons">
<property name="text">
<string>Create raster icons (may be slow)</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="label_53">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Legend item styles</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="cbxAddNewLayersToCurrentGroup">
Expand Down
27 changes: 19 additions & 8 deletions src/ui/qgsrasterlayerpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>678</width>
<height>537</height>
<width>752</width>
<height>599</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -607,12 +607,26 @@
<item>
<widget class="QLabel" name="lblDisplayName">
<property name="text">
<string>Display name</string>
<string>Layer name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leDisplayName"/>
<widget class="QLineEdit" name="mLayerOrigNameLineEd"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>displayed as</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leDisplayName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
Expand Down Expand Up @@ -1146,7 +1160,7 @@ p, li { white-space: pre-wrap; }
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Cantarell'; font-size:11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
Expand Down Expand Up @@ -1238,9 +1252,6 @@ p, li { white-space: pre-wrap; }
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
Expand Down
54 changes: 36 additions & 18 deletions src/ui/qgsvectorlayerpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>4</number>
<number>0</number>
</property>
<property name="iconSize">
<size>
Expand Down Expand Up @@ -297,8 +297,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>920</width>
<height>756</height>
<width>906</width>
<height>720</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
Expand Down Expand Up @@ -615,17 +615,7 @@ p, li { white-space: pre-wrap; }
<string>Display</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_19">
<item row="0" column="0">
<widget class="QLabel" name="textLabel3">
<property name="text">
<string>Legend display text</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txtDisplayName"/>
</item>
<item row="1" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Map Tip display text</string>
Expand Down Expand Up @@ -751,6 +741,34 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="textLabel3">
<property name="text">
<string>Layer name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mLayerOrigNameLineEdit"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>displayed as</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtDisplayName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabWidgetPage5">
Expand Down Expand Up @@ -778,8 +796,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>912</width>
<height>748</height>
<width>866</width>
<height>688</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -890,8 +908,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>912</width>
<height>748</height>
<width>866</width>
<height>688</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_17">
Expand Down