mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-06 16:16:10 +01:00
Restore QModelIndex::child
This commit is contained in:
parent
1c2acc9750
commit
29e9901bdc
2 changed files with 8 additions and 3 deletions
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QDialog, QDrag, QEventLoop, QMenu, QMessageBox, QSinglePointEvent,
|
QAction, QDialog, QDrag, QEventLoop, QMenu, QMessageBox, QSinglePointEvent,
|
||||||
QThread
|
QThread, QModelIndex
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre_extensions import progress_indicator
|
from calibre_extensions import progress_indicator
|
||||||
|
|
@ -36,3 +36,7 @@
|
||||||
# Restore ability to associate a menu with an action
|
# Restore ability to associate a menu with an action
|
||||||
QAction.setMenu = lambda self, menu: progress_indicator.set_menu_on_action(self, menu)
|
QAction.setMenu = lambda self, menu: progress_indicator.set_menu_on_action(self, menu)
|
||||||
QAction.menu = lambda self, menu: progress_indicator.menu_for_action(self)
|
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)
|
||||||
|
|
|
||||||
|
|
@ -170,8 +170,9 @@ def safe_size(index):
|
||||||
|
|
||||||
if hover:
|
if hover:
|
||||||
if top_level:
|
if top_level:
|
||||||
count = index.model().rowCount(index)
|
m = index.model()
|
||||||
total_size = human_readable(sum(safe_size(index.child(r, 0)) for r in range(count)))
|
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}'
|
suffix = f'{NBSP}{count}@{total_size}'
|
||||||
else:
|
else:
|
||||||
suffix = NBSP + human_readable(safe_size(index))
|
suffix = NBSP + human_readable(safe_size(index))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue