1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:47:35 +00:00

FileManager+FileOperation: Switch to east const

(And some adjustments based on MaxWipfli's feedback)
This commit is contained in:
Sam Atkins 2021-06-17 11:23:12 +01:00 committed by Andreas Kling
parent 5217875f6a
commit ca039e6ba1
10 changed files with 93 additions and 93 deletions

View file

@ -33,7 +33,7 @@ void spawn_terminal(String const& directory)
posix_spawn_file_actions_addchdir(&spawn_actions, directory.characters());
pid_t pid;
const char* argv[] = { "Terminal", nullptr };
char const* argv[] = { "Terminal", nullptr };
if ((errno = posix_spawn(&pid, "/bin/Terminal", &spawn_actions, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
} else {
@ -49,7 +49,7 @@ enum class FileOperation {
static HashTable<RefPtr<GUI::Window>> file_operation_windows;
static void run_file_operation([[maybe_unused]] FileOperation operation, const String& source, const String& destination, GUI::Window* parent_window)
static void run_file_operation([[maybe_unused]] FileOperation operation, String const& source, String const& destination, GUI::Window* parent_window)
{
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
@ -98,7 +98,7 @@ static void run_file_operation([[maybe_unused]] FileOperation operation, const S
window->show();
}
NonnullRefPtr<GUI::Action> LauncherHandler::create_launch_action(Function<void(const LauncherHandler&)> launch_handler)
NonnullRefPtr<GUI::Action> LauncherHandler::create_launch_action(Function<void(LauncherHandler const&)> launch_handler)
{
auto icon = GUI::FileIconProvider::icon_for_executable(details().executable).bitmap_for_size(16);
return GUI::Action::create(details().name, move(icon), [this, launch_handler = move(launch_handler)](auto&) {
@ -106,7 +106,7 @@ NonnullRefPtr<GUI::Action> LauncherHandler::create_launch_action(Function<void(c
});
}
RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(const NonnullRefPtrVector<LauncherHandler>& handlers)
RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(NonnullRefPtrVector<LauncherHandler> const& handlers)
{
// If this is an application, pick it first
for (size_t i = 0; i < handlers.size(); i++) {
@ -131,7 +131,7 @@ RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(const NonnullR
return {};
}
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(const URL& url)
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(URL const& url)
{
NonnullRefPtrVector<LauncherHandler> handlers;
for (auto& h : Desktop::Launcher::get_handlers_with_details_for_url(url)) {
@ -140,12 +140,12 @@ NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(const UR
return handlers;
}
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(const String& path)
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(String const& path)
{
return get_launch_handlers(URL::create_with_file_protocol(path));
}
void DirectoryView::handle_activation(const GUI::ModelIndex& index)
void DirectoryView::handle_activation(GUI::ModelIndex const& index)
{
if (!index.is_valid())
return;
@ -207,14 +207,14 @@ DirectoryView::DirectoryView(Mode mode)
set_view_mode(ViewMode::Icon);
}
const GUI::FileSystemModel::Node& DirectoryView::node(const GUI::ModelIndex& index) const
GUI::FileSystemModel::Node const& DirectoryView::node(GUI::ModelIndex const& index) const
{
return model().node(m_sorting_model->map_to_source(index));
}
void DirectoryView::setup_model()
{
m_model->on_directory_change_error = [this](int, const char* error_string) {
m_model->on_directory_change_error = [this](int, char const* error_string) {
auto failed_path = m_model->root_path();
auto error_message = String::formatted("Could not read {}:\n{}", failed_path, error_string);
m_error_label->set_text(error_message);
@ -229,7 +229,7 @@ void DirectoryView::setup_model()
on_path_change(failed_path, false, false);
};
m_model->on_rename_error = [this](int, const char* error_string) {
m_model->on_rename_error = [this](int, char const* error_string) {
GUI::MessageBox::show_error(window(), String::formatted("Unable to rename file: {}", error_string));
};
@ -423,7 +423,7 @@ void DirectoryView::open(String const& path)
model().set_root_path(real_path);
}
void DirectoryView::set_status_message(const StringView& message)
void DirectoryView::set_status_message(StringView const& message)
{
if (on_status_message)
on_status_message(message);
@ -477,7 +477,7 @@ void DirectoryView::update_statusbar()
size_t selected_byte_count = 0;
current_view().selection().for_each_index([&](auto& index) {
const auto& node = this->node(index);
auto const& node = this->node(index);
selected_byte_count += node.size;
});
@ -499,17 +499,17 @@ void DirectoryView::set_should_show_dotfiles(bool show_dotfiles)
m_model->set_should_show_dotfiles(show_dotfiles);
}
void DirectoryView::launch(const URL&, const LauncherHandler& launcher_handler) const
void DirectoryView::launch(URL const&, LauncherHandler const& launcher_handler) const
{
pid_t child;
if (launcher_handler.details().launcher_type == Desktop::Launcher::LauncherType::Application) {
const char* argv[] = { launcher_handler.details().name.characters(), nullptr };
char const* argv[] = { launcher_handler.details().name.characters(), nullptr };
posix_spawn(&child, launcher_handler.details().executable.characters(), nullptr, nullptr, const_cast<char**>(argv), environ);
if (disown(child) < 0)
perror("disown");
} else {
for (auto& path : selected_file_paths()) {
const char* argv[] = { launcher_handler.details().name.characters(), path.characters(), nullptr };
char const* argv[] = { launcher_handler.details().name.characters(), path.characters(), nullptr };
posix_spawn(&child, launcher_handler.details().executable.characters(), nullptr, nullptr, const_cast<char**>(argv), environ);
if (disown(child) < 0)
perror("disown");
@ -522,7 +522,7 @@ Vector<String> DirectoryView::selected_file_paths() const
Vector<String> paths;
auto& view = current_view();
auto& model = *view.model();
view.selection().for_each_index([&](const GUI::ModelIndex& index) {
view.selection().for_each_index([&](GUI::ModelIndex const& index) {
auto parent_index = model.parent_index(index);
auto name_index = model.index(index.row(), GUI::FileSystemModel::Column::Name, parent_index);
auto path = name_index.data(GUI::ModelRole::Custom).to_string();
@ -553,7 +553,7 @@ void DirectoryView::handle_selection_change()
void DirectoryView::setup_actions()
{
m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [&](GUI::Action const&) {
String value;
if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecOK && !value.is_empty()) {
auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
@ -565,7 +565,7 @@ void DirectoryView::setup_actions()
}
});
m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"), [&](GUI::Action const&) {
String value;
if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecOK && !value.is_empty()) {
auto new_file_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
@ -607,7 +607,7 @@ void DirectoryView::setup_actions()
window());
}
void DirectoryView::handle_drop(const GUI::ModelIndex& index, const GUI::DropEvent& event)
void DirectoryView::handle_drop(GUI::ModelIndex const& index, GUI::DropEvent const& event)
{
if (!event.mime_data().has_urls())
return;