Add functionality to PageView to remove multiple object from DataViews. Implement in all DataViews except Person and Family

svn: r10925
This commit is contained in:
Gary Burton 2008-07-26 08:34:09 +00:00
parent 5a75d49007
commit f04fdfb9ef
6 changed files with 75 additions and 174 deletions

View File

@ -44,7 +44,6 @@ import Errors
import Bookmarks
import Config
from DdTargets import DdTargets
from QuestionDialog import QuestionDialog, QuestionDialog2
from Editors import EditEvent, DelEventQuery
from Filters.SideBar import EventSidebarFilter
from ReportBase import CATEGORY_QR_EVENT
@ -221,55 +220,23 @@ class EventView(PageView.ListView):
pass
def remove(self, obj):
prompt = True
if len(self.selected_handles()) > 1:
q = QuestionDialog2(
_("Remove selected events?"),
_("More than one event has been selected for deletion. "
"Ask before deleting each one?"),
_("Yes"),
_("No"))
prompt = q.run()
if not prompt:
self.uistate.set_busy_cursor(1)
self.remove_selected_objects()
for ehandle in self.selected_handles():
person_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(ehandle,['Person']) ]
def remove_object_from_handle(self, handle):
person_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(handle,['Person']) ]
family_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(ehandle,['Family']) ]
event = self.dbstate.db.get_event_from_handle(ehandle)
family_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(handle,['Family']) ]
object = self.dbstate.db.get_event_from_handle(handle)
ans = DelEventQuery(self.dbstate, self.uistate, event,
person_list, family_list)
if prompt:
if len(person_list) + len(family_list) > 0:
msg = _('This event is currently being used. Deleting it '
'will remove it from the database and from all '
'people and families that reference it.')
else:
msg = _('Deleting event will remove it from the database.')
msg = "%s %s" % (msg, Utils.data_recover_msg)
descr = event.get_description()
if descr == "":
descr = event.get_gramps_id()
self.uistate.set_busy_cursor(1)
QuestionDialog(_('Delete %s?') % descr, msg,
_('_Delete Event'), ans.query_response)
self.uistate.set_busy_cursor(0)
else:
ans.query_response()
if not prompt:
self.uistate.set_busy_cursor(0)
query = DelEventQuery(self.dbstate, self.uistate, object,
person_list, family_list)
is_used = len(person_list) + len(family_list) > 0
return (query, is_used, object)
def edit(self, obj):
mlist = []

View File

@ -1,6 +1,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2001-2006 Donald N. Allingham
# Copyright (C) 2008 Gary Burton
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -57,7 +58,6 @@ import gen.lib
from Editors import EditMedia, DeleteMediaQuery
import Errors
from QuestionDialog import QuestionDialog, ErrorDialog
from Filters.SideBar import MediaSidebarFilter
from DdTargets import DdTargets
@ -106,7 +106,8 @@ class MediaView(PageView.ListView):
MediaView.COLUMN_NAMES, len(MediaView.COLUMN_NAMES),
DisplayModels.MediaModel,
signal_map, dbstate.db.get_media_bookmarks(),
Bookmarks.MediaBookmarks, filter_class=MediaSidebarFilter)
Bookmarks.MediaBookmarks, filter_class=MediaSidebarFilter,
multiple=True)
self.func_list = {
'<CONTROL>J' : self.jump,
@ -383,28 +384,18 @@ class MediaView(PageView.ListView):
pass
def remove(self, obj):
self.remove_selected_objects()
def remove_object_from_handle(self, handle):
"""
Remove the selected object from the database after getting
Remove the selected objects from the database after getting
user verification.
"""
handle = self.first_selected()
if not handle:
return
the_lists = Utils.get_media_referents(handle, self.dbstate.db)
ans = DeleteMediaQuery(self.dbstate, self.uistate, handle, the_lists)
if any(the_lists): # quick test for non-emptiness
msg = _('This media object is currently being used. '
'If you delete this object, it will be removed from '
'the database and from all records that reference it.')
else:
msg = _('Deleting media object will remove it from the database.')
msg = "%s %s" % (msg, Utils.data_recover_msg)
self.uistate.set_busy_cursor(1)
QuestionDialog(_('Delete Media Object?'), msg,
_('_Delete Media Object'), ans.query_response)
self.uistate.set_busy_cursor(0)
object = self.dbstate.db.get_object_from_handle(handle)
query = DeleteMediaQuery(self.dbstate, self.uistate, handle, the_lists)
is_used = any(the_lists)
return (query, is_used, object)
def edit(self, obj):
"""

View File

@ -1,6 +1,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2001-2006 Donald N. Allingham
# Copyright (C) 2008 Gary Burton
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -44,7 +45,6 @@ import Config
import ColumnOrder
from gen.lib import Note
from DdTargets import DdTargets
from QuestionDialog import QuestionDialog
from Filters.SideBar import NoteSidebarFilter
from Editors import EditNote, DeleteNoteQuery
@ -95,7 +95,7 @@ class NoteView(PageView.ListView):
dbstate.db.get_note_bookmarks(),
Bookmarks.NoteBookmarks,
filter_class=NoteSidebarFilter,
multiple=False)
multiple=True)
Config.client.notify_add("/apps/gramps/interface/filter",
self.filter_toggle)
@ -196,27 +196,14 @@ class NoteView(PageView.ListView):
pass
def remove(self, obj):
for note_handle in self.selected_handles():
db = self.dbstate.db
the_lists = Utils.get_note_referents(note_handle, db)
self.remove_selected_objects()
note = db.get_note_from_handle(note_handle)
ans = DeleteNoteQuery(self.dbstate, self.uistate, note, the_lists)
if any(the_lists): # quick test for non-emptiness
msg = _('This note is currently being used. Deleting it '
'will remove it from the database and from all '
'other objects that reference it.')
else:
msg = _('Deleting note will remove it from the database.')
msg = "%s %s" % (msg, Utils.data_recover_msg)
descr = note.get_gramps_id()
self.uistate.set_busy_cursor(1)
QuestionDialog(_('Delete %s?') % descr, msg,
_('_Delete Note'), ans.query_response)
self.uistate.set_busy_cursor(0)
def remove_object_from_handle(self, handle):
the_lists = Utils.get_note_referents(handle, self.dbstate.db)
object = self.dbstate.db.get_note_from_handle(handle)
query = DeleteNoteQuery(self.dbstate, self.uistate, object, the_lists)
is_used = any(the_lists)
return (query, is_used, object)
def edit(self, obj):
mlist = []

View File

@ -1,6 +1,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2001-2006 Donald N. Allingham
# Copyright (C) 2008 Gary Burton
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -44,7 +45,6 @@ import Bookmarks
import Config
from DdTargets import DdTargets
from Editors import EditPlace, DeletePlaceQuery
from QuestionDialog import QuestionDialog, ErrorDialog
from Filters.SideBar import PlaceSidebarFilter
#-------------------------------------------------------------------------
@ -221,41 +221,27 @@ class PlaceView(PageView.ListView):
pass
def remove(self, obj):
for place_handle in self.selected_handles():
db = self.dbstate.db
person_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(place_handle,['Person'])]
self.remove_selected_objects()
family_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(place_handle,['Family'])]
event_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(place_handle,['Event'])]
place = db.get_place_from_handle(place_handle)
ans = DeletePlaceQuery(self.dbstate,self.uistate,
place,person_list,family_list,event_list)
def remove_object_from_handle(self, handle):
person_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(handle,['Person'])]
if len(person_list) + len(family_list) > 0:
msg = _('This place is currently being used. Deleting it '
'will remove it from the database and from all '
'people and families that reference it.')
else:
msg = _('Deleting place will remove it from the database.')
msg = "%s %s" % (msg, Utils.data_recover_msg)
descr = place.get_title()
if descr == "":
descr = place.get_gramps_id()
self.uistate.set_busy_cursor(1)
QuestionDialog(_('Delete %s?') % descr, msg,
_('_Delete Place'), ans.query_response)
self.uistate.set_busy_cursor(0)
family_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(handle,['Family'])]
event_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(handle,['Event'])]
object = self.dbstate.db.get_place_from_handle(handle)
query = DeletePlaceQuery(self.dbstate, self.uistate, object,
person_list, family_list, event_list)
is_used = len(person_list) + len(family_list) + len(event_list) > 0
return (query, is_used, object)
def edit(self, obj):
mlist = []

View File

@ -1,6 +1,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2001-2006 Donald N. Allingham
# Copyright (C) 2008 Gary Burton
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -44,7 +45,6 @@ import Errors
import Config
from Editors import EditRepository, DelRepositoryQuery
from DdTargets import DdTargets
from QuestionDialog import QuestionDialog
from Filters.SideBar import RepoSidebarFilter
from ReportBase import CATEGORY_QR_REPOSITORY
@ -104,7 +104,8 @@ class RepositoryView(PageView.ListView):
RepositoryView.COLUMN_NAMES, len(RepositoryView.COLUMN_NAMES),
DisplayModels.RepositoryModel, signal_map,
dbstate.db.get_repo_bookmarks(),
Bookmarks.RepoBookmarks,filter_class=RepoSidebarFilter)
Bookmarks.RepoBookmarks, multiple=True,
filter_class=RepoSidebarFilter)
Config.client.notify_add("/apps/gramps/interface/filter",
self.filter_toggle)
@ -192,33 +193,17 @@ class RepositoryView(PageView.ListView):
EditRepository(self.dbstate, self.uistate, [], gen.lib.Repository())
def remove(self, obj):
db = self.dbstate.db
mlist = []
self.selection.selected_foreach(self.blist, mlist)
self.remove_selected_objects()
for repos_handle in mlist:
source_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(repos_handle,['Source'])]
repository = db.get_repository_from_handle(repos_handle)
ans = DelRepositoryQuery(self.dbstate,self.uistate,
repository,source_list)
if len(source_list) > 0:
msg = _('This repository is currently being used. Deleting it '
'will remove it from the database and from all '
'sources that reference it.')
else:
msg = _('Deleting repository will remove it from the database.')
msg = "%s %s" % (msg, Utils.data_recover_msg)
self.uistate.set_busy_cursor(1)
QuestionDialog(_('Delete %s?') % repository.get_name(), msg,
_('_Delete Repository'), ans.query_response)
self.uistate.set_busy_cursor(0)
def remove_object_from_handle(self, handle):
source_list = [
item[1] for item in
self.dbstate.db.find_backlink_handles(handle, ['Source'])]
object = self.dbstate.db.get_repository_from_handle(handle)
query = DelRepositoryQuery(self.dbstate, self.uistate, object,
source_list)
is_used = len(source_list) > 0
return (query, is_used, object)
def edit(self, obj):
mlist = []

View File

@ -1,6 +1,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2001-2006 Donald N. Allingham
# Copyright (C) 2008 Gary Burton
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -44,7 +45,6 @@ import Bookmarks
import Errors
from DdTargets import DdTargets
from Editors import EditSource, DelSrcQuery
from QuestionDialog import QuestionDialog, ErrorDialog
from Filters.SideBar import SourceSidebarFilter
#-------------------------------------------------------------------------
@ -181,29 +181,14 @@ class SourceView(PageView.ListView):
EditSource(self.dbstate, self.uistate, [], gen.lib.Source())
def remove(self, obj):
for source_handle in self.selected_handles():
db = self.dbstate.db
the_lists = Utils.get_source_referents(source_handle, db)
self.remove_selected_objects()
source = db.get_source_from_handle(source_handle)
ans = DelSrcQuery(self.dbstate,self.uistate,source,the_lists)
if any(the_lists): # quick test for non-emptiness
msg = _('This source is currently being used. Deleting it '
'will remove it from the database and from all '
'people and families that reference it.')
else:
msg = _('Deleting source will remove it from the database.')
msg = "%s %s" % (msg, Utils.data_recover_msg)
descr = source.get_title()
if descr == "":
descr = source.get_gramps_id()
self.uistate.set_busy_cursor(1)
QuestionDialog(_('Delete %s?') % descr, msg,
_('_Delete Source'), ans.query_response)
self.uistate.set_busy_cursor(0)
def remove_object_from_handle(self, handle):
the_lists = Utils.get_source_referents(handle, self.dbstate.db)
object = self.dbstate.db.get_source_from_handle(handle)
query = DelSrcQuery(self.dbstate, self.uistate, object, the_lists)
is_used = any(the_lists)
return (query, is_used, object)
def edit(self, obj):
mlist = []