Let search results be dragged onto a folio like the tree

While a collection search is active the tree is replaced by the flat
ranked list, and that list had no drag support: dragging a result only
moved the selection. Anyone used to searching and then dragging lost the
drag as soon as they typed.

The tree's drag is moved into a static ElementsTreeView::execElementDrag()
taking the source widget, and the results list uses it from the path each
row already carries, so the drag content and pixmap are the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG
This commit is contained in:
ispyisail
2026-09-27 01:56:46 +12:00
parent db387525e2
commit 926bbcf75f
3 changed files with 47 additions and 4 deletions
@@ -82,13 +82,27 @@ void ElementsTreeView::startDrag(Qt::DropActions supportedActions)
@param location : location to use for create the content of the QDrag
*/
void ElementsTreeView::startElementDrag(const ElementsLocation &location)
{
execElementDrag(this, location);
}
/**
@brief ElementsTreeView::execElementDrag
Build and run the QDrag for @a location, from @a source.
Static so that a view which is not an ElementsTreeView -- the flat list
of search results -- starts exactly the same drag as the tree.
@param source : the widget the drag starts from
@param location : location to use for create the content of the QDrag
*/
void ElementsTreeView::execElementDrag(QWidget *source,
const ElementsLocation &location)
{
if (! location.exist()) return;
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
QDrag* drag = new QDrag(this);
QDrag* drag = new QDrag(source);
#else
QScopedPointer<QDrag> drag(new QDrag(this));
QScopedPointer<QDrag> drag(new QDrag(source));
#endif
QString location_str = location.toString();
@@ -209,7 +223,7 @@ void ElementsTreeView::startElementDrag(const ElementsLocation &location)
&elmt_creation_state));
if (elmt_creation_state) { return; }
QPixmap elmt_pixmap(QET::Palette::forPalette(temp_elmt->pixmap(), palette()));
QPixmap elmt_pixmap(QET::Palette::forPalette(temp_elmt->pixmap(), source->palette()));
QPoint elmt_hotspot(temp_elmt->hotspot());
//Adjust the size of the pixmap if he is too big