java-gnome version 4.0.19

org.gnome.gtk
Class ListStore

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.freedesktop.bindings.Proxy
          extended by org.gnome.glib.Object
              extended by org.gnome.gtk.TreeModel
                  extended by org.gnome.gtk.ListStore
All Implemented Interfaces:
TreeDragDest, TreeDragSource, TreeSortable

public class ListStore
extends TreeModel
implements TreeDragSource, TreeDragDest, TreeSortable

The model storing a list of data. ListStores are the concrete TreeModel subclass used as the backing data store by a TreeView displaying tabular data, storing both the material to be presented as well as meta-information used to fine tune the presentation of that data. ListStores are also used as the backing store for the list of options in a ComboBoxes.

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(...);
 

Since:
4.0.5
Author:
Andrew Cowie

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gnome.gtk.TreeModel
TreeModel.RowChanged
 
Constructor Summary
ListStore(DataColumn[] types)
          Construct a new ListStore with the given column types.
 
Method Summary
 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.
 
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

ListStore

public ListStore(DataColumn[] types)
Construct a new ListStore with the given column types. See DataColumn for details. You must include at least one DataColumn in your types array (you can't have a ListStore with no columns).

Method Detail

appendRow

public TreeIter appendRow()
Add a new row to the ListStore. You'll need to fill in the various columns with one of the various setValue() methods, of course.


clear

public void clear()
Remove all rows (and their contents) from this ListStore.

Since:
4.0.6

insertRow

public TreeIter insertRow(int position)
Insert a new row in the ListStore. The row will be placed at 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.

Since:
4.0.7

insertRow

public TreeIter insertRow(TreeIter sibling)
Insert a new row in the ListStore. The empty row will be placed in front of the supplied 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.

Since:
4.0.7

removeRow

public boolean removeRow(TreeIter row)
Delete a row from the ListStore. If there is another row after this then true will be returned and row will still be valid. Otherwise, false is returned and row is invalid from here on.

Since:
4.0.7

setSortColumn

public void setSortColumn(DataColumn column,
                          SortType ordering)
Description copied from interface: TreeSortable
Specify the column from your (underlying) data model which will be used for sorting this TreeModelSort. Specify ASCENDING or DESCENDING order via the ordering parameter.

Specified by:
setSortColumn in interface TreeSortable


java-gnome