getavalon / core

The safe post-production pipeline - https://getavalon.github.io/2.0
MIT License
213 stars 48 forks source link

Add current index preserving in qtreeview context #554

Closed davidlatwe closed 4 years ago

davidlatwe commented 4 years ago

Problem

Loader's subset view gets flushed after clicking asset widget's refresh button.

Subset widget needs asset document id to get subsets. And the asset document id is retrived from view's currentIndex.

https://github.com/getavalon/core/blob/3761095b151c47f5f6a905e1628900def51f7c47/avalon/tools/widgets.py#L90-L93

And it looks like the tools.lib.preserve_states did not preserve the asset's view.currentIndex while refresh the asset model.

https://github.com/getavalon/core/blob/3761095b151c47f5f6a905e1628900def51f7c47/avalon/tools/loader/app.py#L171-L173

https://github.com/getavalon/core/blob/3761095b151c47f5f6a905e1628900def51f7c47/avalon/tools/widgets.py#L79-L83

Solution

Add currentIndex preserve function into tools.lib.preserve_states.

BigRoy commented 4 years ago

Code looks good. Admittedly to match the other argument signatures I'd expect it to be preserve_current_index as opposed to current_index but I must admit the naming convention was long (and a tad redundant) on the others so I can see why just going for current_index is sensible.

Feel free to decide what to do yourself whether keeping it or changing it makes more sense.

Good stuff!

@mkolar is this something you'd like to check too?

mkolar commented 4 years ago

Looks good to me. It was actually recently reported by one of the clients.