Quantum GIS API Documentation
1.7.5-Wroclaw
|
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 | addRasterLayerItem (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.
QgsLegendModel::QgsLegendModel | ( | ) |
Definition at line 37 of file qgslegendmodel.cpp.
References addLayer(), QgsMapLayerRegistry::instance(), mHasTopLevelWindow, and removeLayer().
QgsLegendModel::~QgsLegendModel | ( | ) |
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().
|
slot |
Definition at line 333 of file qgslegendmodel.cpp.
References addRasterLayerItem(), addVectorLayerItems(), addVectorLayerItemsV2(), QgsMapLayer::id(), QgsVectorLayer::isUsingRendererV2(), layersChanged(), QgsMapLayer::name(), QgsMapLayer::RasterLayer, QgsComposerLayerItem::setLayerID(), QgsMapLayer::type(), and QgsMapLayer::VectorLayer.
Referenced by QgsLegendModel(), setAutoUpdate(), and setLayerSet().
|
private |
Adds item of raster layer.
Definition at line 226 of file qgslegendmodel.cpp.
References QgsMapLayer::id(), QgsRasterLayer::legendAsPixmap(), mHasTopLevelWindow, and QgsComposerRasterSymbolItem::setLayerID().
Referenced by addLayer(), and updateLayer().
|
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().
|
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().
|
inline |
Definition at line 88 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 611 of file qgslegendmodel.cpp.
References layersChanged(), and QgsComposerLegendItem::readXML().
Qt::ItemFlags QgsLegendModel::flags | ( | const QModelIndex & | index | ) | const |
Definition at line 523 of file qgslegendmodel.cpp.
References QgsComposerLegendItem::GroupItem, QgsComposerLegendItem::itemType(), and QgsComposerLegendItem::LayerItem.
|
private |
Creates a model item for a vector symbol.
The calling function takes ownership
Definition at line 373 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().
|
signal |
Referenced by addLayer(), dropMimeData(), and removeLayer().
QMimeData * QgsLegendModel::mimeData | ( | const QModelIndexList & | indexes | ) | const |
For the drag operation.
Definition at line 579 of file qgslegendmodel.cpp.
References QgsComposerLegendItem::writeXML().
QStringList QgsLegendModel::mimeTypes | ( | ) | const |
Definition at line 604 of file qgslegendmodel.cpp.
bool QgsLegendModel::readXML | ( | const QDomElement & | legendModelElem, |
const QDomDocument & | doc | ||
) |
Definition at line 479 of file qgslegendmodel.cpp.
References mHasTopLevelWindow, QgsComposerLegendItem::readXML(), and setAutoUpdate().
Referenced by QgsComposerLegend::readXML().
|
slot |
Definition at line 313 of file qgslegendmodel.cpp.
References QgsComposerLayerItem::layerID(), and layersChanged().
Referenced by QgsLegendModel(), and setAutoUpdate().
|
virtual |
Implemented to support drag operations.
Definition at line 551 of file qgslegendmodel.cpp.
void QgsLegendModel::setAutoUpdate | ( | bool | autoUpdate | ) |
Definition at line 679 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 518 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 252 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 273 of file qgslegendmodel.cpp.
References addRasterLayerItem(), addVectorLayerItems(), addVectorLayerItemsV2(), QgsMapLayerRegistry::instance(), QgsVectorLayer::isUsingRendererV2(), QgsComposerLayerItem::layerID(), QgsMapLayerRegistry::mapLayer(), and QgsMapLayer::name().
Referenced by updateItem().
|
inline |
Definition at line 69 of file qgslegendmodel.h.
|
inline |
Tries to update a single classification item.
Definition at line 67 of file qgslegendmodel.h.
|
inline |
Definition at line 68 of file qgslegendmodel.h.
bool QgsLegendModel::writeXML | ( | QDomElement & | composerLegendElem, |
QDomDocument & | doc | ||
) | const |
Definition at line 452 of file qgslegendmodel.cpp.
References mAutoUpdate, and QgsComposerLegendItem::writeXML().
Referenced by QgsComposerLegend::writeXML().
|
protected |
True if the legend is auto updated when layers are added or removed from the map canvas.
Definition at line 119 of file qgslegendmodel.h.
Referenced by setAutoUpdate(), and writeXML().
|
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 116 of file qgslegendmodel.h.
Referenced by addRasterLayerItem(), addVectorLayerItemsV2(), itemFromSymbol(), QgsLegendModel(), and readXML().
|
protected |
Definition at line 113 of file qgslegendmodel.h.
Referenced by setLayerSet().