Improved export for hierarchical views
svn: r13830
This commit is contained in:
parent
bd961672c8
commit
bfd2a9629f
@ -803,8 +803,16 @@ class ListView(NavigationView):
|
|||||||
ofile.open(name)
|
ofile.open(name)
|
||||||
ofile.start_page()
|
ofile.start_page()
|
||||||
ofile.start_row()
|
ofile.start_row()
|
||||||
|
|
||||||
# Headings
|
# Headings
|
||||||
map(ofile.write_cell, column_names)
|
if self.model.get_flags() & gtk.TREE_MODEL_LIST_ONLY:
|
||||||
|
headings = column_names
|
||||||
|
else:
|
||||||
|
levels = self.model.get_tree_levels()
|
||||||
|
headings = levels + column_names[1:]
|
||||||
|
data_cols = data_cols[1:]
|
||||||
|
|
||||||
|
map(ofile.write_cell, headings)
|
||||||
ofile.end_row()
|
ofile.end_row()
|
||||||
|
|
||||||
if self.model.get_flags() & gtk.TREE_MODEL_LIST_ONLY:
|
if self.model.get_flags() & gtk.TREE_MODEL_LIST_ONLY:
|
||||||
@ -816,25 +824,28 @@ class ListView(NavigationView):
|
|||||||
ofile.end_row()
|
ofile.end_row()
|
||||||
else:
|
else:
|
||||||
# Tree model
|
# Tree model
|
||||||
node = self.model.get_iter_first()
|
node = self.model.on_get_iter((0,))
|
||||||
self.write_node(node, 0, ofile, data_cols)
|
self.write_node(node, len(levels), [], ofile, data_cols)
|
||||||
|
|
||||||
ofile.end_page()
|
ofile.end_page()
|
||||||
ofile.close()
|
ofile.close()
|
||||||
|
|
||||||
def write_node(self, node, level, ofile, data_cols):
|
def write_node(self, node, depth, level, ofile, data_cols):
|
||||||
if node is None:
|
if node is None:
|
||||||
return
|
return
|
||||||
while node is not None:
|
while node is not None:
|
||||||
ofile.start_row()
|
new_level = level + [self.model.on_get_value(node, 0)]
|
||||||
map(ofile.write_cell, ('',)*level)
|
if self.model.get_handle(node):
|
||||||
for index in data_cols:
|
ofile.start_row()
|
||||||
ofile.write_cell(self.model.get_value(node, index))
|
padded_level = new_level + [''] * (depth - len(new_level))
|
||||||
ofile.end_row()
|
map(ofile.write_cell, padded_level)
|
||||||
|
for index in data_cols:
|
||||||
|
ofile.write_cell(self.model.on_get_value(node, index))
|
||||||
|
ofile.end_row()
|
||||||
|
|
||||||
first_child = self.model.iter_children(node)
|
first_child = self.model.on_iter_children(node)
|
||||||
self.write_node(first_child, level + 1, ofile, data_cols)
|
self.write_node(first_child, depth, new_level, ofile, data_cols)
|
||||||
node = self.model.iter_next(node)
|
node = self.model.on_iter_next(node)
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# Template functions
|
# Template functions
|
||||||
|
@ -159,6 +159,12 @@ class PeopleModel(TreeBaseModel):
|
|||||||
""" Return the number of columns in the model """
|
""" Return the number of columns in the model """
|
||||||
return len(self.fmap)+1
|
return len(self.fmap)+1
|
||||||
|
|
||||||
|
def get_tree_levels(self):
|
||||||
|
"""
|
||||||
|
Return the headings of the levels in the hierarchy.
|
||||||
|
"""
|
||||||
|
return ['Group As', 'Name']
|
||||||
|
|
||||||
def add_row(self, handle, data):
|
def add_row(self, handle, data):
|
||||||
"""
|
"""
|
||||||
Add nodes to the node map for a single person.
|
Add nodes to the node map for a single person.
|
||||||
|
@ -73,6 +73,12 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel):
|
|||||||
nrgroups = 3,
|
nrgroups = 3,
|
||||||
group_can_have_handle = True)
|
group_can_have_handle = True)
|
||||||
|
|
||||||
|
def get_tree_levels(self):
|
||||||
|
"""
|
||||||
|
Return the headings of the levels in the hierarchy.
|
||||||
|
"""
|
||||||
|
return ['Country', 'State', 'County', 'Place Name']
|
||||||
|
|
||||||
def add_row(self, handle, data):
|
def add_row(self, handle, data):
|
||||||
"""
|
"""
|
||||||
Add nodes to the node map for a single place.
|
Add nodes to the node map for a single place.
|
||||||
|
Loading…
Reference in New Issue
Block a user