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().value( 0 );
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 );