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.
User avatar
bernd
Posts: 8472
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

drag and drop in tree view drag does not work

Postby bernd » Wed Jul 10, 2019 10:04 pm

- 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 5 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
Posts: 8472
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

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

Postby bernd » Wed Jul 10, 2019 10:14 pm

- 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
Site Admin
Posts: 14992
Joined: Thu Feb 19, 2009 10:32 am

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

Postby wmayer » Thu Jul 11, 2019 3:39 pm

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
Site Admin
Posts: 14992
Joined: Thu Feb 19, 2009 10:32 am

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

Postby wmayer » Thu Jul 11, 2019 4:03 pm

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
Site Admin
Posts: 14992
Joined: Thu Feb 19, 2009 10:32 am

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

Postby wmayer » Thu Jul 11, 2019 5:09 pm

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

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

Postby bernd » Thu Jul 11, 2019 6:51 pm

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