Download The demexp Book - Linux

Transcript
26.1
Window backends
We define in this section the three backends that stores the data needed to display the three tree
widgets of the classification window. For this, we define two kinds of backends: tag backend
for the two tree widgets showing tags, and question backend for the tree widget displaying
the set of available questions.
A tag backend contains two columns: the id and the label of each tag.
Moreover, backend tag backend contains a hash table tags hash of all stored tags. Associated methods add tag and remove tag allows to manipulate this hash table. Method clear
removes all entries in the backend.
fixme: Right now, the hash table is not managed jointly with the store. It might be more clean
to manage them together.
130
hclsf.ml 129i+≡
class tag_backend () =
let columns = new GTree.column_list in
let col_id = columns#add Gobject.Data.int in
let col_new = columns#add Gobject.Data.boolean in
let col_voted = columns#add Gobject.Data.boolean in
let col_label = columns#add Gobject.Data.string in
let store = GTree.tree_store columns in
/ 129 131a .
let _ = store#set_sort_column_id col_label.GTree.index ‘ASCENDING in
object
method
method
method
method
method
col_id = col_id
col_new = col_new
col_voted = col_voted
col_label = col_label
store = store
val mutable tags_hash : (int, string)
method tags_hash = tags_hash
method set_tags_hash h = tags_hash <method add_tag id label = Hashtbl.add
method remove_tag id = Hashtbl.remove
method clear () =
Hashtbl.clear tags_hash;
store#clear ()
end
130
Hashtbl.t = Hashtbl.create 3
h
tags_hash id label
tags_hash id
FIXME