Closed zjosua closed 4 years ago
I also tried this, but I'm having two problems with this.
When refreshing is disabled, sorting the leaderboard causes a highlight issue:
Highlighting and auto scrolling are disabled when refreshing is enabled. If I remove if config["refresh"] == "False":
in Line 28, there's another highlighting issue:
I tested this with Anki 2.1.25 on windows.
Scrolling works fine for me. I can see the highlighting issue as well though. However, when I delay the highlighting, it works fine. My guess is that the sortIndicatorChanged signal runs change_colors before sorting is completed.
Just to be clear; I don't propose to add a delay. I commited this change to show that the highlighting issue is probably caused by the async execution of the sorting and the sortIndicatorChanged signal.
The best solution would be a signal that is emitted when sorting is completed, but I could not find one so far. Maybe there is way to make sure the change_colors methods are only called when no other thread is accessing the QTableWidget? Or we could disable sorting and use the QHeaderView.sectionClicked signal to kick off a custom sorting and highlighting function.
You're right, this seems to be the problem. A custom sorting and highlighting function would probably be the best solution. I agree that sorting when refreshing is enabled would be nice, but I think that it's not super urgent. I don't have the time to solve this at the moment, but I'll keep it in mind.
This is how the Qt docs suggest to fix #66, as cited in the SO thread you already linked in the issue. Disable sorting before updating the table and enable it again afterwards.
Tested with Anki version 2.1.26 (961833a1).