28 #include <QDomDocument>
29 #include <QDomElement>
52 int numRows = rowCount();
54 for (
int i = 0; i < numRows; ++i )
99 QDomElement vectorClassElem = doc.createElement(
"VectorClassificationItemNg" );
103 saveSymbolMap.insert(
"classificationSymbol",
mSymbolV2 );
105 vectorClassElem.appendChild( symbolsElem );
107 vectorClassElem.setAttribute(
"text", text() );
108 vectorClassElem.setAttribute(
"userText",
userText() );
109 elem.appendChild( vectorClassElem );
114 if ( itemElem.isNull() )
119 setText( itemElem.attribute(
"text",
"" ) );
120 setUserText( itemElem.attribute(
"userText",
"" ) );
121 QDomElement symbolsElem = itemElem.firstChildElement(
"symbols" );
122 if ( !symbolsElem.isNull() )
126 QgsSymbolV2Map::iterator mapIt = loadSymbolMap.begin();
127 if ( mapIt != loadSymbolMap.end() )
133 if ( xServerAvailable )
176 QDomElement rasterClassElem = doc.createElement(
"RasterClassificationItem" );
177 rasterClassElem.setAttribute(
"layerId",
mLayerID );
178 rasterClassElem.setAttribute(
"text", text() );
179 rasterClassElem.setAttribute(
"userText",
userText() );
180 rasterClassElem.setAttribute(
"color",
mColor.name() );
181 elem.appendChild( rasterClassElem );
186 if ( itemElem.isNull() )
190 setText( itemElem.attribute(
"text",
"" ) );
191 setUserText( itemElem.attribute(
"userText",
"" ) );
192 setLayerID( itemElem.attribute(
"layerId",
"" ) );
193 setColor( QColor( itemElem.attribute(
"color" ) ) );
195 if ( xServerAvailable )
197 QPixmap itemPixmap( 20, 20 );
198 itemPixmap.fill(
mColor );
199 setIcon( QIcon( itemPixmap ) );
206 , mShowFeatureCount( false )
211 , mShowFeatureCount( false )
229 QDomElement layerItemElem = doc.createElement(
"LayerItem" );
230 layerItemElem.setAttribute(
"layerId",
mLayerID );
231 layerItemElem.setAttribute(
"text", text() );
232 layerItemElem.setAttribute(
"userText",
userText() );
236 elem.appendChild( layerItemElem );
241 if ( itemElem.isNull() )
245 setText( itemElem.attribute(
"text",
"" ) );
246 setUserText( itemElem.attribute(
"userText",
"" ) );
247 setLayerID( itemElem.attribute(
"layerId",
"" ) );
252 QDomNodeList childList = itemElem.childNodes();
253 QDomNode currentNode;
254 QDomElement currentElem;
257 int nChildItems = childList.count();
258 for (
int i = 0; i < nChildItems; ++i )
260 currentNode = childList.at( i );
261 if ( !currentNode.isElement() )
266 currentElem = currentNode.toElement();
267 QString elemTag = currentElem.tagName();
268 if ( elemTag ==
"VectorClassificationItem" )
272 else if ( elemTag ==
"VectorClassificationItemNg" )
276 else if ( elemTag ==
"RasterClassificationItem" )
284 currentChildItem->
readXML( currentElem, xServerAvailable );
285 appendRow( currentChildItem );
298 QPair<QString, QgsSymbolV2*> symbolItem = renderer->
legendSymbolItems( scaleDenominator, rule ).value( 0 );
299 if ( renderer->
legendSymbolItems( scaleDenominator, rule ).size() > 1 || !symbolItem.first.isEmpty() )
335 QDomElement layerGroupElem = doc.createElement(
"GroupItem" );
337 layerGroupElem.setAttribute(
"text", text() );
338 layerGroupElem.setAttribute(
"userText",
userText() );
341 elem.appendChild( layerGroupElem );
346 if ( itemElem.isNull() )
351 QString
userText = itemElem.attribute(
"userText",
"" );
352 if ( userText.isEmpty() )
354 userText = itemElem.attribute(
"text",
"" );
362 QDomNodeList childList = itemElem.childNodes();
363 QDomNode currentNode;
364 QDomElement currentElem;
367 int nChildItems = childList.count();
368 for (
int i = 0; i < nChildItems; ++i )
370 currentNode = childList.at( i );
371 if ( !currentNode.isElement() )
376 currentElem = currentNode.toElement();
377 QString elemTag = currentElem.tagName();
379 if ( elemTag ==
"GroupItem" )
383 else if ( elemTag ==
"LayerItem" )
391 currentChildItem->
readXML( currentElem, xServerAvailable );
393 QList<QStandardItem *> itemsList;
395 appendRow( itemsList );
QMap< QString, QgsSymbolV2 * > QgsSymbolV2Map
virtual void readXML(const QDomElement &itemElem, bool xServerAvailable=true)=0
Read item content from xml.
static QgsSymbolV2Map loadSymbols(QDomElement &element)
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
QgsComposerRasterSymbolItem()
virtual void readXML(const QDomElement &itemElem, bool xServerAvailable=true)
Read item content from xml.
void setLayerID(const QString &id)
virtual void readXML(const QDomElement &itemElem, bool xServerAvailable=true)
Read item content from xml.
virtual ~QgsComposerSymbolV2Item()
virtual QgsSymbolV2 * clone() const =0
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, QString rule="")
return a list of item text / symbol
virtual QString userText() const
virtual ~QgsComposerLegendItem()
virtual void writeXML(QDomElement &elem, QDomDocument &doc) const
virtual ~QgsComposerGroupItem()
static QIcon icon(QString icon)
void setLayerID(const QString &id)
void setStyle(QgsComposerLegendStyle::Style style)
static QString styleName(Style s)
Get name for style, used in project file.
virtual ~QgsComposerLayerItem()
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
void setDefaultStyle(double scaleDenominator=-1, QString rule="")
static QDomElement saveSymbols(QgsSymbolV2Map &symbols, QString tagName, QDomDocument &doc)
virtual void readXML(const QDomElement &itemElem, bool xServerAvailable=true)
Read item content from xml.
virtual void writeXML(QDomElement &elem, QDomDocument &doc) const =0
static QString styleLabel(Style s)
Get style label, translated, used in UI.
bool showFeatureCount() const
virtual QStandardItem * clone() const
QgsComposerLegendStyle::Style mStyle
void setSymbolV2(QgsSymbolV2 *s)
Set symbol (takes ownership)
QgsComposerLegendItem(QgsComposerLegendStyle::Style s=QgsComposerLegendStyle::Undefined)
Abstract base class for the legend item types.
static Style styleFromName(QString styleName)
Get style from name, used in project file.
virtual QStandardItem * clone() const
Composer legend components style.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
virtual void writeXML(QDomElement &elem, QDomDocument &doc) const
QgsComposerLegendStyle::Style style() const
virtual void readXML(const QDomElement &itemElem, bool xServerAvailable=true)
Read item content from xml.
void writeXMLChildren(QDomElement &elem, QDomDocument &doc) const
virtual void writeXML(QDomElement &elem, QDomDocument &doc) const
virtual void writeXML(QDomElement &elem, QDomDocument &doc) const
void setShowFeatureCount(bool show)
void setColor(const QColor &c)
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
QgsComposerSymbolV2Item()
virtual ~QgsComposerRasterSymbolItem()
virtual QStandardItem * clone() const
Represents a vector layer which manages a vector based data sets.
virtual void setUserText(const QString &text)
virtual QStandardItem * clone() const