From 0e4eb62dd8b117cd653bc6495278596cb3c63a0a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 17 Apr 2021 00:47:36 +0200 Subject: [PATCH] LibGUI: Make some API's take String instead of StringView --- Userland/Libraries/LibGUI/FileSystemModel.cpp | 13 ++++++------- Userland/Libraries/LibGUI/FileSystemModel.h | 8 ++++---- Userland/Libraries/LibGUI/Menu.cpp | 4 ++-- Userland/Libraries/LibGUI/Menu.h | 3 ++- Userland/Libraries/LibGUI/Statusbar.cpp | 8 ++++---- Userland/Libraries/LibGUI/Statusbar.h | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp index 4b3ca0470b2..c0a19844fdd 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.cpp +++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -200,9 +199,9 @@ String FileSystemModel::Node::full_path() const return LexicalPath::canonicalized_path(builder.to_string()); } -ModelIndex FileSystemModel::index(const StringView& path, int column) const +ModelIndex FileSystemModel::index(String path, int column) const { - LexicalPath lexical_path(path); + LexicalPath lexical_path(move(path)); const Node* node = m_root->m_parent_of_root ? &m_root->children.first() : m_root; if (lexical_path.string() == "/") return node->index(column); @@ -232,8 +231,8 @@ String FileSystemModel::full_path(const ModelIndex& index) const return node.full_path(); } -FileSystemModel::FileSystemModel(const StringView& root_path, Mode mode) - : m_root_path(LexicalPath::canonicalized_path(root_path)) +FileSystemModel::FileSystemModel(String root_path, Mode mode) + : m_root_path(LexicalPath::canonicalized_path(move(root_path))) , m_mode(mode) { setpwent(); @@ -319,12 +318,12 @@ void FileSystemModel::update_node_on_selection(const ModelIndex& index, const bo node.set_selected(selected); } -void FileSystemModel::set_root_path(const StringView& root_path) +void FileSystemModel::set_root_path(String root_path) { if (root_path.is_null()) m_root_path = {}; else - m_root_path = LexicalPath::canonicalized_path(root_path); + m_root_path = LexicalPath::canonicalized_path(move(root_path)); update(); if (m_root->has_error()) { diff --git a/Userland/Libraries/LibGUI/FileSystemModel.h b/Userland/Libraries/LibGUI/FileSystemModel.h index 9189a991317..ee5ac0713aa 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.h +++ b/Userland/Libraries/LibGUI/FileSystemModel.h @@ -118,16 +118,16 @@ public: bool fetch_data(const String& full_path, bool is_root); }; - static NonnullRefPtr create(const StringView& root_path = "/", Mode mode = Mode::FilesAndDirectories) + static NonnullRefPtr create(String root_path = "/", Mode mode = Mode::FilesAndDirectories) { return adopt(*new FileSystemModel(root_path, mode)); } virtual ~FileSystemModel() override; String root_path() const { return m_root_path; } - void set_root_path(const StringView&); + void set_root_path(String); String full_path(const ModelIndex&) const; - ModelIndex index(const StringView& path, int column) const; + ModelIndex index(String path, int column) const; void update_node_on_selection(const ModelIndex&, const bool); ModelIndex m_previously_selected_index {}; @@ -163,7 +163,7 @@ public: void set_should_show_dotfiles(bool); private: - FileSystemModel(const StringView& root_path, Mode); + FileSystemModel(String root_path, Mode); String name_for_uid(uid_t) const; String name_for_gid(gid_t) const; diff --git a/Userland/Libraries/LibGUI/Menu.cpp b/Userland/Libraries/LibGUI/Menu.cpp index 14534d3c9cf..d2ffbd5d182 100644 --- a/Userland/Libraries/LibGUI/Menu.cpp +++ b/Userland/Libraries/LibGUI/Menu.cpp @@ -51,8 +51,8 @@ Menu* Menu::from_menu_id(int menu_id) return (*it).value; } -Menu::Menu(const StringView& name) - : m_name(name) +Menu::Menu(String name) + : m_name(move(name)) { } diff --git a/Userland/Libraries/LibGUI/Menu.h b/Userland/Libraries/LibGUI/Menu.h index 464b39d8ea9..ed2c7cf26d9 100644 --- a/Userland/Libraries/LibGUI/Menu.h +++ b/Userland/Libraries/LibGUI/Menu.h @@ -38,7 +38,6 @@ namespace GUI { class Menu final : public Core::Object { C_OBJECT(Menu) public: - explicit Menu(const StringView& name = ""); virtual ~Menu() override; void realize_menu_if_needed(); @@ -68,6 +67,8 @@ public: private: friend class Menubar; + explicit Menu(String name = ""); + int realize_menu(RefPtr default_action = nullptr); void unrealize_menu(); void realize_if_needed(const RefPtr& default_action); diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp index 62a38a58f30..311dbb9621f 100644 --- a/Userland/Libraries/LibGUI/Statusbar.cpp +++ b/Userland/Libraries/LibGUI/Statusbar.cpp @@ -69,9 +69,9 @@ NonnullRefPtr