MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / collapseSingleFolderRoots

Function collapseSingleFolderRoots

app/src/UI/Taskbar.cpp:1492–1508  ·  view source on GitHub ↗

* @brief Peels a lone top-level folder into its children, repeating until the level holds more * than one item or a non-folder leaf, so the switcher never opens on a single redundant * folder. */

Source from the content-addressed store, hash-verified

1490 * folder.
1491 */
1492static QVariantList collapseSingleFolderRoots(QVariantList level)
1493{
1494 int guard = 0;
1495 while (level.size() == 1 && guard++ < 256) {
1496 const auto node = level.first().toMap();
1497 if (!node.value(QStringLiteral("isFolder")).toBool())
1498 break;
1499
1500 const auto children = node.value(QStringLiteral("children")).toList();
1501 if (children.isEmpty())
1502 break;
1503
1504 level = children;
1505 }
1506
1507 return level;
1508}
1509
1510/**
1511 * @brief Flattens the switcher tree into leaf workspaces, prefixing each label with its folder

Callers 1

Calls 4

firstMethod · 0.80
isEmptyMethod · 0.80
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected