* src/ListModel.py: Be able to select based off an iter
* src/ImageSelect.py: Support keeping selecting attributes after they are edited * src/EventEdit.py: Support keeping selecting events after they are edited * src/AttrEdit.py: Support keeping selecting attributes after they are edited * src/Marriage.py: Support keeping track of events and attributes after they are edited. * src/EditPerson.py: Support keeping track of events and attributes after they are edited. svn: r1690
This commit is contained in:
parent
cd51e2c531
commit
59a6f4d79b
@ -54,7 +54,7 @@ class AttributeEditor:
|
||||
"""
|
||||
Displays a dialog that allows the user to edit an attribute.
|
||||
"""
|
||||
def __init__(self,parent,attrib,title,list):
|
||||
def __init__(self,parent,attrib,title,list,callback):
|
||||
"""
|
||||
Displays the dialog box.
|
||||
|
||||
@ -74,6 +74,7 @@ class AttributeEditor:
|
||||
self.attrib_menu = self.top.get_widget("attr_menu")
|
||||
self.source_field = self.top.get_widget("attr_source")
|
||||
self.priv = self.top.get_widget("priv")
|
||||
self.callback = callback
|
||||
|
||||
self.window = self.top.get_widget("attr_edit")
|
||||
|
||||
@ -135,7 +136,7 @@ class AttributeEditor:
|
||||
|
||||
self.attrib.setSourceRefList(self.srcreflist)
|
||||
self.update(type,value,note,priv)
|
||||
self.parent.redraw_attr_list()
|
||||
self.callback(self.attrib)
|
||||
Utils.destroy_passed_object(obj)
|
||||
|
||||
def check(self,get,set,data):
|
||||
|
@ -657,11 +657,25 @@ class EditPerson:
|
||||
def redraw_attr_list(self):
|
||||
"""redraws the attribute list for the person"""
|
||||
self.atree.clear()
|
||||
self.amap = {}
|
||||
for attr in self.alist:
|
||||
self.atree.add([const.display_pattr(attr.getType()),attr.getValue()],attr)
|
||||
iter = self.atree.add([const.display_pattr(attr.getType()),attr.getValue()],attr)
|
||||
self.amap[str(attr)] = iter
|
||||
if self.alist:
|
||||
self.atree.select_row(0)
|
||||
|
||||
def event_edit_callback(self,event):
|
||||
"""Birth and death events may not be in the map"""
|
||||
self.redraw_event_list()
|
||||
try:
|
||||
self.etree.select_iter(self.emap[str(event)])
|
||||
except:
|
||||
pass
|
||||
|
||||
def attr_edit_callback(self,attr):
|
||||
self.redraw_attr_list()
|
||||
self.atree.select_iter(self.amap[str(attr)])
|
||||
|
||||
def redraw_event_list(self):
|
||||
"""redraw_event_list - Update both the birth and death place combo
|
||||
boxes for any changes that occurred in the 'Event Edit' window.
|
||||
@ -671,9 +685,11 @@ class EditPerson:
|
||||
and restore the value for the event *not* being edited."""
|
||||
|
||||
self.etree.clear()
|
||||
self.emap = {}
|
||||
for event in self.elist:
|
||||
self.etree.add([const.display_pevent(event.getName()),event.getDescription(),
|
||||
event.getQuoteDate(),event.getPlaceName()],event)
|
||||
iter = self.etree.add([const.display_pevent(event.getName()),event.getDescription(),
|
||||
event.getQuoteDate(),event.getPlaceName()],event)
|
||||
self.emap[str(event)] = iter
|
||||
if self.elist:
|
||||
self.etree.select_row(0)
|
||||
|
||||
@ -722,7 +738,8 @@ class EditPerson:
|
||||
"""Brings up the AttributeEditor for a new attribute"""
|
||||
import AttrEdit
|
||||
pname = self.person.getPrimaryName().getName()
|
||||
AttrEdit.AttributeEditor(self,None,pname,const.personalAttributes)
|
||||
AttrEdit.AttributeEditor(self,None,pname,const.personalAttributes,
|
||||
self.attr_edit_callback)
|
||||
|
||||
def on_up_clicked(self,obj):
|
||||
sel = obj.get_selection()
|
||||
@ -743,7 +760,7 @@ class EditPerson:
|
||||
import EventEdit
|
||||
pname = self.person.getPrimaryName().getName()
|
||||
EventEdit.EventEditor(self,pname,const.personalEvents,
|
||||
const.save_fevent,None,None,0,self.callback)
|
||||
const.save_fevent,None,None,0,self.event_edit_callback)
|
||||
|
||||
def on_edit_birth_clicked(self,obj):
|
||||
"""Brings up the EventEditor for the birth record, event
|
||||
@ -763,7 +780,7 @@ class EditPerson:
|
||||
event.setPlace(p)
|
||||
EventEdit.EventEditor(self,pname,const.personalEvents,
|
||||
const.save_fevent,event,def_placename,1,
|
||||
self.callback)
|
||||
self.event_edit_callback)
|
||||
|
||||
def on_edit_death_clicked(self,obj):
|
||||
"""Brings up the EventEditor for the death record, event
|
||||
@ -783,7 +800,7 @@ class EditPerson:
|
||||
event.setPlace(p)
|
||||
EventEdit.EventEditor(self,pname,const.personalEvents,
|
||||
const.save_fevent,event,def_placename,1,
|
||||
self.callback)
|
||||
self.event_edit_callback)
|
||||
|
||||
def on_aka_delete_clicked(self,obj):
|
||||
"""Deletes the selected name from the name list"""
|
||||
@ -999,7 +1016,8 @@ class EditPerson:
|
||||
if iter:
|
||||
attr = self.atree.get_object(iter)
|
||||
pname = self.person.getPrimaryName().getName()
|
||||
AttrEdit.AttributeEditor(self,attr,pname,const.personalAttributes)
|
||||
AttrEdit.AttributeEditor(self,attr,pname,const.personalAttributes,
|
||||
self.attr_edit_callback)
|
||||
|
||||
def on_update_addr_clicked(self,obj):
|
||||
import AddrEdit
|
||||
@ -1025,7 +1043,7 @@ class EditPerson:
|
||||
event = self.etree.get_object(iter)
|
||||
EventEdit.EventEditor(self,pname,const.personalEvents,
|
||||
const.save_fevent,event,None,0,
|
||||
self.callback)
|
||||
self.event_edit_callback)
|
||||
|
||||
def on_event_select_row(self,obj):
|
||||
store,iter = obj.get_selected()
|
||||
|
@ -224,7 +224,7 @@ class EventEditor:
|
||||
|
||||
self.update_event(ename,self.date,eplace_obj,edesc,enote,epriv,ecause)
|
||||
self.parent.redraw_event_list()
|
||||
self.callback(None,self.plist)
|
||||
self.callback(self.event)
|
||||
Utils.destroy_passed_object(obj)
|
||||
|
||||
def update_event(self,name,date,place,desc,note,priv,cause):
|
||||
|
@ -661,9 +661,11 @@ class LocalMediaProperties:
|
||||
|
||||
def redraw_attr_list(self):
|
||||
self.atree.clear()
|
||||
self.amap = {}
|
||||
for attr in self.alist:
|
||||
d = [attr.getType(),attr.getValue()]
|
||||
self.atree.add(d,attr)
|
||||
iter = self.atree.add(d,attr)
|
||||
self.amap[str(attr)] = iter
|
||||
|
||||
def on_apply_clicked(self, obj):
|
||||
priv = self.change_dialog.get_widget("private").get_active()
|
||||
@ -695,7 +697,11 @@ class LocalMediaProperties:
|
||||
else:
|
||||
self.attr_type.set_label('')
|
||||
self.attr_value.set_text('')
|
||||
|
||||
|
||||
def attr_callback(self,attr):
|
||||
self.redraw_attr_list()
|
||||
self.atree.select_iter(self.amap[str(attr)])
|
||||
|
||||
def on_update_attr_clicked(self,obj):
|
||||
import AttrEdit
|
||||
|
||||
@ -703,7 +709,8 @@ class LocalMediaProperties:
|
||||
if iter:
|
||||
attr = self.atree.get_object(iter)
|
||||
AttrEdit.AttributeEditor(self,attr,"Media Object",
|
||||
Plugins.get_image_attributes())
|
||||
Plugins.get_image_attributes(),
|
||||
self.attr_callback)
|
||||
|
||||
def on_delete_attr_clicked(self,obj):
|
||||
if Utils.delete_selected(obj,self.alist):
|
||||
@ -713,7 +720,8 @@ class LocalMediaProperties:
|
||||
def on_add_attr_clicked(self,obj):
|
||||
import AttrEdit
|
||||
AttrEdit.AttributeEditor(self,None,"Media Object",
|
||||
Plugins.get_image_attributes())
|
||||
Plugins.get_image_attributes(),
|
||||
self.attr_callback)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -814,9 +822,11 @@ class GlobalMediaProperties:
|
||||
|
||||
def redraw_attr_list(self):
|
||||
self.atree.clear()
|
||||
self.amap = {}
|
||||
for attr in self.alist:
|
||||
d = [attr.getType(),attr.getValue()]
|
||||
self.atree.add(d,attr)
|
||||
iter = self.atree.add(d,attr)
|
||||
self.amap[str(attr)] = iter
|
||||
|
||||
def button_press(self,obj):
|
||||
store,iter = self.refmodel.selection.get_selected()
|
||||
@ -885,6 +895,10 @@ class GlobalMediaProperties:
|
||||
self.attr_type.set_label('')
|
||||
self.attr_value.set_text('')
|
||||
|
||||
def attr_callback(self,attr):
|
||||
self.redraw_attr_list()
|
||||
self.atree.select_iter(self.amap[str(attr)])
|
||||
|
||||
def on_update_attr_clicked(self,obj):
|
||||
import AttrEdit
|
||||
|
||||
@ -892,7 +906,8 @@ class GlobalMediaProperties:
|
||||
if iter:
|
||||
attr = self.atree.get_object(iter)
|
||||
AttrEdit.AttributeEditor(self,attr,"Media Object",
|
||||
Plugins.get_image_attributes())
|
||||
Plugins.get_image_attributes(),
|
||||
self.attr_callback)
|
||||
|
||||
def on_delete_attr_clicked(self,obj):
|
||||
if Utils.delete_selected(obj,self.alist):
|
||||
@ -902,7 +917,8 @@ class GlobalMediaProperties:
|
||||
def on_add_attr_clicked(self,obj):
|
||||
import AttrEdit
|
||||
AttrEdit.AttributeEditor(self,None,"Media Object",
|
||||
Plugins.get_image_attributes())
|
||||
Plugins.get_image_attributes(),
|
||||
self.attr_callback)
|
||||
|
||||
class DeleteMediaQuery:
|
||||
|
||||
|
@ -34,6 +34,7 @@ class ListModel:
|
||||
|
||||
self.tree.set_rules_hint(gtk.TRUE)
|
||||
self.model = None
|
||||
self.selection = None
|
||||
self.mode = mode
|
||||
self.new_model()
|
||||
self.data_index = l
|
||||
@ -80,7 +81,10 @@ class ListModel:
|
||||
def new_model(self):
|
||||
if self.model:
|
||||
self.cid = self.model.get_sort_column_id()
|
||||
del self.model
|
||||
del self.selection
|
||||
self.count = 0
|
||||
|
||||
self.model = gtk.ListStore(*self.mylist)
|
||||
self.selection = self.tree.get_selection()
|
||||
self.selection.set_mode(self.mode)
|
||||
@ -164,6 +168,9 @@ class ListModel:
|
||||
|
||||
def select_row(self,row):
|
||||
self.selection.select_path((row))
|
||||
|
||||
def select_iter(self,iter):
|
||||
self.selection.select_iter(iter)
|
||||
|
||||
def get_object(self,iter):
|
||||
return self.model.get_value(iter,self.data_index)
|
||||
|
@ -339,18 +339,26 @@ class Marriage:
|
||||
self.family.setEventList(self.elist)
|
||||
self.family.setAttributeList(self.alist)
|
||||
|
||||
def attr_edit_callback(self,attr):
|
||||
self.redraw_attr_list()
|
||||
self.atree.select_iter(self.amap[str(attr)])
|
||||
|
||||
def redraw_attr_list(self):
|
||||
self.atree.clear()
|
||||
self.amap = {}
|
||||
for attr in self.alist:
|
||||
d = [const.display_fattr(attr.getType()),attr.getValue()]
|
||||
self.atree.add(d,attr)
|
||||
iter = self.atree.add(d,attr)
|
||||
self.amap[str(attr)] = iter
|
||||
if self.alist:
|
||||
self.atree.select_row(0)
|
||||
|
||||
def redraw_event_list(self):
|
||||
self.etree.clear()
|
||||
self.emap = {}
|
||||
for data in self.elist:
|
||||
self.etree.add([data.getName(),data.getQuoteDate(),data.getPlaceName()],data)
|
||||
iter = self.etree.add([data.getName(),data.getQuoteDate(),data.getPlaceName()],data)
|
||||
self.emap[str(data)] = iter
|
||||
if self.elist:
|
||||
self.etree.select_row(0)
|
||||
|
||||
@ -502,11 +510,19 @@ class Marriage:
|
||||
Utils.modified()
|
||||
self.update_fv(self.family)
|
||||
|
||||
def event_edit_callback(self,event):
|
||||
"""Birth and death events may not be in the map"""
|
||||
self.redraw_event_list()
|
||||
try:
|
||||
self.etree.select_iter(self.emap[str(event)])
|
||||
except:
|
||||
pass
|
||||
|
||||
def on_add_clicked(self,obj):
|
||||
import EventEdit
|
||||
name = Utils.family_name(self.family)
|
||||
EventEdit.EventEditor(self,name,const.marriageEvents,
|
||||
const.save_pevent,None,None,0,self.cb,
|
||||
const.save_pevent,None,None,0,self.event_edit_callback,
|
||||
const.defaultMarriageEvent)
|
||||
|
||||
def on_event_update_clicked(self,obj):
|
||||
@ -517,7 +533,7 @@ class Marriage:
|
||||
event = self.etree.get_object(iter)
|
||||
name = Utils.family_name(self.family)
|
||||
EventEdit.EventEditor(self,name,const.marriageEvents,
|
||||
const.save_pevent,event,None,0,self.cb)
|
||||
const.save_pevent,event,None,0,self.event_edit_callback)
|
||||
|
||||
def on_delete_clicked(self,obj):
|
||||
if Utils.delete_selected(obj,self.elist):
|
||||
@ -577,7 +593,8 @@ class Marriage:
|
||||
name = father.getPrimaryName().getName()
|
||||
else:
|
||||
name = mother.getPrimaryName().getName()
|
||||
AttrEdit.AttributeEditor(self,attr,name,const.familyAttributes)
|
||||
AttrEdit.AttributeEditor(self,attr,name,const.familyAttributes,
|
||||
self.attr_edit_callback)
|
||||
|
||||
def on_delete_attr_clicked(self,obj):
|
||||
if Utils.delete_selected(obj,self.alist):
|
||||
@ -595,7 +612,8 @@ class Marriage:
|
||||
name = father.getPrimaryName().getName()
|
||||
else:
|
||||
name = mother.getPrimaryName().getName()
|
||||
AttrEdit.AttributeEditor(self,None,name,const.familyAttributes)
|
||||
AttrEdit.AttributeEditor(self,None,name,const.familyAttributes,
|
||||
self.attr_edit_callback)
|
||||
|
||||
def move_element(self,list,src,dest):
|
||||
if src == -1:
|
||||
|
Loading…
Reference in New Issue
Block a user