From 563d9ca2f3f20be169caad403cc9fcc3f2134150 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 21 Nov 2021 20:46:08 +0530 Subject: [PATCH] Restore QModelIndex::child --- src/calibre/gui2/pyqt6_compat.py | 6 +++++- src/calibre/gui2/tweak_book/file_list.py | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/pyqt6_compat.py b/src/calibre/gui2/pyqt6_compat.py index a9d5615753..3fc293c602 100644 --- a/src/calibre/gui2/pyqt6_compat.py +++ b/src/calibre/gui2/pyqt6_compat.py @@ -8,7 +8,7 @@ from qt.core import ( QAction, QDialog, QDrag, QEventLoop, QMenu, QMessageBox, QSinglePointEvent, - QThread + QThread, QModelIndex ) from calibre_extensions import progress_indicator @@ -36,3 +36,7 @@ QMessageBox.exec_ = QMessageBox.exec # Restore ability to associate a menu with an action QAction.setMenu = lambda self, menu: progress_indicator.set_menu_on_action(self, menu) QAction.menu = lambda self, menu: progress_indicator.menu_for_action(self) + + +# Restore QModelIndex child +QModelIndex.child = lambda self, row, column: self.model().index(row, column, self) diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index b2da9aef81..3a2ebb5baa 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -173,8 +173,9 @@ class ItemDelegate(QStyledItemDelegate): # {{{ if hover: if top_level: - count = index.model().rowCount(index) - total_size = human_readable(sum(safe_size(index.child(r, 0)) for r in range(count))) + m = index.model() + count = m.rowCount(index) + total_size = human_readable(sum(safe_size(m.index(r, 0, index)) for r in range(count))) suffix = f'{NBSP}{count}@{total_size}' else: suffix = NBSP + human_readable(safe_size(index))