def edit(self, obj): for handle in self.selected_handles(): place = self.dbstate.db.get_place_from_handle(handle) try: EditPlace(self.dbstate, self.uistate, [], place) except Errors.WindowActiveError: pass
def add(self, obj): """ Add a new place. Attempt to get the top three levels of hierarchy from the currently selected row. """ place = gen.lib.Place() model, pathlist = self.selection.get_selected_rows() level = [u"", u"", u""] level1 = level2 = level3 = u"" if len(pathlist) == 1: path = pathlist[0] node = model.on_get_iter(path) value = model.on_get_value(node, 0) if len(path) == 1: level[0] = node.name elif len(path) == 2: level[1] = node.name parent = model.on_iter_parent(node) level[0] = parent.name elif len(path) == 3: level[2] = node.name parent = model.on_iter_parent(node) level[1] = parent.name parent = model.on_iter_parent(parent) level[0] = parent.name else: parent = model.on_iter_parent(node) level[2] = parent.name parent = model.on_iter_parent(parent) level[1] = parent.name parent = model.on_iter_parent(parent) level[0] = parent.name for ind in [0, 1, 2]: if level[ind] and level[ind] == COUNTRYLEVELS['default'][ind+1]: level[ind] = u"" place.get_main_location().set_country(level[0]) place.get_main_location().set_state(level[1]) place.get_main_location().set_county(level[2]) try: EditPlace(self.dbstate, self.uistate, [], place) except Errors.WindowActiveError: pass
def __edit_place(self, pcountry, pcounty, pstate, plat, plon): """ Edit the selected place at the marker position """ # need to add code here to edit the event. self.select_fct.close() place = self.dbstate.db.get_place_from_gramps_id(self.mark[9]) place.set_latitude(str(plat)) place.set_longitude(str(plon)) loc = place.get_main_location() loc.set_country(pcountry) loc.set_county(pcounty) loc.set_state(pstate) place.set_main_location(loc) try: EditPlace(self.dbstate, self.uistate, [], place) except Errors.WindowActiveError: pass
def __add_place(self, pcountry, pcounty, pstate, plat, plon): """ Add a new place using longitude and latitude of location centered on the map """ self.select_fct.close() new_place = gen.lib.Place() new_place.set_latitude(str(plat)) new_place.set_longitude(str(plon)) loc = new_place.get_main_location() loc.set_country(pcountry) loc.set_county(pcounty) loc.set_state(pstate) new_place.set_main_location(loc) try: EditPlace(self.dbstate, self.uistate, [], new_place) self.add_marker(None, None, plat, plon, None, True) except Errors.WindowActiveError: pass
def __link_place(self, pcountry, pcounty, pstate, 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)) loc = place.get_main_location() loc.set_country(pcountry) loc.set_county(pcounty) loc.set_state(pstate) place.set_main_location(loc) try: EditPlace(self.dbstate, self.uistate, [], place) self.add_marker(None, None, plat, plon, None, True) except Errors.WindowActiveError: pass
def add(self, obj): try: EditPlace(self.dbstate, self.uistate, [], gen.lib.Place()) except Errors.WindowActiveError: pass
def edit_object(dbstate, uistate, reftype, ref): """ Invokes the appropriate editor for an object type and given handle. """ from gui.editors import (EditEvent, EditPerson, EditFamily, EditSource, EditPlace, EditMedia, EditRepository, EditCitation) if reftype == 'Person': try: person = dbstate.db.get_person_from_handle(ref) EditPerson(dbstate, uistate, [], person) except Errors.WindowActiveError: pass elif reftype == 'Family': try: family = dbstate.db.get_family_from_handle(ref) EditFamily(dbstate, uistate, [], family) except Errors.WindowActiveError: pass elif reftype == 'Source': try: source = dbstate.db.get_source_from_handle(ref) EditSource(dbstate, uistate, [], source) except Errors.WindowActiveError: pass elif reftype == 'Citation': try: citation = dbstate.db.get_citation_from_handle(ref) EditCitation(dbstate, uistate, [], citation) except Errors.WindowActiveError: """ Return the text used when citation cannot be edited """ blocked_text = _("Cannot open new citation editor at this time. " "Either the citation is already being edited, " "or the associated source is already being " "edited, and opening a citation editor " "(which also allows the source " "to be edited), would create ambiguity " "by opening two editors on the same source. " "\n\n" "To edit the citation, close the source " "editor and open an editor for the citation " "alone") from QuestionDialog import WarningDialog WarningDialog(_("Cannot open new citation editor"), blocked_text) elif reftype == 'Place': try: place = dbstate.db.get_place_from_handle(ref) EditPlace(dbstate, uistate, [], place) except Errors.WindowActiveError: pass elif reftype == 'Media': try: obj = dbstate.db.get_media_from_handle(ref) EditMedia(dbstate, uistate, [], obj) except Errors.WindowActiveError: pass elif reftype == 'Event': try: event = dbstate.db.get_event_from_handle(ref) EditEvent(dbstate, uistate, [], event) except Errors.WindowActiveError: pass elif reftype == 'Repository': try: repo = dbstate.db.get_repository_from_handle(ref) EditRepository(dbstate, uistate, [], repo) except Errors.WindowActiveError: pass
def on_table_doubleclick(self, obj): """ Handle events on tables. obj is a treeview """ from gui.editors import (EditPerson, EditEvent, EditFamily, EditCitation, EditSource, EditPlace, EditRepository, EditNote, EditMedia) selection = obj.get_selection() store, paths = selection.get_selected_rows() tpath = paths[0] if len(paths) > 0 else None node = store.get_iter(tpath) if tpath else None if not node: return index = store.get_value(node, 0) # index if self._callback_leftdouble: self._callback_leftdouble(store.get_value(node, 1)) return True elif self.__link[index]: objclass, handle = self.__link[index] if objclass == 'Person': person = self.access.dbase.get_person_from_handle(handle) if person: try: EditPerson(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], person) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Event': event = self.access.dbase.get_event_from_handle(handle) if event: try: EditEvent(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], event) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Family': ref = self.access.dbase.get_family_from_handle(handle) if ref: try: EditFamily(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Citation': ref = self.access.dbase.get_citation_from_handle(handle) if ref: try: EditCitation(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Source': ref = self.access.dbase.get_source_from_handle(handle) if ref: try: EditSource(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Place': ref = self.access.dbase.get_place_from_handle(handle) if ref: try: EditPlace(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Repository': ref = self.access.dbase.get_repository_from_handle(handle) if ref: try: EditRepository(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Note': ref = self.access.dbase.get_note_from_handle(handle) if ref: try: EditNote(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass in ['Media', 'MediaObject']: ref = self.access.dbase.get_object_from_handle(handle) if ref: try: EditMedia(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'PersonList': from QuickReports import run_quick_report_by_name run_quick_report_by_name(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, 'filterbyname', 'list of people', handles=handle) elif objclass == 'Filter': from QuickReports import run_quick_report_by_name run_quick_report_by_name(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, 'filterbyname', handle[0]) return False # didn't handle event