mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
Userland: Port lists of mime types to String
This commit is contained in:
parent
e75d694974
commit
9ce2682ce6
15 changed files with 18 additions and 26 deletions
|
@ -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);
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 {};
|
||||
|
|
|
@ -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) =|
|
||||
|
|
Loading…
Add table
Reference in a new issue