diff --git a/src/DataViews/EventView.py b/src/DataViews/EventView.py index b45ae82c2..a82be20ec 100644 --- a/src/DataViews/EventView.py +++ b/src/DataViews/EventView.py @@ -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 = [] diff --git a/src/DataViews/MediaView.py b/src/DataViews/MediaView.py index d5e95b9d6..c546debf5 100644 --- a/src/DataViews/MediaView.py +++ b/src/DataViews/MediaView.py @@ -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 = { '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): """ diff --git a/src/DataViews/NoteView.py b/src/DataViews/NoteView.py index 101163d89..e0a08630f 100644 --- a/src/DataViews/NoteView.py +++ b/src/DataViews/NoteView.py @@ -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 = [] diff --git a/src/DataViews/PlaceView.py b/src/DataViews/PlaceView.py index 3ceea3bc1..2503253ce 100644 --- a/src/DataViews/PlaceView.py +++ b/src/DataViews/PlaceView.py @@ -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 = [] diff --git a/src/DataViews/RepositoryView.py b/src/DataViews/RepositoryView.py index abbc1d3c6..af5394ce9 100644 --- a/src/DataViews/RepositoryView.py +++ b/src/DataViews/RepositoryView.py @@ -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 = [] diff --git a/src/DataViews/SourceView.py b/src/DataViews/SourceView.py index 68a872696..2b0c81c00 100644 --- a/src/DataViews/SourceView.py +++ b/src/DataViews/SourceView.py @@ -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 = []