View Single Post
Old 11-22-2024, 10:15 AM   #664
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,236
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
Quote:
Originally Posted by ownedbycats View Post
Small bug: When sorting by series, the series index is sorted alphabetically and books may appear in the wrong order.
Please test the attached version. It should be fixed.

Quote:
Originally Posted by chaley View Post
If you use utils.icu.numeric_sort_key as the key function when the list is sorted then the problem should go away.
Thanks for the tip. I'm already overriding the __lt__ method in QTreeWidgetItem to fix other sorting issues, so it felt easier to deal with it the same way.

Spoiler:
Code:
class QTreeWidgetItem(QtWidgets.QTreeWidgetItem):
    def __lt__(self, other):
        column = self.treeWidget().sortColumn()
        if column == 4:  # Fix for Series sorting (account for series_index)
            first = self.text(4)
            first_series_name = re.sub(' \[\d+\.\d+\]', '', first)
            first_series_index = re.search('\[\d+\.\d+\]', first)
            second = other.text(4)
            second_series_name = re.sub(' \[\d+\.\d+\]', '', second)
            second_series_index = re.search('\[\d+\.\d+\]', second)
            if first_series_name == second_series_name and first_series_index and second_series_index:
                return float(first_series_index[0].strip('[]')) < float(second_series_index[0].strip('[]'))

Last edited by thiago.eec; 11-22-2024 at 12:30 PM. Reason: Removed test version. Fixed.
thiago.eec is offline   Reply With Quote