From 87c5d3e65c5d8fd195c305fe668035cfe2a0616b Mon Sep 17 00:00:00 2001 From: Gary Burton Date: Sat, 26 Jul 2008 11:59:37 +0000 Subject: [PATCH] Refactoring in the DataViews. svn: r10927 --- src/DataViews/EventView.py | 5 +---- src/DataViews/FamilyList.py | 14 +++----------- src/DataViews/MediaView.py | 22 ++++++++-------------- src/DataViews/NoteView.py | 5 +---- src/DataViews/PlaceView.py | 9 +++------ src/DataViews/RepositoryView.py | 5 +---- src/DataViews/SourceView.py | 9 +++------ 7 files changed, 20 insertions(+), 49 deletions(-) diff --git a/src/DataViews/EventView.py b/src/DataViews/EventView.py index a82be20ec..4a151f7a4 100644 --- a/src/DataViews/EventView.py +++ b/src/DataViews/EventView.py @@ -239,10 +239,7 @@ class EventView(PageView.ListView): return (query, is_used, object) def edit(self, obj): - mlist = [] - self.selection.selected_foreach(self.blist, mlist) - - for handle in mlist: + for handle in self.selected_handles(): event = self.dbstate.db.get_event_from_handle(handle) try: EditEvent(self.dbstate, self.uistate, [], event) diff --git a/src/DataViews/FamilyList.py b/src/DataViews/FamilyList.py index b26e19722..49ebbb810 100644 --- a/src/DataViews/FamilyList.py +++ b/src/DataViews/FamilyList.py @@ -180,9 +180,7 @@ class FamilyListView(PageView.ListView): return self.dbstate.db.get_family_bookmarks() def add_bookmark(self, obj): - mlist = [] - self.selection.selected_foreach(self.blist, mlist) - + mlist = self.selected_handles() if mlist: self.bookmarks.add(mlist[0]) else: @@ -204,19 +202,13 @@ class FamilyListView(PageView.ListView): self.uistate.set_busy_cursor(1) import gen.utils - mlist = [] - self.selection.selected_foreach(self.blist, mlist) - - for handle in mlist: + for handle in self.selected_handles(): gen.utils.remove_family_relationships(self.dbstate.db, handle) self.build_tree() self.uistate.set_busy_cursor(0) def edit(self, obj): - mlist = [] - self.selection.selected_foreach(self.blist, mlist) - - for handle in mlist: + for handle in self.selected_handles(): from Editors import EditFamily family = self.dbstate.db.get_family_from_handle(handle) try: diff --git a/src/DataViews/MediaView.py b/src/DataViews/MediaView.py index c546debf5..3b5c5e90b 100644 --- a/src/DataViews/MediaView.py +++ b/src/DataViews/MediaView.py @@ -223,10 +223,7 @@ class MediaView(PageView.ListView): """ Launch external viewers based of mime types for the selected objects. """ - mlist = [] - self.selection.selected_foreach(self.blist, mlist) - - for handle in mlist: + for handle in self.selected_handles(): ref_obj = self.dbstate.db.get_object_from_handle(handle) mime_type = ref_obj.get_mime_type() app = Mime.get_application(mime_type) @@ -399,17 +396,14 @@ class MediaView(PageView.ListView): def edit(self, obj): """ - Edit the selected object in the EditMedia dialog + Edit the selected objects in the EditMedia dialog """ - handle = self.first_selected() - if not handle: - return - - obj = self.dbstate.db.get_object_from_handle(handle) - try: - EditMedia(self.dbstate, self.uistate, [], obj) - except Errors.WindowActiveError: - pass + for handle in self.selected_handles(): + object = self.dbstate.db.get_object_from_handle(handle) + try: + EditMedia(self.dbstate, self.uistate, [], object) + except Errors.WindowActiveError: + pass def get_handle_from_gramps_id(self, gid): """ diff --git a/src/DataViews/NoteView.py b/src/DataViews/NoteView.py index e0a08630f..c6465477d 100644 --- a/src/DataViews/NoteView.py +++ b/src/DataViews/NoteView.py @@ -206,10 +206,7 @@ class NoteView(PageView.ListView): return (query, is_used, object) def edit(self, obj): - mlist = [] - self.selection.selected_foreach(self.blist, mlist) - - for handle in mlist: + for handle in self.selected_handles(): note = self.dbstate.db.get_note_from_handle(handle) try: EditNote(self.dbstate, self.uistate, [], note) diff --git a/src/DataViews/PlaceView.py b/src/DataViews/PlaceView.py index 2503253ce..6d1577d91 100644 --- a/src/DataViews/PlaceView.py +++ b/src/DataViews/PlaceView.py @@ -43,6 +43,7 @@ import Utils import Errors import Bookmarks import Config +from QuestionDialog import ErrorDialog from DdTargets import DdTargets from Editors import EditPlace, DeletePlaceQuery from Filters.SideBar import PlaceSidebarFilter @@ -244,10 +245,7 @@ class PlaceView(PageView.ListView): return (query, is_used, object) def edit(self, obj): - mlist = [] - self.selection.selected_foreach(self.blist, mlist) - - for handle in mlist: + for handle in self.selected_handles(): place = self.dbstate.db.get_place_from_handle(handle) try: EditPlace(self.dbstate, self.uistate, [], place) @@ -255,8 +253,7 @@ class PlaceView(PageView.ListView): pass def fast_merge(self, obj): - mlist = [] - self.selection.selected_foreach(self.blist, mlist) + mlist = self.selected_handles() if len(mlist) != 2: msg = _("Cannot merge places.") diff --git a/src/DataViews/RepositoryView.py b/src/DataViews/RepositoryView.py index af5394ce9..0a7359ab7 100644 --- a/src/DataViews/RepositoryView.py +++ b/src/DataViews/RepositoryView.py @@ -206,10 +206,7 @@ class RepositoryView(PageView.ListView): return (query, is_used, object) def edit(self, obj): - mlist = [] - self.selection.selected_foreach(self.blist, mlist) - - for handle in mlist: + for handle in self.selected_handles(): repos = self.dbstate.db.get_repository_from_handle(handle) try: EditRepository(self.dbstate, self.uistate, [], repos) diff --git a/src/DataViews/SourceView.py b/src/DataViews/SourceView.py index 2b0c81c00..cbf552a5a 100644 --- a/src/DataViews/SourceView.py +++ b/src/DataViews/SourceView.py @@ -44,6 +44,7 @@ import Utils import Bookmarks import Errors from DdTargets import DdTargets +from QuestionDialog import ErrorDialog from Editors import EditSource, DelSrcQuery from Filters.SideBar import SourceSidebarFilter @@ -191,10 +192,7 @@ class SourceView(PageView.ListView): return (query, is_used, object) def edit(self, obj): - mlist = [] - self.selection.selected_foreach(self.blist, mlist) - - for handle in mlist: + for handle in self.selected_handles(): source = self.dbstate.db.get_source_from_handle(handle) try: EditSource(self.dbstate, self.uistate, [], source) @@ -202,8 +200,7 @@ class SourceView(PageView.ListView): pass def fast_merge(self, obj): - mlist = [] - self.selection.selected_foreach(self.blist, mlist) + mlist = self.selected_handles() if len(mlist) != 2: msg = _("Cannot merge sources.")