[TechDraw] Implement proper selection of subitems (#11804)

This commit is contained in:
Tomas Pavlicek
2023-12-22 14:25:58 +01:00
committed by GitHub
parent 23ec682cbe
commit f3fa2ba9c9
12 changed files with 181 additions and 43 deletions

View File

@@ -539,3 +539,33 @@ double DrawGuiUtil::roundToDigits(double original, int digits)
temp = rounded / factor;
return temp;
}
// Returns true if the item or any of its descendants is selected
bool DrawGuiUtil::isSelectedInTree(QGraphicsItem *item)
{
if (item) {
if (item->isSelected()) {
return true;
}
for (QGraphicsItem *child : item->childItems()) {
if (isSelectedInTree(child)) {
return true;
}
}
}
return false;
}
// Selects or deselects the item and all its descendants
void DrawGuiUtil::setSelectedTree(QGraphicsItem *item, bool selected)
{
if (item) {
item->setSelected(selected);
for (QGraphicsItem *child : item->childItems()) {
setSelectedTree(child, selected);
}
}
}