mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibGUI: Have FileSystemModel accept url-list drags onto directories
This commit is contained in:
parent
6e7ca44dee
commit
8b3864c70a
Notes:
sideshowbarker
2024-07-19 09:21:36 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8b3864c70aa
2 changed files with 12 additions and 1 deletions
|
@ -27,9 +27,9 @@
|
|||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGUI/FileSystemModel.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibThread/BackgroundAction.h>
|
||||
#include <dirent.h>
|
||||
#include <grp.h>
|
||||
|
@ -557,4 +557,14 @@ Model::ColumnMetadata FileSystemModel::column_metadata(int column) const
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool FileSystemModel::accepts_drag(const ModelIndex& index, const StringView& data_type)
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return false;
|
||||
if (data_type != "url-list")
|
||||
return false;
|
||||
auto& node = this->node(index);
|
||||
return node.is_directory();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -124,6 +124,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 "url-list"; }
|
||||
virtual bool accepts_drag(const ModelIndex&, const StringView& data_type) override;
|
||||
|
||||
static String timestamp_string(time_t timestamp)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue