QGIS API Documentation  2.12.0-Lyon
qgsvectorlayerlabeling.cpp
Go to the documentation of this file.
2 
3 #include "qgspallabeling.h"
4 #include "qgsrulebasedlabeling.h"
5 #include "qgsvectorlayer.h"
6 
7 
9 {
10 }
11 
13 {
14  if ( element.attribute( "type" ) == "rule-based" )
15  {
16  return QgsRuleBasedLabeling::create( element );
17  }
18  else
19  {
20  // default
22  }
23 }
24 
26 {
27  if ( layer->customProperty( "labeling" ).toString() == QLatin1String( "pal" ) && layer->labelsEnabled() )
28  return new QgsVectorLayerLabelProvider( layer, false );
29 
30  return 0;
31 }
32 
34 {
35  return "simple";
36 }
37 
39 {
40  // all configuration is kept in layer custom properties (for compatibility)
41  QDomElement elem = doc.createElement( "labeling" );
42  elem.setAttribute( "type", "simple" );
43  return elem;
44 }
virtual QString type() const override
Unique type string of the labeling configuration implementation.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const override
Factory for label provider implementation.
QString attribute(const QString &name, const QString &defValue) const
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
void setAttribute(const QString &name, const QString &value)
virtual QDomElement save(QDomDocument &doc) const override
Return labeling configuration as XML element.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
static QgsRuleBasedLabeling * create(const QDomElement &element)
Create the instance from a DOM element with saved configuration.
static QgsAbstractVectorLayerLabeling * create(const QDomElement &element)
Try to create instance of an implementation based on the XML data.
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
Basic implementation of the labeling interface.
QDomElement createElement(const QString &tagName)
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
Represents a vector layer which manages a vector based data sets.
QString toString() const