[Implemented] Ticket #3923 - change order in tree view

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
tpavlicek
Posts: 60
Joined: Sun Jan 07, 2018 2:15 am

Re: Ticket #3923 - change order in tree view

Post by tpavlicek »

Hello Adrian,

thank You for Your comments and observations.

adrianinsaval wrote: Wed Mar 17, 2021 5:58 am Shouldn't these commands be added to the context menu? Otherwise I think many people will never know about it. Making it work through drag and drop would be ideal but keyboard shortcuts are a great improvement already.
Well, technically it is not a problem, but I am not sure, if the Tree View context menu would not be too "long" then. Probably I would let others decide that. As for drag and drop, the drag/drop functionality is already used for different purpose and there is no "neutral zone" between sibling tree view items. Thus when dropping, Your are always dropping an item on something, never "in-between", which would be crucial for reordering.

adrianinsaval wrote: Wed Mar 17, 2021 5:58 am There are some issues though, this shouldn't allow reordering elements within a PartDesign container as the order of elements is relevant there, not sure if there are other workbenches were order in the tree is important. I'm also not sure if moving around the origin object inside a part container is a good idea but I guess that doesn't do any harm.
The solution in pull request is very general, implemented on level of tree view items, disregarding any specific requirements. Probably we could add a possibility for classes derived from document object view provider to prevent "shuffling" their children. That would be quite easy.

adrianinsaval wrote: Wed Mar 17, 2021 5:58 am On a different and non critical note about UX, maybe when moving something within a container and reaching the limit the selection shouldn't continue to move past that while pressing alt+arrow. Consider the case were you want to move an item to the top of a container and you press alt+up-arrow many times, by accident you press the arrow key two times more than necessary, now the container has changed it's order and collapsed at the same time, this could be annoying.
Yes, I can see that. The "problem" is in shortcut treatment. I will explain that for "Up" action, but "Down" behaves similarly. If the selected item is a first child, the "Move Up" menu item is disabled, to signal the user it is of no use anymore. This effectively removes the shortcut from the shortcut list and "Alt+Up" is sent directly to the tree view widget. Tree view ignores the "Alt" modifier and processes the key press as simple "Up" key. Basically, I can see two possible solutions right away:

1) A duplicate always present Alt+Up/Down shortcut, forwarding the key presses to (eventually disabled) menu functionality, which decides itself whether or not something is to be done.

or

2) Keep the menu commands always enabled, even if it does nothing, eventually displaying a modal dialog with some "You have reached end" information.

Again, I am not quite sure, what's the best, please let me know your opinions.

Kind regards,


Tomas
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Ticket #3923 - change order in tree view

Post by ickby »

The ability to re-order children has to be specified by the view providers. A viewprovider specifies what he groups as his children, and hence this is the natural implementation point to specify if the childrens order is important.
Maybe adding annother overridable function to it would make sense? To give some fine grained control in the reordering operations a option would be to ask the ViewProvider function for each reorder operation, like "allowReordering(docObjct, currentNeighbor, newNeighbor)"?

some notes:
1. This function needs to be overridable by an viewprovider extension, so that current Group ViewProviderExtension can implement it
2. The tree rank function of viewprovider needs to be accessible in python, both read and set.
3. Tree rank changes need to be observable by document observer
4. Considering note 2 and 3 maybe it is better to implement it as hidden property? Than those two things come for free
5. This should somehow integrate with drag and drop, as this is the next thing the users will want to do.
tpavlicek
Posts: 60
Joined: Sun Jan 07, 2018 2:15 am

Re: Ticket #3923 - change order in tree view

Post by tpavlicek »

Hello,

I have updated the pull request https://github.com/FreeCAD/FreeCAD/pull/4626 according to your comments.

adrianinsaval wrote: Wed Mar 17, 2021 5:58 am when moving something within a container and reaching the limit the selection shouldn't continue to move past that while pressing alt+arrow. Consider the case were you want to move an item to the top of a container and you press alt+up-arrow many times, by accident you press the arrow key two times more than necessary, now the container has changed it's order and collapsed at the same time, this could be annoying.
This should be fixed now.

ickby wrote: Wed Mar 17, 2021 9:29 am 2. The tree rank function of viewprovider needs to be accessible in python, both read and set.
3. Tree rank changes need to be observable by document observer
4. Considering note 2 and 3 maybe it is better to implement it as hidden property? Than those two things come for free
ViewProviderDocumentObject has now a hidden TreeRank property, which can be read and written. Assigning it a value <= 0 sets the rank to the greatest known + 1, i.e. effectively places the document object at the tree group end.

ickby wrote: Wed Mar 17, 2021 9:29 am 1. This function needs to be overridable by an viewprovider extension, so that current Group ViewProviderExtension can implement it
ViewProviderDocumentObject has now allowTreeOrderSwap(DocumentObject *child1, DocumentObject *child2) method, which decides, whether or not its children objects may be swapped in the tree. Default implementation in the base class calls each attached ViewProviderExtension and gives it the opportunity to block the reordering. If no one votes against, the swap is allowed.

Drag & Drop
So far, I do not see any simple solution. In my opinion, what we would need is a tree widget with little spaces between items. If the drop would occur above such a space, then we could consider this as "Change order request". Otherwise the item under cursor receives the drop and acts according to its drag/drop interpretation. Maybe we could pop up some little menu to specify what drop should do? I am not sure.

Again, thanks for your interest, any comments or suggestions are welcome.

Kind regards,


Tomas
LHC
Posts: 321
Joined: Thu Sep 17, 2020 4:21 pm
Location: Canadian Coffee Shop

Re: Ticket #3923 - change order in tree view

Post by LHC »

Hey this is an old thread but it looks like this has been merged into the master - am I correct ? I've been looking forward to this for some time :D
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Implemented] Ticket #3923 - change order in tree view

Post by Kunda1 »

Implemented in git commit c62239d
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
kisolre
Veteran
Posts: 4164
Joined: Wed Nov 21, 2018 1:13 pm

Re: [Implemented] Ticket #3923 - change order in tree view

Post by kisolre »

Please check this thread https://forum.freecadweb.org/viewtopic.php?f=3&t=63744 - the order of features under a PD body does not reflect their proper dependency.
hmk
Posts: 159
Joined: Tue Sep 29, 2020 1:19 pm
Location: Berlin, Germany

Re: [Implemented] Ticket #3923 - change order in tree view

Post by hmk »

Kunda1 wrote: Fri Nov 12, 2021 12:22 pm Implemented in git commit c62239d
Note for people who are a bit confused (like myself :)): The feature has been reverted and may not be available. I am not able to reorder with Alt-Up/Down with this build:
Version: 0.20.26498 (Git) AppImage

See also this thread: https://forum.freecadweb.org/viewtopic. ... 4&start=40
LHC
Posts: 321
Joined: Thu Sep 17, 2020 4:21 pm
Location: Canadian Coffee Shop

Re: [Implemented] Ticket #3923 - change order in tree view

Post by LHC »

hmk wrote: Mon Nov 29, 2021 6:04 pm
Kunda1 wrote: Fri Nov 12, 2021 12:22 pm Implemented in git commit c62239d
Note for people who are a bit confused (like myself :)): The feature has been reverted and may not be available. I am not able to reorder with Alt-Up/Down with this build:
Version: 0.20.26498 (Git) AppImage

See also this thread: https://forum.freecadweb.org/viewtopic. ... 4&start=40
Thanks for the post - I was just about to post asking if the revert had been done and it's safe to download the weekly builds again :lol:
User avatar
Vincent B
Veteran
Posts: 4713
Joined: Sun Apr 05, 2015 9:02 am
Location: La Rochelle, France

Re: [Implemented] Ticket #3923 - change order in tree view

Post by Vincent B »

This new useful feature still vanished into new release? :roll: :roll: :roll:
...
OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 0.20.26554 (Git)
Build type: Release
Python version: 3.8.12
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: French/France (fr_FR)
drmacro
Veteran
Posts: 8873
Joined: Sun Mar 02, 2014 4:35 pm

Re: [Implemented] Ticket #3923 - change order in tree view

Post by drmacro »

Vincent B wrote: Sat Dec 11, 2021 6:49 pm This new useful feature still vanished into new release? :roll: :roll: :roll:
...
Only useful if it worked...

:mrgreen:
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Post Reply