Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorControl::SidebarRows Class Reference

Derives the sidebar's visible row list from the page registry. More...

#include <PhosphorControl/SidebarRows.h>

Inheritance diagram for PhosphorControl::SidebarRows:
[legend]

Signals

void registryChanged ()

Public Member Functions

 SidebarRows (QObject *parent=nullptr)
 ~SidebarRows () override
PageRegistry * registry () const
void setRegistry (PageRegistry *registry)
QVariantList build (bool flattenTree, const QString &searchText, const QString &currentParentId, 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 &currentParentId) const
 The drill scope the rail should actually be in, given currentParentId.

Static Public Member Functions

static QString dividerPrefix ()
 The prefix stamped onto a synthetic divider row's pageId.

Detailed Description

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.

Constructor & Destructor Documentation

◆ SidebarRows()

PhosphorControl::SidebarRows::SidebarRows ( QObject * parent = nullptr)
explicit

◆ ~SidebarRows()

PhosphorControl::SidebarRows::~SidebarRows ( )
override

Member Function Documentation

◆ build()

QVariantList PhosphorControl::SidebarRows::build ( bool flattenTree,
const QString & searchText,
const QString & currentParentId,
const QVariantMap & expandedCategories,
const QVariantMap & flatTitleOverrides ) const

Build the visible row list.

Parameters
flattenTreeRender the flat list instead of the tree (see the class doc: multi-leaf drill parents stay as expandable header rows there, everything else is depth 0). Still honoured while searching: a flat-mode search returns flat rows with their overridden titles.
searchTextFilter needle. Filtering is disabled when it is empty AFTER trimming and search-folding, so a query of only whitespace or only combining marks falls back to the normal rail rather than matching nothing.
currentParentIdDrill scope for TREE mode; empty is top level.
expandedCategoriesid → expanded. An ABSENT id counts as expanded, matching the rail's open-by-default behaviour, so only explicit false collapses.
flatTitleOverridesid → display title, consulted in FLAT mode (and by a flat-mode search match) for leaves whose registered tree-context title reads wrong alone.

◆ dividerPrefix()

QString PhosphorControl::SidebarRows::dividerPrefix ( )
static

The prefix stamped onto a synthetic divider row's pageId.

Shared by the producers here and by the navigation guard that must refuse to route such a row into the controller — a rename reaching only the producers would send a divider straight to currentPageId.

◆ flatPageData()

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.

◆ registry()

PageRegistry * PhosphorControl::SidebarRows::registry ( ) const

◆ registryChanged

void PhosphorControl::SidebarRows::registryChanged ( )
signal

◆ resolveDrillScope()

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.

◆ setRegistry()

void PhosphorControl::SidebarRows::setRegistry ( PageRegistry * registry)

The documentation for this class was generated from the following file: