mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:02:45 +00:00 
			
		
		
		
	Help+LibManual: Open sibling page for subsections
Clicking on a subsection now displays the sibling page, which is intended to be the main page for that section.
This commit is contained in:
		
							parent
							
								
									3e67f14e58
								
							
						
					
					
						commit
						201c9d7c77
					
				
					 6 changed files with 26 additions and 2 deletions
				
			
		|  | @ -5,6 +5,8 @@ | |||
|  */ | ||||
| 
 | ||||
| #include "SubsectionNode.h" | ||||
| #include "PageNode.h" | ||||
| #include <AK/TypeCasts.h> | ||||
| 
 | ||||
| namespace Manual { | ||||
| 
 | ||||
|  | @ -16,6 +18,24 @@ SubsectionNode::SubsectionNode(NonnullRefPtr<SectionNode> parent, StringView nam | |||
| 
 | ||||
| Node const* SubsectionNode::parent() const { return m_parent; } | ||||
| 
 | ||||
| PageNode const* SubsectionNode::document() const | ||||
| { | ||||
|     auto maybe_siblings = parent()->children(); | ||||
|     if (maybe_siblings.is_error()) | ||||
|         return nullptr; | ||||
|     auto siblings = maybe_siblings.release_value(); | ||||
|     for (auto const& sibling : siblings) { | ||||
|         if (&*sibling == this) | ||||
|             continue; | ||||
|         auto sibling_name = sibling->name(); | ||||
|         if (sibling_name.is_error()) | ||||
|             continue; | ||||
|         if (sibling_name.value() == m_name && is<PageNode>(*sibling)) | ||||
|             return static_cast<PageNode*>(&*sibling); | ||||
|     } | ||||
|     return nullptr; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<String> SubsectionNode::name() const { return m_name; } | ||||
| 
 | ||||
| ErrorOr<String> SubsectionNode::path() const | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 kleines Filmröllchen
						kleines Filmröllchen