* src/AttrEdit.py: support get_type/set_type in dropdown menu
* src/EditPerson.py: remove items properly based off EventRef svn: r4781
This commit is contained in:
parent
271f9d6a8b
commit
af5df18bcd
@ -1,4 +1,6 @@
|
||||
2005-06-03 Don Allingham <don@gramps-project.org>
|
||||
* src/AttrEdit.py: support get_type/set_type in dropdown menu
|
||||
* src/EditPerson.py: remove items properly based off EventRef
|
||||
* src/DisplayModels.py: remove unused print
|
||||
* src/ListBox.py: get EventBox working for event types
|
||||
* src/PedView.py: handle event types
|
||||
|
@ -123,7 +123,14 @@ class AttributeEditor:
|
||||
l = self.top.get_widget("title")
|
||||
Utils.set_titles(self.window,l,title,_('Attribute Editor'))
|
||||
|
||||
AutoComp.fill_combo(self.attrib_menu,list)
|
||||
if attrib:
|
||||
defval = attrib.get_type()[0]
|
||||
else:
|
||||
defval = None
|
||||
|
||||
self.attrmapper = AutoComp.StandardCustomSelector(
|
||||
Utils.personal_attributes, self.attrib_menu,
|
||||
RelLib.Attribute.CUSTOM, defval)
|
||||
|
||||
if attrib != None:
|
||||
self.type_field.set_text(const.display_attr(attrib.get_type()))
|
||||
@ -205,27 +212,29 @@ class AttributeEditor:
|
||||
Called when the OK button is pressed. Gets data from the
|
||||
form and updates the Attribute data structure.
|
||||
"""
|
||||
attr = unicode(self.type_field.get_text())
|
||||
attr_data = self.attrmapper.get_values()
|
||||
value = unicode(self.value_field.get_text())
|
||||
|
||||
buf = self.note_field.get_buffer()
|
||||
note = unicode(buf.get_text(buf.get_start_iter(),buf.get_end_iter(),False))
|
||||
note = unicode(buf.get_text(buf.get_start_iter(),
|
||||
buf.get_end_iter(),False))
|
||||
format = self.preform.get_active()
|
||||
priv = self.priv.get_active()
|
||||
|
||||
if not attr in self.alist:
|
||||
WarningDialog(_('New attribute type created'),
|
||||
_('The "%s" attribute type has been added to this database.\n'
|
||||
'It will now appear in the attribute menus for this database') % attr)
|
||||
self.alist.append(attr)
|
||||
if (attr_data[0] == RelLib.Attribute.CUSTOM and
|
||||
not attr_data[1] in self.alist):
|
||||
WarningDialog(
|
||||
_('New attribute type created'),
|
||||
_('The "%s" attribute type has been added to this database.\n'
|
||||
'It will now appear in the attribute menus for this database') % attr_data[1])
|
||||
self.alist.append(attr_data[1])
|
||||
self.alist.sort()
|
||||
|
||||
if self.attrib == None:
|
||||
self.attrib = RelLib.Attribute()
|
||||
self.parent.alist.append(self.attrib)
|
||||
|
||||
self.attrib.set_source_reference_list(self.srcreflist)
|
||||
self.update(attr,value,note,format,priv)
|
||||
self.update(attr_data,value,note,format,priv)
|
||||
self.callback(self.attrib)
|
||||
self.close(obj)
|
||||
|
||||
@ -236,10 +245,9 @@ class AttributeEditor:
|
||||
set(data)
|
||||
self.parent.lists_changed = 1
|
||||
|
||||
def update(self,attr,value,note,format,priv):
|
||||
def update(self,attr_data,value,note,format,priv):
|
||||
"""Compares the data items, and updates if necessary"""
|
||||
ntype = const.save_pattr(attr)
|
||||
self.check(self.attrib.get_type,self.attrib.set_type,ntype)
|
||||
self.check(self.attrib.get_type,self.attrib.set_type,attr_data)
|
||||
self.check(self.attrib.get_value,self.attrib.set_value,value)
|
||||
self.check(self.attrib.get_note,self.attrib.set_note,note)
|
||||
self.check(self.attrib.get_note_format,self.attrib.set_note_format,format)
|
||||
|
@ -856,10 +856,10 @@ class EditPerson:
|
||||
for (event_ref,event) in eref_list:
|
||||
if event.get_type()[0] == RelLib.Event.BIRTH:
|
||||
self.person.set_birth_ref(event_ref)
|
||||
self.event_box.data.remove(event_ref)
|
||||
self.event_box.data.remove((event_ref,event))
|
||||
if event.get_type()[0] == RelLib.Event.DEATH:
|
||||
self.person.set_death_ref(event_ref)
|
||||
self.event_box.data.remove(event_ref)
|
||||
self.event_box.data.remove((event_ref,event))
|
||||
eref_list = [event_ref for (event_ref,event) in self.event_box.data]
|
||||
self.person.set_event_ref_list(eref_list)
|
||||
|
||||
|
@ -164,8 +164,6 @@ class EventEditor:
|
||||
# self.witnesslist, self, self.top, self.window, self.wlist,
|
||||
# add_witness, edit_witness, del_witness)
|
||||
|
||||
#AutoComp.fill_combo(self.event_menu,self.elist)
|
||||
|
||||
if event:
|
||||
defval = event.get_type()[0]
|
||||
else:
|
||||
|
@ -27,6 +27,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
import cPickle as pickle
|
||||
from sets import Set
|
||||
import locale
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -56,10 +57,15 @@ import NameDisplay
|
||||
import Utils
|
||||
|
||||
class ListBox:
|
||||
"""
|
||||
The ListBox manages the lists contained by the EditPerson dialog.
|
||||
It manages the add, update, and delete buttons, along with the
|
||||
handling of inline editing.
|
||||
"""
|
||||
def __init__(self, parent, person, obj, label, button_list, titles):
|
||||
self.person = person
|
||||
self.name = NameDisplay.displayer.display(person)
|
||||
self.label = label
|
||||
self.name = NameDisplay.displayer.display(self.person)
|
||||
self.db = parent.db
|
||||
self.parent = parent
|
||||
self.list_model = ListModel(
|
||||
@ -74,6 +80,14 @@ class ListBox:
|
||||
self.tree.connect('key_press_event', self.keypress)
|
||||
self.change_list = Set()
|
||||
|
||||
def build_maps(self,custom,string_map):
|
||||
self.name_map = {}
|
||||
self.val_map = string_map
|
||||
self.custom = custom
|
||||
for key in self.val_map.keys():
|
||||
val = self.val_map[key]
|
||||
self.name_map[val] = key
|
||||
|
||||
def keypress(self,obj,event):
|
||||
if event.keyval == 65379:
|
||||
print "insert"
|
||||
@ -163,8 +177,7 @@ class ReorderListBox(ListBox):
|
||||
|
||||
bits_per = 8; # we're going to pass a string
|
||||
pickled = pickle.dumps(node[0]);
|
||||
data = str((self.dnd_type.drag_type, self.person.get_handle(),
|
||||
pickled));
|
||||
data = str((self.dnd_type.drag_type, self.person.get_handle(), pickled));
|
||||
sel_data.set(sel_data.target, bits_per, data)
|
||||
|
||||
def unpickle(self, data):
|
||||
@ -196,7 +209,10 @@ class AttrListBox(ReorderListBox):
|
||||
|
||||
def __init__(self, parent, person, obj, label, button_list):
|
||||
|
||||
attrlist = Utils.personal_attributes
|
||||
custom_str = Utils.personal_attributes[RelLib.Attribute.CUSTOM]
|
||||
attrlist = filter(lambda x: x != custom_str,
|
||||
Utils.personal_attributes.values())
|
||||
attrlist.sort(locale.strcoll)
|
||||
|
||||
titles = [
|
||||
# Title Sort Col, Size, Type
|
||||
@ -210,8 +226,15 @@ class AttrListBox(ReorderListBox):
|
||||
ListBox.__init__(self, parent, person, obj, label,
|
||||
button_list, titles)
|
||||
|
||||
self.build_maps(RelLib.Attribute.CUSTOM, Utils.personal_attributes)
|
||||
|
||||
def set_type(self,index,value):
|
||||
self.data[index].set_type(value)
|
||||
val = self.name_map.get(value,self.custom)
|
||||
if val == self.custom:
|
||||
self.data[index].set_type((val,value))
|
||||
else:
|
||||
self.data[index].set_type((val,self.val_map[val]))
|
||||
self.change_list.add(self.data[index])
|
||||
|
||||
def set_value(self,index,value):
|
||||
self.data[index].set_value(value)
|
||||
@ -233,8 +256,14 @@ class AttrListBox(ReorderListBox):
|
||||
def display_data(self,attr):
|
||||
has_note = attr.get_note()
|
||||
has_source = len(attr.get_source_references())> 0
|
||||
return [const.display_pattr(attr.get_type()), attr.get_value(),
|
||||
has_source, has_note]
|
||||
|
||||
etype = attr.get_type()
|
||||
if etype[0] == RelLib.Attribute.CUSTOM:
|
||||
name = etype[1]
|
||||
else:
|
||||
name = Utils.personal_attributes[etype[0]]
|
||||
|
||||
return [name, attr.get_value(), has_source, has_note]
|
||||
|
||||
class EventListBox(ReorderListBox):
|
||||
|
||||
@ -255,11 +284,14 @@ class EventListBox(ReorderListBox):
|
||||
self.data.append((event_ref,
|
||||
parent.db.get_event_from_handle(event_ref.ref)))
|
||||
|
||||
eventnames = Utils.personal_events.values()
|
||||
custom_str = Utils.personal_events[RelLib.Attribute.CUSTOM]
|
||||
eventnames = filter(lambda x: x != custom_str,
|
||||
Utils.personal_events.values())
|
||||
eventnames.sort(locale.strcoll)
|
||||
|
||||
evalues = [
|
||||
# Title Sort Col Size, Type Argument
|
||||
(_('Event'), NOSORT, 100, COMBO, eventnames, self.set_name),
|
||||
(_('Event'), NOSORT, 100, COMBO, eventnames, self.set_type),
|
||||
(_('Description'), NOSORT, 140, TEXT, None, self.set_description),
|
||||
(_('Date'), NOSORT, 100, TEXT, None, self.set_date),
|
||||
(_('Place'), NOSORT, 100, TEXT, None, self.set_place),
|
||||
@ -270,13 +302,9 @@ class EventListBox(ReorderListBox):
|
||||
ReorderListBox.__init__(self, parent, person, obj, label,
|
||||
button_list, evalues, DdTargets.EVENT)
|
||||
|
||||
self.name_map = {}
|
||||
self.val_map = Utils.personal_events
|
||||
self.custom = RelLib.Event.CUSTOM
|
||||
for key in self.val_map.keys():
|
||||
self.name_map[self.val_map[key]] = key
|
||||
self.build_maps(RelLib.Event.CUSTOM,Utils.personal_events)
|
||||
|
||||
def set_name(self,index,value):
|
||||
def set_type(self,index,value):
|
||||
val = self.name_map.get(value,self.custom)
|
||||
if val == self.custom:
|
||||
self.data[index][1].set_type((val,value))
|
||||
@ -327,8 +355,7 @@ class EventListBox(ReorderListBox):
|
||||
name = etype[1]
|
||||
else:
|
||||
name = Utils.personal_events[etype[0]]
|
||||
return [name,
|
||||
event.get_description(), event.get_date(),
|
||||
return [name, event.get_description(), event.get_date(),
|
||||
pname, has_source, has_note]
|
||||
|
||||
def unpickle(self, data):
|
||||
@ -366,11 +393,14 @@ class NameListBox(ReorderListBox):
|
||||
def __init__(self,parent,person,obj,label,button_list):
|
||||
|
||||
surnames = parent.db.get_surname_list()
|
||||
types = Utils.name_types.values()
|
||||
|
||||
custom_str = Utils.name_types[RelLib.Name.CUSTOM]
|
||||
types = filter(lambda x: x != custom_str, Utils.name_types.values())
|
||||
types.sort(locale.strcoll)
|
||||
|
||||
titles = [
|
||||
# Title Sort Col Size, Type
|
||||
(_('Family Name'), NOSORT, 150, COMBO, surnames, self.set_name),
|
||||
(_('Family Name'), NOSORT, 180, COMBO, surnames, self.set_name),
|
||||
(_('Prefix'), NOSORT, 50, TEXT, None, self.set_prefix),
|
||||
(_('Given Name'), NOSORT, 200, TEXT, None, self.set_given),
|
||||
(_('Suffix'), NOSORT, 50, TEXT, None, self.set_suffix),
|
||||
@ -383,6 +413,16 @@ class NameListBox(ReorderListBox):
|
||||
ReorderListBox.__init__(self, parent, person, obj, label,
|
||||
button_list, titles, DdTargets.NAME)
|
||||
|
||||
self.build_maps(RelLib.Name.CUSTOM,Utils.name_types)
|
||||
|
||||
def set_type(self,index,value):
|
||||
val = self.name_map.get(value,self.custom)
|
||||
if val == self.custom:
|
||||
self.data[index].set_type((val,value))
|
||||
else:
|
||||
self.data[index].set_type((val,self.val_map[val]))
|
||||
self.change_list.add(self.data[index])
|
||||
|
||||
def set_name(self,index,value):
|
||||
self.data[index].set_surname(value)
|
||||
|
||||
@ -395,9 +435,6 @@ class NameListBox(ReorderListBox):
|
||||
def set_suffix(self,index,value):
|
||||
self.data[index].set_suffix(value)
|
||||
|
||||
def set_type(self,index,value):
|
||||
self.data[index].set_type(value[1])
|
||||
|
||||
def add(self,obj):
|
||||
NameEdit.NameEditor(self.parent, None, self.edit_callback,
|
||||
self.parent.window)
|
||||
@ -492,9 +529,8 @@ class UrlListBox(ReorderListBox):
|
||||
(_('Path'), NOSORT, 250, TEXT, None, self.set_path),
|
||||
(_('Description'), NOSORT, 100, TEXT, None, self.set_description),
|
||||
]
|
||||
|
||||
self.data = person.get_url_list()[:]
|
||||
ReorderListBox.__init__(self, parent, person, obj, label,
|
||||
ReorderListBox.__init__(self, person, person, obj, label,
|
||||
button_list, titles, DdTargets.URL)
|
||||
|
||||
def set_path(self,index,value):
|
||||
|
@ -686,8 +686,8 @@ class PedigreeView:
|
||||
|
||||
def format_relation( self, family, line_count):
|
||||
text = ""
|
||||
for event_handle in family.get_event_list():
|
||||
event = self.db.get_event_from_handle(event_handle)
|
||||
for event_ref in family.get_event_ref_list():
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
if event:
|
||||
if line_count < 3:
|
||||
return event.get_date()
|
||||
|
@ -1265,7 +1265,6 @@ class GrampsParser:
|
||||
self.name.set_type("Birth Name")
|
||||
self.person.set_primary_name (self.name)
|
||||
self.person.get_primary_name().build_sort_name()
|
||||
print "*",self.person.primary_name.get_name()
|
||||
self.name = None
|
||||
|
||||
def stop_ref(self,tag):
|
||||
@ -1305,7 +1304,6 @@ class GrampsParser:
|
||||
|
||||
def stop_person(self,*tag):
|
||||
self.db.commit_person(self.person,self.trans,self.change)
|
||||
print self.person.handle,self.person.primary_name.get_name()
|
||||
self.person = None
|
||||
while gtk.events_pending():
|
||||
gtk.main_iteration()
|
||||
|
@ -3536,7 +3536,7 @@ class Attribute(PrivateSourceNote):
|
||||
|
||||
def set_type(self,val):
|
||||
"""sets the type (or key) of the Attribute instance"""
|
||||
assert type(the_type) == tuple
|
||||
assert type(val) == tuple
|
||||
self.type = val
|
||||
|
||||
def get_type(self):
|
||||
|
Loading…
Reference in New Issue
Block a user