Skip to content

Commit

Permalink
Fix fo ticket #294 (load project didn't honour the collapsed/expanded…
Browse files Browse the repository at this point in the history
… 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/qgis@5955 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Oct 14, 2006
1 parent 34854ae commit 35ce545
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/legend/qgslegend.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 35ce545

Please sign in to comment.