Closed bryce-carson closed 1 month ago
I looked into this a little, IIRC, and it was hard to fix. Qt does the sorting here, and it doesn't have a smart sorting option that is available to me. I don't remember the details. I'll leave this open, because yes, it should be fixed, but since I've already looked at it once and thrown my hands up in despair, I'm going to mark it "long-term" and not look at it for a while.
I did a little searching and reading through the QtSLiM sources and this is something I could fix given some time. It's a helpful way to brush up on my C++ as well.
These are the relevant places in the code, yes?
The sorting you are doing is definitely correct. Your commentary in the code reveals, as you've mentioned that you looked into it before, it really likely is a Qt issue.
An alternative is to use a QMap rather than a QStringList for the entryList
. I can look into this once I'm done with a small Python project. Some obvious requirements are:
Hi @bryce-carson! Yes, those are the relevant spots.
The std::sort()
calls using collator
just need to be replaced with something that works on all platforms. I'm not sure how QMap rather than QStringList helps...? Seems like maybe you just need to write a comparison lambda/function for the std::sort()
call that does the right thing, replacing collator
. In the comparator, strip off whatever prefix is shared between the two strings, extract the number that remains at the beginning (up to a dot or space), convert to integers, and return the comparison of the integers. Should be pretty straightforward. Might get a little more complicated because some of the recipes have a form like Recipe X.Y.Z blah blah blah I
versus Recipe X.Y.Z blah blah blah II
, with a Roman numeral at the end; I think Roman numerals as high as V
are used. Happily, the Roman numerals from I to V (and even a bit further!) happen to be alphabetically sorted already, so in that case you can just revert to an alphabetic sort.
Do please try to avoid rewriting the surrounding code, just for stability; that should not be necessary, I think. If this makes sense to you, then sure, go for it! :->
The sorting order is (correctly) natural when SLiMgui 4.2.2 is used on Ubuntu 18.04. There must have been a change in Qt 5.15 which modified the way sorting operates after the release of Ubuntu 18.04; six years of maintenance changes, so it's possible.
The sorting order is (correctly) natural when SLiMgui 4.2.2 is used on Ubuntu 18.04. There must have been a change in Qt 5.15 which modified the way sorting operates after the release of Ubuntu 18.04; six years of maintenance changes, so it's possible.
Could be a change in Ubuntu, no? Note the comments on the Qt bug saying "You must turn ICU support on to get proper numeric collation" and similar. Maybe Ubuntu 18.04 included ICU in its Qt build (whatever ICU is), and later versions did not? Might even depend on the way Qt was built/installed on a particular Ubuntu system, since there are various ways of getting Qt. Anyhow, the path forward is clear: the QCollator
usage needs to be replaced as discussed above.
@bryce-carson Do you intend to fix this bug? If not, I'm happy to fix it myself, but I'd like it to get fixed one way or the other. :-> Thanks!
@bryce-carson Do you intend to fix this bug? If not, I'm happy to fix it myself, but I'd like it to get fixed one way or the other. :-> Thanks!
I an not able to recently. I would need to do some decent review of C++; it's been a bit for me.
You go ahead with it, please.
OK, no worries! :->
Shouldn't the sorting order be natural? The commit I built from when I saw this is ad71419