Edit Book: Reports: Characters: Fix sorting by count and name not working. Fixes #1598518 [Editor Report Characters](https://bugs.launchpad.net/calibre/+bug/1598518)

This commit is contained in:
Kovid Goyal 2016-07-03 09:29:39 +05:30
parent cc1a8bcf1f
commit 6effd4f2ee

View File

@ -745,11 +745,13 @@ class CharsModel(FileCollection):
self.files = data['chars'] self.files = data['chars']
self.all_chars = tuple(entry.char for entry in self.files) self.all_chars = tuple(entry.char for entry in self.files)
psk = numeric_sort_key psk = numeric_sort_key
self.sort_keys = tuple((psk(entry.char), None, entry.codepoint, len(entry.usage)) for entry in self.files) self.sort_keys = tuple((psk(entry.char), None, entry.codepoint, entry.count) for entry in self.files)
self.endResetModel() self.endResetModel()
def data(self, index, role=Qt.DisplayRole): def data(self, index, role=Qt.DisplayRole):
if role == SORT_ROLE: if role == SORT_ROLE:
if index.column() == 1:
return self.data(index)
try: try:
return self.sort_keys[index.row()][index.column()] return self.sort_keys[index.row()][index.column()]
except IndexError: except IndexError: