1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:57:35 +00:00

Everywhere: Stop using NonnullRefPtrVector

This class had slightly confusing semantics and the added weirdness
doesn't seem worth it just so we can say "." instead of "->" when
iterating over a vector of NNRPs.

This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
This commit is contained in:
Andreas Kling 2023-03-06 14:17:01 +01:00
parent 104be6c8ac
commit 8a48246ed1
168 changed files with 1280 additions and 1280 deletions

View file

@ -52,21 +52,21 @@ NonnullRefPtr<GUI::Action> LauncherHandler::create_launch_action(Function<void(L
});
}
RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(NonnullRefPtrVector<LauncherHandler> const& handlers)
RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(Vector<NonnullRefPtr<LauncherHandler>> const& handlers)
{
// If this is an application, pick it first
for (size_t i = 0; i < handlers.size(); i++) {
if (handlers[i].details().launcher_type == Desktop::Launcher::LauncherType::Application)
if (handlers[i]->details().launcher_type == Desktop::Launcher::LauncherType::Application)
return handlers[i];
}
// If there's a handler preferred by the user, pick this first
for (size_t i = 0; i < handlers.size(); i++) {
if (handlers[i].details().launcher_type == Desktop::Launcher::LauncherType::UserPreferred)
if (handlers[i]->details().launcher_type == Desktop::Launcher::LauncherType::UserPreferred)
return handlers[i];
}
// Otherwise, use the user's default, if available
for (size_t i = 0; i < handlers.size(); i++) {
if (handlers[i].details().launcher_type == Desktop::Launcher::LauncherType::UserDefault)
if (handlers[i]->details().launcher_type == Desktop::Launcher::LauncherType::UserDefault)
return handlers[i];
}
// If still no match, use the first one we find
@ -77,16 +77,16 @@ RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(NonnullRefPtrV
return {};
}
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(URL const& url)
Vector<NonnullRefPtr<LauncherHandler>> DirectoryView::get_launch_handlers(URL const& url)
{
NonnullRefPtrVector<LauncherHandler> handlers;
Vector<NonnullRefPtr<LauncherHandler>> handlers;
for (auto& h : Desktop::Launcher::get_handlers_with_details_for_url(url)) {
handlers.append(adopt_ref(*new LauncherHandler(h)));
}
return handlers;
}
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(DeprecatedString const& path)
Vector<NonnullRefPtr<LauncherHandler>> DirectoryView::get_launch_handlers(DeprecatedString const& path)
{
return get_launch_handlers(URL::create_with_file_scheme(path));
}

View file

@ -58,9 +58,9 @@ public:
void open_next_directory();
int path_history_size() const { return m_path_history.size(); }
int path_history_position() const { return m_path_history_position; }
static RefPtr<LauncherHandler> get_default_launch_handler(NonnullRefPtrVector<LauncherHandler> const& handlers);
static NonnullRefPtrVector<LauncherHandler> get_launch_handlers(URL const& url);
static NonnullRefPtrVector<LauncherHandler> get_launch_handlers(DeprecatedString const& path);
static RefPtr<LauncherHandler> get_default_launch_handler(Vector<NonnullRefPtr<LauncherHandler>> const& handlers);
static Vector<NonnullRefPtr<LauncherHandler>> get_launch_handlers(URL const& url);
static Vector<NonnullRefPtr<LauncherHandler>> get_launch_handlers(DeprecatedString const& path);
void refresh();

View file

@ -66,7 +66,7 @@ static void do_create_archive(Vector<DeprecatedString> const& selected_file_path
static void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window);
static void do_unzip_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window);
static void show_properties(DeprecatedString const& container_dir_path, DeprecatedString const& path, Vector<DeprecatedString> const& selected, GUI::Window* window);
static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers);
static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers);
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
@ -310,7 +310,7 @@ void show_properties(DeprecatedString const& container_dir_path, DeprecatedStrin
properties->show();
}
bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers)
bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers)
{
current_file_launch_handlers = directory_view.get_launch_handlers(full_path);
@ -337,9 +337,9 @@ bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView c
added_open_menu_items = true;
auto& file_open_with_menu = menu->add_submenu("Open with");
for (auto& handler : current_file_launch_handlers) {
if (&handler == default_file_handler.ptr())
if (handler == default_file_handler)
continue;
file_open_with_menu.add_action(handler.create_launch_action([&, full_path = move(full_path)](auto& launcher_handler) {
file_open_with_menu.add_action(handler->create_launch_action([&, full_path = move(full_path)](auto& launcher_handler) {
directory_view.launch(URL::create_with_file_scheme(full_path), launcher_handler);
}));
}
@ -502,7 +502,7 @@ ErrorOr<int> run_in_desktop_mode()
TRY(desktop_context_menu->try_add_action(properties_action));
RefPtr<GUI::Menu> file_context_menu;
NonnullRefPtrVector<LauncherHandler> current_file_handlers;
Vector<NonnullRefPtr<LauncherHandler>> current_file_handlers;
RefPtr<GUI::Action> file_context_menu_action_default_action;
directory_view->on_context_menu_request = [&](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) {
@ -1168,7 +1168,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
TRY(tree_view_directory_context_menu->try_add_action(properties_action));
RefPtr<GUI::Menu> file_context_menu;
NonnullRefPtrVector<LauncherHandler> current_file_handlers;
Vector<NonnullRefPtr<LauncherHandler>> current_file_handlers;
RefPtr<GUI::Action> file_context_menu_action_default_action;
directory_view->on_context_menu_request = [&](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) {