PDA

View Full Version : Model with two different style tree views



Dream In Color
12th October 2012, 04:19
I have a model holding a list of Mailbox items (which are basically just structs holding addresses and some other info like how big the mailbox is) and these items are in a specific order (the order of a mail delivery route).

To display the contents of the model I first have a basic tree view with no children - just a header and rows displaying the appropriate info in each column (basically a list view with a header). The first two columns display the house number and then the street name respectively. And so this view is fine and displays the mail route in the order that it is driven.

But.. I need another tree view that uses the same model (so when Mailbox items are added or deleted it is updated) that displays the streets in alphabetical order and the street numbers as children of the street. I.E

First Tree View:

Col1_Col2
114 | Rosemary Dr
224 | Pickle Lp
324 | Rosemary Dr
551 | Lambardi Ave
105 | Pickle Lp

Second Tree View
Col1___________Col2

Lambardi Ave
|.......................551
Pickle Lp
|.......................105
|.......................224
Rosemary Dr
|.......................114
|.......................324

I understand that probably somehow I need to use the SortFilterProxyModel but I have scratched my head on this for hours and my mind can't bend to the correct angle to understand how to use it. The Mailbox item class doesn't have any sort of children or parent pointers/functions programmed in to it.. Will I need to add that maybe? Anyways any help appreciated and let me know if you need to see any code. Thanks!