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:
parent
5a75d49007
commit
f04fdfb9ef
@ -44,7 +44,6 @@ import Errors
|
|||||||
import Bookmarks
|
import Bookmarks
|
||||||
import Config
|
import Config
|
||||||
from DdTargets import DdTargets
|
from DdTargets import DdTargets
|
||||||
from QuestionDialog import QuestionDialog, QuestionDialog2
|
|
||||||
from Editors import EditEvent, DelEventQuery
|
from Editors import EditEvent, DelEventQuery
|
||||||
from Filters.SideBar import EventSidebarFilter
|
from Filters.SideBar import EventSidebarFilter
|
||||||
from ReportBase import CATEGORY_QR_EVENT
|
from ReportBase import CATEGORY_QR_EVENT
|
||||||
@ -221,55 +220,23 @@ class EventView(PageView.ListView):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def remove(self, obj):
|
def remove(self, obj):
|
||||||
prompt = True
|
self.remove_selected_objects()
|
||||||
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)
|
|
||||||
|
|
||||||
for ehandle in self.selected_handles():
|
def remove_object_from_handle(self, handle):
|
||||||
person_list = [
|
person_list = [
|
||||||
item[1] for item in
|
item[1] for item in
|
||||||
self.dbstate.db.find_backlink_handles(ehandle,['Person']) ]
|
self.dbstate.db.find_backlink_handles(handle,['Person']) ]
|
||||||
|
|
||||||
family_list = [
|
family_list = [
|
||||||
item[1] for item in
|
item[1] for item in
|
||||||
self.dbstate.db.find_backlink_handles(ehandle,['Family']) ]
|
self.dbstate.db.find_backlink_handles(handle,['Family']) ]
|
||||||
|
|
||||||
event = self.dbstate.db.get_event_from_handle(ehandle)
|
object = self.dbstate.db.get_event_from_handle(handle)
|
||||||
|
|
||||||
ans = DelEventQuery(self.dbstate, self.uistate, event,
|
query = DelEventQuery(self.dbstate, self.uistate, object,
|
||||||
person_list, family_list)
|
person_list, family_list)
|
||||||
|
is_used = len(person_list) + len(family_list) > 0
|
||||||
if prompt:
|
return (query, is_used, object)
|
||||||
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)
|
|
||||||
|
|
||||||
def edit(self, obj):
|
def edit(self, obj):
|
||||||
mlist = []
|
mlist = []
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2001-2006 Donald N. Allingham
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||||
|
# Copyright (C) 2008 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# 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
|
from Editors import EditMedia, DeleteMediaQuery
|
||||||
import Errors
|
import Errors
|
||||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
|
||||||
from Filters.SideBar import MediaSidebarFilter
|
from Filters.SideBar import MediaSidebarFilter
|
||||||
from DdTargets import DdTargets
|
from DdTargets import DdTargets
|
||||||
|
|
||||||
@ -106,7 +106,8 @@ class MediaView(PageView.ListView):
|
|||||||
MediaView.COLUMN_NAMES, len(MediaView.COLUMN_NAMES),
|
MediaView.COLUMN_NAMES, len(MediaView.COLUMN_NAMES),
|
||||||
DisplayModels.MediaModel,
|
DisplayModels.MediaModel,
|
||||||
signal_map, dbstate.db.get_media_bookmarks(),
|
signal_map, dbstate.db.get_media_bookmarks(),
|
||||||
Bookmarks.MediaBookmarks, filter_class=MediaSidebarFilter)
|
Bookmarks.MediaBookmarks, filter_class=MediaSidebarFilter,
|
||||||
|
multiple=True)
|
||||||
|
|
||||||
self.func_list = {
|
self.func_list = {
|
||||||
'<CONTROL>J' : self.jump,
|
'<CONTROL>J' : self.jump,
|
||||||
@ -383,28 +384,18 @@ class MediaView(PageView.ListView):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def remove(self, obj):
|
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.
|
user verification.
|
||||||
"""
|
"""
|
||||||
handle = self.first_selected()
|
|
||||||
if not handle:
|
|
||||||
return
|
|
||||||
the_lists = Utils.get_media_referents(handle, self.dbstate.db)
|
the_lists = Utils.get_media_referents(handle, self.dbstate.db)
|
||||||
|
object = self.dbstate.db.get_object_from_handle(handle)
|
||||||
ans = DeleteMediaQuery(self.dbstate, self.uistate, handle, the_lists)
|
query = DeleteMediaQuery(self.dbstate, self.uistate, handle, the_lists)
|
||||||
if any(the_lists): # quick test for non-emptiness
|
is_used = any(the_lists)
|
||||||
msg = _('This media object is currently being used. '
|
return (query, is_used, object)
|
||||||
'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)
|
|
||||||
|
|
||||||
def edit(self, obj):
|
def edit(self, obj):
|
||||||
"""
|
"""
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2001-2006 Donald N. Allingham
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||||
|
# Copyright (C) 2008 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -44,7 +45,6 @@ import Config
|
|||||||
import ColumnOrder
|
import ColumnOrder
|
||||||
from gen.lib import Note
|
from gen.lib import Note
|
||||||
from DdTargets import DdTargets
|
from DdTargets import DdTargets
|
||||||
from QuestionDialog import QuestionDialog
|
|
||||||
from Filters.SideBar import NoteSidebarFilter
|
from Filters.SideBar import NoteSidebarFilter
|
||||||
from Editors import EditNote, DeleteNoteQuery
|
from Editors import EditNote, DeleteNoteQuery
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ class NoteView(PageView.ListView):
|
|||||||
dbstate.db.get_note_bookmarks(),
|
dbstate.db.get_note_bookmarks(),
|
||||||
Bookmarks.NoteBookmarks,
|
Bookmarks.NoteBookmarks,
|
||||||
filter_class=NoteSidebarFilter,
|
filter_class=NoteSidebarFilter,
|
||||||
multiple=False)
|
multiple=True)
|
||||||
|
|
||||||
Config.client.notify_add("/apps/gramps/interface/filter",
|
Config.client.notify_add("/apps/gramps/interface/filter",
|
||||||
self.filter_toggle)
|
self.filter_toggle)
|
||||||
@ -196,27 +196,14 @@ class NoteView(PageView.ListView):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def remove(self, obj):
|
def remove(self, obj):
|
||||||
for note_handle in self.selected_handles():
|
self.remove_selected_objects()
|
||||||
db = self.dbstate.db
|
|
||||||
the_lists = Utils.get_note_referents(note_handle, db)
|
|
||||||
|
|
||||||
note = db.get_note_from_handle(note_handle)
|
def remove_object_from_handle(self, handle):
|
||||||
|
the_lists = Utils.get_note_referents(handle, self.dbstate.db)
|
||||||
ans = DeleteNoteQuery(self.dbstate, self.uistate, note, the_lists)
|
object = self.dbstate.db.get_note_from_handle(handle)
|
||||||
|
query = DeleteNoteQuery(self.dbstate, self.uistate, object, the_lists)
|
||||||
if any(the_lists): # quick test for non-emptiness
|
is_used = any(the_lists)
|
||||||
msg = _('This note is currently being used. Deleting it '
|
return (query, is_used, object)
|
||||||
'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 edit(self, obj):
|
def edit(self, obj):
|
||||||
mlist = []
|
mlist = []
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2001-2006 Donald N. Allingham
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||||
|
# Copyright (C) 2008 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -44,7 +45,6 @@ import Bookmarks
|
|||||||
import Config
|
import Config
|
||||||
from DdTargets import DdTargets
|
from DdTargets import DdTargets
|
||||||
from Editors import EditPlace, DeletePlaceQuery
|
from Editors import EditPlace, DeletePlaceQuery
|
||||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
|
||||||
from Filters.SideBar import PlaceSidebarFilter
|
from Filters.SideBar import PlaceSidebarFilter
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -221,41 +221,27 @@ class PlaceView(PageView.ListView):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def remove(self, obj):
|
def remove(self, obj):
|
||||||
for place_handle in self.selected_handles():
|
self.remove_selected_objects()
|
||||||
db = self.dbstate.db
|
|
||||||
person_list = [
|
|
||||||
item[1] for item in
|
|
||||||
self.dbstate.db.find_backlink_handles(place_handle,['Person'])]
|
|
||||||
|
|
||||||
family_list = [
|
def remove_object_from_handle(self, handle):
|
||||||
item[1] for item in
|
person_list = [
|
||||||
self.dbstate.db.find_backlink_handles(place_handle,['Family'])]
|
item[1] for item in
|
||||||
|
self.dbstate.db.find_backlink_handles(handle,['Person'])]
|
||||||
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)
|
|
||||||
|
|
||||||
if len(person_list) + len(family_list) > 0:
|
family_list = [
|
||||||
msg = _('This place is currently being used. Deleting it '
|
item[1] for item in
|
||||||
'will remove it from the database and from all '
|
self.dbstate.db.find_backlink_handles(handle,['Family'])]
|
||||||
'people and families that reference it.')
|
|
||||||
else:
|
event_list = [
|
||||||
msg = _('Deleting place will remove it from the database.')
|
item[1] for item in
|
||||||
|
self.dbstate.db.find_backlink_handles(handle,['Event'])]
|
||||||
msg = "%s %s" % (msg, Utils.data_recover_msg)
|
|
||||||
descr = place.get_title()
|
object = self.dbstate.db.get_place_from_handle(handle)
|
||||||
if descr == "":
|
query = DeletePlaceQuery(self.dbstate, self.uistate, object,
|
||||||
descr = place.get_gramps_id()
|
person_list, family_list, event_list)
|
||||||
|
|
||||||
self.uistate.set_busy_cursor(1)
|
is_used = len(person_list) + len(family_list) + len(event_list) > 0
|
||||||
QuestionDialog(_('Delete %s?') % descr, msg,
|
return (query, is_used, object)
|
||||||
_('_Delete Place'), ans.query_response)
|
|
||||||
self.uistate.set_busy_cursor(0)
|
|
||||||
|
|
||||||
def edit(self, obj):
|
def edit(self, obj):
|
||||||
mlist = []
|
mlist = []
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2001-2006 Donald N. Allingham
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||||
|
# Copyright (C) 2008 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -44,7 +45,6 @@ import Errors
|
|||||||
import Config
|
import Config
|
||||||
from Editors import EditRepository, DelRepositoryQuery
|
from Editors import EditRepository, DelRepositoryQuery
|
||||||
from DdTargets import DdTargets
|
from DdTargets import DdTargets
|
||||||
from QuestionDialog import QuestionDialog
|
|
||||||
from Filters.SideBar import RepoSidebarFilter
|
from Filters.SideBar import RepoSidebarFilter
|
||||||
from ReportBase import CATEGORY_QR_REPOSITORY
|
from ReportBase import CATEGORY_QR_REPOSITORY
|
||||||
|
|
||||||
@ -104,7 +104,8 @@ class RepositoryView(PageView.ListView):
|
|||||||
RepositoryView.COLUMN_NAMES, len(RepositoryView.COLUMN_NAMES),
|
RepositoryView.COLUMN_NAMES, len(RepositoryView.COLUMN_NAMES),
|
||||||
DisplayModels.RepositoryModel, signal_map,
|
DisplayModels.RepositoryModel, signal_map,
|
||||||
dbstate.db.get_repo_bookmarks(),
|
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",
|
Config.client.notify_add("/apps/gramps/interface/filter",
|
||||||
self.filter_toggle)
|
self.filter_toggle)
|
||||||
@ -192,33 +193,17 @@ class RepositoryView(PageView.ListView):
|
|||||||
EditRepository(self.dbstate, self.uistate, [], gen.lib.Repository())
|
EditRepository(self.dbstate, self.uistate, [], gen.lib.Repository())
|
||||||
|
|
||||||
def remove(self, obj):
|
def remove(self, obj):
|
||||||
db = self.dbstate.db
|
self.remove_selected_objects()
|
||||||
mlist = []
|
|
||||||
self.selection.selected_foreach(self.blist, mlist)
|
|
||||||
|
|
||||||
for repos_handle in mlist:
|
def remove_object_from_handle(self, handle):
|
||||||
|
source_list = [
|
||||||
source_list = [
|
item[1] for item in
|
||||||
item[1] for item in
|
self.dbstate.db.find_backlink_handles(handle, ['Source'])]
|
||||||
self.dbstate.db.find_backlink_handles(repos_handle,['Source'])]
|
object = self.dbstate.db.get_repository_from_handle(handle)
|
||||||
|
query = DelRepositoryQuery(self.dbstate, self.uistate, object,
|
||||||
repository = db.get_repository_from_handle(repos_handle)
|
source_list)
|
||||||
|
is_used = len(source_list) > 0
|
||||||
ans = DelRepositoryQuery(self.dbstate,self.uistate,
|
return (query, is_used, object)
|
||||||
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 edit(self, obj):
|
def edit(self, obj):
|
||||||
mlist = []
|
mlist = []
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2001-2006 Donald N. Allingham
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||||
|
# Copyright (C) 2008 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -44,7 +45,6 @@ import Bookmarks
|
|||||||
import Errors
|
import Errors
|
||||||
from DdTargets import DdTargets
|
from DdTargets import DdTargets
|
||||||
from Editors import EditSource, DelSrcQuery
|
from Editors import EditSource, DelSrcQuery
|
||||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
|
||||||
from Filters.SideBar import SourceSidebarFilter
|
from Filters.SideBar import SourceSidebarFilter
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -181,29 +181,14 @@ class SourceView(PageView.ListView):
|
|||||||
EditSource(self.dbstate, self.uistate, [], gen.lib.Source())
|
EditSource(self.dbstate, self.uistate, [], gen.lib.Source())
|
||||||
|
|
||||||
def remove(self, obj):
|
def remove(self, obj):
|
||||||
for source_handle in self.selected_handles():
|
self.remove_selected_objects()
|
||||||
db = self.dbstate.db
|
|
||||||
the_lists = Utils.get_source_referents(source_handle, db)
|
|
||||||
|
|
||||||
source = db.get_source_from_handle(source_handle)
|
def remove_object_from_handle(self, handle):
|
||||||
|
the_lists = Utils.get_source_referents(handle, self.dbstate.db)
|
||||||
ans = DelSrcQuery(self.dbstate,self.uistate,source,the_lists)
|
object = self.dbstate.db.get_source_from_handle(handle)
|
||||||
if any(the_lists): # quick test for non-emptiness
|
query = DelSrcQuery(self.dbstate, self.uistate, object, the_lists)
|
||||||
msg = _('This source is currently being used. Deleting it '
|
is_used = any(the_lists)
|
||||||
'will remove it from the database and from all '
|
return (query, is_used, object)
|
||||||
'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 edit(self, obj):
|
def edit(self, obj):
|
||||||
mlist = []
|
mlist = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user