Hi, I am writing an editor for multi-columned hierarchical data (for example project tasks or software requirements) and would like to allow the user to sort the rows as if the data had a flat structure.
Example TreeView: Hierarchy | Task name | Priority | Man-days ----------+-----------+------------+--------- > 1 | Task 1 | High | 5 1.1 | Subtask 1 | High | 3 1.2 | Subtask 2 | Low | 2 2 | Task 2 | High | 1 Now I would like to sort all the project tasks and subtasks by priority. If I store the data in a TreeModel, wrap a TreeModelSort over it and display the result via TreeView, the sorting mechanism is not able to put "Task 2" before "Task 1.2" even if "Task 2" has higher priority. It is caused by respecting the hierarchy - sorting won't break a child from its parent (but I need to do so). Required result: Hierarchy | Task name | Priority v | Man-days ----------+-----------+------------+--------- 1 | Task 1 | High | 5 1.1 | Subtask 1 | High | 3 2 | Task 2 | High | 1 1.2 | Subtask 2 | Low | 2 <--- breaks the hierarchy Is there any way how to achieve such sorting without maintaining two copies of all data - one in TreeStore and one in ListStore and sorting/displaying the ListStore instead? I was able to hide the expanders via setting the expander column to a hidden one so the view part seems to be OK. I don't think TreeSortable.set_sort_func() would help here as the comparison works but the rows to be compared are chosen only from one parent and within the same tree depth (i.e. 1.1 is compared only with 1.2 but not with 1 or 2). Maybe I could write a wrapper providing a ListStore-like behavior while having no own data but taking them from a TreeStore + put this ListStore in its own TreeView? Or inheriting from a plain ListStore and implement "child" collapse/expand on my own? Any ideas are welcome, thanks! Jirka _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/