Help: Include page names in the search
This fixes the problem before, where searching "Shell" would list "Shell-vars" in the results, but searching "Shell-vars" would make it disappear. Also removed some now-unnecessary includes.
This commit is contained in:
parent
8461f8c1cd
commit
85a54261b3
Notes:
sideshowbarker
2024-07-17 22:33:20 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/85a54261b3f Pull-request: https://github.com/SerenityOS/serenity/pull/11331
2 changed files with 16 additions and 3 deletions
|
@ -8,10 +8,7 @@
|
|||
#include "ManualNode.h"
|
||||
#include "ManualPageNode.h"
|
||||
#include "ManualSectionNode.h"
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Try.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGUI/FilteringProxyModel.h>
|
||||
|
||||
static ManualSectionNode s_sections[] = {
|
||||
{ "1", "User programs" },
|
||||
|
@ -49,6 +46,17 @@ Optional<GUI::ModelIndex> ManualModel::index_from_path(StringView path) const
|
|||
return {};
|
||||
}
|
||||
|
||||
String ManualModel::page_name(const GUI::ModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
auto* node = static_cast<const ManualNode*>(index.internal_data());
|
||||
if (!node->is_page())
|
||||
return {};
|
||||
auto* page = static_cast<const ManualPageNode*>(node);
|
||||
return page->name();
|
||||
}
|
||||
|
||||
String ManualModel::page_path(const GUI::ModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
|
@ -165,6 +173,10 @@ void ManualModel::update_section_node_on_toggle(const GUI::ModelIndex& index, co
|
|||
|
||||
TriState ManualModel::data_matches(const GUI::ModelIndex& index, const GUI::Variant& term) const
|
||||
{
|
||||
auto name = page_name(index);
|
||||
if (name.contains(term.as_string()))
|
||||
return TriState::True;
|
||||
|
||||
auto view_result = page_view(page_path(index));
|
||||
if (view_result.is_error() || view_result.value().is_empty())
|
||||
return TriState::False;
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
|
||||
Optional<GUI::ModelIndex> index_from_path(StringView) const;
|
||||
|
||||
String page_name(const GUI::ModelIndex&) const;
|
||||
String page_path(const GUI::ModelIndex&) const;
|
||||
String page_and_section(const GUI::ModelIndex&) const;
|
||||
ErrorOr<StringView> page_view(String const& path) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue