* @brief Flattens the switcher tree into leaf workspaces, prefixing each label with its folder * path so nested workspaces stay distinguishable without submenus. */
| 1512 | * path so nested workspaces stay distinguishable without submenus. |
| 1513 | */ |
| 1514 | static void flattenSwitcherNodes(const QVariantList& nodes, |
| 1515 | const QString& prefix, |
| 1516 | QVariantList& out) |
| 1517 | { |
| 1518 | for (const auto& value : nodes) { |
| 1519 | const auto node = value.toMap(); |
| 1520 | const auto title = node.value(QStringLiteral("text")).toString(); |
| 1521 | const bool isFolder = node.value(QStringLiteral("isFolder")).toBool(); |
| 1522 | |
| 1523 | if (isFolder) { |
| 1524 | const auto branch = prefix.isEmpty() ? title : prefix + QStringLiteral(" / ") + title; |
| 1525 | flattenSwitcherNodes(node.value(QStringLiteral("children")).toList(), branch, out); |
| 1526 | continue; |
| 1527 | } |
| 1528 | |
| 1529 | QVariantMap entry; |
| 1530 | entry[QStringLiteral("id")] = node.value(QStringLiteral("id")); |
| 1531 | entry[QStringLiteral("text")] = |
| 1532 | prefix.isEmpty() ? title : prefix + QStringLiteral(" / ") + title; |
| 1533 | entry[QStringLiteral("icon")] = node.value(QStringLiteral("icon")); |
| 1534 | out.append(entry); |
| 1535 | } |
| 1536 | } |
| 1537 | |
| 1538 | /** |
| 1539 | * @brief Returns the cached flat switcher list: empty workspaces removed, a lone root folder |
no test coverage detected