mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Cleanup previous PR
This commit is contained in:
parent
e653df9794
commit
94eee05a2e
@ -2368,7 +2368,7 @@ class Cache:
|
|||||||
def get_all_link_maps_for_book(self, book_id):
|
def get_all_link_maps_for_book(self, book_id):
|
||||||
'''
|
'''
|
||||||
Returns all links for all fields referenced by book identified by book_id.
|
Returns all links for all fields referenced by book identified by book_id.
|
||||||
If book_id is None or doesn't exist then the method returns {}.
|
If book_id doesn't exist then the method returns {}.
|
||||||
|
|
||||||
Example: Assume author A has link X, author B has link Y, tag S has link
|
Example: Assume author A has link X, author B has link Y, tag S has link
|
||||||
F, and tag T has link G. If book 1 has author A and tag T,
|
F, and tag T has link G. If book 1 has author A and tag T,
|
||||||
@ -2380,7 +2380,7 @@ class Cache:
|
|||||||
:return: {field: {field_value, link_value}, ... for all fields with a field_value having a non-empty link value for that book
|
:return: {field: {field_value, link_value}, ... for all fields with a field_value having a non-empty link value for that book
|
||||||
|
|
||||||
'''
|
'''
|
||||||
if not self.has_id(book_id):
|
if not self._has_id(book_id):
|
||||||
# Works for book_id is None.
|
# Works for book_id is None.
|
||||||
return {}
|
return {}
|
||||||
cached = self.link_maps_cache.get(book_id)
|
cached = self.link_maps_cache.get(book_id)
|
||||||
|
@ -392,8 +392,8 @@ def add_item_specific_entries(menu, data, book_info, copy_menu, search_menu):
|
|||||||
ac.setText(_('Remove %s from this book') % escape_for_menu(author))
|
ac.setText(_('Remove %s from this book') % escape_for_menu(author))
|
||||||
menu.addAction(ac)
|
menu.addAction(ac)
|
||||||
# See if we need to add a click associated link menu line for the author
|
# See if we need to add a click associated link menu line for the author
|
||||||
link_map = get_gui().current_db.new_api.get_all_link_maps_for_book(data.get('book_id', None))
|
link_map = get_gui().current_db.new_api.get_all_link_maps_for_book(data.get('book_id', -1))
|
||||||
link = link_map.get("authors", {}).get(author, None)
|
link = link_map.get("authors", {}).get(author)
|
||||||
if link:
|
if link:
|
||||||
menu.addAction(QIcon.ic('external-link'), _('Open associated link'),
|
menu.addAction(QIcon.ic('external-link'), _('Open associated link'),
|
||||||
lambda : book_info.link_clicked.emit(link))
|
lambda : book_info.link_clicked.emit(link))
|
||||||
@ -442,8 +442,8 @@ def add_item_specific_entries(menu, data, book_info, copy_menu, search_menu):
|
|||||||
ac.setText(_('Remove %s from this book') % escape_for_menu(remove_name or data.get('original_value') or value))
|
ac.setText(_('Remove %s from this book') % escape_for_menu(remove_name or data.get('original_value') or value))
|
||||||
menu.addAction(ac)
|
menu.addAction(ac)
|
||||||
# See if we need to add a click associated link menu line
|
# See if we need to add a click associated link menu line
|
||||||
link_map = get_gui().current_db.new_api.get_all_link_maps_for_book(data.get('book_id', None))
|
link_map = get_gui().current_db.new_api.get_all_link_maps_for_book(data.get('book_id', -1))
|
||||||
link = link_map.get(field, {}).get(value, None)
|
link = link_map.get(field, {}).get(value)
|
||||||
if link:
|
if link:
|
||||||
menu.addAction(QIcon.ic('external-link'), _('Open associated link'),
|
menu.addAction(QIcon.ic('external-link'), _('Open associated link'),
|
||||||
lambda : book_info.link_clicked.emit(link))
|
lambda : book_info.link_clicked.emit(link))
|
||||||
@ -520,7 +520,7 @@ def details_context_menu_event(view, ev, book_info, add_popup_action=False, edit
|
|||||||
ac.current_url = url
|
ac.current_url = url
|
||||||
ac.setText(_('Copy link location'))
|
ac.setText(_('Copy link location'))
|
||||||
menu.addAction(ac)
|
menu.addAction(ac)
|
||||||
menu.addAction(QIcon.ic('external-link'), _('Open this link'), lambda : book_info.link_clicked.emit(url))
|
menu.addAction(QIcon.ic('external-link'), _('Open associated link'), lambda : book_info.link_clicked.emit(url))
|
||||||
if not copy_links_added:
|
if not copy_links_added:
|
||||||
create_copy_links(copy_menu)
|
create_copy_links(copy_menu)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user