From d5f871e8e790e69e3aadf82bd1f22b50bc6ae11b Mon Sep 17 00:00:00 2001 From: SNoiraud Date: Wed, 23 Dec 2015 11:14:24 +0100 Subject: [PATCH] 9127 : Geography : performance issue when selecting the events or places views. --- gramps/plugins/view/geoevents.py | 22 ++++++++++++---------- gramps/plugins/view/geoplaces.py | 18 +++++++++++------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/gramps/plugins/view/geoevents.py b/gramps/plugins/view/geoevents.py index 19e731e98..3a560e765 100644 --- a/gramps/plugins/view/geoevents.py +++ b/gramps/plugins/view/geoevents.py @@ -133,6 +133,7 @@ class GeoEvents(GeoGraphyView): self.generic_filter = None self.additional_uis.append(self.additional_ui()) self.no_show_places_in_status_bar = False + self.show_all = False def get_title(self): """ @@ -178,6 +179,7 @@ class GeoEvents(GeoGraphyView): """ Ask to show all events. """ + self.show_all = True self._createmap(None) def build_tree(self): @@ -283,20 +285,20 @@ class GeoEvents(GeoGraphyView): self.cal = config.get('preferences.calendar-format-report') self.no_show_places_in_status_bar = False - if self.generic_filter: + if self.show_all: + self.show_all = False + events_handle = dbstate.db.get_event_handles() + for event_hdl in events_handle: + event = dbstate.db.get_event_from_handle(event_hdl) + self._createmap_for_one_event(event) + elif self.generic_filter: events_list = self.generic_filter.apply(dbstate.db) for event_handle in events_list: event = dbstate.db.get_event_from_handle(event_handle) self._createmap_for_one_event(event) - else: - if obj is None: - events_handle = dbstate.db.get_event_handles() - for event_hdl in events_handle: - event = dbstate.db.get_event_from_handle(event_hdl) - self._createmap_for_one_event(event) - else: - event = dbstate.db.get_event_from_handle(obj) - self._createmap_for_one_event(event) + elif obj: + event = dbstate.db.get_event_from_handle(obj) + self._createmap_for_one_event(event) self.sort = sorted(self.place_list, key=operator.itemgetter(3, 4, 6) ) diff --git a/gramps/plugins/view/geoplaces.py b/gramps/plugins/view/geoplaces.py index 3c7f3d8a7..14da915c5 100644 --- a/gramps/plugins/view/geoplaces.py +++ b/gramps/plugins/view/geoplaces.py @@ -133,6 +133,7 @@ class GeoPlaces(GeoGraphyView): self.generic_filter = None self.additional_uis.append(self.additional_ui()) self.no_show_places_in_status_bar = False + self.show_all = False def get_title(self): """ @@ -178,6 +179,7 @@ class GeoPlaces(GeoGraphyView): """ Ask to show all places. """ + self.show_all = True self._createmap(None) def build_tree(self): @@ -256,12 +258,8 @@ class GeoPlaces(GeoGraphyView): # 65598 places : createmap : 08'48"; create_markers : 0'01"; draw markers : 0'07" _LOG.debug("%s" % time.strftime("start createmap : " "%a %d %b %Y %H:%M:%S", time.gmtime())) - if self.generic_filter: - place_list = self.generic_filter.apply(dbstate.db) - for place_handle in place_list: - place = dbstate.db.get_place_from_handle(place_handle) - self._create_one_place(place) - else: + if self.show_all: + self.show_all = False try: places_handle = dbstate.db.get_place_handles() except: @@ -269,8 +267,14 @@ class GeoPlaces(GeoGraphyView): for place_hdl in places_handle: place = dbstate.db.get_place_from_handle(place_hdl) self._create_one_place(place) - if place_x: + elif self.generic_filter: + place_list = self.generic_filter.apply(dbstate.db) + for place_handle in place_list: + place = dbstate.db.get_place_from_handle(place_handle) + self._create_one_place(place) + elif place_x: place = dbstate.db.get_place_from_handle(place_x) + self._create_one_place(place) if ( place.get_latitude() != "" and place.get_longitude() != "" ): self.osm.set_center_and_zoom(float(place.get_latitude()), float(place.get_longitude()),