Jump to content

New API: populate a QTreeView


Mike

Recommended Posts

I'm making a QTreeView and I'd like to populate it like the task tree in the web app.  Currently, I have a UI set up that shows all active projects.  When you select a project it opens up another tab that reveals the a task tree for that project (like the web app)... however I only have it showing the immediate children right now because I can't figure out the best way to populate the entire QTreeView 

I know how to populate a tree view with python using os.walk() or QFileSystemModel, but I'm not sure how to query all of the Ftrack data and store it efficiently to build the tree.  So, how should I go about populating this Task QTreeView with the new API?  

Thanks!

Side note: I did some digging into the Ftrack widgets folder and found how the BrowseTasksWidget was creating the tree view.  I started to build my tree view this way, but after a lot of though,  i decided that it might be too clunky to build the tree based on user input.  It also might result in slow performance/poor UX when a user gets deeper into the tree or collapses a branch.  

Link to comment
Share on other sites

Hi Mike,

We have done something similar. The main problem is if you ask ftrack to return all of your project or shot data at once it ends up being quite slow depending on the size of the project.

What we ended up doing is something called deferred loading using events. This is how it works. by example:

The user selects the project. You query all the children of the project and display this in you view.

Then when a user clicks (This is the event I was talking about) on one of the children, you then load those children and so on and so forth.

Your local data structure can then store the data as you go along so that if a user collapses a branch and then reopens it, it would open using the cached version.

This also means you are not loading unnecessary data. Hope that helps

 

Link to comment
Share on other sites

Hey bryand,

Ahhh ok, this is how the ftrack widget does it, but I wasn't sure if there was a built-in system for it.  Thank you!

6 hours ago, bryand said:

Your local data structure can then store the data as you go along so that if a user collapses a branch and then reopens it, it would open using the cached version.

This also means you are not loading unnecessary data. Hope that helps

 

Quick question, does this get stored automatically, or do I have to tell ftrack to store it?

Link to comment
Share on other sites

We store it in our own data structure. But something could be done with Redis and Ftrack's caching in the new api.

I guess the simplest approach might be storing the data in a json file.  using a data structure that can be read by your QTreeView.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...