23 #include <QDomElement>
24 #include <QStringList>
31 , mChangingChildVisibility( false )
38 , mName( other.mName )
39 , mChecked( other.mChecked )
40 , mChangingChildVisibility( false )
82 QList<QgsLayerTreeNode*> nodes;
114 if ( childLayer->
layer() == layer )
158 if ( childLayer->
layerId() == layerId )
173 QList<QgsLayerTreeLayer*> list;
206 if ( element.tagName() !=
"layer-tree-group" )
209 QString
name = element.attribute(
"name" );
210 bool isExpanded = ( element.attribute(
"expanded",
"1" ) ==
"1" );
214 groupNode->setExpanded( isExpanded );
216 groupNode->readCommonXML( element );
218 groupNode->readChildrenFromXML( element );
225 QDomDocument doc = parentElement.ownerDocument();
226 QDomElement elem = doc.createElement(
"layer-tree-group" );
227 elem.setAttribute(
"name",
mName );
228 elem.setAttribute(
"expanded",
mExpanded ?
"1" :
"0" );
236 parentElement.appendChild( elem );
241 QList<QgsLayerTreeNode*> nodes;
242 QDomElement childElem = element.firstChildElement();
243 while ( !childElem.isNull() )
249 childElem = childElem.nextSiblingElement();
257 QString header = QString(
"GROUP: %1 visible=%2 expanded=%3\n" ).arg(
name() ).arg(
mChecked ).arg(
mExpanded );
258 QStringList childrenDump;
260 childrenDump << node->
dump().split(
"\n" );
261 for (
int i = 0; i < childrenDump.count(); ++i )
262 childrenDump[i].prepend(
" " );
263 return header + childrenDump.join(
"\n" );
330 bool hasVisible =
false, hasHidden =
false;
337 if ( layerVisible ) hasVisible =
true;
338 if ( !layerVisible ) hasHidden =
true;
343 if ( state == Qt::Checked || state == Qt::PartiallyChecked ) hasVisible =
true;
344 if ( state == Qt::Unchecked || state == Qt::PartiallyChecked ) hasHidden =
true;
348 Qt::CheckState newState;
349 if ( hasVisible && !hasHidden )
350 newState = Qt::Checked;
351 else if ( hasHidden && !hasVisible )
352 newState = Qt::Unchecked;
354 newState = Qt::PartiallyChecked;