Geography : Use progress meter while selecting places or events.

This commit is contained in:
SNoiraud 2015-12-26 18:35:46 +01:00
parent 99c1cb5642
commit 664359e681
2 changed files with 26 additions and 2 deletions

View File

@ -64,6 +64,7 @@ from gramps.gui.filters.sidebar import EventSidebarFilter
from gramps.gui.views.navigationview import NavigationView from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import EventBookmarks from gramps.gui.views.bookmarks import EventBookmarks
from gramps.plugins.lib.maps.geography import GeoGraphyView from gramps.plugins.lib.maps.geography import GeoGraphyView
from gramps.gui.utils import ProgressMeter
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -116,7 +117,8 @@ class GeoEvents(GeoGraphyView):
""" """
def __init__(self, pdata, dbstate, uistate, nav_group=0): def __init__(self, pdata, dbstate, uistate, nav_group=0):
GeoGraphyView.__init__(self, _('Events places map'), self.window_name = _('Events places map')
GeoGraphyView.__init__(self, self.window_name,
pdata, dbstate, uistate, pdata, dbstate, uistate,
EventBookmarks, EventBookmarks,
nav_group) nav_group)
@ -289,14 +291,24 @@ class GeoEvents(GeoGraphyView):
if self.show_all: if self.show_all:
self.show_all = False self.show_all = False
events_handle = dbstate.db.get_event_handles() events_handle = dbstate.db.get_event_handles()
progress = ProgressMeter(self.window_name, can_cancel=False)
length = len(events_handle)
progress.set_pass(_('Selecting all events markers'), length)
for event_hdl in events_handle: for event_hdl in events_handle:
event = dbstate.db.get_event_from_handle(event_hdl) event = dbstate.db.get_event_from_handle(event_hdl)
self._createmap_for_one_event(event) self._createmap_for_one_event(event)
progress.step()
progress.close()
elif self.generic_filter: elif self.generic_filter:
events_list = self.generic_filter.apply(dbstate.db) events_list = self.generic_filter.apply(dbstate.db)
progress = ProgressMeter(self.window_name, can_cancel=False)
length = len(events_list)
progress.set_pass(_('Selecting all events markers'), length)
for event_handle in events_list: for event_handle in events_list:
event = dbstate.db.get_event_from_handle(event_handle) event = dbstate.db.get_event_from_handle(event_handle)
self._createmap_for_one_event(event) self._createmap_for_one_event(event)
progress.step()
progress.close()
elif obj: elif obj:
event = dbstate.db.get_event_from_handle(obj) event = dbstate.db.get_event_from_handle(obj)
self._createmap_for_one_event(event) self._createmap_for_one_event(event)

View File

@ -64,6 +64,7 @@ from gramps.gui.filters.sidebar import PlaceSidebarFilter
from gramps.gui.views.navigationview import NavigationView from gramps.gui.views.navigationview import NavigationView
from gramps.gui.views.bookmarks import PlaceBookmarks from gramps.gui.views.bookmarks import PlaceBookmarks
from gramps.plugins.lib.maps.geography import GeoGraphyView from gramps.plugins.lib.maps.geography import GeoGraphyView
from gramps.gui.utils import ProgressMeter
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -116,7 +117,8 @@ class GeoPlaces(GeoGraphyView):
""" """
def __init__(self, pdata, dbstate, uistate, nav_group=0): def __init__(self, pdata, dbstate, uistate, nav_group=0):
GeoGraphyView.__init__(self, _('Places map'), self.window_name = _('Places map')
GeoGraphyView.__init__(self, self.window_name,
pdata, dbstate, uistate, pdata, dbstate, uistate,
PlaceBookmarks, PlaceBookmarks,
nav_group) nav_group)
@ -264,14 +266,24 @@ class GeoPlaces(GeoGraphyView):
places_handle = dbstate.db.get_place_handles() places_handle = dbstate.db.get_place_handles()
except: except:
return return
progress = ProgressMeter(self.window_name, can_cancel=False)
length = len(places_handle)
progress.set_pass(_('Selecting all places markers'), length)
for place_hdl in places_handle: for place_hdl in places_handle:
place = dbstate.db.get_place_from_handle(place_hdl) place = dbstate.db.get_place_from_handle(place_hdl)
self._create_one_place(place) self._create_one_place(place)
progress.step()
progress.close()
elif self.generic_filter: elif self.generic_filter:
place_list = self.generic_filter.apply(dbstate.db) place_list = self.generic_filter.apply(dbstate.db)
progress = ProgressMeter(self.window_name, can_cancel=False)
length = len(place_list)
progress.set_pass(_('Selecting all places markers'), length)
for place_handle in place_list: for place_handle in place_list:
place = dbstate.db.get_place_from_handle(place_handle) place = dbstate.db.get_place_from_handle(place_handle)
self._create_one_place(place) self._create_one_place(place)
progress.step()
progress.close()
elif place_x: elif place_x:
place = dbstate.db.get_place_from_handle(place_x) place = dbstate.db.get_place_from_handle(place_x)
self._create_one_place(place) self._create_one_place(place)