55 foreach (
int id, order )
66 int numNodes = lst.
count();
75 QgsDebugMsg(
"Legend node order manipulation is invalid without existing legend" );
82 for (
int i = 0; i < numNodes; ++i )
94 if ( orderStr ==
"empty" )
103 int id = item.
toInt( &ok );
104 if ( !ok || id < 0 || id >= numNodes )
141 if ( !userLabel.
isNull() )
152 foreach (
int idx, order )
160 newOrder << nodes[idx];
165 for (
int i = 0; i < nodes.
count(); ++i )
217 widthMax[parentKey] = qMax( sz.width(), widthMax.contains( parentKey ) ? widthMax[parentKey] : 0 );
226 Q_ASSERT( widthMax[parentKey] > 0 );
227 const int twiceMarginWidth = 2;
231 if ( nodes.
count() == 1 && nodes[0]->data( Qt::EditRole ).toString().
isEmpty() )
232 nodes[0]->setEmbeddedInParent(
true );
269 if ( rasterItemList.
count() == 0 )
275 int max_count = 1000;
278 itemIt != rasterItemList.
constEnd(); ++itemIt, ++count )
282 if ( count == max_count )
284 QString label =
tr(
"following %1 items\nnot displayed" ).
arg( rasterItemList.
size() - max_count );
306 QSize iconSize( 16, 16 );
309 if ( symbologyList.
count() == 0 )
313 foreach ( XY item, symbologyList )
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
static void setLegendNodeOrder(QgsLayerTreeLayer *nodeLayer, const QList< int > &order)
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
static QgsMapLayerLegend * defaultPluginLegend(QgsPluginLayer *pl)
Create new legend implementation for raster layer.
virtual QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
static void setLegendNodeUserLabel(QgsLayerTreeLayer *nodeLayer, int originalIndex, const QString &newLabel)
virtual QgsLegendSymbologyList legendSymbologyItems(const QSize &iconSize)
return a list of symbology items for the legend (defult implementation returns nothing) ...
QgsMapLayer * layer() const
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
Base class for plugin layers.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
virtual QList< QgsLayerTreeModelLegendNode * > createLayerTreeModelLegendNodes(QgsLayerTreeLayer *nodeLayer) override
Return list of legend nodes to be used for a particular layer tree layer node.
QStringList customProperties() const
Return list of keys stored in custom properties.
Implementation of legend node interface for displaying raster legend entries.
static QList< int > legendNodeOrder(QgsLayerTreeLayer *nodeLayer)
QgsDefaultPluginLayerLegend(QgsPluginLayer *pl)
bool contains(const QString &str, Qt::CaseSensitivity cs) const
Default legend implementation for raster layers.
QSize minimumIconSize() const
Get the minimum icon size to prevent cropping.
static bool hasLegendNodeOrder(QgsLayerTreeLayer *nodeLayer)
QString join(const QString &separator) const
QgsDefaultVectorLayerLegend(QgsVectorLayer *vl)
QString tr(const char *sourceText, const char *disambiguation, int n)
QgsSymbolV2 * symbol() const
Return associated symbol. May be null.
virtual QList< QgsLayerTreeModelLegendNode * > createLayerTreeModelLegendNodes(QgsLayerTreeLayer *nodeLayer) override
Return list of legend nodes to be used for a particular layer tree layer node.
rule key of the parent legend node - for legends with tree hierarchy (QString). Added in 2...
QString number(int n, int base)
int count(const T &value) const
void append(const T &value)
static int _originalLegendNodeCount(QgsLayerTreeLayer *nodeLayer)
virtual QString legendClassificationAttribute() const
If supported by the renderer, return classification attribute for the use in legend.
static QString legendNodeUserLabel(QgsLayerTreeLayer *nodeLayer, int originalIndex)
virtual QVariant data(int role) const override
Return data associated with the item.
int toInt(bool *ok, int base) const
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer...
static bool hasLegendNodeUserLabel(QgsLayerTreeLayer *nodeLayer, int originalIndex)
Implementation of legend node interface for displaying arbitrary label with icon. ...
const QgsDiagramRendererV2 * diagramRenderer() const
static void applyLayerNodeProperties(QgsLayerTreeLayer *nodeLayer, QList< QgsLayerTreeModelLegendNode * > &nodes)
update according to layer node's custom properties (order of items, user labels for items) ...
bool countSymbolFeatures(bool showProgress=true)
Count features for symbols.
static QgsMapLayerLegend * defaultVectorLegend(QgsVectorLayer *vl)
Create new legend implementation for vector layer.
bool contains(const T &value) const
QgsMapLayerLegend * legend() const
Can be null.
Implementation of legend node interface for displaying WMS legend entries.
QVariant value(const QString &key, const QVariant &defaultValue) const
void itemsChanged()
Emitted when existing items/nodes got invalid and should be replaced by new ones. ...
static QgsMapLayerLegend * defaultRasterLegend(QgsRasterLayer *rl)
Create new legend implementation for raster layer.
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
QgsDefaultRasterLayerLegend(QgsRasterLayer *rl)
Default legend implementation for plugin layers.
virtual QList< QgsLayerTreeModelLegendNode * > createLayerTreeModelLegendNodes(QgsLayerTreeLayer *nodeLayer) override
Return list of legend nodes to be used for a particular layer tree layer node.
static QList< int > _makeNodeOrder(QgsLayerTreeLayer *nodeLayer)
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
QgsMapLayerLegend(QObject *parent=0)
Implementation of legend node interface for displaying preview of vector symbols and their labels and...
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
const_iterator constEnd() const
const_iterator constBegin() const
void setIconSize(const QSize &sz)
Set the icon size.
Default legend implementation for vector layers.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QgsLegendColorList legendSymbologyItems() const
Returns a list with classification items (Text and color)
Represents a vector layer which manages a vector based data sets.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual QList< QgsLayerTreeModelLegendNode * > createLayerTreeModelLegendNodes(QgsLayerTreeLayer *nodeLayer)=0
Return list of legend nodes to be used for a particular layer tree layer node.
virtual void setUserLabel(const QString &userLabel)
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for the node.
Layer tree node points to a map layer.