summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-13 21:46:52 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-13 21:48:32 +0100
commit8b3864c70aafc7247a74ad629ac8ca792c0e0f22 (patch)
tree81cb68540c3a8793791677bb23b6b627dfc2c60a
parent6e7ca44dee53cc7f972f84b93dedf7aa8ac6e56a (diff)
downloadserenity-8b3864c70aafc7247a74ad629ac8ca792c0e0f22.zip
LibGUI: Have FileSystemModel accept url-list drags onto directories
-rw-r--r--Libraries/LibGUI/FileSystemModel.cpp12
-rw-r--r--Libraries/LibGUI/FileSystemModel.h1
2 files changed, 12 insertions, 1 deletions
diff --git a/Libraries/LibGUI/FileSystemModel.cpp b/Libraries/LibGUI/FileSystemModel.cpp
index c14e51e498..ea7a12ffd9 100644
--- a/Libraries/LibGUI/FileSystemModel.cpp
+++ b/Libraries/LibGUI/FileSystemModel.cpp
@@ -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();
+}
+
}
diff --git a/Libraries/LibGUI/FileSystemModel.h b/Libraries/LibGUI/FileSystemModel.h
index 02bc652075..83c9d39aed 100644
--- a/Libraries/LibGUI/FileSystemModel.h
+++ b/Libraries/LibGUI/FileSystemModel.h
@@ -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)
{