Re: [Java-gnome-developer] Problems with TreeView
Brought to you by:
afcowie
From: Andrew C. <an...@op...> - 2006-07-09 11:19:28
|
On Sun, 2006-07-09 at 00:17 +0200, Keywan Najafi Tonekaboni wrote: > Hi, > > I have a application with groupchat window. I save the roster of the > user, who are in the groupchat, in a TreeView. I use a ListStore with > two columns (Pixbuf and String). > > I read the tutorial and create my ListStore/TreeView nearly exact as > shown in the tutorial. > > Now I want to modify the rows in the TreeView. I wonder how I could get > a specified row. You need to hunt down the row you want to modify, which means getting a TreeIter that points at it. How do you do that? Assuming you do not have a TreeRowReference kicking around that points at it, then what you need to do is iterate through the ListStore to find your row. TreeIter pointer = model.getFirstIter(); Then, as you loop through, you just call getValue() on a particular column and see if its the one you want, and if not, pointer = model.getNextIter(); An example of this is line 601 of http://research.operationaldynamics.com/source/darcsweb/?r=objective;a=headblob;f=/src/accounts/ui/TransactionListView.java#l595 Incidentally, this is half the reason one usually stores a DataColumnObject in the ListStore with a reference to the domain object we're modelling - easier to just test the result of getValue() == obj. If you're reacting to a selection event, you can get a TreePath from the Event and from there a TreeIter. If you're reacting to an activate, you can get a TreeIter right off of the Event... and from there quickly lift the domain object you're modelling and then carry on with business logic from there. AfC London -- Andrew Frederick Cowie Technology strategy, managing change, establishing procedures, and executing successful upgrades to mission critical business infrastructure. http://www.operationaldynamics.com/ Sydney New York Toronto London |