mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:17:35 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -16,7 +16,7 @@ void History::push(StringView history_item)
|
|||
m_current_history_item++;
|
||||
}
|
||||
|
||||
String History::current()
|
||||
DeprecatedString History::current()
|
||||
{
|
||||
if (m_current_history_item == -1)
|
||||
return {};
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
class History final {
|
||||
public:
|
||||
void push(StringView history_item);
|
||||
String current();
|
||||
DeprecatedString current();
|
||||
|
||||
void go_back();
|
||||
void go_forward();
|
||||
|
@ -23,6 +23,6 @@ public:
|
|||
void clear();
|
||||
|
||||
private:
|
||||
Vector<String> m_items;
|
||||
Vector<DeprecatedString> m_items;
|
||||
int m_current_history_item { -1 };
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
#include "MainWidget.h"
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/URL.h>
|
||||
#include <Applications/Help/HelpWindowGML.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
|
@ -66,7 +66,7 @@ MainWidget::MainWidget()
|
|||
}
|
||||
auto& search_model = *static_cast<GUI::FilteringProxyModel*>(view_model);
|
||||
auto const& mapped_index = search_model.map(index);
|
||||
String path = m_manual_model->page_path(mapped_index);
|
||||
DeprecatedString path = m_manual_model->page_path(mapped_index);
|
||||
if (path.is_null()) {
|
||||
m_web_view->load_empty_document();
|
||||
return;
|
||||
|
@ -79,7 +79,7 @@ MainWidget::MainWidget()
|
|||
|
||||
m_browse_view = find_descendant_of_type_named<GUI::TreeView>("browse_view");
|
||||
m_browse_view->on_selection_change = [this] {
|
||||
String path = m_manual_model->page_path(m_browse_view->selection().first());
|
||||
DeprecatedString path = m_manual_model->page_path(m_browse_view->selection().first());
|
||||
if (path.is_null())
|
||||
return;
|
||||
|
||||
|
@ -114,7 +114,7 @@ MainWidget::MainWidget()
|
|||
}
|
||||
auto const section = url.paths()[0];
|
||||
auto const page = url.paths()[1];
|
||||
auto const path = String::formatted("/usr/share/man/man{}/{}.md", section, page);
|
||||
auto const path = DeprecatedString::formatted("/usr/share/man/man{}/{}.md", section, page);
|
||||
|
||||
m_history.push(path);
|
||||
open_url(URL::create_with_file_scheme(path, url.fragment()));
|
||||
|
@ -150,7 +150,7 @@ MainWidget::MainWidget()
|
|||
m_go_forward_action->set_enabled(false);
|
||||
|
||||
m_go_home_action = GUI::CommonActions::make_go_home_action([this](auto&) {
|
||||
String path = "/usr/share/man/man7/Help-index.md";
|
||||
DeprecatedString path = "/usr/share/man/man7/Help-index.md";
|
||||
m_history.push(path);
|
||||
open_page(path);
|
||||
});
|
||||
|
@ -180,7 +180,7 @@ void MainWidget::set_start_page(StringView start_page, u32 section)
|
|||
if (!start_page.is_null()) {
|
||||
if (section != 0) {
|
||||
// > Help [section] [name]
|
||||
String path = String::formatted("/usr/share/man/man{}/{}.md", section, start_page);
|
||||
DeprecatedString path = DeprecatedString::formatted("/usr/share/man/man{}/{}.md", section, start_page);
|
||||
m_history.push(path);
|
||||
open_page(path);
|
||||
set_start_page = true;
|
||||
|
@ -204,7 +204,7 @@ void MainWidget::set_start_page(StringView start_page, u32 section)
|
|||
"8"
|
||||
};
|
||||
for (auto s : sections) {
|
||||
String path = String::formatted("/usr/share/man/man{}/{}.md", s, start_page);
|
||||
DeprecatedString path = DeprecatedString::formatted("/usr/share/man/man{}/{}.md", s, start_page);
|
||||
if (Core::File::exists(path)) {
|
||||
m_history.push(path);
|
||||
open_page(path);
|
||||
|
@ -246,7 +246,7 @@ ErrorOr<void> MainWidget::initialize_fallibles(GUI::Window& window)
|
|||
auto help_menu = TRY(window.try_add_menu("&Help"));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::Action::create("&Contents", { Key_F1 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png"sv)), [&](auto&) {
|
||||
String path = "/usr/share/man/man1/Help.md";
|
||||
DeprecatedString path = "/usr/share/man/man1/Help.md";
|
||||
open_page(path);
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Help", TRY(GUI::Icon::try_create_default_icon("app-help"sv)), &window)));
|
||||
|
@ -282,8 +282,8 @@ void MainWidget::open_url(URL const& url)
|
|||
if (browse_view_index.has_value()) {
|
||||
m_browse_view->expand_tree(browse_view_index.value().parent());
|
||||
|
||||
String page_and_section = m_manual_model->page_and_section(browse_view_index.value());
|
||||
window()->set_title(String::formatted("{} - Help", page_and_section));
|
||||
DeprecatedString page_and_section = m_manual_model->page_and_section(browse_view_index.value());
|
||||
window()->set_title(DeprecatedString::formatted("{} - Help", page_and_section));
|
||||
} else {
|
||||
window()->set_title("Help");
|
||||
}
|
||||
|
@ -294,10 +294,10 @@ void MainWidget::open_url(URL const& url)
|
|||
void MainWidget::open_external(URL const& url)
|
||||
{
|
||||
if (!Desktop::Launcher::open(url))
|
||||
GUI::MessageBox::show(window(), String::formatted("The link to '{}' could not be opened.", url), "Failed to open link"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(window(), DeprecatedString::formatted("The link to '{}' could not be opened.", url), "Failed to open link"sv, GUI::MessageBox::Type::Error);
|
||||
}
|
||||
|
||||
void MainWidget::open_page(String const& path)
|
||||
void MainWidget::open_page(DeprecatedString const& path)
|
||||
{
|
||||
m_go_back_action->set_enabled(m_history.can_go_back());
|
||||
m_go_forward_action->set_enabled(m_history.can_go_forward());
|
||||
|
|
|
@ -26,7 +26,7 @@ private:
|
|||
MainWidget();
|
||||
|
||||
void open_url(URL const&);
|
||||
void open_page(String const& path);
|
||||
void open_page(DeprecatedString const& path);
|
||||
void open_external(URL const&);
|
||||
|
||||
History m_history;
|
||||
|
|
|
@ -46,7 +46,7 @@ Optional<GUI::ModelIndex> ManualModel::index_from_path(StringView path) const
|
|||
return {};
|
||||
}
|
||||
|
||||
String ManualModel::page_name(const GUI::ModelIndex& index) const
|
||||
DeprecatedString ManualModel::page_name(const GUI::ModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
|
@ -57,7 +57,7 @@ String ManualModel::page_name(const GUI::ModelIndex& index) const
|
|||
return page->name();
|
||||
}
|
||||
|
||||
String ManualModel::page_path(const GUI::ModelIndex& index) const
|
||||
DeprecatedString ManualModel::page_path(const GUI::ModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
|
@ -68,7 +68,7 @@ String ManualModel::page_path(const GUI::ModelIndex& index) const
|
|||
return page->path();
|
||||
}
|
||||
|
||||
ErrorOr<StringView> ManualModel::page_view(String const& path) const
|
||||
ErrorOr<StringView> ManualModel::page_view(DeprecatedString const& path) const
|
||||
{
|
||||
if (path.is_empty())
|
||||
return StringView {};
|
||||
|
@ -87,7 +87,7 @@ ErrorOr<StringView> ManualModel::page_view(String const& path) const
|
|||
return view;
|
||||
}
|
||||
|
||||
String ManualModel::page_and_section(const GUI::ModelIndex& index) const
|
||||
DeprecatedString ManualModel::page_and_section(const GUI::ModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
|
@ -96,7 +96,7 @@ String ManualModel::page_and_section(const GUI::ModelIndex& index) const
|
|||
return {};
|
||||
auto* page = static_cast<ManualPageNode const*>(node);
|
||||
auto* section = static_cast<ManualSectionNode const*>(page->parent());
|
||||
return String::formatted("{}({})", page->name(), section->section_name());
|
||||
return DeprecatedString::formatted("{}({})", page->name(), section->section_name());
|
||||
}
|
||||
|
||||
GUI::ModelIndex ManualModel::index(int row, int column, const GUI::ModelIndex& parent_index) const
|
||||
|
@ -151,7 +151,7 @@ GUI::Variant ManualModel::data(const GUI::ModelIndex& index, GUI::ModelRole role
|
|||
case GUI::ModelRole::Search:
|
||||
if (!node->is_page())
|
||||
return {};
|
||||
return String(page_view(page_path(index)).value());
|
||||
return DeprecatedString(page_view(page_path(index)).value());
|
||||
case GUI::ModelRole::Display:
|
||||
return node->name();
|
||||
case GUI::ModelRole::Icon:
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGUI/Model.h>
|
||||
|
||||
class ManualModel final : public GUI::Model {
|
||||
|
@ -23,10 +23,10 @@ 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;
|
||||
DeprecatedString page_name(const GUI::ModelIndex&) const;
|
||||
DeprecatedString page_path(const GUI::ModelIndex&) const;
|
||||
DeprecatedString page_and_section(const GUI::ModelIndex&) const;
|
||||
ErrorOr<StringView> page_view(DeprecatedString const& path) const;
|
||||
|
||||
void update_section_node_on_toggle(const GUI::ModelIndex&, bool const);
|
||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
|
@ -42,5 +42,5 @@ private:
|
|||
GUI::Icon m_section_open_icon;
|
||||
GUI::Icon m_section_icon;
|
||||
GUI::Icon m_page_icon;
|
||||
mutable HashMap<String, NonnullRefPtr<Core::MappedFile>> m_mapped_files;
|
||||
mutable HashMap<DeprecatedString, NonnullRefPtr<Core::MappedFile>> m_mapped_files;
|
||||
};
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/String.h>
|
||||
|
||||
class ManualNode {
|
||||
public:
|
||||
|
@ -16,7 +16,7 @@ public:
|
|||
|
||||
virtual NonnullOwnPtrVector<ManualNode>& children() const = 0;
|
||||
virtual ManualNode const* parent() const = 0;
|
||||
virtual String name() const = 0;
|
||||
virtual DeprecatedString name() const = 0;
|
||||
virtual bool is_page() const { return false; }
|
||||
virtual bool is_open() const { return false; }
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ NonnullOwnPtrVector<ManualNode>& ManualPageNode::children() const
|
|||
return empty_vector;
|
||||
}
|
||||
|
||||
String ManualPageNode::path() const
|
||||
DeprecatedString ManualPageNode::path() const
|
||||
{
|
||||
return String::formatted("{}/{}.md", m_section.path(), m_page);
|
||||
return DeprecatedString::formatted("{}/{}.md", m_section.path(), m_page);
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ public:
|
|||
|
||||
virtual NonnullOwnPtrVector<ManualNode>& children() const override;
|
||||
virtual ManualNode const* parent() const override;
|
||||
virtual String name() const override { return m_page; };
|
||||
virtual DeprecatedString name() const override { return m_page; };
|
||||
virtual bool is_page() const override { return true; }
|
||||
|
||||
String path() const;
|
||||
DeprecatedString path() const;
|
||||
|
||||
private:
|
||||
ManualSectionNode const& m_section;
|
||||
String m_page;
|
||||
DeprecatedString m_page;
|
||||
};
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
#include "ManualSectionNode.h"
|
||||
#include "ManualPageNode.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
|
||||
String ManualSectionNode::path() const
|
||||
DeprecatedString ManualSectionNode::path() const
|
||||
{
|
||||
return String::formatted("/usr/share/man/man{}", m_section);
|
||||
return DeprecatedString::formatted("/usr/share/man/man{}", m_section);
|
||||
}
|
||||
|
||||
void ManualSectionNode::reify_if_needed() const
|
||||
|
@ -24,7 +24,7 @@ void ManualSectionNode::reify_if_needed() const
|
|||
|
||||
Core::DirIterator dir_iter { path(), Core::DirIterator::Flags::SkipDots };
|
||||
|
||||
Vector<String> page_names;
|
||||
Vector<DeprecatedString> page_names;
|
||||
while (dir_iter.has_next()) {
|
||||
LexicalPath lexical_path(dir_iter.next_path());
|
||||
if (lexical_path.extension() != "md")
|
||||
|
|
|
@ -13,9 +13,9 @@ class ManualSectionNode : public ManualNode {
|
|||
public:
|
||||
virtual ~ManualSectionNode() override = default;
|
||||
|
||||
ManualSectionNode(String section, String name)
|
||||
ManualSectionNode(DeprecatedString section, DeprecatedString name)
|
||||
: m_section(section)
|
||||
, m_full_name(String::formatted("{}. {}", section, name))
|
||||
, m_full_name(DeprecatedString::formatted("{}. {}", section, name))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -26,18 +26,18 @@ public:
|
|||
}
|
||||
|
||||
virtual ManualNode const* parent() const override { return nullptr; }
|
||||
virtual String name() const override { return m_full_name; }
|
||||
virtual DeprecatedString name() const override { return m_full_name; }
|
||||
virtual bool is_open() const override { return m_open; }
|
||||
void set_open(bool open);
|
||||
|
||||
String const& section_name() const { return m_section; }
|
||||
String path() const;
|
||||
DeprecatedString const& section_name() const { return m_section; }
|
||||
DeprecatedString path() const;
|
||||
|
||||
private:
|
||||
void reify_if_needed() const;
|
||||
|
||||
String m_section;
|
||||
String m_full_name;
|
||||
DeprecatedString m_section;
|
||||
DeprecatedString m_full_name;
|
||||
mutable NonnullOwnPtrVector<ManualNode> m_children;
|
||||
mutable bool m_reified { false };
|
||||
bool m_open { false };
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
using namespace Help;
|
||||
|
||||
static String parse_input(StringView input)
|
||||
static DeprecatedString parse_input(StringView input)
|
||||
{
|
||||
AK::URL url(input);
|
||||
if (url.is_valid())
|
||||
|
@ -39,7 +39,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Core::System::unveil("/tmp/session/%sid/portal/webcontent", "rw"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
String start_page;
|
||||
DeprecatedString start_page;
|
||||
u32 section = 0;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue