* src/AddMedia.py: use new MediaList update routine

* src/DisplayModels.py: new update list routine
* src/ImageSelect.py: use new MediaList update routine
* src/MediaView.py: use new MediaList update routine
* src/PlaceView.py: new update list routine
* src/SourceView.py: new update list routine


svn: r3521
This commit is contained in:
Don Allingham 2004-08-31 03:51:05 +00:00
parent 0e4693a675
commit bc0e50c8f0
7 changed files with 62 additions and 37 deletions

View File

@ -1,3 +1,11 @@
2004-08-30 Don Allingham <dallingham@users.sourceforge.net>
* src/AddMedia.py: use new MediaList update routine
* src/DisplayModels.py: new update list routine
* src/ImageSelect.py: use new MediaList update routine
* src/MediaView.py: use new MediaList update routine
* src/PlaceView.py: new update list routine
* src/SourceView.py: new update list routine
2004-08-29 Don Allingham <dallingham@users.sourceforge.net> 2004-08-29 Don Allingham <dallingham@users.sourceforge.net>
* src/GrampsBSDDB.py: add remove_place function * src/GrampsBSDDB.py: add remove_place function
* src/DisplayModels.py: added row deletion and updating * src/DisplayModels.py: added row deletion and updating

View File

@ -134,7 +134,7 @@ class AddMediaObject:
self.db.commit_media_object(mobj,trans) self.db.commit_media_object(mobj,trans)
self.db.transaction_commit(trans,_("Add Media Object")) self.db.transaction_commit(trans,_("Add Media Object"))
if self.update: if self.update:
self.update() self.update(mobj.get_handle())
def on_name_changed(self,*obj): def on_name_changed(self,*obj):
""" """

View File

@ -59,6 +59,12 @@ class BaseModel(gtk.GenericTreeModel):
del self.datalist[index] del self.datalist[index]
self.row_deleted(index) self.row_deleted(index)
def add_row_by_handle(self,handle):
self.datalist = self.sort_keys()
index = self.datalist.index(handle)
iter = self.get_iter(index)
self.row_inserted(index,iter)
def delete_row_by_handle(self,handle): def delete_row_by_handle(self,handle):
index = self.datalist.index(handle) index = self.datalist.index(handle)
del self.datalist[index] del self.datalist[index]

View File

@ -1108,11 +1108,11 @@ class GlobalMediaProperties:
if self.lists_changed: if self.lists_changed:
self.obj.set_attribute_list(self.alist) self.obj.set_attribute_list(self.alist)
self.obj.set_source_reference_list(self.srcreflist) self.obj.set_source_reference_list(self.srcreflist)
if self.update != None:
self.update()
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
self.db.commit_media_object(self.obj,trans) self.db.commit_media_object(self.obj,trans)
self.db.transaction_commit(trans,_("Edit Media Object")) self.db.transaction_commit(trans,_("Edit Media Object"))
if self.update != None:
self.update(self.obj)
def on_help_clicked(self, obj): def on_help_clicked(self, obj):
"""Display the relevant portion of GRAMPS manual""" """Display the relevant portion of GRAMPS manual"""

View File

@ -150,8 +150,8 @@ class MediaView:
self.build_tree() self.build_tree()
def build_tree(self): def build_tree(self):
self.model = gtk.TreeModelSort(DisplayModels.MediaModel(self.parent.db)) #self.model = gtk.TreeModelSort(DisplayModels.MediaModel(self.parent.db))
# self.model = DisplayModels.MediaModel(self.parent.db) self.model = DisplayModels.MediaModel(self.parent.db)
self.list.set_model(self.model) self.list.set_model(self.model)
self.selection = self.list.get_selection() self.selection = self.list.get_selection()
@ -258,21 +258,24 @@ class MediaView:
name = RelImage.import_media_object(self.obj.get_path(),path,handle) name = RelImage.import_media_object(self.obj.get_path(),path,handle)
if name: if name:
self.obj.set_path(name) self.obj.set_path(name)
self.load_media()
def popup_change_description(self, obj): def popup_change_description(self, obj):
ImageSelect.GlobalMediaProperties(self.db,self.obj,self.load_media, ImageSelect.GlobalMediaProperties(self.db,self.obj,
self,self.topWindow) self.update_display,
self,self.topWindow)
def load_media(self):
pass
def on_add_clicked(self,obj): def on_add_clicked(self,obj):
"""Add a new media object to the media list""" """Add a new media object to the media list"""
import AddMedia import AddMedia
am = AddMedia.AddMediaObject(self.db,self.build_tree) am = AddMedia.AddMediaObject(self.db,self.add_object)
am.run() am.run()
def add_object(self,mobj_handle):
self.model.add_row_by_handle(mobj_handle)
def update_display(self,mobj):
self.model.update_row_by_handle(mobj.get_handle())
def on_edit_clicked(self,obj): def on_edit_clicked(self,obj):
"""Edit the properties of an existing media object in the media list""" """Edit the properties of an existing media object in the media list"""
@ -280,8 +283,9 @@ class MediaView:
if node: if node:
handle = list_store.get_value(node,5) handle = list_store.get_value(node,5)
obj = self.db.get_object_from_handle(handle) obj = self.db.get_object_from_handle(handle)
ImageSelect.GlobalMediaProperties(self.db,obj,self.load_media, ImageSelect.GlobalMediaProperties(self.db,obj,
self,self.topWindow) self.update_display,
self,self.topWindow)
def on_delete_clicked(self,obj): def on_delete_clicked(self,obj):
store,node = self.selection.get_selected() store,node = self.selection.get_selected()
@ -291,7 +295,8 @@ class MediaView:
handle = store.get_value(node,5) handle = store.get_value(node,5)
mobj = self.db.get_object_from_handle(handle) mobj = self.db.get_object_from_handle(handle)
if self.is_object_used(mobj): if self.is_object_used(mobj):
ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.build_tree) ans = ImageSelect.DeleteMediaQuery(mobj,self.db,
self.model.delete_row_by_handle)
QuestionDialog(_('Delete Media Object?'), QuestionDialog(_('Delete Media Object?'),
_('This media object is currently being used. ' _('This media object is currently being used. '
'If you delete this object, it will be removed ' 'If you delete this object, it will be removed '
@ -300,33 +305,39 @@ class MediaView:
_('_Delete Media Object'), _('_Delete Media Object'),
ans.query_response) ans.query_response)
else: else:
trans = self.db.transaction_begin() self.delete_object(mobj)
self.db.remove_object(mobj.get_handle(),trans)
self.db.transaction_commit(trans,_("Remove Media Object")) def delete_object(self,media_obj):
self.build_tree() trans = self.parent.db.transaction_begin()
mobj_handle = media_obj.get_handle()
self.parent.db.remove_object(mobj_handle,trans)
title_msg = _("Delete Media Object?")
self.parent.db.transaction_commit(trans,title_msg)
self.model.delete_row_by_handle(mobj_handle)
def is_object_used(self,mobj): def is_object_used(self,mobj):
for family_handle in self.db.get_family_handles(): mhandle = mobj.get_handle()
for family_handle in self.db.get_family_handles(sort_handles=False):
p = self.db.get_family_from_handle(family_handle) p = self.db.get_family_from_handle(family_handle)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference_handle() == mobj.get_handle(): if o.get_reference_handle() == mhandle:
return 1 return True
for key in self.db.get_person_handles(sort_handles=False): for key in self.db.get_person_handles(sort_handles=False):
p = self.db.get_person_from_handle(key) p = self.db.get_person_from_handle(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference_handle() == mobj.get_handle(): if o.get_reference_handle() == mhandle:
return 1 return True
for key in self.db.get_source_handles(): for key in self.db.get_source_handles(sort_handles=False):
p = self.db.get_source_from_handle(key) p = self.db.get_source_from_handle(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference_handle() == mobj.get_handle(): if o.get_reference_handle() == mhandle:
return 1 return True
for key in self.db.get_place_handles(): for key in self.db.get_place_handles(sort_handles=False):
p = self.db.get_place_handle(key) p = self.db.get_place_from_handle(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference_handle() == mobj.get_handle(): if o.get_reference_handle() == mhandle:
return 1 return True
return 0 return False
def on_drag_begin(self,obj,context): def on_drag_begin(self,obj,context):
store,node = self.selection.get_selected() store,node = self.selection.get_selected()
@ -363,7 +374,6 @@ class MediaView:
photo.set_description(description) photo.set_description(description)
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
self.db.add_object(photo,trans) self.db.add_object(photo,trans)
self.load_media()
if GrampsCfg.get_media_reference() == 0: if GrampsCfg.get_media_reference() == 0:
name = RelImage.import_media_object(name, name = RelImage.import_media_object(name,
self.db.get_save_path(), self.db.get_save_path(),
@ -375,8 +385,9 @@ class MediaView:
self.db.transaction_commit(trans,_("Add Media Object")) self.db.transaction_commit(trans,_("Add Media Object"))
if GrampsCfg.get_media_global(): if GrampsCfg.get_media_global():
ImageSelect.GlobalMediaProperties(self.db,photo,self.load_media, ImageSelect.GlobalMediaProperties(self.db,photo,
self,self.topWindow) self.update_display,
self,self.topWindow)
elif protocol != "": elif protocol != "":
import urllib import urllib
u = urllib.URLopener() u = urllib.URLopener()

View File

@ -173,7 +173,7 @@ class PlaceView:
EditPlace.EditPlace(self.parent,RelLib.Place(),self.new_place_after_edit) EditPlace.EditPlace(self.parent,RelLib.Place(),self.new_place_after_edit)
def new_place_after_edit(self,place): def new_place_after_edit(self,place):
self.build_tree() self.model.add_row_by_handle(place.get_handle())
def update_display(self,place): def update_display(self,place):
self.model.update_row_by_handle(place.get_handle()) self.model.update_row_by_handle(place.get_handle())

View File

@ -249,7 +249,7 @@ class SourceView:
self.topWindow, self.update_display) self.topWindow, self.update_display)
def new_after_edit(self,source): def new_after_edit(self,source):
self.build_tree() self.model.add_row_by_handle(source.get_handle())
def update_display(self,source): def update_display(self,source):
self.model.update_row_by_handle(source.get_handle()) self.model.update_row_by_handle(source.get_handle())