ladybird/Userland/Applications/Help/ManualSectionNode.h

45 lines
1.1 KiB
C
Raw Normal View History

/*
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "ManualNode.h"
class ManualSectionNode : public ManualNode {
public:
virtual ~ManualSectionNode() override = default;
ManualSectionNode(String section, String name)
: m_section(section)
2020-10-05 16:05:35 +00:00
, m_full_name(String::formatted("{}. {}", section, name))
{
}
virtual NonnullOwnPtrVector<ManualNode>& children() const override
{
reify_if_needed();
return m_children;
}
2022-04-01 17:58:27 +00:00
virtual ManualNode const* parent() const override { return nullptr; }
virtual String name() const override { return m_full_name; }
virtual bool is_open() const override { return m_open; }
void set_open(bool open);
2022-04-01 17:58:27 +00:00
String const& section_name() const { return m_section; }
String path() const;
private:
void reify_if_needed() const;
String m_section;
String m_full_name;
mutable NonnullOwnPtrVector<ManualNode> m_children;
mutable bool m_reified { false };
bool m_open { false };
};