Refactoring in the DataViews.

svn: r10927
This commit is contained in:
Gary Burton 2008-07-26 11:59:37 +00:00
parent f71e2b13b7
commit 87c5d3e65c
7 changed files with 20 additions and 49 deletions

View File

@ -239,10 +239,7 @@ class EventView(PageView.ListView):
return (query, is_used, object) return (query, is_used, object)
def edit(self, obj): def edit(self, obj):
mlist = [] for handle in self.selected_handles():
self.selection.selected_foreach(self.blist, mlist)
for handle in mlist:
event = self.dbstate.db.get_event_from_handle(handle) event = self.dbstate.db.get_event_from_handle(handle)
try: try:
EditEvent(self.dbstate, self.uistate, [], event) EditEvent(self.dbstate, self.uistate, [], event)

View File

@ -180,9 +180,7 @@ class FamilyListView(PageView.ListView):
return self.dbstate.db.get_family_bookmarks() return self.dbstate.db.get_family_bookmarks()
def add_bookmark(self, obj): def add_bookmark(self, obj):
mlist = [] mlist = self.selected_handles()
self.selection.selected_foreach(self.blist, mlist)
if mlist: if mlist:
self.bookmarks.add(mlist[0]) self.bookmarks.add(mlist[0])
else: else:
@ -204,19 +202,13 @@ class FamilyListView(PageView.ListView):
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(1)
import gen.utils import gen.utils
mlist = [] for handle in self.selected_handles():
self.selection.selected_foreach(self.blist, mlist)
for handle in mlist:
gen.utils.remove_family_relationships(self.dbstate.db, handle) gen.utils.remove_family_relationships(self.dbstate.db, handle)
self.build_tree() self.build_tree()
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(0)
def edit(self, obj): def edit(self, obj):
mlist = [] for handle in self.selected_handles():
self.selection.selected_foreach(self.blist, mlist)
for handle in mlist:
from Editors import EditFamily from Editors import EditFamily
family = self.dbstate.db.get_family_from_handle(handle) family = self.dbstate.db.get_family_from_handle(handle)
try: try:

View File

@ -223,10 +223,7 @@ class MediaView(PageView.ListView):
""" """
Launch external viewers based of mime types for the selected objects. Launch external viewers based of mime types for the selected objects.
""" """
mlist = [] for handle in self.selected_handles():
self.selection.selected_foreach(self.blist, mlist)
for handle in mlist:
ref_obj = self.dbstate.db.get_object_from_handle(handle) ref_obj = self.dbstate.db.get_object_from_handle(handle)
mime_type = ref_obj.get_mime_type() mime_type = ref_obj.get_mime_type()
app = Mime.get_application(mime_type) app = Mime.get_application(mime_type)
@ -399,17 +396,14 @@ class MediaView(PageView.ListView):
def edit(self, obj): def edit(self, obj):
""" """
Edit the selected object in the EditMedia dialog Edit the selected objects in the EditMedia dialog
""" """
handle = self.first_selected() for handle in self.selected_handles():
if not handle: object = self.dbstate.db.get_object_from_handle(handle)
return try:
EditMedia(self.dbstate, self.uistate, [], object)
obj = self.dbstate.db.get_object_from_handle(handle) except Errors.WindowActiveError:
try: pass
EditMedia(self.dbstate, self.uistate, [], obj)
except Errors.WindowActiveError:
pass
def get_handle_from_gramps_id(self, gid): def get_handle_from_gramps_id(self, gid):
""" """

View File

@ -206,10 +206,7 @@ class NoteView(PageView.ListView):
return (query, is_used, object) return (query, is_used, object)
def edit(self, obj): def edit(self, obj):
mlist = [] for handle in self.selected_handles():
self.selection.selected_foreach(self.blist, mlist)
for handle in mlist:
note = self.dbstate.db.get_note_from_handle(handle) note = self.dbstate.db.get_note_from_handle(handle)
try: try:
EditNote(self.dbstate, self.uistate, [], note) EditNote(self.dbstate, self.uistate, [], note)

View File

@ -43,6 +43,7 @@ import Utils
import Errors import Errors
import Bookmarks import Bookmarks
import Config import Config
from QuestionDialog import ErrorDialog
from DdTargets import DdTargets from DdTargets import DdTargets
from Editors import EditPlace, DeletePlaceQuery from Editors import EditPlace, DeletePlaceQuery
from Filters.SideBar import PlaceSidebarFilter from Filters.SideBar import PlaceSidebarFilter
@ -244,10 +245,7 @@ class PlaceView(PageView.ListView):
return (query, is_used, object) return (query, is_used, object)
def edit(self, obj): def edit(self, obj):
mlist = [] for handle in self.selected_handles():
self.selection.selected_foreach(self.blist, mlist)
for handle in mlist:
place = self.dbstate.db.get_place_from_handle(handle) place = self.dbstate.db.get_place_from_handle(handle)
try: try:
EditPlace(self.dbstate, self.uistate, [], place) EditPlace(self.dbstate, self.uistate, [], place)
@ -255,8 +253,7 @@ class PlaceView(PageView.ListView):
pass pass
def fast_merge(self, obj): def fast_merge(self, obj):
mlist = [] mlist = self.selected_handles()
self.selection.selected_foreach(self.blist, mlist)
if len(mlist) != 2: if len(mlist) != 2:
msg = _("Cannot merge places.") msg = _("Cannot merge places.")

View File

@ -206,10 +206,7 @@ class RepositoryView(PageView.ListView):
return (query, is_used, object) return (query, is_used, object)
def edit(self, obj): def edit(self, obj):
mlist = [] for handle in self.selected_handles():
self.selection.selected_foreach(self.blist, mlist)
for handle in mlist:
repos = self.dbstate.db.get_repository_from_handle(handle) repos = self.dbstate.db.get_repository_from_handle(handle)
try: try:
EditRepository(self.dbstate, self.uistate, [], repos) EditRepository(self.dbstate, self.uistate, [], repos)

View File

@ -44,6 +44,7 @@ import Utils
import Bookmarks import Bookmarks
import Errors import Errors
from DdTargets import DdTargets from DdTargets import DdTargets
from QuestionDialog import ErrorDialog
from Editors import EditSource, DelSrcQuery from Editors import EditSource, DelSrcQuery
from Filters.SideBar import SourceSidebarFilter from Filters.SideBar import SourceSidebarFilter
@ -191,10 +192,7 @@ class SourceView(PageView.ListView):
return (query, is_used, object) return (query, is_used, object)
def edit(self, obj): def edit(self, obj):
mlist = [] for handle in self.selected_handles():
self.selection.selected_foreach(self.blist, mlist)
for handle in mlist:
source = self.dbstate.db.get_source_from_handle(handle) source = self.dbstate.db.get_source_from_handle(handle)
try: try:
EditSource(self.dbstate, self.uistate, [], source) EditSource(self.dbstate, self.uistate, [], source)
@ -202,8 +200,7 @@ class SourceView(PageView.ListView):
pass pass
def fast_merge(self, obj): def fast_merge(self, obj):
mlist = [] mlist = self.selected_handles()
self.selection.selected_foreach(self.blist, mlist)
if len(mlist) != 2: if len(mlist) != 2:
msg = _("Cannot merge sources.") msg = _("Cannot merge sources.")