mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +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:
parent
f502e24bd7
commit
4625f7aab5
6 changed files with 23 additions and 10 deletions
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
SectionNode(StringView section, StringView name)
|
||||
: m_section(MUST(String::from_utf8(section)))
|
||||
, m_full_name(MUST(String::formatted("{}. {}", section, name)))
|
||||
, m_name(MUST(String::from_utf8(name)))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -30,18 +30,20 @@ public:
|
|||
}
|
||||
|
||||
virtual Node const* parent() const override { return nullptr; }
|
||||
virtual String name() const override { return m_full_name; }
|
||||
virtual ErrorOr<String> name() const override;
|
||||
String const& section_name() const { return m_section; }
|
||||
ErrorOr<String> path() const;
|
||||
|
||||
virtual bool is_open() const override { return m_open; }
|
||||
void set_open(bool open);
|
||||
|
||||
String const& section_name() const { return m_section; }
|
||||
ErrorOr<String> path() const;
|
||||
protected:
|
||||
String m_section;
|
||||
String m_name;
|
||||
|
||||
private:
|
||||
ErrorOr<void> reify_if_needed() const;
|
||||
|
||||
String m_section;
|
||||
String m_full_name;
|
||||
mutable NonnullRefPtrVector<Node> m_children;
|
||||
mutable bool m_reified { false };
|
||||
bool m_open { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue