[ruby-gnome2-doc-cvs] [Hiki] update - tut-treeview-model

アーカイブの一覧に戻る

ruby-****@sourc***** ruby-****@sourc*****
2004年 4月 3日 (土) 05:59:25 JST


-------------------------
REMOTE_ADDR = 200.216.151.125
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/en/?tut-treeview-model
-------------------------
+ {{link "tut-treeview-components", nil, "tut-treeview", "tut-treeview-model-data"}}
  = ((<Gtk::TreeModels|Gtk::TreeModel>)) for Data Storage: Gtk::ListStore and Gtk::TreeStore
  
  It is important to realise what Gtk::TreeModel is and what it is not. Gtk::TreeModel is basically just an 'interface' to the data store, meaning that it is a standardised set of methods that allows a Gtk::TreeView widget (and the application programmer) to query certain characteristics of a data store, for example how many rows there are, which rows have children, and how many children a particular row has. It also provides methods for retrieving data from the data store, and tell the tree view what type of data is stored in the model. Every data store must implement the Gtk::TreeModel interface and provide these methods. Gtk::TreeModel itself only provides a way to query a data store's characteristics and to retrieve existing data, it does not provide a way to remove or add rows to the store. This is done using the specific store's methods.
  
  Gtk+ comes with two built-in data stores (models): Gtk::ListStore and Gtk::TreeStore. As the names imply, Gtk::ListStore is used for simple lists of data items where items have no hierarchical parent-child relationships, and Gtk::TreeStore is used for tree-like data structures, where items can have parent-child relationships. A list of files in a directory would be an example of a simple list structure, whereas a directory tree is an example for a tree structure. A list is basically just a special case of a tree with none of the items having any children, so one could use a tree store to maintain a simple list of items as well. The only reason Gtk::ListStore exists is in order to provide an easier interface that does not need to cater for child-parent relationships, and because a simple list model can be optimised for the special case where no children exist, which makes it faster and more efficient.
  
  Tree model implementations like Gtk::ListStore and Gtk::TreeStore will take care of the view side for you once you have configured the Gtk::TreeView to display what you want. If you change data in the store, the model will notify the tree view and your data display will be updated. If you add or remove rows, the model will also notify the store, and your row will appear in or disappear from the view as well.





ruby-gnome2-cvs メーリングリストの案内
アーカイブの一覧に戻る