1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibGUI: Make SortingProxyModel proxy accepts_drag()

This commit is contained in:
Andreas Kling 2021-01-09 11:35:42 +01:00
parent 12d0d12a78
commit 7baaa34490
6 changed files with 11 additions and 5 deletions

View file

@ -589,7 +589,7 @@ String FileSystemModel::column_name(int column) const
ASSERT_NOT_REACHED();
}
bool FileSystemModel::accepts_drag(const ModelIndex& index, const Vector<String>& mime_types)
bool FileSystemModel::accepts_drag(const ModelIndex& index, const Vector<String>& mime_types) const
{
if (!index.is_valid())
return false;

View file

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

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -71,7 +71,7 @@ ModelIndex Model::index(int row, int column, const ModelIndex&) const
return create_index(row, column);
}
bool Model::accepts_drag(const ModelIndex&, const Vector<String>&)
bool Model::accepts_drag(const ModelIndex&, const Vector<String>&) const
{
return false;
}

View file

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

View file

@ -63,6 +63,11 @@ void SortingProxyModel::model_did_update(unsigned flags)
invalidate(flags);
}
bool SortingProxyModel::accepts_drag(const ModelIndex& proxy_index, const Vector<String>& mime_types) const
{
return source().accepts_drag(map_to_source(proxy_index), mime_types);
}
int SortingProxyModel::row_count(const ModelIndex& proxy_index) const
{
return source().row_count(map_to_source(proxy_index));

View file

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