1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibGUI: Make some API's take String instead of StringView

This commit is contained in:
Andreas Kling 2021-04-17 00:47:36 +02:00
parent 36f27094d0
commit 0e4eb62dd8
6 changed files with 20 additions and 20 deletions

View file

@ -36,7 +36,6 @@
#include <LibGUI/Painter.h> #include <LibGUI/Painter.h>
#include <LibGfx/Bitmap.h> #include <LibGfx/Bitmap.h>
#include <LibThread/BackgroundAction.h> #include <LibThread/BackgroundAction.h>
#include <dirent.h>
#include <grp.h> #include <grp.h>
#include <pwd.h> #include <pwd.h>
#include <stdio.h> #include <stdio.h>
@ -200,9 +199,9 @@ String FileSystemModel::Node::full_path() const
return LexicalPath::canonicalized_path(builder.to_string()); 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; const Node* node = m_root->m_parent_of_root ? &m_root->children.first() : m_root;
if (lexical_path.string() == "/") if (lexical_path.string() == "/")
return node->index(column); return node->index(column);
@ -232,8 +231,8 @@ String FileSystemModel::full_path(const ModelIndex& index) const
return node.full_path(); return node.full_path();
} }
FileSystemModel::FileSystemModel(const StringView& root_path, Mode mode) FileSystemModel::FileSystemModel(String root_path, Mode mode)
: m_root_path(LexicalPath::canonicalized_path(root_path)) : m_root_path(LexicalPath::canonicalized_path(move(root_path)))
, m_mode(mode) , m_mode(mode)
{ {
setpwent(); setpwent();
@ -319,12 +318,12 @@ void FileSystemModel::update_node_on_selection(const ModelIndex& index, const bo
node.set_selected(selected); 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()) if (root_path.is_null())
m_root_path = {}; m_root_path = {};
else else
m_root_path = LexicalPath::canonicalized_path(root_path); m_root_path = LexicalPath::canonicalized_path(move(root_path));
update(); update();
if (m_root->has_error()) { if (m_root->has_error()) {

View file

@ -118,16 +118,16 @@ public:
bool fetch_data(const String& full_path, bool is_root); bool fetch_data(const String& full_path, bool is_root);
}; };
static NonnullRefPtr<FileSystemModel> create(const StringView& root_path = "/", Mode mode = Mode::FilesAndDirectories) static NonnullRefPtr<FileSystemModel> create(String root_path = "/", Mode mode = Mode::FilesAndDirectories)
{ {
return adopt(*new FileSystemModel(root_path, mode)); return adopt(*new FileSystemModel(root_path, mode));
} }
virtual ~FileSystemModel() override; virtual ~FileSystemModel() override;
String root_path() const { return m_root_path; } 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; 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); void update_node_on_selection(const ModelIndex&, const bool);
ModelIndex m_previously_selected_index {}; ModelIndex m_previously_selected_index {};
@ -163,7 +163,7 @@ public:
void set_should_show_dotfiles(bool); void set_should_show_dotfiles(bool);
private: private:
FileSystemModel(const StringView& root_path, Mode); FileSystemModel(String root_path, Mode);
String name_for_uid(uid_t) const; String name_for_uid(uid_t) const;
String name_for_gid(gid_t) const; String name_for_gid(gid_t) const;

View file

@ -51,8 +51,8 @@ Menu* Menu::from_menu_id(int menu_id)
return (*it).value; return (*it).value;
} }
Menu::Menu(const StringView& name) Menu::Menu(String name)
: m_name(name) : m_name(move(name))
{ {
} }

View file

@ -38,7 +38,6 @@ namespace GUI {
class Menu final : public Core::Object { class Menu final : public Core::Object {
C_OBJECT(Menu) C_OBJECT(Menu)
public: public:
explicit Menu(const StringView& name = "");
virtual ~Menu() override; virtual ~Menu() override;
void realize_menu_if_needed(); void realize_menu_if_needed();
@ -68,6 +67,8 @@ public:
private: private:
friend class Menubar; friend class Menubar;
explicit Menu(String name = "");
int realize_menu(RefPtr<Action> default_action = nullptr); int realize_menu(RefPtr<Action> default_action = nullptr);
void unrealize_menu(); void unrealize_menu();
void realize_if_needed(const RefPtr<Action>& default_action); void realize_if_needed(const RefPtr<Action>& default_action);

View file

@ -69,9 +69,9 @@ NonnullRefPtr<Label> Statusbar::create_label()
return label; return label;
} }
void Statusbar::set_text(const StringView& text) void Statusbar::set_text(String text)
{ {
m_labels.first().set_text(text); m_labels.first().set_text(move(text));
} }
String Statusbar::text() const String Statusbar::text() const
@ -79,9 +79,9 @@ String Statusbar::text() const
return m_labels.first().text(); return m_labels.first().text();
} }
void Statusbar::set_text(int index, const StringView& text) void Statusbar::set_text(int index, String text)
{ {
m_labels.at(index).set_text(text); m_labels.at(index).set_text(move(text));
} }
String Statusbar::text(int index) const String Statusbar::text(int index) const

View file

@ -37,8 +37,8 @@ public:
String text() const; String text() const;
String text(int index) const; String text(int index) const;
void set_text(const StringView&); void set_text(String);
void set_text(int index, const StringView&); void set_text(int index, String);
protected: protected:
explicit Statusbar(int label_count = 1); explicit Statusbar(int label_count = 1);