#include <qgslegendmodel.h>
The classification items are children of the layer items.
Definition at line 34 of file qgslegendmodel.h.
Public Slots | |
| void | removeLayer (const QString &layerId) |
| void | addLayer (QgsMapLayer *theMapLayer) |
Signals | |
| void | layersChanged () |
Public Member Functions | |
| QgsLegendModel () | |
| ~QgsLegendModel () | |
| void | setLayerSet (const QStringList &layerIds) |
| void | updateItem (QStandardItem *item) |
| Tries to automatically update a model entry (e.g. | |
| void | updateLayer (QStandardItem *layerItem) |
| Updates the whole symbology of a layer. | |
| void | updateVectorClassificationItem (QStandardItem *classificationItem, QgsSymbol *symbol, QString itemText) |
| Tries to update a single classification item. | |
| void | updateRasterClassificationItem (QStandardItem *classificationItem) |
| bool | writeXML (QDomElement &composerLegendElem, QDomDocument &doc) const |
| bool | readXML (const QDomElement &legendModelElem, const QDomDocument &doc) |
Protected Attributes | |
| QStringList | mLayerIds |
Private Member Functions | |
| int | addVectorLayerItems (QStandardItem *layerItem, QgsMapLayer *vlayer) |
| Adds classification items of vector layers. | |
| int | addRasterLayerItem (QStandardItem *layerItem, QgsMapLayer *rlayer) |
| Adds item of raster layer. | |
| void | insertSymbol (QgsSymbol *s) |
| Insert a symbol into QgsLegendModel symbol storage. | |
| void | removeSymbol (QgsSymbol *s) |
| Removes and deletes a symbol. | |
| void | removeAllSymbols () |
| Removes and deletes all stored symbols. | |
| QStandardItem * | itemFromSymbol (QgsSymbol *s) |
| Creates a model item for a vector symbol. | |
Private Attributes | |
| QSet< QgsSymbol * > | mSymbols |
| Keep track of copied symbols to delete them if not used anymore. | |
| QgsLegendModel::QgsLegendModel | ( | ) |
Definition at line 31 of file qgslegendmodel.cpp.
References addLayer(), QgsMapLayerRegistry::instance(), and removeLayer().
| QgsLegendModel::~QgsLegendModel | ( | ) |
| void QgsLegendModel::setLayerSet | ( | const QStringList & | layerIds | ) |
Definition at line 45 of file qgslegendmodel.cpp.
References addRasterLayerItem(), addVectorLayerItems(), QgsMapLayer::getLayerID(), QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayer(), mLayerIds, QgsMapLayer::name(), QgsMapLayer::RasterLayer, QgsMapLayer::type(), and QgsMapLayer::VectorLayer.
Referenced by QgsComposerLegend::QgsComposerLegend(), and QgsComposerLegend::updateLegend().
| void QgsLegendModel::updateItem | ( | QStandardItem * | item | ) |
Tries to automatically update a model entry (e.g.
a whole layer or only a single item)
Definition at line 194 of file qgslegendmodel.cpp.
References updateLayer(), updateRasterClassificationItem(), and updateVectorClassificationItem().
| void QgsLegendModel::updateLayer | ( | QStandardItem * | layerItem | ) |
Updates the whole symbology of a layer.
Definition at line 228 of file qgslegendmodel.cpp.
References addRasterLayerItem(), addVectorLayerItems(), QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayer(), QgsMapLayer::RasterLayer, QgsMapLayer::type(), and QgsMapLayer::VectorLayer.
Referenced by updateItem().
| void QgsLegendModel::updateVectorClassificationItem | ( | QStandardItem * | classificationItem, | |
| QgsSymbol * | symbol, | |||
| QString | itemText | |||
| ) |
Tries to update a single classification item.
Definition at line 261 of file qgslegendmodel.cpp.
References QgsMapLayerRegistry::instance(), itemFromSymbol(), QgsSymbol::label(), QgsSymbol::lowerValue(), QgsMapLayerRegistry::mapLayer(), removeSymbol(), QgsVectorLayer::renderer(), QgsRenderer::symbols(), and QgsSymbol::upperValue().
Referenced by updateItem().
| void QgsLegendModel::updateRasterClassificationItem | ( | QStandardItem * | classificationItem | ) |
Definition at line 341 of file qgslegendmodel.cpp.
References QgsMapLayerRegistry::instance(), QgsRasterLayer::legendAsPixmap(), and QgsMapLayerRegistry::mapLayer().
Referenced by updateItem().
| bool QgsLegendModel::writeXML | ( | QDomElement & | composerLegendElem, | |
| QDomDocument & | doc | |||
| ) | const |
Definition at line 482 of file qgslegendmodel.cpp.
References QgsSymbol::writeXML().
Referenced by QgsComposerLegend::writeXML().
| bool QgsLegendModel::readXML | ( | const QDomElement & | legendModelElem, | |
| const QDomDocument & | doc | |||
| ) |
Definition at line 550 of file qgslegendmodel.cpp.
References insertSymbol(), QgsMapLayerRegistry::instance(), QGis::Line, QgsMapLayerRegistry::mapLayer(), QGis::Point, QGis::Polygon, QgsMapLayer::readXML(), removeAllSymbols(), and QGis::UnknownGeometry.
Referenced by QgsComposerLegend::readXML().
| void QgsLegendModel::removeLayer | ( | const QString & | layerId | ) | [slot] |
Definition at line 371 of file qgslegendmodel.cpp.
References layersChanged().
Referenced by QgsLegendModel().
| void QgsLegendModel::addLayer | ( | QgsMapLayer * | theMapLayer | ) | [slot] |
Definition at line 394 of file qgslegendmodel.cpp.
References addRasterLayerItem(), addVectorLayerItems(), QgsMapLayer::getLayerID(), layersChanged(), QgsMapLayer::name(), QgsMapLayer::RasterLayer, QgsMapLayer::type(), and QgsMapLayer::VectorLayer.
Referenced by QgsLegendModel().
| void QgsLegendModel::layersChanged | ( | ) | [signal] |
Referenced by addLayer(), and removeLayer().
| int QgsLegendModel::addVectorLayerItems | ( | QStandardItem * | layerItem, | |
| QgsMapLayer * | vlayer | |||
| ) | [private] |
Adds classification items of vector layers.
Definition at line 82 of file qgslegendmodel.cpp.
References QgsRenderer::classificationAttributes(), QgsVectorLayer::dataProvider(), itemFromSymbol(), QgsVectorLayer::renderer(), and QgsRenderer::symbols().
Referenced by addLayer(), setLayerSet(), and updateLayer().
| int QgsLegendModel::addRasterLayerItem | ( | QStandardItem * | layerItem, | |
| QgsMapLayer * | rlayer | |||
| ) | [private] |
Adds item of raster layer.
Definition at line 148 of file qgslegendmodel.cpp.
References QgsRasterLayer::legendAsPixmap().
Referenced by addLayer(), setLayerSet(), and updateLayer().
| void QgsLegendModel::insertSymbol | ( | QgsSymbol * | s | ) | [private] |
Insert a symbol into QgsLegendModel symbol storage.
Definition at line 169 of file qgslegendmodel.cpp.
References mSymbols.
Referenced by itemFromSymbol(), and readXML().
| void QgsLegendModel::removeSymbol | ( | QgsSymbol * | s | ) | [private] |
Removes and deletes a symbol.
Definition at line 179 of file qgslegendmodel.cpp.
References mSymbols.
Referenced by updateVectorClassificationItem().
| void QgsLegendModel::removeAllSymbols | ( | ) | [private] |
Removes and deletes all stored symbols.
Definition at line 184 of file qgslegendmodel.cpp.
References mSymbols.
Referenced by readXML(), and ~QgsLegendModel().
| QStandardItem * QgsLegendModel::itemFromSymbol | ( | QgsSymbol * | s | ) | [private] |
Creates a model item for a vector symbol.
The calling function takes ownership
Definition at line 423 of file qgslegendmodel.cpp.
References QgsSymbol::getLineSymbolAsImage(), QgsSymbol::getPointSymbolAsImage(), QgsSymbol::getPolygonSymbolAsImage(), insertSymbol(), QgsSymbol::label(), QGis::Line, QgsSymbol::lowerValue(), QGis::Point, QGis::Polygon, QgsSymbol::type(), and QgsSymbol::upperValue().
Referenced by addVectorLayerItems(), and updateVectorClassificationItem().
QSet<QgsSymbol*> QgsLegendModel::mSymbols [private] |
Keep track of copied symbols to delete them if not used anymore.
Definition at line 82 of file qgslegendmodel.h.
Referenced by insertSymbol(), removeAllSymbols(), and removeSymbol().
QStringList QgsLegendModel::mLayerIds [protected] |
1.5.1