Skip to content
Permalink
Browse files
Fix for ticket #91.
- Captialising the layer name is now a global, per-user settings.
- Moved the capitalise code to QgsMapLayer so that it's not repeated in
  the code for loading each layer type.



git-svn-id: http://svn.osgeo.org/qgis/trunk@5434 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed May 11, 2006
1 parent fff1b7a commit 7e988cbf67b74eb9c6b2d11e1482ee46a14846c4
Showing with 125 additions and 85 deletions.
  1. +19 −2 src/gui/qgsmaplayer.cpp
  2. +5 −3 src/gui/qgsmaplayer.h
  3. +4 −0 src/gui/qgsoptions.cpp
  4. +6 −7 src/gui/qgsvectorlayer.cpp
  5. +6 −10 src/raster/qgsrasterlayer.cpp
  6. +85 −63 src/ui/qgsoptionsbase.ui
@@ -30,6 +30,7 @@
#include <QKeyEvent>
#include <QMenu>
#include <QRegExp>
#include <QSettings>

#include "qgisapp.h"
#include "qgslogger.h"
@@ -65,7 +66,7 @@ QgsMapLayer::QgsMapLayer(int type,
QgsDebugMsg("QgsMapLayer::QgsMapLayer - lyrname is '" + lyrname);

// Set the display name = internal name
layerName = internalName;
layerName = capitaliseLayerName(internalName);

QgsDebugMsg("QgsMapLayer::QgsMapLayer - layerName is '" + layerName);

@@ -108,7 +109,7 @@ QString const & QgsMapLayer::getLayerID() const
void QgsMapLayer::setLayerName(const QString & _newVal)
{
QgsDebugMsg("QgsMapLayer::setLayerName: new name is '" + _newVal);
layerName = _newVal;
layerName = capitaliseLayerName(_newVal);
// And update the legend if one exists
if (mLegend)
mLegend->setName(mLegendLayerFile, layerName);
@@ -703,3 +704,19 @@ QMenu* QgsMapLayer::contextMenu()
{
return popMenu;
}

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();

QString layerName(name);

if (capitaliseLayerName)
layerName = layerName.left(1).upper() + layerName.mid(1);

return layerName;
}
@@ -429,9 +429,6 @@ public slots:

QPixmap mEditablePixmap;

/** Name of the layer - used for display */
QString layerName;

/** Internal name of the layer. Derived from the datasource */
QString internalName;

@@ -474,6 +471,9 @@ public slots:
/// QgsMapLayer not copyable
QgsMapLayer & operator=( QgsMapLayer const & );

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

/** Unique ID of this layer - used to refer to this layer in QGIS code */
QString ID;

@@ -483,6 +483,8 @@ public slots:
//! Tag for embedding additional information
QString tag;

/** Name of the layer - used for display */
QString layerName;

/** true if visible ? */
bool m_visible;
@@ -106,6 +106,8 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
myGreen = settings.value("/qgis/default_canvas_color_green",255).toInt();
myBlue = settings.value("/qgis/default_canvas_color_blue",255).toInt();
pbnCanvasColor->setPaletteBackgroundColor(QColor(myRed,myGreen,myBlue));

capitaliseCheckBox->setChecked(settings.value("qgis/capitaliseLayerName", QVariant(false)).toBool());
}

//! Destructor
@@ -148,6 +150,8 @@ void QgsOptions::saveOptions()
settings.writeEntry("/qgis/hideSplash",cbxHideSplash->isChecked());
settings.writeEntry("/qgis/new_layers_visible",chkAddedVisibility->isChecked());
settings.writeEntry("/qgis/enable_anti_aliasing",chkAntiAliasing->isChecked());
settings.setValue("qgis/capitaliseLayerName", capitaliseCheckBox->isChecked());

if(cmbTheme->currentText().length() == 0)
{
settings.writeEntry("/Themes", "default");
@@ -2129,16 +2129,15 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )

if (providerKey == "postgres")
{
QgsDebugMsg("Beautifying layer name " + layerName);
QgsDebugMsg("Beautifying layer name " + name());
// adjust the display name for postgres layers
layerName = layerName.mid(layerName.find(".") + 1);
layerName = layerName.left(layerName.find("(") - 1); // Take one away, to avoid a trailing space
QgsDebugMsg("Beautifying layer name " + layerName);
QString lName(name());
lName = lName.mid(lName.find(".") + 1);
lName = lName.left(lName.find("(") - 1); // Take one away, to avoid a trailing space
setLayerName(lName);
QgsDebugMsg("Beautifying layer name " + name());
}

// upper case the first letter of the layer name
layerName = layerName.left(1).upper() + layerName.mid(1);

// label
mLabel = new QgsLabel ( dataProvider->fields() );
mLabelOn = false;
@@ -470,9 +470,7 @@ QgsRasterLayer::QgsRasterLayer(QString const & path, QString const & baseName)

if ( ! baseName.isEmpty() ) // XXX shouldn't this happen in parent?
{
QString layerTitle = baseName;
layerTitle = layerTitle.left(1).upper() + layerTitle.mid(1);
setLayerName(layerTitle);
setLayerName(baseName);
}

// load the file if one specified
@@ -1075,9 +1073,9 @@ bool QgsRasterLayer::draw(QPainter * theQPainter,
{
return;
}
}
}
*/

// clip raster extent to view extent
QgsRect myRasterExtent = theViewExtent->intersect(&layerExtent);
if (myRasterExtent.isEmpty())
@@ -2701,7 +2699,7 @@ const QgsRasterBandStats QgsRasterLayer::getRasterBandStats(int theBandNoInt)
return myRasterBandStats;
}
// only print message if we are actually gathering the stats
emit setStatus(QString("Retrieving stats for ")+layerName);
emit setStatus(QString("Retrieving stats for ")+name());
qApp->processEvents();
QgsDebugMsg("QgsRasterLayer::retrieve stats for band " + QString::number(theBandNoInt));
GDALRasterBand *myGdalBand = gdalDataset->GetRasterBand(theBandNoInt);
@@ -2751,7 +2749,7 @@ const QgsRasterBandStats QgsRasterLayer::getRasterBandStats(int theBandNoInt)

myRasterBandStats.elementCountInt = 0; // because we'll be counting only VALID pixels later

emit setStatus(QString("Calculating stats for ")+layerName);
emit setStatus(QString("Calculating stats for ")+name());
//reset the main app progress bar
emit setProgress(0,0);

@@ -4971,9 +4969,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
layerExtent.setYmax(mbr->yMax());
layerExtent.setYmin(mbr->yMin());

// upper case the first letter of the layer name
layerName = layerName.left(1).upper() + layerName.mid(1);
QgsDebugMsg("QgsRasterLayer::setDataProvider: layerName: " + layerName);
QgsDebugMsg("QgsRasterLayer::setDataProvider: layerName: " + name());


//
@@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>517</width>
<height>413</height>
<width>554</width>
<height>434</height>
</rect>
</property>
<property name="windowTitle" >
@@ -21,43 +21,30 @@
<property name="sizeGripEnabled" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<item>
<widget class="QTabWidget" name="tabWidget" >
<widget class="QWidget" name="tabAppearance" >
<attribute name="title" >
<string>&amp;Appearance</string>
</attribute>
<layout class="QGridLayout" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="3" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" >
<widget class="QGroupBox" name="groupBox_9" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Default Map Appearance (Overridden by project properties)</string>
<string>&amp;Splash screen</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
@@ -66,50 +53,17 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="2" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Background Color:</string>
</property>
<property name="buddy" >
<cstring>pbnCanvasColor</cstring>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="QToolButton" name="pbnCanvasColor" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QToolButton" name="pbnSelectionColour" >
<property name="minimumSize" >
<size>
<width>10</width>
<height>22</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1_9" >
<widget class="QCheckBox" name="cbxHideSplash" >
<property name="text" >
<string>Selection Color:</string>
</property>
<property name="buddy" >
<cstring>pbnSelectionColour</cstring>
<string>Hide splash screen at startup</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" >
<item>
<widget class="QGroupBox" name="groupBox_2" >
<property name="title" >
<string>&amp;Icon Theme</string>
@@ -177,10 +131,10 @@
</layout>
</widget>
</item>
<item row="0" column="0" >
<widget class="QGroupBox" name="groupBox" >
<item>
<widget class="QGroupBox" name="groupBox_9" >
<property name="title" >
<string>&amp;Splash screen</string>
<string>Default Map Appearance (Overridden by project properties)</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
@@ -189,16 +143,84 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="2" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Background Color:</string>
</property>
<property name="buddy" >
<cstring>pbnCanvasColor</cstring>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="QToolButton" name="pbnCanvasColor" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QToolButton" name="pbnSelectionColour" >
<property name="minimumSize" >
<size>
<width>10</width>
<height>22</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QCheckBox" name="cbxHideSplash" >
<widget class="QLabel" name="textLabel1_9" >
<property name="text" >
<string>Hide splash screen at startup</string>
<string>Selection Color:</string>
</property>
<property name="buddy" >
<cstring>pbnSelectionColour</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3" >
<property name="title" >
<string>Appearance</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="capitaliseCheckBox" >
<property name="text" >
<string>Capitalise layer name</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="TabPage" >
@@ -609,7 +631,7 @@ identifying features without zooming in very close.
</widget>
</widget>
</item>
<item row="1" column="0" >
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>

0 comments on commit 7e988cb

Please sign in to comment.