本文整理匯總了Python中calibre.gui2.library.alternate_views.AlternateViews.set_context_menu方法的典型用法代碼示例。如果您正苦於以下問題:Python AlternateViews.set_context_menu方法的具體用法?Python AlternateViews.set_context_menu怎麽用?Python AlternateViews.set_context_menu使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類calibre.gui2.library.alternate_views.AlternateViews
的用法示例。
在下文中一共展示了AlternateViews.set_context_menu方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: BooksView
# 需要導入模塊: from calibre.gui2.library.alternate_views import AlternateViews [as 別名]
# 或者: from calibre.gui2.library.alternate_views.AlternateViews import set_context_menu [as 別名]
#.........這裏部分代碼省略.........
self.cc_names_delegate)
else:
self.setItemDelegateForColumn(cm.index(colhead),
self.tags_delegate)
else:
self.setItemDelegateForColumn(cm.index(colhead), self.cc_text_delegate)
elif cc['datatype'] == 'series':
self.setItemDelegateForColumn(cm.index(colhead), self.cc_text_delegate)
elif cc['datatype'] in ('int', 'float'):
self.setItemDelegateForColumn(cm.index(colhead), self.cc_number_delegate)
elif cc['datatype'] == 'bool':
self.setItemDelegateForColumn(cm.index(colhead), self.cc_bool_delegate)
elif cc['datatype'] == 'rating':
self.setItemDelegateForColumn(cm.index(colhead), self.rating_delegate)
elif cc['datatype'] == 'composite':
self.setItemDelegateForColumn(cm.index(colhead), self.cc_template_delegate)
elif cc['datatype'] == 'enumeration':
self.setItemDelegateForColumn(cm.index(colhead), self.cc_enum_delegate)
else:
dattr = colhead+'_delegate'
delegate = colhead if hasattr(self, dattr) else 'text'
self.setItemDelegateForColumn(cm.index(colhead), getattr(self,
delegate+'_delegate'))
self.restore_state()
self.set_ondevice_column_visibility()
# incase there were marked books
self.model().set_row_decoration(set())
self.row_header.headerDataChanged(Qt.Vertical, 0, self.row_header.count()-1)
self.row_header.geometriesChanged.emit()
# }}}
# Context Menu {{{
def set_context_menu(self, menu, edit_collections_action):
self.setContextMenuPolicy(Qt.DefaultContextMenu)
self.context_menu = menu
self.alternate_views.set_context_menu(menu)
self.edit_collections_action = edit_collections_action
def contextMenuEvent(self, event):
sac = self.gui.iactions['Sort By']
sort_added = tuple(ac for ac in self.context_menu.actions() if ac is sac.qaction)
if sort_added:
sac.update_menu()
self.context_menu.popup(event.globalPos())
event.accept()
# }}}
@property
def column_map(self):
return self._model.column_map
@property
def visible_columns(self):
h = self.horizontalHeader()
logical_indices = (x for x in xrange(h.count()) if not h.isSectionHidden(x))
rmap = {i:x for i, x in enumerate(self.column_map)}
return (rmap[h.visualIndex(x)] for x in logical_indices if h.visualIndex(x) > -1)
def refresh_book_details(self):
idx = self.currentIndex()
if idx.isValid():
self._model.current_changed(idx, idx)
return True
return False