1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibManual: Refactor SectionNode in preparation for subsections

- Calculate the full name on demand
- Make section and name protected
- Reorder some members logically
- Change the name getter to be fallible, as some implementors need to
  allocate
This commit is contained in:
kleines Filmröllchen 2022-06-18 21:53:44 +02:00 committed by Linus Groh
parent f502e24bd7
commit 4625f7aab5
6 changed files with 23 additions and 10 deletions

View file

@ -47,7 +47,10 @@ Optional<String> ManualModel::page_name(const GUI::ModelIndex& index) const
if (!node->is_page())
return {};
auto* page = static_cast<Manual::PageNode const*>(node);
return page->name();
auto path = page->name();
if (path.is_error())
return {};
return path.release_value();
}
Optional<String> ManualModel::page_path(const GUI::ModelIndex& index) const
@ -159,7 +162,9 @@ GUI::Variant ManualModel::data(const GUI::ModelIndex& index, GUI::ModelRole role
return DeprecatedString(page.release_value());
return {};
case GUI::ModelRole::Display:
return node->name();
if (auto name = node->name(); !name.is_error())
return name.release_value();
return {};
case GUI::ModelRole::Icon:
if (node->is_page())
return m_page_icon;