| 199 | | setExpanded(clickedItem, !isExpanded(clickedItem)); |
| | 199 | { |
| | 200 | bool wasExpanded = isExpanded(clickedItem); |
| | 201 | setExpanded(clickedItem, !wasExpanded); |
| | 202 | |
| | 203 | // setExpand may fail, for example after changing sorting an |
| | 204 | // expanded group can be collapsed but sometimes cannot be expanded |
| | 205 | // again. This was seen with Qt 4.4.0. |
| | 206 | if (isExpanded(clickedItem) == wasExpanded) |
| | 207 | { |
| | 208 | // Setting expanded state to same state as view currently (falsely) |
| | 209 | // reports seems to fix it, then set it again to the state we |
| | 210 | // actually wanted, this times it works. |
| | 211 | setExpanded(clickedItem, wasExpanded); |
| | 212 | setExpanded(clickedItem, !wasExpanded); |
| | 213 | } |
| | 214 | } |