@@ -280,13 +280,20 @@ QgsDockBrowserTreeView::QgsDockBrowserTreeView( QWidget *parent ) : QgsBrowserTr
280280
281281}
282282
283- void QgsDockBrowserTreeView::dragEnterEvent ( QDragEnterEvent *e )
283+ void QgsDockBrowserTreeView::setAction ( QDropEvent *e )
284284{
285285 // if this mime data come from layer tree, the proposed action will be MoveAction
286286 // but for browser we really need CopyAction
287287 if ( e->mimeData ()->hasFormat ( QStringLiteral ( " application/qgis.layertreemodeldata" ) ) &&
288288 e->mimeData ()->hasFormat ( QStringLiteral ( " application/x-vnd.qgis.qgis.uri" ) ) )
289+ {
289290 e->setDropAction ( Qt::CopyAction );
291+ }
292+ }
293+
294+ void QgsDockBrowserTreeView::dragEnterEvent ( QDragEnterEvent *e )
295+ {
296+ setAction ( e );
290297
291298 // accept drag enter so that our widget will not get ignored
292299 // and drag events will not get passed to QgisApp
@@ -303,13 +310,10 @@ void QgsDockBrowserTreeView::dragMoveEvent( QDragMoveEvent *e )
303310 return;
304311 }*/
305312
306- // if this mime data come from layer tree, the proposed action will be MoveAction
307- // but for browser we really need CopyAction
308- if ( e->mimeData ()->hasFormat ( QStringLiteral ( " application/qgis.layertreemodeldata" ) ) &&
309- e->mimeData ()->hasFormat ( QStringLiteral ( " application/x-vnd.qgis.qgis.uri" ) ) )
310- e->setDropAction ( Qt::CopyAction );
311-
313+ setAction ( e );
312314 QTreeView::dragMoveEvent ( e );
315+ // reset action because QTreeView::dragMoveEvent() accepts proposed action
316+ setAction ( e );
313317
314318 if ( !e->mimeData ()->hasFormat ( QStringLiteral ( " application/x-vnd.qgis.qgis.uri" ) ) )
315319 {
@@ -320,16 +324,12 @@ void QgsDockBrowserTreeView::dragMoveEvent( QDragMoveEvent *e )
320324
321325void QgsDockBrowserTreeView::dropEvent ( QDropEvent *e )
322326{
323- // if this mime data come from layer tree, the proposed action will be MoveAction
324- // but for browser we really need CopyAction
325- if ( e->mimeData ()->hasFormat ( QStringLiteral ( " application/qgis.layertreemodeldata" ) ) &&
326- e->mimeData ()->hasFormat ( QStringLiteral ( " application/x-vnd.qgis.qgis.uri" ) ) )
327- e->setDropAction ( Qt::CopyAction );
328-
327+ setAction ( e );
329328 QTreeView::dropEvent ( e );
329+ // reset action because QTreeView::dropEvent() accepts proposed action
330+ setAction ( e );
330331}
331332
332-
333333//
334334// QgsBrowserTreeFilterProxyModel
335335//
0 commit comments