mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:57:35 +00:00
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
2 changed files with 16 additions and 3 deletions
|
@ -8,10 +8,7 @@
|
||||||
#include "ManualNode.h"
|
#include "ManualNode.h"
|
||||||
#include "ManualPageNode.h"
|
#include "ManualPageNode.h"
|
||||||
#include "ManualSectionNode.h"
|
#include "ManualSectionNode.h"
|
||||||
#include <AK/ByteBuffer.h>
|
|
||||||
#include <AK/Try.h>
|
#include <AK/Try.h>
|
||||||
#include <LibCore/File.h>
|
|
||||||
#include <LibGUI/FilteringProxyModel.h>
|
|
||||||
|
|
||||||
static ManualSectionNode s_sections[] = {
|
static ManualSectionNode s_sections[] = {
|
||||||
{ "1", "User programs" },
|
{ "1", "User programs" },
|
||||||
|
@ -49,6 +46,17 @@ Optional<GUI::ModelIndex> ManualModel::index_from_path(StringView path) const
|
||||||
return {};
|
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
|
String ManualModel::page_path(const GUI::ModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.is_valid())
|
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
|
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));
|
auto view_result = page_view(page_path(index));
|
||||||
if (view_result.is_error() || view_result.value().is_empty())
|
if (view_result.is_error() || view_result.value().is_empty())
|
||||||
return TriState::False;
|
return TriState::False;
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
|
|
||||||
Optional<GUI::ModelIndex> index_from_path(StringView) const;
|
Optional<GUI::ModelIndex> index_from_path(StringView) const;
|
||||||
|
|
||||||
|
String page_name(const GUI::ModelIndex&) const;
|
||||||
String page_path(const GUI::ModelIndex&) const;
|
String page_path(const GUI::ModelIndex&) const;
|
||||||
String page_and_section(const GUI::ModelIndex&) const;
|
String page_and_section(const GUI::ModelIndex&) const;
|
||||||
ErrorOr<StringView> page_view(String const& path) const;
|
ErrorOr<StringView> page_view(String const& path) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue