public class ListStore extends TreeModel implements TreeDragSource, TreeDragDest, TreeSortable
Detailed discussion of how to instantiate ListStores is included in the
DataColumn
class. In summary, given
final DataColumnString monarchName; final DataColumnInteger coronatedYear; final DataColumnPixbuf portrait; final ListStore model; ...you build a three column model as follows:
model = new ListStore(new DataColumn[] { monarchName = new DataColumnString(), coronatedYear = new DataColumnInteger(), portrait = new DataColumnPixbuf() });
Although we talk about TreeModels all the time as the base superclass, it's
not a good idea to declare your model as a TreeModel when instantiating
because you'll need appendRow()
method which is here,
on the concrete type ListStore. In other words, do:
ListStore model = new ListStore(...);as shown above, not:
TreeModel model = new ListStore(...);
TreeModel.RowChanged
Constructor and Description |
---|
ListStore(DataColumn[] types)
Construct a new ListStore with the given column types.
|
Modifier and Type | Method and Description |
---|---|
TreeIter |
appendRow()
Add a new row to the ListStore.
|
void |
clear()
Remove all rows (and their contents) from this ListStore.
|
TreeIter |
insertRow(int position)
Insert a new row in the ListStore.
|
TreeIter |
insertRow(TreeIter sibling)
Insert a new row in the ListStore.
|
boolean |
removeRow(TreeIter row)
Delete a row from the ListStore.
|
void |
setSortColumn(DataColumn column,
SortType ordering)
Specify the column from your (underlying) data model which will be used
for sorting this TreeModelSort.
|
public ListStore(DataColumn[] types)
DataColumn
for details. You must include at least
one DataColumn in your types
array (you can't have a
ListStore with no columns).public TreeIter appendRow()
setValue()
methods, of course.public void clear()
public TreeIter insertRow(int position)
position
, which must be between 0
and the
number or rows in the model.
If you have a TreeIter pointing at a row already you can instead use
the other form of insertRow()
to inject an
new row there.
As with appendRow()
the new row will be empty;
you'll need to call one of the various setValue()
methods
to populate it.
public TreeIter insertRow(TreeIter sibling)
sibling
.
Alternately, see insertRow()
to insert a row at
a given position, and appendRow()
to add a blank
row at the end of the model.
public boolean removeRow(TreeIter row)
true
will be returned and row
will still
be valid. Otherwise, false
is returned and
row
is invalid from here on.public void setSortColumn(DataColumn column, SortType ordering)
TreeSortable
ASCENDING
or DESCENDING
order via the
ordering
parameter.setSortColumn
in interface TreeSortable