Skip to content
Permalink
Browse files
Make the top level legend item bold for each layer so that it stands …
…out from the categories under it.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8488 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed May 21, 2008
1 parent 41af53b commit cd1b492ee0ab65957bf6c12bf0694b69551f6f61
Showing with 45 additions and 28 deletions.
  1. +38 −28 src/app/legend/qgslegendlayer.cpp
  2. +7 −0 src/app/legend/qgslegendlayer.h
@@ -50,6 +50,7 @@ QgsLegendLayer::QgsLegendLayer(QTreeWidgetItem* parent,QString name)
setFlags(Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
setCheckState (0, Qt::Checked);
setText(0, name);
setupFont();
}

QgsLegendLayer::QgsLegendLayer(QTreeWidget* parent, QString name): QgsLegendItem(parent, name)
@@ -58,6 +59,7 @@ QgsLegendLayer::QgsLegendLayer(QTreeWidget* parent, QString name): QgsLegendItem
setFlags(Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
setCheckState (0, Qt::Checked);
setText(0, name);
setupFont();
}

QgsLegendLayer::QgsLegendLayer(QString name): QgsLegendItem()
@@ -66,13 +68,20 @@ QgsLegendLayer::QgsLegendLayer(QString name): QgsLegendItem()
setFlags(Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
setCheckState (0, Qt::Checked);
setText(0, name);
setupFont();
}

QgsLegendLayer::~QgsLegendLayer()
{
mType=LEGEND_LAYER;
}

void QgsLegendLayer::setupFont() //private method
{
QFont myFont = font(0);
myFont.setBold(true); //visually differentiate layer labels from the rest
setFont(0,myFont);
}
void QgsLegendLayer::setLayerTypeIcon()
{
QIcon myIcon(getOriginalPixmap());
@@ -205,48 +214,48 @@ std::list<QgsLegendLayerFile*> QgsLegendLayer::legendLayerFiles()
void QgsLegendLayer::updateLayerSymbologySettings(const QgsMapLayer* mapLayer)
{
if(mapLayer)
{
//find all layers
std::list<QgsMapLayer*> theMapLayers = mapLayers();
for(std::list<QgsMapLayer*>::iterator it = theMapLayers.begin(); it != theMapLayers.end(); ++it)
{
//find all layers
std::list<QgsMapLayer*> theMapLayers = mapLayers();
for(std::list<QgsMapLayer*>::iterator it = theMapLayers.begin(); it != theMapLayers.end(); ++it)
{
if((*it) != mapLayer)
{
(*it)->copySymbologySettings(*mapLayer);
}
}
// source might have changed - e.g. other subset
setToolTip(0, mapLayer->publicSource());
if((*it) != mapLayer)
{
(*it)->copySymbologySettings(*mapLayer);
}
}
// source might have changed - e.g. other subset
setToolTip(0, mapLayer->publicSource());
}
}

void QgsLegendLayer::updateCheckState()
{
std::list<QgsLegendLayerFile*> llfiles = legendLayerFiles();
if(llfiles.size() < 1)
{
return;
}
{
return;
}

std::list<QgsLegendLayerFile*>::iterator iter = llfiles.begin();
Qt::CheckState theState = (*iter)->checkState(0);
for(; iter != llfiles.end(); ++iter)
{
if(theState != (*iter)->checkState(0))
{
if(theState != (*iter)->checkState(0))
{
theState = Qt::PartiallyChecked;
break;
}
theState = Qt::PartiallyChecked;
break;
}
}

if(theState != checkState(0))
{
treeWidget()->blockSignals(true);
setCheckState(0, theState);
//notify the legend that the check state has changed
legend()->updateCheckStates(this, theState);
treeWidget()->blockSignals(false);
}
{
treeWidget()->blockSignals(true);
setCheckState(0, theState);
//notify the legend that the check state has changed
legend()->updateCheckStates(this, theState);
treeWidget()->blockSignals(false);
}
}

void QgsLegendLayer::refreshSymbology(const QString& key, double widthScale)
@@ -355,8 +364,9 @@ void QgsLegendLayer::vectorLayerSymbology(const QgsVectorLayer* layer, double wi
QPixmap pix = QPixmap::fromImage(img); // convert to pixmap
itemList.push_back(std::make_pair(values, pix));
}

if(renderer->needsAttributes()) //create an item for each classification field (only one for most renderers)

//create an item for each classification field (only one for most renderers)
if(renderer->needsAttributes())
{
QgsAttributeList classfieldlist = renderer->classificationAttributes();
const QgsFieldMap& fields = layer->getDataProvider()->fields();
@@ -112,6 +112,13 @@ class QgsLegendLayer : public QgsLegendItem
void updateLayerSymbologySettings(const QgsMapLayer* mapLayer);

QPixmap getOriginalPixmap() const;

private:
/** Helper method to make the font bold from all ctors.
* Not to be confused with setFont() which is inherited
* from the QTreeWidgetItem base class.
*/
void setupFont();
};

#endif

0 comments on commit cd1b492

Please sign in to comment.