Userland: Port lists of mime types to String

This commit is contained in:
Karol Kosek 2023-08-23 14:41:26 +02:00 committed by Sam Atkins
parent e75d694974
commit 9ce2682ce6
15 changed files with 18 additions and 26 deletions

View file

@ -11,15 +11,6 @@
namespace Core {
Vector<DeprecatedString> MimeData::formats() const
{
Vector<DeprecatedString> mime_types;
mime_types.ensure_capacity(m_data.size());
for (auto& it : m_data)
mime_types.unchecked_append(it.key.to_deprecated_string());
return mime_types;
}
Vector<URL> MimeData::urls() const
{
auto it = m_data.find("text/uri-list"sv);

View file

@ -24,7 +24,7 @@ public:
void set_data(String const& mime_type, ByteBuffer&& data) { m_data.set(mime_type, move(data)); }
bool has_format(StringView mime_type) const { return m_data.contains(mime_type); }
Vector<DeprecatedString> formats() const;
Vector<String> formats() const { return m_data.keys(); }
// Convenience helpers for "text/plain"
bool has_text() const { return has_format("text/plain"sv); }

View file

@ -283,7 +283,7 @@ void Application::set_pending_drop_widget(Widget* widget)
m_pending_drop_widget->update();
}
void Application::set_drag_hovered_widget_impl(Widget* widget, Gfx::IntPoint position, Vector<DeprecatedString> mime_types)
void Application::set_drag_hovered_widget_impl(Widget* widget, Gfx::IntPoint position, Vector<String> mime_types)
{
if (widget == m_drag_hovered_widget)
return;

View file

@ -78,7 +78,7 @@ public:
Widget* pending_drop_widget() { return m_pending_drop_widget.ptr(); }
Widget const* pending_drop_widget() const { return m_pending_drop_widget.ptr(); }
void set_drag_hovered_widget(Badge<Window>, Widget* widget, Gfx::IntPoint position = {}, Vector<DeprecatedString> mime_types = {})
void set_drag_hovered_widget(Badge<Window>, Widget* widget, Gfx::IntPoint position = {}, Vector<String> mime_types = {})
{
set_drag_hovered_widget_impl(widget, position, move(mime_types));
}
@ -106,7 +106,7 @@ private:
void request_tooltip_show();
void tooltip_hide_timer_did_fire();
void set_drag_hovered_widget_impl(Widget*, Gfx::IntPoint = {}, Vector<DeprecatedString> = {});
void set_drag_hovered_widget_impl(Widget*, Gfx::IntPoint = {}, Vector<String> = {});
void set_pending_drop_widget(Widget*);
OwnPtr<Core::EventLoop> m_event_loop;

View file

@ -259,7 +259,7 @@ void ConnectionToWindowServer::mouse_up(i32 window_id, Gfx::IntPoint mouse_posit
Core::EventLoop::current().post_event(*window, make<MouseEvent>(Event::MouseUp, mouse_position, buttons, to_mouse_button(button), modifiers, wheel_delta_x, wheel_delta_y, wheel_raw_delta_x, wheel_raw_delta_y));
}
void ConnectionToWindowServer::mouse_move(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, i32 wheel_raw_delta_x, i32 wheel_raw_delta_y, bool is_drag, Vector<DeprecatedString> const& mime_types)
void ConnectionToWindowServer::mouse_move(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, i32 wheel_raw_delta_x, i32 wheel_raw_delta_y, bool is_drag, Vector<String> const& mime_types)
{
if (auto* window = Window::from_window_id(window_id)) {
if (is_drag)

View file

@ -26,7 +26,7 @@ private:
virtual void fast_greet(Vector<Gfx::IntRect> const&, u32, u32, u32, Core::AnonymousBuffer const&, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, Vector<bool> const&, i32) override;
virtual void paint(i32, Gfx::IntSize, Vector<Gfx::IntRect> const&) override;
virtual void mouse_move(i32, Gfx::IntPoint, u32, u32, u32, i32, i32, i32, i32, bool, Vector<DeprecatedString> const&) override;
virtual void mouse_move(i32, Gfx::IntPoint, u32, u32, u32, i32, i32, i32, i32, bool, Vector<String> const&) override;
virtual void mouse_down(i32, Gfx::IntPoint, u32, u32, u32, i32, i32, i32, i32) override;
virtual void mouse_double_click(i32, Gfx::IntPoint, u32, u32, u32, i32, i32, i32, i32) override;
virtual void mouse_up(i32, Gfx::IntPoint, u32, u32, u32, i32, i32, i32, i32) override;

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <Kernel/API/KeyCode.h>
@ -460,7 +461,7 @@ private:
class DragEvent final : public Event {
public:
DragEvent(Type type, Gfx::IntPoint position, Vector<DeprecatedString> mime_types)
DragEvent(Type type, Gfx::IntPoint position, Vector<String> mime_types)
: Event(type)
, m_position(position)
, m_mime_types(move(mime_types))
@ -468,11 +469,11 @@ public:
}
Gfx::IntPoint position() const { return m_position; }
Vector<DeprecatedString> const& mime_types() const { return m_mime_types; }
Vector<String> const& mime_types() const { return m_mime_types; }
private:
Gfx::IntPoint m_position;
Vector<DeprecatedString> m_mime_types;
Vector<String> m_mime_types;
};
class DropEvent final : public Event {

View file

@ -787,7 +787,7 @@ ErrorOr<String> FileSystemModel::column_name(int column) const
VERIFY_NOT_REACHED();
}
bool FileSystemModel::accepts_drag(ModelIndex const& index, Vector<DeprecatedString> const& mime_types) const
bool FileSystemModel::accepts_drag(ModelIndex const& index, Vector<String> const& mime_types) const
{
if (!mime_types.contains_slow("text/uri-list"sv))
return false;

View file

@ -132,7 +132,7 @@ public:
virtual ModelIndex parent_index(ModelIndex const&) const override;
virtual ModelIndex index(int row, int column = 0, ModelIndex const& parent = ModelIndex()) const override;
virtual StringView drag_data_type() const override { return "text/uri-list"sv; }
virtual bool accepts_drag(ModelIndex const&, Vector<DeprecatedString> const& mime_types) const override;
virtual bool accepts_drag(ModelIndex const&, Vector<String> const& mime_types) const override;
virtual bool is_column_sortable(int column_index) const override { return column_index != Column::Icon; }
virtual bool is_editable(ModelIndex const&) const override;
virtual bool is_searchable() const override { return true; }

View file

@ -63,7 +63,7 @@ ModelIndex Model::index(int row, int column, ModelIndex const&) const
return create_index(row, column);
}
bool Model::accepts_drag(ModelIndex const&, Vector<DeprecatedString> const&) const
bool Model::accepts_drag(ModelIndex const&, Vector<String> const&) const
{
return false;
}

View file

@ -81,7 +81,7 @@ public:
virtual bool is_searchable() const { return false; }
virtual void set_data(ModelIndex const&, Variant const&) { }
virtual int tree_column() const { return 0; }
virtual bool accepts_drag(ModelIndex const&, Vector<DeprecatedString> const& mime_types) const;
virtual bool accepts_drag(ModelIndex const&, Vector<String> const& mime_types) const;
virtual Vector<ModelIndex> matches(StringView, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) { return {}; }
virtual bool is_column_sortable([[maybe_unused]] int column_index) const { return true; }

View file

@ -49,7 +49,7 @@ void SortingProxyModel::model_did_update(unsigned flags)
update_sort(flags);
}
bool SortingProxyModel::accepts_drag(ModelIndex const& proxy_index, Vector<DeprecatedString> const& mime_types) const
bool SortingProxyModel::accepts_drag(ModelIndex const& proxy_index, Vector<String> const& mime_types) const
{
return source().accepts_drag(map_to_source(proxy_index), mime_types);
}

View file

@ -34,7 +34,7 @@ public:
virtual bool is_searchable() const override;
virtual void set_data(ModelIndex const&, Variant const&) override;
virtual Vector<ModelIndex> matches(StringView, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) override;
virtual bool accepts_drag(ModelIndex const&, Vector<DeprecatedString> const& mime_types) const override;
virtual bool accepts_drag(ModelIndex const&, Vector<String> const& mime_types) const override;
virtual bool is_column_sortable(int column_index) const override;

View file

@ -114,7 +114,7 @@ public:
int wheel_raw_delta_y() const { return m_wheel_raw_delta_y; }
bool is_drag() const { return m_drag; }
Vector<DeprecatedString> mime_types() const
Vector<String> mime_types() const
{
if (!m_mime_data)
return {};

View file

@ -6,7 +6,7 @@ endpoint WindowClient
fast_greet(Vector<Gfx::IntRect> screen_rects, u32 main_screen_index, u32 workspace_rows, u32 workspace_columns, Core::AnonymousBuffer theme_buffer, DeprecatedString default_font_query, DeprecatedString fixed_width_font_query, DeprecatedString window_title_font_query, Vector<bool> effects, i32 client_id) =|
paint(i32 window_id, Gfx::IntSize window_size, Vector<Gfx::IntRect> rects) =|
mouse_move(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, i32 wheel_raw_delta_x, i32 wheel_raw_delta_y, bool is_drag, Vector<DeprecatedString> mime_types) =|
mouse_move(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, i32 wheel_raw_delta_x, i32 wheel_raw_delta_y, bool is_drag, Vector<String> mime_types) =|
mouse_down(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, i32 wheel_raw_delta_x, i32 wheel_raw_delta_y) =|
mouse_double_click(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, i32 wheel_raw_delta_x, i32 wheel_raw_delta_y) =|
mouse_up(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, i32 wheel_raw_delta_x, i32 wheel_raw_delta_y) =|