2007-12-21 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/DataViews/_PersonView.py: pass create_quickreport uistate * src/Editors/_EditPrimary.py: pass create_quickreport uistate * src/plugins/all_events.py: use SimpleTable * src/plugins/siblings.py: use SimpleTable * src/QuickReports.py: pass create_quickreport uistate * src/Simple/_SimpleTable.py: Handles raw objects, click/doubleclick * src/PageView.py: pass create_quickreport uistate * src/docgen/TextBufDoc.py: need to make a managed window, transient svn: r9552
This commit is contained in:
parent
f8d3f210f8
commit
c23b1259c8
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2007-12-21 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||
* src/DataViews/_PersonView.py: pass create_quickreport uistate
|
||||
* src/Editors/_EditPrimary.py: pass create_quickreport uistate
|
||||
* src/plugins/all_events.py: use SimpleTable
|
||||
* src/plugins/siblings.py: use SimpleTable
|
||||
* src/QuickReports.py: pass create_quickreport uistate
|
||||
* src/Simple/_SimpleTable.py: Handles raw objects, click/doubleclick
|
||||
* src/PageView.py: pass create_quickreport uistate
|
||||
* src/docgen/TextBufDoc.py: need to make a managed window, transient
|
||||
|
||||
2007-12-20 Brian Matherly <brian@gramps-project.org>
|
||||
* src/ReportBase/_GraphvizReportDialog.py: Misc improvements.
|
||||
|
||||
|
@ -854,6 +854,7 @@ class PersonView(PageView.PersonNavView):
|
||||
(ui, reportactions) = create_quickreport_menu(
|
||||
CATEGORY_QR_PERSON,
|
||||
self.dbstate,
|
||||
self.uistate,
|
||||
self.dbstate.active.handle)
|
||||
if len(reportactions) > 1 :
|
||||
qr_menu = gtk.Menu()
|
||||
|
@ -216,7 +216,8 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
||||
ui_qr = ''
|
||||
if self.QR_CATEGORY > -1 :
|
||||
(ui_qr, reportactions) = create_quickreport_menu(self.QR_CATEGORY,
|
||||
self.dbstate, self.obj.get_handle())
|
||||
self.dbstate, self.uistate,
|
||||
self.obj.get_handle())
|
||||
self.report_action = gtk.ActionGroup("/PersonReport")
|
||||
self.report_action.add_actions(reportactions)
|
||||
self.report_action.set_visible(True)
|
||||
|
@ -965,6 +965,7 @@ class ListView(BookMarkView):
|
||||
(ui, reportactions) = create_quickreport_menu(
|
||||
self.QR_CATEGORY,
|
||||
self.dbstate,
|
||||
self.uistate,
|
||||
self.first_selected())
|
||||
if len(reportactions) > 1 :
|
||||
qr_menu = gtk.Menu()
|
||||
|
@ -62,7 +62,7 @@ from ReportBase import CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,\
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY
|
||||
|
||||
|
||||
def create_quickreport_menu(category,dbstate,handle) :
|
||||
def create_quickreport_menu(category,dbstate,uistate,handle) :
|
||||
#import present version of the
|
||||
from PluginUtils import quick_report_list
|
||||
''' This functions querries the registered quick reports with
|
||||
@ -99,7 +99,8 @@ def create_quickreport_menu(category,dbstate,handle) :
|
||||
new_key = report[2].replace(' ', '-')
|
||||
ofile.write('<menuitem action="%s"/>' % new_key)
|
||||
actions.append((new_key, None, report[1], None, None,
|
||||
make_quick_report_callback(report, category, dbstate, handle)))
|
||||
make_quick_report_callback(report, category,
|
||||
dbstate, uistate, handle)))
|
||||
ofile.write('</menu>')
|
||||
|
||||
return (ofile.getvalue(), actions)
|
||||
@ -107,15 +108,17 @@ def create_quickreport_menu(category,dbstate,handle) :
|
||||
def by_menu_name(first, second):
|
||||
return cmp(first[1], second[1])
|
||||
|
||||
def make_quick_report_callback(lst, category, dbstate, handle):
|
||||
return lambda x: run_report(dbstate, category, handle, lst[0])
|
||||
def make_quick_report_callback(lst, category, dbstate, uistate, handle):
|
||||
return lambda x: run_report(dbstate, uistate, category, handle, lst[0])
|
||||
|
||||
def run_report(dbstate, category,handle,func):
|
||||
def run_report(dbstate, uistate, category,handle,func):
|
||||
from TextBufDoc import TextBufDoc
|
||||
from Simple import make_basic_stylesheet
|
||||
|
||||
if dbstate.active and handle:
|
||||
d = TextBufDoc(make_basic_stylesheet(), None, None)
|
||||
d.dbstate = dbstate
|
||||
d.uistate = uistate
|
||||
if category == CATEGORY_QR_PERSON :
|
||||
obj = dbstate.db.get_person_from_handle(handle)
|
||||
elif category == CATEGORY_QR_FAMILY :
|
||||
|
@ -23,6 +23,8 @@ Provides a simplified table creation interface
|
||||
"""
|
||||
|
||||
import copy
|
||||
import gen.lib
|
||||
import Errors
|
||||
|
||||
class SimpleTable:
|
||||
"""
|
||||
@ -31,21 +33,100 @@ class SimpleTable:
|
||||
|
||||
def __init__(self, access, doc, title=None):
|
||||
"""
|
||||
Initializes the class with the real document
|
||||
Initializes the class with a simpledb, and simpledoc
|
||||
"""
|
||||
self.access = access
|
||||
self.doc = doc # simpledoc; doc.doc = actual document
|
||||
self.simpledoc = doc # simpledoc; simpledoc.doc = docgen object
|
||||
self.title = title
|
||||
self.__columns = []
|
||||
self.__rows = []
|
||||
self.__link = []
|
||||
self.__sort_col = None
|
||||
self.__sort_reverse = False
|
||||
|
||||
def columns(self, *columns):
|
||||
"""
|
||||
Set the columns
|
||||
"""
|
||||
self.__columns = list(copy.copy(columns))
|
||||
|
||||
def on_table_doubleclick(self, obj, path, view_column):
|
||||
"""
|
||||
Handle events on tables. obj is a treeview
|
||||
"""
|
||||
from Editors import EditPerson, EditEvent
|
||||
selection = obj.get_selection()
|
||||
store, node = selection.get_selected()
|
||||
if not node:
|
||||
return
|
||||
index = store.get_value(node, 0) # index
|
||||
if self.__link[index]:
|
||||
htype, handle = self.__link[index]
|
||||
if htype == 'Person':
|
||||
person = self.access.dbase.get_person_from_handle(handle)
|
||||
try:
|
||||
EditPerson(self.simpledoc.doc.dbstate,
|
||||
self.simpledoc.doc.uistate, [], person)
|
||||
return True # handled event
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
elif htype == 'Event':
|
||||
event = self.access.dbase.get_event_from_handle(handle)
|
||||
try:
|
||||
EditEvent(self.simpledoc.doc.dbstate,
|
||||
self.simpledoc.doc.uistate, [], event)
|
||||
return True # handled event
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
return False # didn't handle event
|
||||
|
||||
def on_table_click(self, obj):
|
||||
"""
|
||||
Handle events on tables. obj is a treeview
|
||||
"""
|
||||
selection = obj.get_selection()
|
||||
store, node = selection.get_selected()
|
||||
if not node:
|
||||
return
|
||||
index = store.get_value(node, 0) # index
|
||||
if self.__link[index]:
|
||||
htype, handle = self.__link[index]
|
||||
if htype == 'Person':
|
||||
person = self.access.dbase.get_person_from_handle(handle)
|
||||
self.simpledoc.doc.dbstate.change_active_person(person)
|
||||
return True
|
||||
elif htype == 'Event':
|
||||
pass
|
||||
return False # didn't handle event
|
||||
|
||||
def row(self, *data):
|
||||
self.__rows.append(copy.copy(data))
|
||||
"""
|
||||
Add a row of data.
|
||||
"""
|
||||
retval = []
|
||||
link = None
|
||||
for item in data:
|
||||
if type(item) in [str, unicode]:
|
||||
retval.append(item)
|
||||
elif isinstance(item, gen.lib.Person):
|
||||
name = self.access.name(item)
|
||||
retval.append(name)
|
||||
link = ('Person', item.handle)
|
||||
elif isinstance(item, gen.lib.Family): pass
|
||||
elif isinstance(item, gen.lib.Source): pass
|
||||
elif isinstance(item, gen.lib.Event):
|
||||
name = self.access.event_type(item)
|
||||
retval.append(name)
|
||||
link = ('Event', item.handle)
|
||||
elif isinstance(item, gen.lib.MediaObject): pass
|
||||
elif isinstance(item, gen.lib.Place): pass
|
||||
elif isinstance(item, gen.lib.Repository): pass
|
||||
elif isinstance(item, gen.lib.Note): pass
|
||||
else:
|
||||
raise AttributeError, ("unknown object type: '%s': %s" %
|
||||
(item, type(item)))
|
||||
self.__link.append(link)
|
||||
self.__rows.append(retval)
|
||||
|
||||
def sort(self, column_name, reverse=False):
|
||||
self.__sort_col = column_name
|
||||
@ -59,48 +140,51 @@ class SimpleTable:
|
||||
self.__rows.sort(lambda a, b: cmp(a[idx],b[idx]))
|
||||
|
||||
def write(self):
|
||||
if self.doc.doc.type == "standard":
|
||||
self.doc.start_table('simple','Table')
|
||||
if self.simpledoc.doc.type == "standard":
|
||||
doc = self.simpledoc.doc
|
||||
doc.start_table('simple','Table')
|
||||
columns = len(self.__columns)
|
||||
if self.title:
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell('TableHead',columns)
|
||||
self.doc.start_paragraph('TableTitle')
|
||||
self.doc.write_text(_(self.title))
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
doc.start_row()
|
||||
doc.start_cell('TableHead',columns)
|
||||
doc.start_paragraph('TableTitle')
|
||||
doc.write_text(_(self.title))
|
||||
doc.end_paragraph()
|
||||
doc.end_cell()
|
||||
doc.end_row()
|
||||
if self.__sort_col:
|
||||
self.__sort()
|
||||
self.doc.start_row()
|
||||
doc.start_row()
|
||||
for col in self.__columns:
|
||||
self.doc.start_cell('TableNormalCell',1)
|
||||
self.doc.write_text(col,'TableTitle')
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
doc.start_cell('TableNormalCell',1)
|
||||
doc.write_text(col,'TableTitle')
|
||||
doc.end_cell()
|
||||
doc.end_row()
|
||||
for row in self.__rows:
|
||||
self.doc.start_row()
|
||||
doc.start_row()
|
||||
for col in row:
|
||||
self.doc.start_cell('TableNormalCell',1)
|
||||
self.doc.write_text(col,'Normal')
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
self.doc.end_table()
|
||||
self.doc.start_paragraph("Normal")
|
||||
self.doc.end_paragraph()
|
||||
elif self.doc.doc.type == "gtk":
|
||||
doc.start_cell('TableNormalCell',1)
|
||||
doc.write_text(col,'Normal')
|
||||
doc.end_cell()
|
||||
doc.end_row()
|
||||
doc.end_table()
|
||||
doc.start_paragraph("Normal")
|
||||
doc.end_paragraph()
|
||||
elif self.simpledoc.doc.type == "gtk":
|
||||
import gtk
|
||||
buffer = self.doc.doc.buffer
|
||||
text_view = self.doc.doc.text_view
|
||||
model_index = 0
|
||||
buffer = self.simpledoc.doc.buffer
|
||||
text_view = self.simpledoc.doc.text_view
|
||||
model_index = 1 # start after index
|
||||
if self.__sort_col:
|
||||
sort_index = self.__columns.index(self.__sort_col)
|
||||
else:
|
||||
sort_index = 0
|
||||
treeview = gtk.TreeView()
|
||||
treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
|
||||
treeview.connect('row-activated', self.on_table_doubleclick)
|
||||
treeview.connect('cursor-changed', self.on_table_click)
|
||||
renderer = gtk.CellRendererText()
|
||||
types = []
|
||||
types = [int] # index
|
||||
for col in self.__columns:
|
||||
types.append(type(col))
|
||||
column = gtk.TreeViewColumn(col,renderer,text=model_index)
|
||||
@ -109,6 +193,7 @@ class SimpleTable:
|
||||
#if model_index == sort_index:
|
||||
# FIXME: what to set here?
|
||||
model_index += 1
|
||||
# Make a GUI to put the tree view in
|
||||
frame = gtk.Frame()
|
||||
frame.add(treeview)
|
||||
model = gtk.ListStore(*types)
|
||||
@ -116,7 +201,9 @@ class SimpleTable:
|
||||
iter = buffer.get_end_iter()
|
||||
anchor = buffer.create_child_anchor(iter)
|
||||
text_view.add_child_at_anchor(frame, anchor)
|
||||
count = 0
|
||||
for data in self.__rows:
|
||||
model.append(row=list(data))
|
||||
model.append(row=([count] + list(data)))
|
||||
count += 1
|
||||
frame.show_all()
|
||||
self.doc.paragraph("")
|
||||
self.simpledoc.paragraph("")
|
||||
|
@ -61,6 +61,7 @@ _WIDTH_IN_CHARS = 72
|
||||
|
||||
|
||||
class DisplayBuf:
|
||||
# FIXME: make a managed window now that we have uistate
|
||||
def __init__(self, title, document):
|
||||
g = gtk.glade.XML(const.GLADE_FILE,'scrollmsg')
|
||||
self.top = g.get_widget('scrollmsg')
|
||||
|
@ -23,17 +23,11 @@
|
||||
Display a person's events, both personal and family
|
||||
"""
|
||||
|
||||
from Simple import SimpleAccess, by_date, SimpleDoc
|
||||
from Simple import SimpleAccess, by_date, SimpleDoc, SimpleTable
|
||||
from gettext import gettext as _
|
||||
from PluginUtils import register_quick_report
|
||||
from ReportBase import CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY
|
||||
|
||||
# define the formatting string once as a constant. Since this is reused
|
||||
|
||||
__FMT = "%-15s\t%-15s\t%s"
|
||||
__FMT_fam = "%-15s\t%-15s\t%-15s\t%s"
|
||||
|
||||
|
||||
def run(database, document, person):
|
||||
"""
|
||||
Loops through the person events and the family events of any family
|
||||
@ -43,6 +37,7 @@ def run(database, document, person):
|
||||
|
||||
sdb = SimpleAccess(database)
|
||||
sdoc = SimpleDoc(document)
|
||||
stab = SimpleTable(sdb, sdoc)
|
||||
|
||||
# get the personal events
|
||||
event_list = sdb.events(person)
|
||||
@ -60,12 +55,13 @@ def run(database, document, person):
|
||||
sdoc.title(_("Sorted events of %s") % sdb.name(person))
|
||||
sdoc.paragraph("")
|
||||
|
||||
sdoc.header1(__FMT % (_("Event Type"), _("Event Date"), _("Event Place")))
|
||||
stab.columns(_("Event Type"), _("Event Date"), _("Event Place"))
|
||||
|
||||
for event in event_list:
|
||||
sdoc.paragraph(__FMT % (sdb.event_type(event),
|
||||
sdb.event_date(event),
|
||||
sdb.event_place(event)))
|
||||
stab.row(event,
|
||||
sdb.event_date(event),
|
||||
sdb.event_place(event))
|
||||
stab.write()
|
||||
|
||||
def run_fam(database, document, family):
|
||||
"""
|
||||
@ -75,21 +71,22 @@ def run_fam(database, document, family):
|
||||
|
||||
sdb = SimpleAccess(database)
|
||||
sdoc = SimpleDoc(document)
|
||||
stab = SimpleTable(sdb, sdoc)
|
||||
|
||||
# get the family events
|
||||
event_list = [(_('Family'), x) for x in sdb.events(family)]
|
||||
|
||||
# get the events of father and mother
|
||||
fathername = sdb.first_name(sdb.father(family))
|
||||
event_list += [(fathername, x) for x in sdb.events(sdb.father(family))]
|
||||
mothername = sdb.first_name(sdb.mother(family))
|
||||
event_list += [(mothername, x) for x in sdb.events(sdb.mother(family))]
|
||||
#fathername = sdb.first_name(sdb.father(family))
|
||||
event_list += [(sdb.father(family), x) for x in sdb.events(sdb.father(family))]
|
||||
#mothername = sdb.first_name(sdb.mother(family))
|
||||
event_list += [(sdb.mother(family), x) for x in sdb.events(sdb.mother(family))]
|
||||
|
||||
# children events
|
||||
event_list_children = []
|
||||
for child in sdb.children(family) :
|
||||
name = sdb.first_name(child)
|
||||
event_list_children += [(name, x) for x in sdb.events(child)]
|
||||
#name = sdb.first_name(child)
|
||||
event_list_children += [(child, x) for x in sdb.events(child)]
|
||||
|
||||
# Sort the events by their date
|
||||
event_list.sort(fam_sort)
|
||||
@ -102,21 +99,24 @@ def run_fam(database, document, family):
|
||||
sdb.name(sdb.mother(family))))
|
||||
sdoc.paragraph("")
|
||||
|
||||
sdoc.header2(__FMT_fam % (_("Family Member"), _("Event Type"),
|
||||
_("Event Date"), _("Event Place")))
|
||||
stab.columns(_("Family Member"), _("Event Type"),
|
||||
_("Event Date"), _("Event Place"))
|
||||
|
||||
for (name, event) in event_list:
|
||||
sdoc.paragraph(__FMT_fam % (name, sdb.event_type(event),
|
||||
sdb.event_date(event),
|
||||
sdb.event_place(event)))
|
||||
sdoc.paragraph("")
|
||||
for (person, event) in event_list:
|
||||
stab.row(person, sdb.event_type(event),
|
||||
sdb.event_date(event),
|
||||
sdb.event_place(event))
|
||||
stab.write()
|
||||
|
||||
stab = SimpleTable(sdb, sdoc)
|
||||
sdoc.header1(_("Personal events of the children"))
|
||||
sdoc.header2(__FMT_fam % (_("Family Member"), _("Event Type"),
|
||||
_("Event Date"), _("Event Place")))
|
||||
for (name, event) in event_list_children:
|
||||
sdoc.paragraph(__FMT_fam % (name, sdb.event_type(event),
|
||||
sdb.event_date(event),
|
||||
sdb.event_place(event)))
|
||||
stab.columns(_("Family Member"), _("Event Type"),
|
||||
_("Event Date"), _("Event Place"))
|
||||
for (person, event) in event_list_children:
|
||||
stab.row(person, sdb.event_type(event),
|
||||
sdb.event_date(event),
|
||||
sdb.event_place(event))
|
||||
stab.write()
|
||||
|
||||
def fam_sort(event1, event2):
|
||||
"""
|
||||
|
@ -34,10 +34,11 @@ def run(database, document, person):
|
||||
Loops through the families that the person is a child in, and display
|
||||
the information about the other children.
|
||||
"""
|
||||
|
||||
# setup the simple access functions
|
||||
sdb = SimpleAccess(database)
|
||||
sdoc = SimpleDoc(document)
|
||||
stab = SimpleTable(sdb, sdoc)
|
||||
|
||||
rel_class = relationship_class()
|
||||
rel_str_m = rel_class.get_sibling_relationship_string(
|
||||
rel_class.NORM_SIB, person.get_gender(),
|
||||
@ -52,12 +53,10 @@ def run(database, document, person):
|
||||
# display the title
|
||||
sdoc.title(_("Siblings of %s") % sdb.name(person))
|
||||
sdoc.paragraph("")
|
||||
st = SimpleTable(sdb, sdoc)
|
||||
st.columns(_("Sibling"), _("Gender"), _("Birth Date"), _("Type"))
|
||||
stab.columns(_("Sibling"), _("Gender"), _("Birth Date"), _("Type"))
|
||||
|
||||
# grab our current id, so we can filter the active person out
|
||||
# of the data
|
||||
|
||||
gid = sdb.gid(person)
|
||||
|
||||
# loop through each family in which the person is a child
|
||||
@ -72,10 +71,12 @@ def run(database, document, person):
|
||||
if rel_str == rel_str_m or rel_str == rel_str_f or \
|
||||
rel_str == rel_str_u :
|
||||
rel_str = ''
|
||||
st.row(sdb.name(child), sdb.gender(child), sdb.birth_date(child),
|
||||
rel_str)
|
||||
#st.sort(_("Sibling"))
|
||||
st.write()
|
||||
# pass row the child object to make link:
|
||||
stab.row(child,
|
||||
sdb.gender(child),
|
||||
sdb.birth_date(child),
|
||||
rel_str)
|
||||
stab.write()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user