mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:47:34 +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:
parent
104be6c8ac
commit
8a48246ed1
168 changed files with 1280 additions and 1280 deletions
|
@ -61,12 +61,12 @@ void URLResult::activate() const
|
|||
Desktop::Launcher::open(URL::create_with_url_or_path(title()));
|
||||
}
|
||||
|
||||
void AppProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
|
||||
void AppProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
if (query.starts_with('=') || query.starts_with('$'))
|
||||
return;
|
||||
|
||||
NonnullRefPtrVector<Result> results;
|
||||
Vector<NonnullRefPtr<Result>> results;
|
||||
|
||||
Desktop::AppFile::for_each([&](NonnullRefPtr<Desktop::AppFile> app_file) {
|
||||
auto query_and_arguments = query.split_limit(' ', 2);
|
||||
|
@ -83,7 +83,7 @@ void AppProvider::query(DeprecatedString const& query, Function<void(NonnullRefP
|
|||
on_complete(move(results));
|
||||
}
|
||||
|
||||
void CalculatorProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
|
||||
void CalculatorProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
if (!query.starts_with('='))
|
||||
return;
|
||||
|
@ -108,7 +108,7 @@ void CalculatorProvider::query(DeprecatedString const& query, Function<void(Nonn
|
|||
calculation = result.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<Result> results;
|
||||
Vector<NonnullRefPtr<Result>> results;
|
||||
results.append(adopt_ref(*new CalculatorResult(calculation)));
|
||||
on_complete(move(results));
|
||||
}
|
||||
|
@ -123,16 +123,16 @@ FileProvider::FileProvider()
|
|||
build_filesystem_cache();
|
||||
}
|
||||
|
||||
void FileProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
|
||||
void FileProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
build_filesystem_cache();
|
||||
|
||||
if (m_fuzzy_match_work)
|
||||
m_fuzzy_match_work->cancel();
|
||||
|
||||
m_fuzzy_match_work = Threading::BackgroundAction<Optional<NonnullRefPtrVector<Result>>>::construct(
|
||||
[this, query](auto& task) -> Optional<NonnullRefPtrVector<Result>> {
|
||||
NonnullRefPtrVector<Result> results;
|
||||
m_fuzzy_match_work = Threading::BackgroundAction<Optional<Vector<NonnullRefPtr<Result>>>>::construct(
|
||||
[this, query](auto& task) -> Optional<Vector<NonnullRefPtr<Result>>> {
|
||||
Vector<NonnullRefPtr<Result>> results;
|
||||
|
||||
for (auto& path : m_full_path_cache) {
|
||||
if (task.is_cancelled())
|
||||
|
@ -203,19 +203,19 @@ void FileProvider::build_filesystem_cache()
|
|||
});
|
||||
}
|
||||
|
||||
void TerminalProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
|
||||
void TerminalProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
if (!query.starts_with('$'))
|
||||
return;
|
||||
|
||||
auto command = query.substring(1).trim_whitespace();
|
||||
|
||||
NonnullRefPtrVector<Result> results;
|
||||
Vector<NonnullRefPtr<Result>> results;
|
||||
results.append(adopt_ref(*new TerminalResult(move(command))));
|
||||
on_complete(move(results));
|
||||
}
|
||||
|
||||
void URLProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
|
||||
void URLProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
if (query.is_empty() || query.starts_with('=') || query.starts_with('$'))
|
||||
return;
|
||||
|
@ -232,7 +232,7 @@ void URLProvider::query(DeprecatedString const& query, Function<void(NonnullRefP
|
|||
if (!url.is_valid())
|
||||
return;
|
||||
|
||||
NonnullRefPtrVector<Result> results;
|
||||
Vector<NonnullRefPtr<Result>> results;
|
||||
results.append(adopt_ref(*new URLResult(url)));
|
||||
on_complete(results);
|
||||
}
|
||||
|
|
|
@ -134,28 +134,28 @@ class Provider : public RefCounted<Provider> {
|
|||
public:
|
||||
virtual ~Provider() = default;
|
||||
|
||||
virtual void query(DeprecatedString const&, Function<void(NonnullRefPtrVector<Result>)> on_complete) = 0;
|
||||
virtual void query(DeprecatedString const&, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) = 0;
|
||||
};
|
||||
|
||||
class AppProvider final : public Provider {
|
||||
public:
|
||||
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
};
|
||||
|
||||
class CalculatorProvider final : public Provider {
|
||||
public:
|
||||
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
};
|
||||
|
||||
class FileProvider final : public Provider {
|
||||
public:
|
||||
FileProvider();
|
||||
|
||||
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
void build_filesystem_cache();
|
||||
|
||||
private:
|
||||
RefPtr<Threading::BackgroundAction<Optional<NonnullRefPtrVector<Result>>>> m_fuzzy_match_work;
|
||||
RefPtr<Threading::BackgroundAction<Optional<Vector<NonnullRefPtr<Result>>>>> m_fuzzy_match_work;
|
||||
bool m_building_cache { false };
|
||||
Vector<DeprecatedString> m_full_path_cache;
|
||||
Queue<DeprecatedString> m_work_queue;
|
||||
|
@ -163,12 +163,12 @@ private:
|
|||
|
||||
class TerminalProvider final : public Provider {
|
||||
public:
|
||||
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
};
|
||||
|
||||
class URLProvider final : public Provider {
|
||||
public:
|
||||
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Assistant {
|
|||
|
||||
struct AppState {
|
||||
Optional<size_t> selected_index;
|
||||
NonnullRefPtrVector<Result const> results;
|
||||
Vector<NonnullRefPtr<Result const>> results;
|
||||
size_t visible_result_count { 0 };
|
||||
|
||||
Threading::Mutex lock;
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
Function<void(NonnullRefPtrVector<Result const>)> on_new_results;
|
||||
Function<void(Vector<NonnullRefPtr<Result const>>)> on_new_results;
|
||||
|
||||
void search(DeprecatedString const& query)
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
auto& result_array = m_result_cache.ensure(query);
|
||||
if (result_array.at(i) != nullptr)
|
||||
return;
|
||||
result_array[i] = make<NonnullRefPtrVector<Result>>(results);
|
||||
result_array[i] = make<Vector<NonnullRefPtr<Result>>>(results);
|
||||
}
|
||||
on_result_cache_updated();
|
||||
});
|
||||
|
@ -142,7 +142,7 @@ private:
|
|||
Array<NonnullRefPtr<Provider>, ProviderCount> m_providers;
|
||||
|
||||
Threading::Mutex m_mutex;
|
||||
HashMap<DeprecatedString, Array<OwnPtr<NonnullRefPtrVector<Result>>, ProviderCount>> m_result_cache;
|
||||
HashMap<DeprecatedString, Array<OwnPtr<Vector<NonnullRefPtr<Result>>>, ProviderCount>> m_result_cache;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (!app_state.selected_index.has_value())
|
||||
return;
|
||||
lockfile.release();
|
||||
app_state.results[app_state.selected_index.value()].activate();
|
||||
app_state.results[app_state.selected_index.value()]->activate();
|
||||
GUI::Application::the()->quit();
|
||||
};
|
||||
text_box.on_up_pressed = [&]() {
|
||||
|
@ -254,11 +254,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
for (size_t i = 0; i < app_state.visible_result_count; ++i) {
|
||||
auto& result = app_state.results[i];
|
||||
auto& match = results_container.add<Assistant::ResultRow>();
|
||||
match.set_icon(result.bitmap());
|
||||
match.set_text(String::from_deprecated_string(result.title()).release_value_but_fixme_should_propagate_errors());
|
||||
match.set_tooltip(move(result.tooltip()));
|
||||
match.set_icon(result->bitmap());
|
||||
match.set_text(String::from_deprecated_string(result->title()).release_value_but_fixme_should_propagate_errors());
|
||||
match.set_tooltip(move(result->tooltip()));
|
||||
match.on_click = [&result](auto) {
|
||||
result.activate();
|
||||
result->activate();
|
||||
GUI::Application::the()->quit();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -243,13 +243,13 @@ void BookmarksBarWidget::update_content_size()
|
|||
|
||||
for (size_t i = 0; i < m_bookmarks.size(); ++i) {
|
||||
auto& bookmark = m_bookmarks.at(i);
|
||||
if (x_position + bookmark.width() + m_additional->width() > width()) {
|
||||
if (x_position + bookmark->width() + m_additional->width() > width()) {
|
||||
m_last_visible_index = i;
|
||||
break;
|
||||
}
|
||||
bookmark.set_x(x_position);
|
||||
bookmark.set_visible(true);
|
||||
x_position += bookmark.width();
|
||||
bookmark->set_x(x_position);
|
||||
bookmark->set_visible(true);
|
||||
x_position += bookmark->width();
|
||||
}
|
||||
|
||||
if (m_last_visible_index < 0) {
|
||||
|
@ -261,8 +261,8 @@ void BookmarksBarWidget::update_content_size()
|
|||
m_additional->set_menu(m_additional_menu);
|
||||
for (size_t i = m_last_visible_index; i < m_bookmarks.size(); ++i) {
|
||||
auto& bookmark = m_bookmarks.at(i);
|
||||
bookmark.set_visible(false);
|
||||
m_additional_menu->add_action(GUI::Action::create(bookmark.text().to_deprecated_string(), g_icon_bag.filetype_html, [&](auto&) { bookmark.on_click(0); }));
|
||||
bookmark->set_visible(false);
|
||||
m_additional_menu->add_action(GUI::Action::create(bookmark->text().to_deprecated_string(), g_icon_bag.filetype_html, [&](auto&) { bookmark->on_click(0); }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ private:
|
|||
RefPtr<GUI::Action> m_context_menu_default_action;
|
||||
DeprecatedString m_context_menu_url;
|
||||
|
||||
NonnullRefPtrVector<GUI::Button> m_bookmarks;
|
||||
Vector<NonnullRefPtr<GUI::Button>> m_bookmarks;
|
||||
|
||||
int m_last_visible_index { -1 };
|
||||
};
|
||||
|
|
|
@ -65,7 +65,7 @@ WindowActions::WindowActions(GUI::Window& window)
|
|||
on_tabs[i]();
|
||||
},
|
||||
&window));
|
||||
m_tab_actions.last().set_status_tip(DeprecatedString::formatted("Switch to tab {}", i + 1));
|
||||
m_tab_actions.last()->set_status_tip(DeprecatedString::formatted("Switch to tab {}", i + 1));
|
||||
}
|
||||
m_tab_actions.append(GUI::Action::create(
|
||||
"Last tab", { Mod_Ctrl, Key_9 }, [this](auto&) {
|
||||
|
@ -73,7 +73,7 @@ WindowActions::WindowActions(GUI::Window& window)
|
|||
on_tabs[8]();
|
||||
},
|
||||
&window));
|
||||
m_tab_actions.last().set_status_tip("Switch to last tab");
|
||||
m_tab_actions.last()->set_status_tip("Switch to last tab");
|
||||
|
||||
m_about_action = GUI::CommonActions::make_about_action("Browser", GUI::Icon::default_icon("app-browser"sv), &window);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
RefPtr<GUI::Action> m_create_new_window_action;
|
||||
RefPtr<GUI::Action> m_next_tab_action;
|
||||
RefPtr<GUI::Action> m_previous_tab_action;
|
||||
NonnullRefPtrVector<GUI::Action> m_tab_actions;
|
||||
Vector<NonnullRefPtr<GUI::Action>> m_tab_actions;
|
||||
RefPtr<GUI::Action> m_about_action;
|
||||
RefPtr<GUI::Action> m_show_bookmarks_bar_action;
|
||||
RefPtr<GUI::Action> m_vertical_tabs_action;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -63,7 +63,7 @@ private:
|
|||
|
||||
auto background_color = this->background_color();
|
||||
for (auto& stack : stacks())
|
||||
stack.paint(painter, background_color);
|
||||
stack->paint(painter, background_color);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, V
|
|||
auto account = AccountNode::create(move(name));
|
||||
|
||||
// This holds all of the ancestors of the current leaf folder.
|
||||
NonnullRefPtrVector<MailboxNode> folder_stack;
|
||||
Vector<NonnullRefPtr<MailboxNode>> folder_stack;
|
||||
|
||||
for (auto& mailbox : mailboxes) {
|
||||
// mailbox.name is converted to StringView to get access to split by string.
|
||||
|
@ -44,7 +44,7 @@ void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, V
|
|||
// Only keep the ancestors of the current leaf folder.
|
||||
folder_stack.shrink(subfolders.size() - 1);
|
||||
|
||||
parent_folder.add_child(mailbox_node);
|
||||
parent_folder->add_child(mailbox_node);
|
||||
VERIFY(!mailbox_node->has_parent());
|
||||
mailbox_node->set_parent(parent_folder);
|
||||
|
||||
|
@ -54,7 +54,7 @@ void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, V
|
|||
} else {
|
||||
// FIXME: This assumes that the server has the "CHILDREN" capability.
|
||||
if (mailbox.flags & (unsigned)IMAP::MailboxFlag::HasChildren) {
|
||||
if (!folder_stack.is_empty() && folder_stack.first().select_name() != mailbox.name) {
|
||||
if (!folder_stack.is_empty() && folder_stack.first()->select_name() != mailbox.name) {
|
||||
// This is a new root folder, clear the stack as there are no ancestors of the current leaf folder at this point.
|
||||
folder_stack.clear();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
m_mailboxes.append(move(mailbox));
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<MailboxNode> const& mailboxes() const { return m_mailboxes; }
|
||||
Vector<NonnullRefPtr<MailboxNode>> const& mailboxes() const { return m_mailboxes; }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
|
||||
private:
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
}
|
||||
|
||||
DeprecatedString m_name;
|
||||
NonnullRefPtrVector<MailboxNode> m_mailboxes;
|
||||
Vector<NonnullRefPtr<MailboxNode>> m_mailboxes;
|
||||
};
|
||||
|
||||
class MailboxNode final : public BaseNode {
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
void set_parent(NonnullRefPtr<MailboxNode> parent) { m_parent = parent; }
|
||||
|
||||
bool has_children() const { return !m_children.is_empty(); }
|
||||
NonnullRefPtrVector<MailboxNode> const& children() const { return m_children; }
|
||||
Vector<NonnullRefPtr<MailboxNode>> const& children() const { return m_children; }
|
||||
void add_child(NonnullRefPtr<MailboxNode> child) { m_children.append(child); }
|
||||
|
||||
private:
|
||||
|
@ -81,7 +81,7 @@ private:
|
|||
IMAP::ListItem m_mailbox;
|
||||
DeprecatedString m_display_name;
|
||||
|
||||
NonnullRefPtrVector<MailboxNode> m_children;
|
||||
Vector<NonnullRefPtr<MailboxNode>> m_children;
|
||||
RefPtr<MailboxNode> m_parent;
|
||||
};
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
|
||||
void add_account_with_name_and_mailboxes(DeprecatedString, Vector<IMAP::ListItem> const&);
|
||||
|
||||
NonnullRefPtrVector<AccountNode> const& accounts() const { return m_accounts; }
|
||||
Vector<NonnullRefPtr<AccountNode>> const& accounts() const { return m_accounts; }
|
||||
MailboxTreeModel& mailbox_tree_model() { return *m_mailbox_tree_model; }
|
||||
|
||||
private:
|
||||
|
@ -104,6 +104,6 @@ private:
|
|||
|
||||
void rebuild_tree();
|
||||
|
||||
NonnullRefPtrVector<AccountNode> m_accounts;
|
||||
Vector<NonnullRefPtr<AccountNode>> m_accounts;
|
||||
RefPtr<MailboxTreeModel> m_mailbox_tree_model;
|
||||
};
|
||||
|
|
|
@ -48,14 +48,14 @@ GUI::ModelIndex MailboxTreeModel::parent_index(GUI::ModelIndex const& index) con
|
|||
|
||||
if (!mailbox_node.has_parent()) {
|
||||
for (size_t row = 0; row < mailbox_node.associated_account().mailboxes().size(); ++row) {
|
||||
if (&mailbox_node.associated_account().mailboxes()[row] == &mailbox_node) {
|
||||
if (mailbox_node.associated_account().mailboxes()[row] == &mailbox_node) {
|
||||
return create_index(row, index.column(), &mailbox_node.associated_account());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
VERIFY(mailbox_node.parent()->has_children());
|
||||
for (size_t row = 0; row < mailbox_node.parent()->children().size(); ++row) {
|
||||
if (&mailbox_node.parent()->children()[row] == &mailbox_node) {
|
||||
if (mailbox_node.parent()->children()[row] == &mailbox_node) {
|
||||
return create_index(row, index.column(), mailbox_node.parent());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,9 +118,9 @@ GUI::ModelIndex OutlineModel::parent_index(const GUI::ModelIndex& index) const
|
|||
if (!parent)
|
||||
return {};
|
||||
|
||||
NonnullRefPtrVector<PDF::OutlineItem> parent_siblings = (parent->parent ? parent->parent->children : m_outline->children);
|
||||
Vector<NonnullRefPtr<PDF::OutlineItem>> parent_siblings = (parent->parent ? parent->parent->children : m_outline->children);
|
||||
for (size_t i = 0; i < parent_siblings.size(); i++) {
|
||||
auto* parent_sibling = &parent_siblings[i];
|
||||
auto* parent_sibling = parent_siblings[i].ptr();
|
||||
if (parent_sibling == parent.ptr())
|
||||
return create_index(static_cast<int>(i), index.column(), parent.ptr());
|
||||
}
|
||||
|
|
|
@ -30,5 +30,5 @@ private:
|
|||
TrackManager& m_track_manager;
|
||||
MainWidget& m_main_widget;
|
||||
|
||||
NonnullRefPtrVector<ProcessorParameterWidget> m_parameter_widgets;
|
||||
Vector<NonnullRefPtr<ProcessorParameterWidget>> m_parameter_widgets;
|
||||
};
|
||||
|
|
|
@ -42,11 +42,11 @@ void Image::paint_into(GUI::Painter& painter, Gfx::IntRect const& dest_rect, flo
|
|||
Gfx::PainterStateSaver saver(painter);
|
||||
painter.add_clip_rect(dest_rect);
|
||||
for (auto const& layer : m_layers) {
|
||||
if (!layer.is_visible())
|
||||
if (!layer->is_visible())
|
||||
continue;
|
||||
auto target = dest_rect.to_type<float>().translated(layer.location().x() * scale, layer.location().y() * scale);
|
||||
target.set_size(layer.size().width() * scale, layer.size().height() * scale);
|
||||
painter.draw_scaled_bitmap(target.to_type<int>(), layer.display_bitmap(), layer.rect(), (float)layer.opacity_percent() / 100.0f);
|
||||
auto target = dest_rect.to_type<float>().translated(layer->location().x() * scale, layer->location().y() * scale);
|
||||
target.set_size(layer->size().width() * scale, layer->size().height() * scale);
|
||||
painter.draw_scaled_bitmap(target.to_type<int>(), layer->display_bitmap(), layer->rect(), (float)layer->opacity_percent() / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,17 +126,17 @@ ErrorOr<void> Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json
|
|||
auto json_layers = TRY(json.add_array("layers"sv));
|
||||
for (auto const& layer : m_layers) {
|
||||
auto json_layer = TRY(json_layers.add_object());
|
||||
TRY(json_layer.add("width"sv, layer.size().width()));
|
||||
TRY(json_layer.add("height"sv, layer.size().height()));
|
||||
TRY(json_layer.add("name"sv, layer.name()));
|
||||
TRY(json_layer.add("locationx"sv, layer.location().x()));
|
||||
TRY(json_layer.add("locationy"sv, layer.location().y()));
|
||||
TRY(json_layer.add("opacity_percent"sv, layer.opacity_percent()));
|
||||
TRY(json_layer.add("visible"sv, layer.is_visible()));
|
||||
TRY(json_layer.add("selected"sv, layer.is_selected()));
|
||||
TRY(json_layer.add("bitmap"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(layer.content_bitmap()))))));
|
||||
if (layer.is_masked())
|
||||
TRY(json_layer.add("mask"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(*layer.mask_bitmap()))))));
|
||||
TRY(json_layer.add("width"sv, layer->size().width()));
|
||||
TRY(json_layer.add("height"sv, layer->size().height()));
|
||||
TRY(json_layer.add("name"sv, layer->name()));
|
||||
TRY(json_layer.add("locationx"sv, layer->location().x()));
|
||||
TRY(json_layer.add("locationy"sv, layer->location().y()));
|
||||
TRY(json_layer.add("opacity_percent"sv, layer->opacity_percent()));
|
||||
TRY(json_layer.add("visible"sv, layer->is_visible()));
|
||||
TRY(json_layer.add("selected"sv, layer->is_selected()));
|
||||
TRY(json_layer.add("bitmap"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(layer->content_bitmap()))))));
|
||||
if (layer->is_masked())
|
||||
TRY(json_layer.add("mask"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(*layer->mask_bitmap()))))));
|
||||
TRY(json_layer.finish());
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ ErrorOr<void> Image::export_qoi_to_file(NonnullOwnPtr<Stream> stream) const
|
|||
void Image::add_layer(NonnullRefPtr<Layer> layer)
|
||||
{
|
||||
for (auto& existing_layer : m_layers) {
|
||||
VERIFY(&existing_layer != layer.ptr());
|
||||
VERIFY(existing_layer != layer);
|
||||
}
|
||||
m_layers.append(move(layer));
|
||||
|
||||
|
@ -256,7 +256,7 @@ ErrorOr<void> Image::restore_snapshot(Image const& snapshot)
|
|||
size_t Image::index_of(Layer const& layer) const
|
||||
{
|
||||
for (size_t i = 0; i < m_layers.size(); ++i) {
|
||||
if (&m_layers.at(i) == &layer)
|
||||
if (m_layers[i] == &layer)
|
||||
return i;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -350,18 +350,18 @@ ErrorOr<void> Image::merge_layers(LayerMergeMode layer_merge_mode)
|
|||
if (m_layers.size() < 2)
|
||||
return {};
|
||||
|
||||
NonnullRefPtrVector<Layer> new_layers;
|
||||
Vector<NonnullRefPtr<Layer>> new_layers;
|
||||
Gfx::IntRect merged_layer_bounding_rect = {};
|
||||
size_t bottom_layer_index = 0;
|
||||
for (auto const& layer : m_layers) {
|
||||
if (!layer.is_visible()) {
|
||||
if (!layer->is_visible()) {
|
||||
if (layer_merge_mode == LayerMergeMode::VisibleOnly)
|
||||
TRY(new_layers.try_append(layer));
|
||||
if (merged_layer_bounding_rect.is_empty())
|
||||
bottom_layer_index++;
|
||||
continue;
|
||||
}
|
||||
merged_layer_bounding_rect = merged_layer_bounding_rect.united(layer.relative_rect());
|
||||
merged_layer_bounding_rect = merged_layer_bounding_rect.united(layer->relative_rect());
|
||||
}
|
||||
|
||||
if (merged_layer_bounding_rect.is_empty())
|
||||
|
@ -379,9 +379,9 @@ ErrorOr<void> Image::merge_layers(LayerMergeMode layer_merge_mode)
|
|||
painter.blit(bottom_layer->location() - merged_layer->location(), bottom_layer->display_bitmap(), bottom_layer->rect(), static_cast<float>(bottom_layer->opacity_percent()) / 100.0f);
|
||||
for (size_t index = bottom_layer_index + 1; index < m_layers.size(); index++) {
|
||||
auto& layer = m_layers.at(index);
|
||||
if (!layer.is_visible())
|
||||
if (!layer->is_visible())
|
||||
continue;
|
||||
painter.blit(layer.location() - merged_layer->location(), layer.display_bitmap(), layer.rect(), static_cast<float>(layer.opacity_percent()) / 100.0f);
|
||||
painter.blit(layer->location() - merged_layer->location(), layer->display_bitmap(), layer->rect(), static_cast<float>(layer->opacity_percent()) / 100.0f);
|
||||
}
|
||||
|
||||
TRY(new_layers.try_append(merged_layer));
|
||||
|
@ -421,7 +421,7 @@ ErrorOr<void> Image::merge_active_layer(NonnullRefPtr<Layer> const& layer, Layer
|
|||
|
||||
Optional<NonnullRefPtr<Layer>> maybe_adjacent_layer;
|
||||
while (layer_to_merge_index >= 0 && layer_to_merge_index < layer_count) {
|
||||
auto& layer = m_layers.at(layer_to_merge_index);
|
||||
auto const& layer = *m_layers[layer_to_merge_index];
|
||||
if (layer.is_visible()) {
|
||||
maybe_adjacent_layer = layer;
|
||||
break;
|
||||
|
@ -541,7 +541,7 @@ ErrorOr<void> Image::flip(Gfx::Orientation orientation)
|
|||
auto& layer = m_layers[i];
|
||||
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
|
||||
|
||||
if (layer.is_selected())
|
||||
if (layer->is_selected())
|
||||
selected_layer_index = i;
|
||||
|
||||
TRY(new_layer->flip(orientation, Layer::NotifyClients::No));
|
||||
|
@ -551,9 +551,9 @@ ErrorOr<void> Image::flip(Gfx::Orientation orientation)
|
|||
|
||||
m_layers = move(flipped_layers);
|
||||
for (auto& layer : m_layers)
|
||||
layer.did_modify_bitmap({}, Layer::NotifyClients::No);
|
||||
layer->did_modify_bitmap({}, Layer::NotifyClients::No);
|
||||
|
||||
select_layer(&m_layers[selected_layer_index]);
|
||||
select_layer(m_layers[selected_layer_index]);
|
||||
|
||||
did_change();
|
||||
|
||||
|
@ -572,7 +572,7 @@ ErrorOr<void> Image::rotate(Gfx::RotationDirection direction)
|
|||
auto& layer = m_layers[i];
|
||||
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
|
||||
|
||||
if (layer.is_selected())
|
||||
if (layer->is_selected())
|
||||
selected_layer_index = i;
|
||||
|
||||
TRY(new_layer->rotate(direction, Layer::NotifyClients::No));
|
||||
|
@ -582,9 +582,9 @@ ErrorOr<void> Image::rotate(Gfx::RotationDirection direction)
|
|||
|
||||
m_layers = move(rotated_layers);
|
||||
for (auto& layer : m_layers)
|
||||
layer.did_modify_bitmap({}, Layer::NotifyClients::Yes);
|
||||
layer->did_modify_bitmap({}, Layer::NotifyClients::Yes);
|
||||
|
||||
select_layer(&m_layers[selected_layer_index]);
|
||||
select_layer(m_layers[selected_layer_index]);
|
||||
|
||||
m_size = { m_size.height(), m_size.width() };
|
||||
did_change_rect();
|
||||
|
@ -604,7 +604,7 @@ ErrorOr<void> Image::crop(Gfx::IntRect const& cropped_rect)
|
|||
auto& layer = m_layers[i];
|
||||
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
|
||||
|
||||
if (layer.is_selected())
|
||||
if (layer->is_selected())
|
||||
selected_layer_index = i;
|
||||
|
||||
auto layer_location = new_layer->location();
|
||||
|
@ -621,9 +621,9 @@ ErrorOr<void> Image::crop(Gfx::IntRect const& cropped_rect)
|
|||
|
||||
m_layers = move(cropped_layers);
|
||||
for (auto& layer : m_layers)
|
||||
layer.did_modify_bitmap({}, Layer::NotifyClients::Yes);
|
||||
layer->did_modify_bitmap({}, Layer::NotifyClients::Yes);
|
||||
|
||||
select_layer(&m_layers[selected_layer_index]);
|
||||
select_layer(m_layers[selected_layer_index]);
|
||||
|
||||
m_size = { cropped_rect.width(), cropped_rect.height() };
|
||||
did_change_rect(cropped_rect);
|
||||
|
@ -638,10 +638,10 @@ Optional<Gfx::IntRect> Image::nonempty_content_bounding_rect() const
|
|||
|
||||
Optional<Gfx::IntRect> bounding_rect;
|
||||
for (auto const& layer : m_layers) {
|
||||
auto layer_content_rect_in_layer_coordinates = layer.nonempty_content_bounding_rect();
|
||||
auto layer_content_rect_in_layer_coordinates = layer->nonempty_content_bounding_rect();
|
||||
if (!layer_content_rect_in_layer_coordinates.has_value())
|
||||
continue;
|
||||
auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates->translated(layer.location());
|
||||
auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates->translated(layer->location());
|
||||
if (!bounding_rect.has_value())
|
||||
bounding_rect = layer_content_rect_in_image_coordinates;
|
||||
else
|
||||
|
@ -674,7 +674,7 @@ ErrorOr<void> Image::resize(Gfx::IntSize new_size, Gfx::Painter::ScalingMode sca
|
|||
auto& layer = m_layers[i];
|
||||
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
|
||||
|
||||
if (layer.is_selected())
|
||||
if (layer->is_selected())
|
||||
selected_layer_index = i;
|
||||
|
||||
Gfx::IntPoint new_location(scale_x * new_layer->location().x(), scale_y * new_layer->location().y());
|
||||
|
@ -685,9 +685,9 @@ ErrorOr<void> Image::resize(Gfx::IntSize new_size, Gfx::Painter::ScalingMode sca
|
|||
|
||||
m_layers = move(resized_layers);
|
||||
for (auto& layer : m_layers)
|
||||
layer.did_modify_bitmap({}, Layer::NotifyClients::Yes);
|
||||
layer->did_modify_bitmap({}, Layer::NotifyClients::Yes);
|
||||
|
||||
select_layer(&m_layers[selected_layer_index]);
|
||||
select_layer(m_layers[selected_layer_index]);
|
||||
|
||||
m_size = { new_size.width(), new_size.height() };
|
||||
did_change_rect();
|
||||
|
@ -699,11 +699,11 @@ Color Image::color_at(Gfx::IntPoint point) const
|
|||
{
|
||||
Color color;
|
||||
for (auto const& layer : m_layers) {
|
||||
if (!layer.is_visible() || !layer.rect().contains(point))
|
||||
if (!layer->is_visible() || !layer->rect().contains(point))
|
||||
continue;
|
||||
|
||||
auto layer_color = layer.display_bitmap().get_pixel(point);
|
||||
float layer_opacity = layer.opacity_percent() / 100.0f;
|
||||
auto layer_color = layer->display_bitmap().get_pixel(point);
|
||||
float layer_opacity = layer->opacity_percent() / 100.0f;
|
||||
layer_color.set_alpha((u8)(layer_color.alpha() * layer_opacity));
|
||||
color = color.blend(layer_color);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ private:
|
|||
ErrorOr<void> merge_active_layer(NonnullRefPtr<Layer> const&, LayerMergeDirection);
|
||||
|
||||
Gfx::IntSize m_size;
|
||||
NonnullRefPtrVector<Layer> m_layers;
|
||||
Vector<NonnullRefPtr<Layer>> m_layers;
|
||||
|
||||
HashTable<ImageClient*> m_clients;
|
||||
|
||||
|
|
|
@ -187,11 +187,11 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
if (m_show_guides) {
|
||||
for (auto& guide : m_guides) {
|
||||
if (guide.orientation() == Guide::Orientation::Horizontal) {
|
||||
int y_coordinate = (int)content_to_frame_position({ 0.0f, guide.offset() }).y();
|
||||
if (guide->orientation() == Guide::Orientation::Horizontal) {
|
||||
int y_coordinate = (int)content_to_frame_position({ 0.0f, guide->offset() }).y();
|
||||
painter.draw_line({ 0, y_coordinate }, { rect().width(), y_coordinate }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
|
||||
} else if (guide.orientation() == Guide::Orientation::Vertical) {
|
||||
int x_coordinate = (int)content_to_frame_position({ guide.offset(), 0.0f }).x();
|
||||
} else if (guide->orientation() == Guide::Orientation::Vertical) {
|
||||
int x_coordinate = (int)content_to_frame_position({ guide->offset(), 0.0f }).x();
|
||||
painter.draw_line({ x_coordinate, 0 }, { x_coordinate, rect().height() }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
|
||||
}
|
||||
}
|
||||
|
@ -768,10 +768,10 @@ ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::File> file)
|
|||
auto json_guides = TRY(json.add_array("guides"sv));
|
||||
for (auto const& guide : m_guides) {
|
||||
auto json_guide = TRY(json_guides.add_object());
|
||||
TRY(json_guide.add("offset"sv, (double)guide.offset()));
|
||||
if (guide.orientation() == Guide::Orientation::Vertical)
|
||||
TRY(json_guide.add("offset"sv, (double)guide->offset()));
|
||||
if (guide->orientation() == Guide::Orientation::Vertical)
|
||||
TRY(json_guide.add("orientation"sv, "vertical"));
|
||||
else if (guide.orientation() == Guide::Orientation::Horizontal)
|
||||
else if (guide->orientation() == Guide::Orientation::Horizontal)
|
||||
TRY(json_guide.add("orientation"sv, "horizontal"));
|
||||
TRY(json_guide.finish());
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
void save_project_as();
|
||||
void save_project();
|
||||
|
||||
NonnullRefPtrVector<Guide> const& guides() const { return m_guides; }
|
||||
Vector<NonnullRefPtr<Guide>> const& guides() const { return m_guides; }
|
||||
bool guide_visibility() { return m_show_guides; }
|
||||
void set_guide_visibility(bool show_guides);
|
||||
Function<void(bool)> on_set_guide_visibility;
|
||||
|
@ -168,7 +168,7 @@ private:
|
|||
DeprecatedString m_path;
|
||||
DeprecatedString m_title;
|
||||
|
||||
NonnullRefPtrVector<Guide> m_guides;
|
||||
Vector<NonnullRefPtr<Guide>> m_guides;
|
||||
bool m_show_guides { true };
|
||||
bool m_show_rulers { true };
|
||||
bool m_show_pixel_grid { true };
|
||||
|
|
|
@ -24,15 +24,15 @@ RefPtr<Guide> GuideTool::closest_guide(Gfx::IntPoint point)
|
|||
|
||||
for (auto& guide : guides) {
|
||||
int relevant_position = 0;
|
||||
if (guide.orientation() == Guide::Orientation::Horizontal)
|
||||
if (guide->orientation() == Guide::Orientation::Horizontal)
|
||||
relevant_position = point.y();
|
||||
else if (guide.orientation() == Guide::Orientation::Vertical)
|
||||
else if (guide->orientation() == Guide::Orientation::Vertical)
|
||||
relevant_position = point.x();
|
||||
|
||||
auto distance = abs(relevant_position - (int)guide.offset());
|
||||
auto distance = abs(relevant_position - (int)guide->offset());
|
||||
|
||||
if (distance < closest_guide_distance) {
|
||||
closest_guide = &guide;
|
||||
closest_guide = guide;
|
||||
closest_guide_distance = distance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ void TextToolEditor::handle_keyevent(Badge<TextTool>, GUI::KeyEvent& event)
|
|||
TextEditor::keydown_event(event);
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<GUI::Action> TextToolEditor::actions()
|
||||
Vector<NonnullRefPtr<GUI::Action>> TextToolEditor::actions()
|
||||
{
|
||||
static NonnullRefPtrVector<GUI::Action> actions = { cut_action(), copy_action(), paste_action(), undo_action(), redo_action(), select_all_action() };
|
||||
static Vector<NonnullRefPtr<GUI::Action>> actions = { cut_action(), copy_action(), paste_action(), undo_action(), redo_action(), select_all_action() };
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
@ -290,9 +290,9 @@ bool TextTool::on_keydown(GUI::KeyEvent& event)
|
|||
|
||||
// Pass key events that would normally be handled by menu shortcuts to our TextEditor subclass.
|
||||
for (auto& action : m_text_editor->actions()) {
|
||||
auto const& shortcut = action.shortcut();
|
||||
auto const& shortcut = action->shortcut();
|
||||
if (event.key() == shortcut.key() && event.modifiers() == shortcut.modifiers()) {
|
||||
action.activate(m_text_editor);
|
||||
action->activate(m_text_editor);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class TextToolEditor : public GUI::TextEditor {
|
|||
public:
|
||||
virtual ~TextToolEditor() override = default;
|
||||
virtual void handle_keyevent(Badge<TextTool>, GUI::KeyEvent&);
|
||||
NonnullRefPtrVector<GUI::Action> actions();
|
||||
Vector<NonnullRefPtr<GUI::Action>> actions();
|
||||
|
||||
protected:
|
||||
TextToolEditor();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "Presentation.h"
|
||||
#include <AK/JsonObject.h>
|
||||
|
||||
Slide::Slide(NonnullRefPtrVector<SlideObject> slide_objects, DeprecatedString title)
|
||||
Slide::Slide(Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title)
|
||||
: m_slide_objects(move(slide_objects))
|
||||
, m_title(move(title))
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ ErrorOr<Slide> Slide::parse_slide(JsonObject const& slide_json)
|
|||
return Error::from_string_view("Slide objects must be an array"sv);
|
||||
|
||||
auto const& json_slide_objects = maybe_slide_objects.value();
|
||||
NonnullRefPtrVector<SlideObject> slide_objects;
|
||||
Vector<NonnullRefPtr<SlideObject>> slide_objects;
|
||||
for (auto const& maybe_slide_object_json : json_slide_objects.values()) {
|
||||
if (!maybe_slide_object_json.is_object())
|
||||
return Error::from_string_view("Slides must be objects"sv);
|
||||
|
@ -43,6 +43,6 @@ ErrorOr<HTMLElement> Slide::render(Presentation const& presentation) const
|
|||
HTMLElement wrapper;
|
||||
wrapper.tag_name = "div"sv;
|
||||
for (auto const& object : m_slide_objects)
|
||||
TRY(wrapper.children.try_append(TRY(object.render(presentation))));
|
||||
TRY(wrapper.children.try_append(TRY(object->render(presentation))));
|
||||
return wrapper;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ public:
|
|||
ErrorOr<HTMLElement> render(Presentation const&) const;
|
||||
|
||||
private:
|
||||
Slide(NonnullRefPtrVector<SlideObject> slide_objects, DeprecatedString title);
|
||||
Slide(Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title);
|
||||
|
||||
NonnullRefPtrVector<SlideObject> m_slide_objects;
|
||||
Vector<NonnullRefPtr<SlideObject>> m_slide_objects;
|
||||
DeprecatedString m_title;
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
ConditionsView();
|
||||
|
||||
Vector<ConditionalFormat>* m_formats { nullptr };
|
||||
NonnullRefPtrVector<GUI::Widget> m_widgets;
|
||||
Vector<NonnullRefPtr<GUI::Widget>> m_widgets;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::File& file,
|
|||
auto export_worksheet = [&]() -> ErrorOr<void> {
|
||||
JsonArray array;
|
||||
for (auto& sheet : workbook.sheets())
|
||||
array.append(sheet.to_json());
|
||||
array.append(sheet->to_json());
|
||||
|
||||
auto file_content = array.to_deprecated_string();
|
||||
return file.write_entire_buffer(file_content.bytes());
|
||||
|
|
|
@ -112,7 +112,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
|
|||
window->set_title(DeprecatedString::formatted("Spreadsheet Help - Example {} for {}", name, entry));
|
||||
window->on_close = [window = window.ptr()] { window->remove_from_parent(); };
|
||||
|
||||
auto widget = window->set_main_widget<SpreadsheetWidget>(window, NonnullRefPtrVector<Sheet> {}, false).release_value_but_fixme_should_propagate_errors();
|
||||
auto widget = window->set_main_widget<SpreadsheetWidget>(window, Vector<NonnullRefPtr<Sheet>> {}, false).release_value_but_fixme_should_propagate_errors();
|
||||
auto sheet = Sheet::from_json(value, widget->workbook());
|
||||
if (!sheet) {
|
||||
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, url.path()));
|
||||
|
|
|
@ -174,13 +174,13 @@ void CSVImportDialogPage::update_preview()
|
|||
m_data_preview_table_view->update();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook)
|
||||
ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook)
|
||||
{
|
||||
auto wizard = GUI::WizardDialog::construct(&parent);
|
||||
wizard->set_title("File Import Wizard");
|
||||
wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16));
|
||||
|
||||
auto import_xsv = [&]() -> ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> {
|
||||
auto import_xsv = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> {
|
||||
auto contents_or_error = file.read_until_eof();
|
||||
if (contents_or_error.is_error())
|
||||
return DeprecatedString::formatted("{}", contents_or_error.release_error());
|
||||
|
@ -191,7 +191,7 @@ ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run
|
|||
if (result == GUI::Dialog::ExecResult::OK) {
|
||||
auto& reader = page.reader();
|
||||
|
||||
NonnullRefPtrVector<Sheet> sheets;
|
||||
Vector<NonnullRefPtr<Sheet>> sheets;
|
||||
|
||||
if (reader.has_value()) {
|
||||
reader->parse();
|
||||
|
@ -209,7 +209,7 @@ ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run
|
|||
return DeprecatedString { "CSV Import was cancelled" };
|
||||
};
|
||||
|
||||
auto import_worksheet = [&]() -> ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> {
|
||||
auto import_worksheet = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> {
|
||||
auto contents_or_error = file.read_until_eof();
|
||||
if (contents_or_error.is_error())
|
||||
return DeprecatedString::formatted("{}", contents_or_error.release_error());
|
||||
|
@ -221,7 +221,7 @@ ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run
|
|||
if (!json_value.is_array())
|
||||
return DeprecatedString::formatted("Did not find a spreadsheet in {}", filename);
|
||||
|
||||
NonnullRefPtrVector<Sheet> sheets;
|
||||
Vector<NonnullRefPtr<Sheet>> sheets;
|
||||
|
||||
auto& json_array = json_value.as_array();
|
||||
json_array.for_each([&](auto& sheet_json) {
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
};
|
||||
|
||||
struct ImportDialog {
|
||||
static ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&);
|
||||
static ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -390,7 +390,7 @@ void WorkbookObject::visit_edges(Visitor& visitor)
|
|||
{
|
||||
Base::visit_edges(visitor);
|
||||
for (auto& sheet : m_workbook.sheets())
|
||||
visitor.visit(&sheet.global_object());
|
||||
visitor.visit(&sheet->global_object());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet)
|
||||
|
@ -411,13 +411,13 @@ JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet)
|
|||
if (name_value.is_string()) {
|
||||
auto name = TRY(name_value.as_string().deprecated_string());
|
||||
for (auto& sheet : workbook.sheets()) {
|
||||
if (sheet.name() == name)
|
||||
return JS::Value(&sheet.global_object());
|
||||
if (sheet->name() == name)
|
||||
return JS::Value(&sheet->global_object());
|
||||
}
|
||||
} else {
|
||||
auto index = TRY(name_value.to_length(vm));
|
||||
if (index < workbook.sheets().size())
|
||||
return JS::Value(&workbook.sheets()[index].global_object());
|
||||
return JS::Value(&workbook.sheets()[index]->global_object());
|
||||
}
|
||||
|
||||
return JS::js_undefined();
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVector<Sheet>&& sheets, bool should_add_sheet_if_empty)
|
||||
SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullRefPtr<Sheet>>&& sheets, bool should_add_sheet_if_empty)
|
||||
: m_workbook(make<Workbook>(move(sheets), parent_window))
|
||||
{
|
||||
set_fill_with_background_color(true);
|
||||
|
@ -111,7 +111,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
|
|||
m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::load_from_file("/res/icons/16x16/new-tab.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
|
||||
DeprecatedString name;
|
||||
if (GUI::InputBox::show(window(), name, "Name for new sheet"sv, "Create sheet"sv) == GUI::Dialog::ExecResult::OK) {
|
||||
NonnullRefPtrVector<Sheet> new_sheets;
|
||||
Vector<NonnullRefPtr<Sheet>> new_sheets;
|
||||
new_sheets.append(m_workbook->add_sheet(name));
|
||||
setup_tabs(move(new_sheets));
|
||||
}
|
||||
|
@ -330,10 +330,10 @@ void SpreadsheetWidget::clipboard_content_did_change(DeprecatedString const& mim
|
|||
m_paste_action->set_enabled(!sheet->selected_cells().is_empty() && mime_type.starts_with("text/"sv));
|
||||
}
|
||||
|
||||
void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
||||
void SpreadsheetWidget::setup_tabs(Vector<NonnullRefPtr<Sheet>> new_sheets)
|
||||
{
|
||||
for (auto& sheet : new_sheets) {
|
||||
auto& new_view = m_tab_widget->add_tab<SpreadsheetView>(sheet.name(), sheet);
|
||||
auto& new_view = m_tab_widget->add_tab<SpreadsheetView>(sheet->name(), sheet);
|
||||
new_view.model()->on_cell_data_change = [&](auto& cell, auto& previous_data) {
|
||||
undo_stack().push(make<CellsUndoCommand>(cell, previous_data));
|
||||
window()->set_modified(true);
|
||||
|
@ -570,7 +570,7 @@ void SpreadsheetWidget::add_sheet()
|
|||
name.append("Sheet"sv);
|
||||
name.appendff(" {}", m_workbook->sheets().size() + 1);
|
||||
|
||||
NonnullRefPtrVector<Sheet> new_sheets;
|
||||
Vector<NonnullRefPtr<Sheet>> new_sheets;
|
||||
new_sheets.append(m_workbook->add_sheet(name.string_view()));
|
||||
setup_tabs(move(new_sheets));
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ void SpreadsheetWidget::add_sheet(NonnullRefPtr<Sheet>&& sheet)
|
|||
{
|
||||
VERIFY(m_workbook == &sheet->workbook());
|
||||
|
||||
NonnullRefPtrVector<Sheet> new_sheets;
|
||||
Vector<NonnullRefPtr<Sheet>> new_sheets;
|
||||
new_sheets.append(move(sheet));
|
||||
m_workbook->sheets().extend(new_sheets);
|
||||
setup_tabs(new_sheets);
|
||||
|
|
|
@ -60,9 +60,9 @@ private:
|
|||
// ^GUI::Clipboard::ClipboardClient
|
||||
virtual void clipboard_content_did_change(DeprecatedString const& mime_type) override;
|
||||
|
||||
explicit SpreadsheetWidget(GUI::Window& window, NonnullRefPtrVector<Sheet>&& sheets = {}, bool should_add_sheet_if_empty = true);
|
||||
explicit SpreadsheetWidget(GUI::Window& window, Vector<NonnullRefPtr<Sheet>>&& sheets = {}, bool should_add_sheet_if_empty = true);
|
||||
|
||||
void setup_tabs(NonnullRefPtrVector<Sheet> new_sheets);
|
||||
void setup_tabs(Vector<NonnullRefPtr<Sheet>> new_sheets);
|
||||
|
||||
void try_generate_tip_for_input_expression(StringView source, size_t offset);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace Spreadsheet {
|
||||
|
||||
Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_window)
|
||||
Workbook::Workbook(Vector<NonnullRefPtr<Sheet>>&& sheets, GUI::Window& parent_window)
|
||||
: m_sheets(move(sheets))
|
||||
, m_vm(JS::VM::create())
|
||||
, m_interpreter(JS::Interpreter::create<JS::GlobalObject>(m_vm))
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Spreadsheet {
|
|||
|
||||
class Workbook {
|
||||
public:
|
||||
Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_window);
|
||||
Workbook(Vector<NonnullRefPtr<Sheet>>&& sheets, GUI::Window& parent_window);
|
||||
|
||||
ErrorOr<void, DeprecatedString> open_file(String const& filename, Core::File&);
|
||||
ErrorOr<void> write_to_file(String const& filename, Core::File&);
|
||||
|
@ -28,8 +28,8 @@ public:
|
|||
|
||||
bool has_sheets() const { return !m_sheets.is_empty(); }
|
||||
|
||||
NonnullRefPtrVector<Sheet> const& sheets() const { return m_sheets; }
|
||||
NonnullRefPtrVector<Sheet> sheets() { return m_sheets; }
|
||||
Vector<NonnullRefPtr<Sheet>> const& sheets() const { return m_sheets; }
|
||||
Vector<NonnullRefPtr<Sheet>> sheets() { return m_sheets; }
|
||||
|
||||
Sheet& add_sheet(StringView name)
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
JS::VM const& vm() const { return *m_vm; }
|
||||
|
||||
private:
|
||||
NonnullRefPtrVector<Sheet> m_sheets;
|
||||
Vector<NonnullRefPtr<Sheet>> m_sheets;
|
||||
NonnullRefPtr<JS::VM> m_vm;
|
||||
NonnullOwnPtr<JS::Interpreter> m_interpreter;
|
||||
JS::VM::InterpreterExecutionScope m_interpreter_scope;
|
||||
|
|
|
@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->resize(640, 480);
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
||||
auto spreadsheet_widget = TRY(window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, NonnullRefPtrVector<Spreadsheet::Sheet> {}, filename.is_empty()));
|
||||
auto spreadsheet_widget = TRY(window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, Vector<NonnullRefPtr<Spreadsheet::Sheet>> {}, filename.is_empty()));
|
||||
|
||||
spreadsheet_widget->initialize_menubar(*window);
|
||||
spreadsheet_widget->update_window_title();
|
||||
|
|
|
@ -497,7 +497,7 @@ void ProcessModel::update()
|
|||
thread_data->previous_state = move(thread_data->current_state);
|
||||
thread_data->current_state = move(state);
|
||||
if (auto maybe_thread_index = (*process_state)->threads.find_first_index(thread_data); maybe_thread_index.has_value()) {
|
||||
(*process_state)->threads.ptr_at(maybe_thread_index.value()) = thread_data;
|
||||
(*process_state)->threads[maybe_thread_index.value()] = thread_data;
|
||||
} else {
|
||||
(*process_state)->threads.append(thread_data);
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ private:
|
|||
|
||||
struct Process {
|
||||
pid_t pid;
|
||||
NonnullRefPtrVector<Thread> threads;
|
||||
Vector<NonnullRefPtr<Thread>> threads;
|
||||
|
||||
bool operator==(Process const& other) const
|
||||
{
|
||||
|
@ -224,7 +224,7 @@ private:
|
|||
{
|
||||
auto main_thread_index = -1;
|
||||
for (size_t i = 0; i < threads.size(); ++i) {
|
||||
if (threads[i].is_main_thread()) {
|
||||
if (threads[i]->is_main_thread()) {
|
||||
main_thread_index = static_cast<int>(i);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue