summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-04-17 00:47:36 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-17 01:27:30 +0200
commit0e4eb62dd8b117cd653bc6495278596cb3c63a0a (patch)
treef6ab4a07bb5c78b488d33a34ee872f63c6e41d4c /Userland/Libraries
parent36f27094d0e4cd1b82b4ba50a7c9f92736a86817 (diff)
downloadserenity-0e4eb62dd8b117cd653bc6495278596cb3c63a0a.zip
LibGUI: Make some API's take String instead of StringView
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGUI/FileSystemModel.cpp13
-rw-r--r--Userland/Libraries/LibGUI/FileSystemModel.h8
-rw-r--r--Userland/Libraries/LibGUI/Menu.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Menu.h3
-rw-r--r--Userland/Libraries/LibGUI/Statusbar.cpp8
-rw-r--r--Userland/Libraries/LibGUI/Statusbar.h4
6 files changed, 20 insertions, 20 deletions
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp
index 4b3ca0470b..c0a19844fd 100644
--- a/Userland/Libraries/LibGUI/FileSystemModel.cpp
+++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp
@@ -36,7 +36,6 @@
#include <LibGUI/Painter.h>
#include <LibGfx/Bitmap.h>
#include <LibThread/BackgroundAction.h>
-#include <dirent.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
@@ -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 9189a99131..ee5ac0713a 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<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));
}
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 14534d3c9c..d2ffbd5d18 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 464b39d8ea..ed2c7cf26d 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<Action> default_action = nullptr);
void unrealize_menu();
void realize_if_needed(const RefPtr<Action>& default_action);
diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp
index 62a38a58f3..311dbb9621 100644
--- a/Userland/Libraries/LibGUI/Statusbar.cpp
+++ b/Userland/Libraries/LibGUI/Statusbar.cpp
@@ -69,9 +69,9 @@ NonnullRefPtr<Label> Statusbar::create_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
@@ -79,9 +79,9 @@ String Statusbar::text() const
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
diff --git a/Userland/Libraries/LibGUI/Statusbar.h b/Userland/Libraries/LibGUI/Statusbar.h
index c01e910603..a40cc1927f 100644
--- a/Userland/Libraries/LibGUI/Statusbar.h
+++ b/Userland/Libraries/LibGUI/Statusbar.h
@@ -37,8 +37,8 @@ public:
String text() const;
String text(int index) const;
- void set_text(const StringView&);
- void set_text(int index, const StringView&);
+ void set_text(String);
+ void set_text(int index, String);
protected:
explicit Statusbar(int label_count = 1);