本文整理匯總了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()