Quantum GIS API Documentation
1.8
|
A model that provides group, layer and classification items. More...
#include <qgslegendmodel.h>
Public Types | |
enum | ItemType { GroupItem = 0, LayerItem, ClassificationItem } |
Public Slots | |
void | removeLayer (const QString &layerId) |
void | addLayer (QgsMapLayer *theMapLayer) |
Signals | |
void | layersChanged () |
Public Member Functions | |
QgsLegendModel () | |
~QgsLegendModel () | |
void | setLayerSetAndGroups (const QStringList &layerIds, const QList< GroupLayerInfo > &groupInfo) |
Sets layer set and groups. | |
void | setLayerSet (const QStringList &layerIds) |
QStandardItem * | addGroup (QString text=tr("Group"), int position=-1) |
Adds a group to a toplevel position (or -1 if it should be placed at the end of the legend). | |
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 | updateVectorV2ClassificationItem (QStandardItem *classificationItem, QgsSymbolV2 *symbol, QString itemText) |
void | updateRasterClassificationItem (QStandardItem *classificationItem) |
bool | writeXML (QDomElement &composerLegendElem, QDomDocument &doc) const |
bool | readXML (const QDomElement &legendModelElem, const QDomDocument &doc) |
Qt::DropActions | supportedDropActions () const |
Qt::ItemFlags | flags (const QModelIndex &index) const |
virtual bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
Implemented to support drag operations. | |
QMimeData * | mimeData (const QModelIndexList &indexes) const |
For the drag operation. | |
QStringList | mimeTypes () const |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
Implements the drop operation. | |
void | setAutoUpdate (bool autoUpdate) |
bool | autoUpdate () |
Protected Attributes | |
QStringList | mLayerIds |
bool | mHasTopLevelWindow |
True if this application has toplevel windows (normally true). | |
bool | mAutoUpdate |
True if the legend is auto updated when layers are added or removed from the map canvas. | |
Private Member Functions | |
int | addVectorLayerItems (QStandardItem *layerItem, QgsVectorLayer *vlayer) |
Adds classification items of vector layers. | |
int | addVectorLayerItemsV2 (QStandardItem *layerItem, QgsVectorLayer *vlayer) |
Adds classification items of vector layers using new symbology. | |
int | addRasterLayerItems (QStandardItem *layerItem, QgsMapLayer *rlayer) |
Adds item of raster layer. | |
QStandardItem * | itemFromSymbol (QgsSymbol *s, int opacity, const QString &layerID) |
Creates a model item for a vector symbol. |
A model that provides group, layer and classification items.
Definition at line 40 of file qgslegendmodel.h.
Definition at line 46 of file qgslegendmodel.h.
Definition at line 37 of file qgslegendmodel.cpp.
References addLayer(), QgsMapLayerRegistry::instance(), mHasTopLevelWindow, and removeLayer().
Definition at line 50 of file qgslegendmodel.cpp.
QStandardItem * QgsLegendModel::addGroup | ( | QString | text = tr( "Group" ) , |
int | position = -1 |
||
) |
Adds a group to a toplevel position (or -1 if it should be placed at the end of the legend).
Returns a pointer to the added group
Definition at line 120 of file qgslegendmodel.cpp.
Referenced by setLayerSetAndGroups().
void QgsLegendModel::addLayer | ( | QgsMapLayer * | theMapLayer | ) | [slot] |
Definition at line 340 of file qgslegendmodel.cpp.
References addRasterLayerItems(), addVectorLayerItems(), addVectorLayerItemsV2(), QgsMapLayer::id(), QgsVectorLayer::isUsingRendererV2(), layersChanged(), QgsMapLayer::name(), QgsMapLayer::RasterLayer, QgsComposerLayerItem::setLayerID(), QgsMapLayer::type(), and QgsMapLayer::VectorLayer.
Referenced by QgsLegendModel(), setAutoUpdate(), and setLayerSet().
int QgsLegendModel::addRasterLayerItems | ( | QStandardItem * | layerItem, |
QgsMapLayer * | rlayer | ||
) | [private] |
Adds item of raster layer.
Definition at line 226 of file qgslegendmodel.cpp.
References QgsMapLayer::id(), QgsRasterLayer::legendSymbologyItems(), mHasTopLevelWindow, QgsComposerRasterSymbolItem::setColor(), and QgsComposerRasterSymbolItem::setLayerID().
Referenced by addLayer(), and updateLayer().
int QgsLegendModel::addVectorLayerItems | ( | QStandardItem * | layerItem, |
QgsVectorLayer * | vlayer | ||
) | [private] |
Adds classification items of vector layers.
Definition at line 167 of file qgslegendmodel.cpp.
References QgsVectorLayer::attributeDisplayName(), QgsRenderer::classificationAttributes(), ClassificationItem, QgsMapLayer::getTransparency(), QgsMapLayer::id(), itemFromSymbol(), QgsVectorLayer::pendingFields(), QgsVectorLayer::renderer(), and QgsRenderer::symbols().
Referenced by addLayer(), and updateLayer().
int QgsLegendModel::addVectorLayerItemsV2 | ( | QStandardItem * | layerItem, |
QgsVectorLayer * | vlayer | ||
) | [private] |
Adds classification items of vector layers using new symbology.
Definition at line 134 of file qgslegendmodel.cpp.
References QgsFeatureRendererV2::legendSymbolItems(), mHasTopLevelWindow, QgsVectorLayer::rendererV2(), QgsComposerSymbolV2Item::setSymbolV2(), and QgsSymbolLayerV2Utils::symbolPreviewIcon().
Referenced by addLayer(), and updateLayer().
bool QgsLegendModel::autoUpdate | ( | ) | [inline] |
Definition at line 91 of file qgslegendmodel.h.
Referenced by setAutoUpdate().
bool QgsLegendModel::dropMimeData | ( | const QMimeData * | data, |
Qt::DropAction | action, | ||
int | row, | ||
int | column, | ||
const QModelIndex & | parent | ||
) |
Implements the drop operation.
Definition at line 620 of file qgslegendmodel.cpp.
References layersChanged(), and QgsComposerLegendItem::readXML().
Qt::ItemFlags QgsLegendModel::flags | ( | const QModelIndex & | index | ) | const |
Definition at line 532 of file qgslegendmodel.cpp.
References QgsComposerLegendItem::GroupItem, QgsComposerLegendItem::itemType(), and QgsComposerLegendItem::LayerItem.
QStandardItem * QgsLegendModel::itemFromSymbol | ( | QgsSymbol * | s, |
int | opacity, | ||
const QString & | layerID | ||
) | [private] |
Creates a model item for a vector symbol.
The calling function takes ownership
Definition at line 380 of file qgslegendmodel.cpp.
References QgsSymbol::getLineSymbolAsImage(), QgsSymbol::getPointSymbolAsImage(), QgsSymbol::getPolygonSymbolAsImage(), QgsSymbol::label(), QGis::Line, QgsSymbol::lowerValue(), mHasTopLevelWindow, QGis::Point, QGis::Polygon, QgsComposerSymbolItem::setLayerID(), QgsComposerSymbolItem::setSymbol(), QgsSymbol::type(), and QgsSymbol::upperValue().
Referenced by addVectorLayerItems().
void QgsLegendModel::layersChanged | ( | ) | [signal] |
Referenced by addLayer(), dropMimeData(), and removeLayer().
QMimeData * QgsLegendModel::mimeData | ( | const QModelIndexList & | indexes | ) | const |
For the drag operation.
Definition at line 588 of file qgslegendmodel.cpp.
References QgsComposerLegendItem::writeXML().
QStringList QgsLegendModel::mimeTypes | ( | ) | const |
Definition at line 613 of file qgslegendmodel.cpp.
bool QgsLegendModel::readXML | ( | const QDomElement & | legendModelElem, |
const QDomDocument & | doc | ||
) |
Definition at line 486 of file qgslegendmodel.cpp.
References mHasTopLevelWindow, QgsComposerLegendItem::readXML(), and setAutoUpdate().
Referenced by QgsComposerLegend::readXML().
void QgsLegendModel::removeLayer | ( | const QString & | layerId | ) | [slot] |
Definition at line 320 of file qgslegendmodel.cpp.
References QgsComposerLayerItem::layerID(), and layersChanged().
Referenced by QgsLegendModel(), and setAutoUpdate().
bool QgsLegendModel::removeRows | ( | int | row, |
int | count, | ||
const QModelIndex & | parent = QModelIndex() |
||
) | [virtual] |
Implemented to support drag operations.
Definition at line 560 of file qgslegendmodel.cpp.
void QgsLegendModel::setAutoUpdate | ( | bool | autoUpdate | ) |
Definition at line 691 of file qgslegendmodel.cpp.
References addLayer(), autoUpdate(), QgsMapLayerRegistry::instance(), mAutoUpdate, and removeLayer().
Referenced by readXML().
void QgsLegendModel::setLayerSet | ( | const QStringList & | layerIds | ) |
Definition at line 103 of file qgslegendmodel.cpp.
References addLayer(), QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayer(), and mLayerIds.
Referenced by setLayerSetAndGroups(), and QgsComposerLegend::updateLegend().
void QgsLegendModel::setLayerSetAndGroups | ( | const QStringList & | layerIds, |
const QList< GroupLayerInfo > & | groupInfo | ||
) |
Sets layer set and groups.
Definition at line 54 of file qgslegendmodel.cpp.
References addGroup(), QgsComposerLayerItem::layerID(), and setLayerSet().
Qt::DropActions QgsLegendModel::supportedDropActions | ( | ) | const |
Definition at line 527 of file qgslegendmodel.cpp.
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 259 of file qgslegendmodel.cpp.
References QgsComposerLegendItem::itemType(), QgsComposerLegendItem::LayerItem, and updateLayer().
void QgsLegendModel::updateLayer | ( | QStandardItem * | layerItem | ) |
Updates the whole symbology of a layer.
Definition at line 280 of file qgslegendmodel.cpp.
References addRasterLayerItems(), addVectorLayerItems(), addVectorLayerItemsV2(), QgsMapLayerRegistry::instance(), QgsVectorLayer::isUsingRendererV2(), QgsComposerLayerItem::layerID(), QgsMapLayerRegistry::mapLayer(), and QgsMapLayer::name().
Referenced by updateItem().
void QgsLegendModel::updateRasterClassificationItem | ( | QStandardItem * | classificationItem | ) | [inline] |
Definition at line 71 of file qgslegendmodel.h.
void QgsLegendModel::updateVectorClassificationItem | ( | QStandardItem * | classificationItem, |
QgsSymbol * | symbol, | ||
QString | itemText | ||
) | [inline] |
Tries to update a single classification item.
Definition at line 67 of file qgslegendmodel.h.
void QgsLegendModel::updateVectorV2ClassificationItem | ( | QStandardItem * | classificationItem, |
QgsSymbolV2 * | symbol, | ||
QString | itemText | ||
) | [inline] |
Definition at line 69 of file qgslegendmodel.h.
bool QgsLegendModel::writeXML | ( | QDomElement & | composerLegendElem, |
QDomDocument & | doc | ||
) | const |
Definition at line 459 of file qgslegendmodel.cpp.
References mAutoUpdate, and QgsComposerLegendItem::writeXML().
Referenced by QgsComposerLegend::writeXML().
bool QgsLegendModel::mAutoUpdate [protected] |
True if the legend is auto updated when layers are added or removed from the map canvas.
Definition at line 122 of file qgslegendmodel.h.
Referenced by setAutoUpdate(), and writeXML().
bool QgsLegendModel::mHasTopLevelWindow [protected] |
True if this application has toplevel windows (normally true).
If this is false, this means that the application might not have a running x-server on unix systems and so QPixmap and QIcon cannot be used
Definition at line 119 of file qgslegendmodel.h.
Referenced by addRasterLayerItems(), addVectorLayerItemsV2(), itemFromSymbol(), QgsLegendModel(), and readXML().
QStringList QgsLegendModel::mLayerIds [protected] |
Definition at line 116 of file qgslegendmodel.h.
Referenced by setLayerSet().