本文整理汇总了Python中calibre.gui2.library.alternate_views.AlternateViews.set_database方法的典型用法代码示例。如果您正苦于以下问题:Python AlternateViews.set_database方法的具体用法?Python AlternateViews.set_database怎么用?Python AlternateViews.set_database使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.gui2.library.alternate_views.AlternateViews
的用法示例。
在下文中一共展示了AlternateViews.set_database方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BooksView
# 需要导入模块: from calibre.gui2.library.alternate_views import AlternateViews [as 别名]
# 或者: from calibre.gui2.library.alternate_views.AlternateViews import set_database [as 别名]
#.........这里部分代码省略.........
self.was_restored = True
def refresh_row_sizing(self):
self.row_sizing_done = False
self.do_row_sizing()
def do_row_sizing(self):
# Resize all rows to have the correct height
if not self.row_sizing_done and self.model().rowCount(QModelIndex()) > 0:
vh = self.verticalHeader()
vh.setDefaultSectionSize(max(vh.minimumSectionSize(), self.default_row_height + gprefs['book_list_extra_row_spacing']))
self._model.set_row_height(self.rowHeight(0))
self.row_sizing_done = True
def resize_column_to_fit(self, column):
col = self.column_map.index(column)
self.column_resized(col, self.columnWidth(col), self.columnWidth(col))
def column_resized(self, col, old_size, new_size):
# arbitrary: scroll bar + header + some
max_width = self.width() - (self.verticalScrollBar().width() +
self.verticalHeader().width() + 10)
if max_width < 200:
max_width = 200
if new_size > max_width:
self.column_header.blockSignals(True)
self.setColumnWidth(col, max_width)
self.column_header.blockSignals(False)
# }}}
# Initialization/Delegate Setup {{{
def set_database(self, db):
self.alternate_views.set_database(db)
self.save_state()
self._model.set_database(db)
self.tags_delegate.set_database(db)
self.cc_names_delegate.set_database(db)
self.authors_delegate.set_database(db)
self.series_delegate.set_auto_complete_function(db.all_series)
self.publisher_delegate.set_auto_complete_function(db.all_publishers)
self.alternate_views.set_database(db, stage=1)
def marked_changed(self, old_marked, current_marked):
self.alternate_views.marked_changed(old_marked, current_marked)
if bool(old_marked) == bool(current_marked):
changed = old_marked | current_marked
i = self.model().db.data.id_to_index
def f(x):
try:
return i(x)
except ValueError:
pass
sections = tuple(x for x in map(f, changed) if x is not None)
if sections:
self.row_header.headerDataChanged(Qt.Vertical, min(sections), max(sections))
# This is needed otherwise Qt does not always update the
# viewport correctly. See https://bugs.launchpad.net/bugs/1404697
self.row_header.viewport().update()
else:
# Marked items have either appeared or all been removed
self.model().set_row_decoration(current_marked)
self.row_header.headerDataChanged(Qt.Vertical, 0, self.row_header.count()-1)
self.row_header.geometriesChanged.emit()