Use new option_box in ExportCsv
svn: r15508
This commit is contained in:
parent
a6c702638f
commit
ea7bf26054
@ -50,6 +50,7 @@ LOG = logging.getLogger(".ExportCSV")
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from Filters import GenericFilter, Rules, build_filter_model
|
from Filters import GenericFilter, Rules, build_filter_model
|
||||||
|
from ExportOptions import WriterOptionBox
|
||||||
import Utils
|
import Utils
|
||||||
import gen.proxy
|
import gen.proxy
|
||||||
import DateHandler
|
import DateHandler
|
||||||
@ -150,68 +151,52 @@ class UnicodeWriter(object):
|
|||||||
# CSVWriter Options
|
# CSVWriter Options
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class CSVWriterOptionBox(object):
|
class CSVWriterOptionBox(WriterOptionBox):
|
||||||
"""
|
"""
|
||||||
Create a VBox with the option widgets and define methods to retrieve
|
Create a VBox with the option widgets and define methods to retrieve
|
||||||
the options.
|
the options.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, person, dbstate, uistate):
|
def __init__(self, person, dbstate, uistate):
|
||||||
self.person = person
|
WriterOptionBox.__init__(self, person, dbstate, uistate)
|
||||||
self.include_individuals = 1
|
self.include_individuals = 1
|
||||||
self.include_marriages = 1
|
self.include_marriages = 1
|
||||||
self.include_children = 1
|
self.include_children = 1
|
||||||
self.translate_headers = 1
|
self.translate_headers = 1
|
||||||
|
self.include_individuals_check = None
|
||||||
|
self.include_marriages_check = None
|
||||||
|
self.include_children_check = None
|
||||||
|
self.translate_headers_check = None
|
||||||
|
|
||||||
def get_option_box(self):
|
def get_option_box(self):
|
||||||
self.topDialog = Glade()
|
import gtk
|
||||||
self.filters = self.topDialog.get_object("filter")
|
option_box = WriterOptionBox.get_option_box(self)
|
||||||
|
|
||||||
all = GenericFilter()
|
self.include_individuals_check = gtk.CheckButton(_("Include people"))
|
||||||
all.set_name(_("Entire Database"))
|
self.include_marriages_check = gtk.CheckButton(_("Include marraiges"))
|
||||||
all.add_rule(Rules.Person.Everyone([]))
|
self.include_children_check = gtk.CheckButton(_("Include children"))
|
||||||
|
self.translate_headers_check = gtk.CheckButton(_("Translate headers"))
|
||||||
|
|
||||||
the_filters = [all]
|
self.include_individuals_check.set_active(1)
|
||||||
|
self.include_marriages_check.set_active(1)
|
||||||
|
self.include_children_check.set_active(1)
|
||||||
|
self.translate_headers_check.set_active(1)
|
||||||
|
|
||||||
if self.person:
|
option_box.pack_start(self.include_individuals_check, False)
|
||||||
des = GenericFilter()
|
option_box.pack_start(self.include_marriages_check, False)
|
||||||
des.set_name(_("Descendants of %s") %
|
option_box.pack_start(self.include_children_check, False)
|
||||||
self.person.get_primary_name().get_name())
|
option_box.pack_start(self.translate_headers_check, False)
|
||||||
des.add_rule(Rules.Person.IsDescendantOf(
|
|
||||||
[self.person.get_gramps_id(),1]))
|
|
||||||
|
|
||||||
ans = GenericFilter()
|
return option_box
|
||||||
ans.set_name(_("Ancestors of %s") %
|
|
||||||
self.person.get_primary_name().get_name())
|
|
||||||
ans.add_rule(Rules.Person.IsAncestorOf(
|
|
||||||
[self.person.get_gramps_id(),1]))
|
|
||||||
|
|
||||||
com = GenericFilter()
|
|
||||||
com.set_name(_("People with common ancestor with %s") %
|
|
||||||
self.person.get_primary_name().get_name())
|
|
||||||
com.add_rule(Rules.Person.HasCommonAncestorWith(
|
|
||||||
[self.person.get_gramps_id()]))
|
|
||||||
|
|
||||||
the_filters += [des,ans,com]
|
|
||||||
|
|
||||||
from Filters import CustomFilters
|
|
||||||
the_filters.extend(CustomFilters.get_filters('Person'))
|
|
||||||
self.filter_menu = build_filter_model(the_filters)
|
|
||||||
self.filters.set_model(self.filter_menu)
|
|
||||||
self.filters.set_active(0)
|
|
||||||
|
|
||||||
the_box = self.topDialog.get_object('vbox1')
|
|
||||||
the_parent = self.topDialog.get_object('dialog-vbox1')
|
|
||||||
the_parent.remove(the_box)
|
|
||||||
self.topDialog.toplevel.destroy()
|
|
||||||
return the_box
|
|
||||||
|
|
||||||
def parse_options(self):
|
def parse_options(self):
|
||||||
self.include_individuals = self.topDialog.get_object("individuals").get_active()
|
WriterOptionBox.parse_options(self)
|
||||||
self.include_marriages = self.topDialog.get_object("marriages").get_active()
|
if self.include_individuals_check:
|
||||||
self.include_children = self.topDialog.get_object("children").get_active()
|
self.include_individuals = self.include_individuals_check.get_active()
|
||||||
self.translate_headers = self.topDialog.get_object("translate_headers").get_active()
|
self.include_marriages = self.include_marriages_check.get_active()
|
||||||
self.cfilter = self.filter_menu[self.filters.get_active()][1]
|
self.include_children = self.include_children_check.get_active()
|
||||||
|
self.translate_headers = self.translate_headers_check.get_active()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -244,31 +229,30 @@ class CSVWriter(object):
|
|||||||
self.translate_headers = 1
|
self.translate_headers = 1
|
||||||
else:
|
else:
|
||||||
self.option_box.parse_options()
|
self.option_box.parse_options()
|
||||||
|
self.db = option_box.get_filtered_database(self.db)
|
||||||
|
|
||||||
self.include_individuals = self.option_box.include_individuals
|
self.include_individuals = self.option_box.include_individuals
|
||||||
self.include_marriages = self.option_box.include_marriages
|
self.include_marriages = self.option_box.include_marriages
|
||||||
self.include_children = self.option_box.include_children
|
self.include_children = self.option_box.include_children
|
||||||
self.translate_headers = self.option_box.translate_headers
|
self.translate_headers = self.option_box.translate_headers
|
||||||
|
|
||||||
if not option_box.cfilter.is_empty():
|
self.plist = [x for x in self.db.iter_person_handles()]
|
||||||
self.db = gen.proxy.FilterProxyDb(self.db, option_box.cfilter)
|
|
||||||
|
|
||||||
self.plist.update([p, 1] for p in self.db.iter_person_handles())
|
|
||||||
|
|
||||||
# get the families for which these people are spouses:
|
# get the families for which these people are spouses:
|
||||||
self.flist = {}
|
self.flist = {}
|
||||||
for key in self.plist:
|
for key in self.plist:
|
||||||
p = self.db.get_person_from_handle(key)
|
p = self.db.get_person_from_handle(key)
|
||||||
for family_handle in p.get_family_handle_list():
|
if p:
|
||||||
self.flist[family_handle] = 1
|
for family_handle in p.get_family_handle_list():
|
||||||
# now add the families for which these people are a child:
|
|
||||||
family_handles = self.db.iter_family_handles()
|
|
||||||
for family_handle in family_handles:
|
|
||||||
family = self.db.get_family_from_handle(family_handle)
|
|
||||||
for child_ref in family.get_child_ref_list():
|
|
||||||
child_handle = child_ref.ref
|
|
||||||
if child_handle in self.plist:
|
|
||||||
self.flist[family_handle] = 1
|
self.flist[family_handle] = 1
|
||||||
|
# now add the families for which these people are a child:
|
||||||
|
for family_handle in self.db.iter_family_handles():
|
||||||
|
family = self.db.get_family_from_handle(family_handle)
|
||||||
|
if family:
|
||||||
|
for child_ref in family.get_child_ref_list():
|
||||||
|
if child_ref:
|
||||||
|
child_handle = child_ref.ref
|
||||||
|
if child_handle in self.plist:
|
||||||
|
self.flist[family_handle] = 1
|
||||||
|
|
||||||
def update_empty(self):
|
def update_empty(self):
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user