[yast-devel] Table sorting and locales in YaST UI
Hi all, I found out that sorting a table in Yast does not work the same way in all UIs. The Qt UI respects the current locale, while ncurses and Gtk always use standard C (ASCII) sorting. That makes a trouble when sorting texts with accents. E.g. ["Z", "Ž", "á", "Á", "A", "a"] is in Qt sorted as users would expect ["a", "A", "á", "Á", "Z", "Ž"] (unless the locale is C/POSIX), while the others always display ["A", "Z", "a", "Á", "á", "Ž"], which is IMHO a bug. The problem is additionally complicated by the locale setting, i.e. it depends on invocation, ssh or su/kdesu keeps the current locale, but "su -" or logging in a text console sets POSIX locale (which results in C sorting). On the other hand locale sorting does not work correctly with numbers, in the repository module I pad priority number with spaces so in C sorting values " 90" and "100" are sorted correctly. However, this does not work when locale sorting is active, the values are in order like this: " 99", " 90", "105", "100", which looks strange. So C sorting would be good here. So how to solve all these problems? - I think table sorting should respect the current locale (so there is a bug in Gtk/ncurses) - The numeric sorting problem can be solved by padding numbers with zeroes instead of spaces e.g. "090" instead of " 90" - it does not look nice but I haven't found any better solution. Any idea? (I tried some tricks with UTF-8 non-breakable space but that didn't help.) Any comments? (BTW I foud out this problem when debugging bnc#752768, I could not reproduce it in 12.1, but I could in 12.2M3.) -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Thu May 3 2012 16:08:56 Ladislav Slezak wrote:
Hi all,
I found out that sorting a table in Yast does not work the same way in all UIs.
The Qt UI respects the current locale, while ncurses and Gtk always use standard C (ASCII) sorting. That makes a trouble when sorting texts with accents.
E.g. ["Z", "Ž", "á", "Á", "A", "a"] is in Qt sorted as users would expect ["a", "A", "á", "Á", "Z", "Ž"] (unless the locale is C/POSIX), while the others always display ["A", "Z", "a", "Á", "á", "Ž"], which is IMHO a bug.
The problem is additionally complicated by the locale setting, i.e. it depends on invocation, ssh or su/kdesu keeps the current locale, but "su -" or logging in a text console sets POSIX locale (which results in C sorting).
On the other hand locale sorting does not work correctly with numbers, in the repository module I pad priority number with spaces so in C sorting values " 90" and "100" are sorted correctly. However, this does not work when locale sorting is active, the values are in order like this: " 99", " 90", "105", "100", which looks strange. So C sorting would be good here.
So how to solve all these problems?
- I think table sorting should respect the current locale (so there is a bug in Gtk/ncurses) I agree.
- The numeric sorting problem can be solved by padding numbers with zeroes instead of spaces e.g. "090" instead of " 90" - it does not look nice but I haven't found any better solution. Any idea? (I tried some tricks with UTF-8 non-breakable space but that didn't help.)
I'd propose _NOT_ to add zeros to the ycp code, because it makes the table unreadable. It's an UI issue that needs to be fixed in the UI. I just fixed the numeric sorting in yast2-qt (version 2.22.6). Columns that contain digits only are sorted in numeric order now. Cheers, Thomas -- Thomas Goettlicher SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5 90409 Nürnberg Germany
Dne 4.5.2012 10:31, Thomas Goettlicher napsal(a):
On Thu May 3 2012 16:08:56 Ladislav Slezak wrote: [...]
- The numeric sorting problem can be solved by padding numbers with zeroes instead of spaces e.g. "090" instead of " 90" - it does not look nice but I haven't found any better solution. Any idea? (I tried some tricks with UTF-8 non-breakable space but that didn't help.)
I'd propose _NOT_ to add zeros to the ycp code, because it makes the table unreadable. It's an UI issue that needs to be fixed in the UI.
I just fixed the numeric sorting in yast2-qt (version 2.22.6). Columns that contain digits only are sorted in numeric order now.
Wow, good idea! Thanks! Would it be possible to put a regexp there? I mean, the repository module display the priority number but for 99 it adds _(" (default)") suffix so the actual displayed value is "99 (default)". That's because users can easily see what's the default and which repos have higer/lower priority than the default. (BTW the default value 99 looks strange, at least for me, I would use 100... This is another reason to explicitly tell users that value 99 is OK.) Or any other idea to force numeric sorting even for not completely numeric values? -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Dne 4.5.2012 11:19, Ladislav Slezak napsal(a):
Dne 4.5.2012 10:31, Thomas Goettlicher napsal(a):
On Thu May 3 2012 16:08:56 Ladislav Slezak wrote: [...]
- The numeric sorting problem can be solved by padding numbers with zeroes instead of spaces e.g. "090" instead of " 90" - it does not look nice but I haven't found any better solution. Any idea? (I tried some tricks with UTF-8 non-breakable space but that didn't help.)
I'd propose _NOT_ to add zeros to the ycp code, because it makes the table unreadable. It's an UI issue that needs to be fixed in the UI.
I just fixed the numeric sorting in yast2-qt (version 2.22.6). Columns that contain digits only are sorted in numeric order now.
Wow, good idea! Thanks!
Would it be possible to put a regexp there? I mean, the repository module display the priority number but for 99 it adds _(" (default)") suffix so the actual displayed value is "99 (default)". That's because users can easily see what's the default and which repos have higer/lower priority than the default.
Actually, anything that starts with a number should IMHO be sorted numerically according the number alone. The text, which is possibly appended to the number, should be taken into account only if there are two items with the same number (not the case mentioned above). Just for completeness, I don't think that we need to solve exceptions like e.g. date (where sorting should work according to the date), however, I'm not aware of any single place in YaST where it could be used. Jiri
(BTW the default value 99 looks strange, at least for me, I would use 100... This is another reason to explicitly tell users that value 99 is OK.)
Or any other idea to force numeric sorting even for not completely numeric values?
--
Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE
-- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Fri, May 04, 2012 at 10:51:51AM +0200, Jiri Srain wrote:
Actually, anything that starts with a number should IMHO be sorted numerically according the number alone. The text, which is possibly appended to the number, should be taken into account only if there are two items with the same number (not the case mentioned above).
Just for completeness, I don't think that we need to solve exceptions like e.g. date (where sorting should work according to the date), however, I'm not aware of any single place in YaST where it could be used.
Sorting sizes in human format (e.g. 1.3 GB, 2.2 kB, 4.5 MB) could
be used in the partitioner.
But even if that would work sorting in the partitioner will
remain disabled (use 'keepSorting) since the devices are sorted
very special according to types (e.g. hard disk, LVM) and other
information e.g. partition number or name.
Regards,
Arvin
--
Arvin Schnell,
On Fri, 4 May 2012 12:00:55 +0200
Arvin Schnell
On Fri, May 04, 2012 at 10:51:51AM +0200, Jiri Srain wrote:
Actually, anything that starts with a number should IMHO be sorted numerically according the number alone. The text, which is possibly appended to the number, should be taken into account only if there are two items with the same number (not the case mentioned above).
Just for completeness, I don't think that we need to solve exceptions like e.g. date (where sorting should work according to the date), however, I'm not aware of any single place in YaST where it could be used.
Sorting sizes in human format (e.g. 1.3 GB, 2.2 kB, 4.5 MB) could be used in the partitioner.
But even if that would work sorting in the partitioner will remain disabled (use 'keepSorting) since the devices are sorted very special according to types (e.g. hard disk, LVM) and other information e.g. partition number or name.
Regards, Arvin
If we start having more special request on sorting function it would be nice if we can pass sorting method there ( like almost all languages allow ). Josef -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Dne 4.5.2012 12:48, Josef Reidinger napsal(a): [...]
If we start having more special request on sorting function it would be nice if we can pass sorting method there ( like almost all languages allow ).
Yeah, I don't think it would be possible for Yast because of the architecture. Passing an YCP code to UI would mean that all Yast UIs would have to include YCP interpreter. (Well, maybe it already is there, I'm not sure...) And think about the other languages supported by Yast (perl, python, ruby), you would not be able to pass a sorting method from e.g. python or you would have to pass it as a string containing YCP code (pretty ugly)... -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Fri May 4 2012 10:51:51 Jiri Srain wrote:
Dne 4.5.2012 11:19, Ladislav Slezak napsal(a):
Dne 4.5.2012 10:31, Thomas Goettlicher napsal(a):
On Thu May 3 2012 16:08:56 Ladislav Slezak wrote: [...]
- The numeric sorting problem can be solved by padding numbers with zeroes instead of spaces e.g. "090" instead of " 90" - it does not look nice but I haven't found any better solution. Any idea? (I tried some tricks with UTF-8 non-breakable space but that didn't help.)
I'd propose _NOT_ to add zeros to the ycp code, because it makes the table unreadable. It's an UI issue that needs to be fixed in the UI.
I just fixed the numeric sorting in yast2-qt (version 2.22.6). Columns that contain digits only are sorted in numeric order now.
Wow, good idea! Thanks!
Would it be possible to put a regexp there? I mean, the repository module display the priority number but for 99 it adds _(" (default)") suffix so the actual displayed value is "99 (default)". That's because users can easily see what's the default and which repos have higer/lower priority than the default.
Actually, anything that starts with a number should IMHO be sorted numerically according the number alone. The text, which is possibly appended to the number, should be taken into account only if there are two items with the same number (not the case mentioned above).
Just for completeness, I don't think that we need to solve exceptions like e.g. date (where sorting should work according to the date), however, I'm not aware of any single place in YaST where it could be used. I agree, we don't need an over-engineered solution.
Cheers, Thomas
Jiri
(BTW the default value 99 looks strange, at least for me, I would use 100... This is another reason to explicitly tell users that value 99 is OK.)
Or any other idea to force numeric sorting even for not completely numeric values?
--
Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE
-- Thomas Goettlicher SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5 90409 Nürnberg Germany
On 05/04/2012 11:19 AM, Ladislav Slezak wrote:
(BTW the default value 99 looks strange, at least for me, I would use 100... This is another reason to explicitly tell users that value 99 is OK.)
I'd even use a different scale: From +100 (max) To -100 (min) Default 0 But 200-0 (with 99 as the default) is a libzypp design. Bye Lukas -- Lukas Ocilka, Appliances Department SUSE LINUX s.r.o., Praha -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Fri May 4 2012 11:19:24 Ladislav Slezak wrote:
Dne 4.5.2012 10:31, Thomas Goettlicher napsal(a):
On Thu May 3 2012 16:08:56 Ladislav Slezak wrote: [...]
- The numeric sorting problem can be solved by padding numbers with zeroes instead of spaces e.g. "090" instead of " 90" - it does not look nice but I haven't found any better solution. Any idea? (I tried some tricks with UTF-8 non-breakable space but that didn't help.)
I'd propose _NOT_ to add zeros to the ycp code, because it makes the table unreadable. It's an UI issue that needs to be fixed in the UI.
I just fixed the numeric sorting in yast2-qt (version 2.22.6). Columns that contain digits only are sorted in numeric order now.
Wow, good idea! Thanks!
Would it be possible to put a regexp there? I mean, the repository module display the priority number but for 99 it adds _(" (default)") suffix so the actual displayed value is "99 (default)". That's because users can easily see what's the default and which repos have higer/lower priority than the default. Right now the following regexp is used to test if it's a number: \\d* For conversion QString::toInt() is used, see: http://qt-project.org/doc/qt-4.8/qstring.html#toInt
Which regexp do you propose? Please keep in mind, that the regexp needs to be executed each time the user wants to sort the columns for all rows of the table. We should keep the regexp simple as it's critical to performance.
(BTW the default value 99 looks strange, at least for me, I would use 100... This is another reason to explicitly tell users that value 99 is OK.)
Or any other idea to force numeric sorting even for not completely numeric values?
You can add the rows in the order you want the Table widget to show the items and switch on keepSorting. See: http://doc.opensuse.org/projects/YaST/SLES11/onefile/yast-onefile.html#Table Cheers, Thomas -- Thomas Goettlicher SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5 90409 Nürnberg Germany
Dne 4.5.2012 11:48, Thomas Goettlicher napsal(a):
On Fri May 4 2012 11:19:24 Ladislav Slezak wrote: [...] Which regexp do you propose? Please keep in mind, that the regexp needs to be executed each time the user wants to sort the columns for all rows of the table. We should keep the regexp simple as it's critical to performance.
According to http://qt-project.org/doc/qt-4.8/qregexp.html I'd propose "^\\s*(\\d+)" i.e. if it starts with a number (ignore the spaces at the beginning) use the number for sorting and ignore the rest.
You can add the rows in the order you want the Table widget to show the items and switch on keepSorting. See: http://doc.opensuse.org/projects/YaST/SLES11/onefile/yast-onefile.html#Table
Yes, but users then would not be able to change the sorting. Sometimes it is useful to sort by status to see enabled or disabled repos together or sort by name or even by URL (to see e.g. all cd:// or dvd:// repos together)... -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Fri May 4 2012 13:25:24 Ladislav Slezak wrote: > Dne 4.5.2012 11:48, Thomas Goettlicher napsal(a): > > On Fri May 4 2012 11:19:24 Ladislav Slezak wrote: > [...] > > > Which regexp do you propose? Please keep in mind, that the regexp needs > > to be executed each time the user wants to sort the columns for all rows > > of the table. We should keep the regexp simple as it's critical to > > performance. > > According to http://qt-project.org/doc/qt-4.8/qregexp.html I'd propose > > "^\\s*(\\d+)" I fine-tuned the sort function now: * Leading blanks for numbers are ignored * '+' and '-' in front of numbers are respected * text separated by a blank right of a number is being ignored I think that's a sufficient solution for >95% of scenarios. Cheers, Thomas -- Thomas Goettlicher SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5 90409 Nürnberg Germany
Dne 4.5.2012 15:41, Thomas Goettlicher napsal(a):
On Fri May 4 2012 13:25:24 Ladislav Slezak wrote: [...] I fine-tuned the sort function now: * Leading blanks for numbers are ignored * '+' and '-' in front of numbers are respected * text separated by a blank right of a number is being ignored
Great! Thanks!
I think that's a sufficient solution for >95% of scenarios.
Yes, I agree. Could someone enhance also Gtk and ncurses UI so they behave the same way? Thanks in advance! -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Fri May 4 2012 15:49:28 Ladislav Slezak wrote:
Dne 4.5.2012 15:41, Thomas Goettlicher napsal(a):
On Fri May 4 2012 13:25:24 Ladislav Slezak wrote: [...]
I fine-tuned the sort function now: * Leading blanks for numbers are ignored * '+' and '-' in front of numbers are respected * text separated by a blank right of a number is being ignored
Great! Thanks!
I think that's a sufficient solution for >95% of scenarios.
Yes, I agree.
Could someone enhance also Gtk and ncurses UI so they behave the same way? Thanks in advance!
If you implement it in gtk or ncurses and want to spy at my code, it's: QY2ListViewItem::operator<() See: http://svn.opensuse.org/svn/yast/trunk/qt/src/QY2ListView.cc Cheers, Thomas
--
Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE
-- Thomas Goettlicher SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5 90409 Nürnberg Germany
Am 04.05.2012 15:55, schrieb Thomas Goettlicher:
On Fri May 4 2012 15:49:28 Ladislav Slezak wrote:
Dne 4.5.2012 15:41, Thomas Goettlicher napsal(a):
On Fri May 4 2012 13:25:24 Ladislav Slezak wrote: [...]
I fine-tuned the sort function now: * Leading blanks for numbers are ignored * '+' and '-' in front of numbers are respected * text separated by a blank right of a number is being ignored
Great! Thanks!
I think that's a sufficient solution for>95% of scenarios.
Yes, I agree.
Could someone enhance also Gtk and ncurses UI so they behave the same way? Thanks in advance!
If you implement it in gtk or ncurses and want to spy at my code, it's: QY2ListViewItem::operator<() See: http://svn.opensuse.org/svn/yast/trunk/qt/src/QY2ListView.cc
I will add the improvements (respect locale and sort numbers correctly) to YaST ncurses. I have already changed the ncurses package selector to respect the locale setting when sorting the package table. Greetings Gabi
Cheers, Thomas
--
Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE
-- Gabriele Mohr SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstr. 5 Tel: +49 911 740 53 362 90409 Nürnberg Email: gs@suse.de ----------------------------------------------------------------- -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Hello, On May 3 16:08 Ladislav Slezak wrote (excerpt):
I found out that sorting a table in Yast does not work the same way in all UIs. ... So how to solve all these problems?
If the automated table sorting does not work for your use case, (which probably happens in almost all non-trivial use cases), sort your table content in your own code so that you control the result and explicitly forbid the UI to change the ordering of your content, i.e. use: `Table ( `opt( `keepSorting ), your_sorted_table_content ) I do this everywhere because "since ever" automated table sorting didn't work for my use cases. I am not a UI programming expert but I was rather surprised when I found out that by default the UI changes the content. Kind Regards Johannes Meixner -- SUSE LINUX Products GmbH -- Maxfeldstrasse 5 -- 90409 Nuernberg -- Germany HRB 16746 (AG Nuernberg) GF: Jeff Hawn, Jennifer Guild, Felix Imendoerffer -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
participants (8)
-
Arvin Schnell
-
Gabriele Mohr
-
Jiri Srain
-
Johannes Meixner
-
Josef Reidinger
-
Ladislav Slezak
-
Lukas Ocilka
-
Thomas Goettlicher