def _handle_history(self, kwargs): if kwargs['filename'] == self.filename: id_ = kwargs['id_'] # The history event may have effects also on target and backlinks backlinks = links_api.find_back_links(self.filename, id_) target = links_api.find_link_target(self.filename, id_) if target is False: rbits = 3 if len(backlinks) > 0 else 0 # Find any possible old target and update it # This fixes for example the case of undoing the linking # of an item to another, which wouldn't update the tree # icon of the old target because this function would be # called *after* removing the link, so the old target # would not be retrievable through a database query old_target = links_api.get_last_known_target( self.filename, id_) if old_target is not None: self._reset_item_no_tree_update(old_target) elif target is None: rbits = 5 if len(backlinks) > 0 else 2 else: rbits = 4 if len(backlinks) > 0 else 1 target_target = links_api.find_link_target( self.filename, target) if target_target is False: target_rbits = 3 elif target_target is None: target_rbits = 5 else: target_rbits = 4 self._update_item_no_tree_update(target, target_rbits) self._update_item_no_tree_update(id_, rbits) for blink in backlinks: blink_backlinks = links_api.find_back_links( self.filename, blink) blink_rbits = 4 if len(blink_backlinks) > 0 else 1 self._update_item_no_tree_update(blink, blink_rbits)
def _handle_upsert_link(self, kwargs): if kwargs['filename'] == self.filename: id_ = kwargs['id_'] target = kwargs['target'] oldtarget = kwargs['oldtarget'] backlinks = links_api.find_back_links(self.filename, id_) target_target = links_api.find_link_target(self.filename, target) if target is None: rbits = 5 if len(backlinks) > 0 else 2 else: rbits = 4 if len(backlinks) > 0 else 1 if target_target is False: target_rbits = 3 elif target_target is None: target_rbits = 5 else: target_rbits = 4 self._update_item(id_, rbits) if target is not None: self._update_item(target, target_rbits) # oldtarget may not exist anymore if oldtarget is not False and core_api.is_item(self.filename, oldtarget): self._reset_item(oldtarget)
def _handle_upsert_link(self, kwargs): if kwargs['filename'] == self.filename: id_ = kwargs['id_'] target = kwargs['target'] oldtarget = kwargs['oldtarget'] backlinks = links_api.find_back_links(self.filename, id_) target_target = links_api.find_link_target(self.filename, target) if target is None: rbits = 5 if len(backlinks) > 0 else 2 else: rbits = 4 if len(backlinks) > 0 else 1 if target_target is False: target_rbits = 3 elif target_target is None: target_rbits = 5 else: target_rbits = 4 self._update_item(id_, rbits) if target is not None: self._update_item(target, target_rbits) # oldtarget may not exist anymore if oldtarget is not False and core_api.is_item( self.filename, oldtarget): self._reset_item(oldtarget)
def _handle_history(self, kwargs): if kwargs['filename'] == self.filename: id_ = kwargs['id_'] # The history event may have effects also on target and backlinks backlinks = links_api.find_back_links(self.filename, id_) target = links_api.find_link_target(self.filename, id_) if target is False: rbits = 3 if len(backlinks) > 0 else 0 # Find any possible old target and update it # This fixes for example the case of undoing the linking # of an item to another, which wouldn't update the tree # icon of the old target because this function would be # called *after* removing the link, so the old target # would not be retrievable through a database query old_target = links_api.get_last_known_target(self.filename, id_) if old_target is not None: self._reset_item_no_tree_update(old_target) elif target is None: rbits = 5 if len(backlinks) > 0 else 2 else: rbits = 4 if len(backlinks) > 0 else 1 target_target = links_api.find_link_target(self.filename, target) if target_target is False: target_rbits = 3 elif target_target is None: target_rbits = 5 else: target_rbits = 4 self._update_item_no_tree_update(target, target_rbits) self._update_item_no_tree_update(id_, rbits) for blink in backlinks: blink_backlinks = links_api.find_back_links(self.filename, blink) blink_rbits = 4 if len(blink_backlinks) > 0 else 1 self._update_item_no_tree_update(blink, blink_rbits)
def _compute_rbits(self, id_): backlinks = links_api.find_back_links(self.filename, id_) target = links_api.find_link_target(self.filename, id_) if target is False: rbits = 3 if len(backlinks) > 0 else 0 elif target is None: rbits = 5 if len(backlinks) > 0 else 2 else: rbits = 4 if len(backlinks) > 0 else 1 return rbits
def post_init(self): self.target = links_api.find_link_target(self.filename, self.id_) self._init_buttons() self._refresh_mod_state() self.lpanel.Fit() wxgui_api.expand_panel(self.filename, self.id_, self.fpanel) if not self.target: wxgui_api.collapse_panel(self.filename, self.id_, self.fpanel) wxgui_api.bind_to_apply_editor(self._handle_apply) wxgui_api.bind_to_check_editor_modified_state( self._handle_check_editor_modified) wxgui_api.bind_to_close_editor(self._handle_close)