Skip to content
Permalink
Browse files
Fix fo ticket #294 (load project didn't honour the collapsed/expanded…
… state of

legend layers). Seems to be a bug in Qt, so this commit implements a
workaround. 


git-svn-id: http://svn.osgeo.org/qgis/trunk@5955 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Oct 14, 2006
1 parent 8cb9813 commit dbd4dc587b648353c388ea8b03bc6b34c639bbab
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/legend/qgslegend.cpp
@@ -927,6 +927,13 @@ bool QgsLegend::readXML(QDomNode& legendnode)

child = legendnode.firstChild();

// For some unexplained reason, collapsing/expanding the legendLayer items
// immediately after they have been created doesn't work (they all end up
// expanded). The legendGroups and legendLayerFiles seems ok through. The
// workaround is to store the required states of the legendLayers and set
// them at the end of this function.
QList<QTreeWidgetItem*> collapsed, expanded;

if(!child.isNull())
{
clear(); //remove all items first
@@ -978,7 +985,7 @@ bool QgsLegend::readXML(QDomNode& legendnode)
lastGroup = 0;
}

childelem.attribute("open") == "true" ? expandItem(theLayer) : collapseItem(theLayer);
childelem.attribute("open") == "true" ? expanded.push_back(theLayer) : collapsed.push_back(theLayer);

//set the checkbox of the legend layer to the right state
blockSignals(true);
@@ -1056,6 +1063,14 @@ bool QgsLegend::readXML(QDomNode& legendnode)
}
while(!(child.isNull()));
}

// Do the tree item expands and collapses.
for (int i = 0; i < collapsed.size(); ++i)
collapseItem(collapsed[i]);

for (int i = 0; i < expanded.size(); ++i)
expandItem(expanded[i]);

return true;
}

0 comments on commit dbd4dc5

Please sign in to comment.