|
java-gnome version 4.0.19 | ||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectorg.freedesktop.bindings.Pointer
org.freedesktop.bindings.Proxy
org.gnome.glib.Object
org.gnome.gtk.TreeModel
org.gnome.gtk.TreeModelFilter
public class TreeModelFilter
A TreeModel which can present a subset of its backing model as determined by a filter function. TreeModelFilter acts to wrap an underlying TreeModel. You store your data in this underlying model; the TreeModelFilter just adds the functionality to selectively determine which rows should be visible.
Usage is straight forward. Given the following declarations:
final ListStore model; final TreeModelFilter filter; final DataColumnInteger elevation; ...you initialize and populate your ListStore as usual. To add the filtering functionality, you wrap your ListStore in a TreeModelFilter:
filter = new TreeModelFilter(model, null);then instruct the TreeModelFilter how to select the rows from the concrete TreeModel it is proxying to be included in the virtual model it presents via the
setVisibleCallback()
. For instance, if you have a list of all mountains
and only want to present peaks higher than 8000 meters, you might do:
filter.setVisibleCallback(new TreeModelFilter.Visible() { public boolean onVisible(TreeModelFilter source, TreeModel base, TreeIter row) { if (base.getValue(row, elevation) > 8000) { return true; } else { return false; } } }Assuming you are using this data to back a display Widget such as a TreeView, and you only want to present this filtered list of rows, then you use the TreeModelFilter, not the ListStore, as the model backing the TreeView:
view = new TreeView(filter);
Note:
For some reason, TreeModelFilter does not implement TreeSortable. If
you plan to sort the filtered model (ie via TreeViewColumn's
setSortColumn()
) make sure
you wrap your TreeModelFilter in a TreeModelSort
and add that to
the TreeView instead:
store = new ListStore(...); filtered = new TreeModelFilter(store, null); sorted = new TreeModelSort(filtered); view = new TreeView(sorted); vertical = view.appendColumn(); vertical.setSortColumn(...);otherwise GTK will object vociferously.
Nested Class Summary | |
---|---|
static interface |
TreeModelFilter.Visible
The callback invoked when a TreeModelFilter wants to ask if a given row in its child TreeModel should be considered visible in the TreeModelFilter. |
Nested classes/interfaces inherited from class org.gnome.gtk.TreeModel |
---|
TreeModel.RowChanged |
Constructor Summary | |
---|---|
TreeModelFilter(TreeModel base,
TreePath root)
Construct a new TreeModelFilter. |
Method Summary | |
---|---|
TreeIter |
convertIterBaseToFilter(TreeIter row)
Convert a TreeIter valid in the underying TreeModel to one usable with this TreeModelFilter. |
TreeIter |
convertIterFilterToBase(TreeIter row)
Convert a TreeIter valid in this TreeModelFilter into one usable with the underying TreeModel. |
TreePath |
convertPathBaseToFilter(TreePath path)
Convert a TreePath representing a row in the underying TreeModel into the corresponding locator in this TreeModelFilter. |
TreePath |
convertPathFilterToBase(TreePath path)
Convert a TreePath representing a row in this TreeModelFilter into one that points to the corresponding row in the underying TreeModel. |
void |
refilter()
Cause the TreeModelFilter to re-calculate whether rows are visible. |
void |
setVisibleCallback(TreeModelFilter.Visible handler)
Hookup the Visible callback that will be used to determine
whether rows from the underlying TreeModel are to be included in the
set presented by this TreeModelFilter. |
Methods inherited from class org.gnome.gtk.TreeModel |
---|
connect, getIter, getIterFirst, getPath, getValue, getValue, getValue, getValue, getValue, getValue, getValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue |
Methods inherited from class org.freedesktop.bindings.Pointer |
---|
toString |
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TreeModelFilter(TreeModel base, TreePath root)
base
- The underlying model that you are filteringroot
- You can give a TreePath to be used as a virtual root so that
the TreeModelFilter only presents and operates on a
subsection of the base TreeModel. This is rarely necessary,
so specify null
.Method Detail |
---|
public TreeIter convertIterBaseToFilter(TreeIter row)
null
if the row is not (currently) present in the
TreeModelFilter.public TreeIter convertIterFilterToBase(TreeIter row)
public TreePath convertPathBaseToFilter(TreePath path)
If the row represented by path
isn't (currently) present
in the narrowed representation provided by this TreeModelFilter, then
null
is returned.
public TreePath convertPathFilterToBase(TreePath path)
public void refilter()
Visible
callback to be hit for each
row.
public void setVisibleCallback(TreeModelFilter.Visible handler)
Visible
callback that will be used to determine
whether rows from the underlying TreeModel are to be included in the
set presented by this TreeModelFilter.
|
![]() java-gnome |
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |