|
| | SidebarRows (QObject *parent=nullptr) |
| | ~SidebarRows () override |
| PageRegistry * | registry () const |
| void | setRegistry (PageRegistry *registry) |
| QVariantList | build (bool flattenTree, const QString &searchText, const QString ¤tParentId, const QVariantMap &expandedCategories, const QVariantMap &flatTitleOverrides) const |
| | Build the visible row list.
|
| QVariantMap | flatPageData (const QString &pageId, const QVariantMap &flatTitleOverrides) const |
| | Registry page-data for pageId with its flat-mode title override applied, or an empty map for an unknown id.
|
| QString | resolveDrillScope (const QString ¤tParentId) const |
| | The drill scope the rail should actually be in, given currentParentId.
|
Derives the sidebar's visible row list from the page registry.
Three walks over the tier-filtered tree, one per rail mode:
- FLAT: every visible navigable page in sibling order, with no drill steps. Collapsible CATEGORY headers dissolve into their surroundings, but a no-QML drill parent with two or more navigable descendants stays as a collapsible header row (consulting expandedCategories) with its subtree indented one step; one descendant dissolves the parent and the leaf emits under its own title. Only TOP-LEVEL entries contribute section seams.
- TREE: the children of the current drill scope, with collapsible accordion headers, drill parents, and per-entry seams.
- SEARCH: a flat match list from every scope, each row titled with its ancestor breadcrumb.
Lives in C++ rather than in Sidebar.qml so the walks are directly unit-testable without a Qt Quick engine or a built page tree — the same split, for the same reason, as animationpagescope / decorationpagescope on the app side. Sidebar.qml keeps the genuinely view-side work (the incremental ListModel diff, drill animation, expand state).
ROW ROLE CONTRACT — the public model schema consumers bind to via modelData.<role>. Renaming any of these breaks downstream trailing delegates:
- pageId, title, iconSource, hasQmlSource — page identity.
- _depth, _isCollapsibleHeader, _isDrillParent, _isExpanded, _isDivider — underscore-prefixed layout/state hints. View-internal by convention (do not store or derive from them), but part of the contract because a consumer's trailingDelegate must read them to render badges and active stripes.
pageId (not id) is deliberate: id would shadow QML's id: directive in the delegate and trips qmlformat's parser.
| QVariantMap PhosphorControl::SidebarRows::flatPageData |
( |
const QString & | pageId, |
|
|
const QVariantMap & | flatTitleOverrides ) const |
Registry page-data for pageId with its flat-mode title override applied, or an empty map for an unknown id.
Exists so Breadcrumbs resolves the override through the SAME code the rail uses. It previously re-implemented the lookup in QML JS (down to its own hasOwnProperty guard against ids colliding with Object.prototype names), which meant two implementations of one rule, the QML one uncovered — the lib has no QML test harness, so a divergence between them would ship green. QVariantMap has no prototype, so the guard the JS needed is structurally unnecessary here.
| QString PhosphorControl::SidebarRows::resolveDrillScope |
( |
const QString & | currentParentId | ) |
const |
The drill scope the rail should actually be in, given currentParentId.
Returns currentParentId when the rail can still render it, and an empty string when it must fall back to the top level. A scope stops being renderable in three ways, and the rail is wrong differently for each: the tier filter hides the parent itself, so the rail renders a scope the mode has abolished; the filter leaves the parent standing (the mode gate walks the tier chain only) but hides its whole visible subtree, so the child list comes back empty and the rail would collapse to a lone Back button over an empty list; or exactly ONE navigable descendant remains, which build() flattens into a direct row one level up rather than offering as a drill target, so the rail would be sitting in a scope its own rows do not present as enterable. The node must also HAVE visible children and must not be collapsible, matching build()'s drill test clause for clause.
Lives here rather than in QML because it is the same rule build() walks, and the lib has no QML test harness, so a second copy in JS would ship green when it diverged.