From 8b89f9f49d6e46e07c2f79bfa4b97ca8476bfc04 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Mon, 28 Dec 2020 18:04:18 +0100 Subject: Better drag handling. --- src/modlistsortproxy.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/modlistsortproxy.cpp') diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index e86c6f34..cf82ca74 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -618,6 +618,26 @@ bool ModListSortProxy::filterAcceptsRow(int row, const QModelIndex &parent) cons } } +bool ModListSortProxy::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) const +{ + if (!data->hasUrls() && sortColumn() != ModList::COL_PRIORITY) { + return false; + } + + // disable drop install with group proxy, except the one for collapsible separator + // - it would be nice to be able to "install to category" or something like that but + // it's a bit more complicated since the drop position is based on the category, so + // just disabling for now + if (data->hasText() && data->text() == "archive") { + // maybe there is a cleaner way? + if (qobject_cast(sourceModel())) { + return false; + } + } + + return QSortFilterProxyModel::canDropMimeData(data, action, row, column, parent); +} + bool ModListSortProxy::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { -- cgit v1.3.1