drag and drop in tree view drag does not work

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

drag and drop in tree view drag does not work

Post by bernd »

- start FreeCAD
- open the attached document
- Drag MeshGroup001 out of FEMMeshGmsh001 and Drop it into FEMMeshGmsh
- Drop does work
- Drag does not work
- The MeshGroup001 is still a member of FEMMeshGmsh001 but it should have been moved

Is there an error in the implementation or this an intended behave?

code: https://github.com/FreeCAD/FreeCAD/blob ... #L173-L240


fem-drag-and-drop.FCStd
(200.25 KiB) Downloaded 13 times


OS: Debian GNU/Linux 10 (buster) (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17331 (Git)
Build type: Unknown
Branch: master
Hash: cf18161dc26267c259ac21675cb9637263bf4152
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Switzerland (de_CH)
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: drag and drop in tree view drag does not work

Post by bernd »

- it works if MeshGroup001 is draged out of FEMMeshGmsh001 into the document first and afterwards dropped into the FEMMeshGmsh

- Is there a preference or something else to move an object instead of just add it tho another ?
wmayer
Founder
Posts: 20300
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: drag and drop in tree view drag does not work

Post by wmayer »

In Qt a QDropEvent provides several kind of drop-actions: https://doc.qt.io/qt-5/qdropevent.html#dropAction

When just dragging an item with the cursor then a Qt::CopyAction is done which as its name says copies an item from one group to another group.
When the type is set to Qt::MoveAction then the item is really moved from one group to the other.

A Qt::MoveAction is set when pressing the Shift key while starting the drag/drop. But I don't know where this behaviour is implemented -- I assume it's Qt but don't know for sure.
wmayer
Founder
Posts: 20300
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: drag and drop in tree view drag does not work

Post by wmayer »

I have created a QTreeWidget inside QtDesigner and enabled its acceptDrops property and set dragDropMode to DragDrop.

Now when dragging items around it copies them and when pressing the Shift key the items are moved. So, the behaviour is done by Qt.
However, there is also the property defaultDropAction that can be set to MoveAction and then by default items are moved when dragging/dropping them and you have to press the Ctrl key to copy them.
wmayer
Founder
Posts: 20300
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: drag and drop in tree view drag does not work

Post by wmayer »

git commit 747a2823e I guess MoveAction is the more intuitive behaviour.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: drag and drop in tree view drag does not work

Post by bernd »

wmayer wrote: Thu Jul 11, 2019 4:03 pm press the Ctrl key to copy them.
good to know and works great here


wmayer wrote: Thu Jul 11, 2019 5:09 pm git commit 747a2823e I guess MoveAction is the more intuitive behaviour.
+1
Post Reply