def link_place(self, menu, event, lat, lon): """ Link an existing place using longitude and latitude of location centered on the map If we have a place history, we must show all places to avoid an empty place selection in the PlaceSelection. """ if self.uistate.get_active('Place'): self._createmap(None) selector = SelectPlace(self.dbstate, self.uistate, []) place = selector.run() if place: parent_list = place.get_placeref_list() if len(parent_list) > 0: parent = parent_list[0].ref else: parent = None places_handle = self.dbstate.db.iter_place_handles() nb_places = 0 gids = "" place_title = _pd.display(self.dbstate.db, place) for place_hdl in places_handle: plce = self.dbstate.db.get_place_from_handle(place_hdl) plce_title = _pd.display(self.dbstate.db, plce) if plce_title == place_title: nb_places += 1 if gids == "": gids = plce.gramps_id else: # TODO for Arabic, should the next comma be translated? gids = gids + ", " + plce.gramps_id if nb_places > 1: from gramps.gui.dialog import WarningDialog WarningDialog( _('You have at least two places with the same title.'), _("The title of the places is:\n%(title)s\n" "The following places are similar: %(gid)s\n" "You should eiher rename the places or merge them.\n\n" "%(bold_start)s" "I can't proceed with your request" "%(bold_end)s.\n") % { 'bold_start' : '<b>', 'bold_end' : '</b>', 'title': '<b>' + place_title + '</b>', 'gid': gids}, parent=self.uistate.window ) else: self.mark = [None, None, None, None, None, None, None, None, None, place.gramps_id, None, None] self.select_fct = PlaceSelection(self.uistate, self.dbstate, self.osm, self.selection_layer, self.place_list, lat, lon, self.__edit_place, parent)
def link_place(self, menu, event, lat, lon): """ Link an existing place using longitude and latitude of location centered on the map If we have a place history, we must show all places to avoid an empty place selection in the PlaceSelection. """ if self.uistate.get_active('Place'): self._createmap(None) selector = SelectPlace(self.dbstate, self.uistate, []) place = selector.run() if place: parent_list = place.get_placeref_list() if len(parent_list) > 0: parent = parent_list[0].ref else: parent = None places_handle = self.dbstate.db.iter_place_handles() nb_places = 0 gids = "" for place_hdl in places_handle: plce = self.dbstate.db.get_place_from_handle(place_hdl) if plce.get_title() == place.get_title(): nb_places += 1 if gids == "": gids = plce.gramps_id else: gids = gids + ", " + plce.gramps_id if nb_places > 1: from gramps.gui.dialog import WarningDialog WarningDialog( _('You have at least two places with the same title.'), _("The title of the places is :\n" "<b>%(title)s</b>\n" "The following places are similar : %(gid)s\n" "Eiher you rename the places either you merge them." "\n\n<b>I can't proceed your request</b>.\n") % { 'title': place.get_title(), 'gid': gids} ) else: self.mark = [None, None, None, None, None, None, None, None, None, place.gramps_id, None, None] self.select_fct = PlaceSelection(self.uistate, self.dbstate, self.osm, self.selection_layer, self.place_list, lat, lon, self.__edit_place, parent)
def __link_place(self, parent, plat, plon): """ Link an existing place using longitude and latitude of location centered on the map """ selector = SelectPlace(self.dbstate, self.uistate, []) place = selector.run() if place: self.select_fct.close() place.set_latitude(str(plat)) place.set_longitude(str(plon)) if parent: placeref = PlaceRef() placeref.ref = parent place.add_placeref(placeref) try: EditPlace(self.dbstate, self.uistate, [], place) self.add_marker(None, None, plat, plon, None, True, 0) except WindowActiveError: pass