Bug 42434 - countries not sorted using locale collation sequence in kaddressbook
Summary: countries not sorted using locale collation sequence in kaddressbook
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kab3
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Don Sanders
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-10 13:33 UTC by Miloslav Trmac
Modified: 2009-08-05 15:42 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch agains kdepim 3.1.4 to use QString::localeAwareCompare for country list sorting (1.28 KB, patch)
2003-10-07 15:58 UTC, Miloslav Trmac
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Miloslav Trmac 2002-05-10 13:18:23 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kaddressbook
Version:           KDE 3.0.0 
Severity:          normal
Installed from:    RedHat RPMs
Compiler:          Not Specified
OS:                Linux
OS/Compiler notes: Not Specified

Countries in the combo box (described below) are sorted using ASCII string comparison or something instead of locale-specified collation sequence.

Steps to Reproduce:
1.Set your locale to cs_CZ (or something other you can read which
places accented characters between unaccented Latin ones)
2.Run kaddressbook create a new entry push the Address button
3.Open the Country combo box. 

Actual Results:  The countries whose name starts with
an accented character (i.e. [using HTML notation because bugzilla will probably mangle it etc.] Česká republika [Czech Republic]) are placed after all others.

Expected Results:  Česká republika is placed after countries whose name starts with C but before countries with name starting with D similarly for other countries.

(Submitted via bugs.kde.org)
Comment 1 Tobias Koenig 2002-07-15 10:44:06 UTC
Hi

this bug is fixed in CVS HEAD

Thank you for your bug report

Ciao
Tobias
-- 
In a world without walls and fences who
needs Windows and Gates???
Comment 2 Miloslav Trmac 2003-10-06 10:27:36 UTC
Still wrong in kdepim-3.1.3.
"countries.sort ()" is used in AddressEditDialog::fillCountryCombo (), but
it uses QString::operator< (), which compares unicode values.
Comment 3 Miloslav Trmac 2003-10-07 15:58:59 UTC
Created attachment 2705 [details]
Patch agains kdepim 3.1.4 to use QString::localeAwareCompare for country list sorting
Comment 4 Tobias Koenig 2003-10-10 09:53:35 UTC
Subject: kdepim/kaddressbook

CVS commit by tokoe: 

Sort the country list locale aware. That fixes bug #42434.
CCMAIL:42434-done@bugs.kde.org


  M +40 -1     addresseditwidget.cpp   1.29


--- kdepim/kaddressbook/addresseditwidget.cpp  #1.28:1.29
@@ -53,4 +53,6 @@
 #include "addresseditwidget.h"
 
+static QStringList sortLocaleAware( const QStringList &list );
+
 class TabPressEater : public QObject
 {
@@ -562,5 +564,5 @@ void AddressEditDialog::fillCountryCombo
     countries.append( country[ i ] );
 
-  countries.sort();
+  countries = sortLocaleAware( countries );
 
   mCountryCombo->insertStringList( countries );
@@ -607,4 +609,41 @@ int AddressTypeDialog::type() const
 
   return type;
+}
+
+/**
+  Small helper class, I hope we can remove it as soon as a general solution has
+  been committed to kdelibs
+ */
+class LocaleAwareString : public QString
+{
+  public:
+    LocaleAwareString() : QString()
+    {}
+
+    LocaleAwareString( const QString &str ) : QString( str )
+    {}
+};
+
+static bool operator<( const LocaleAwareString &s1, const LocaleAwareString &s2 )
+{
+  return ( QString::localeAwareCompare( s1, s2 ) < 0 );
+}
+
+QStringList sortLocaleAware( const QStringList &list )
+{
+  QValueList<LocaleAwareString> sortedList;
+
+  QStringList::ConstIterator it;
+  for ( it = list.begin(); it != list.end(); ++it )
+    sortedList.append( LocaleAwareString( *it ) );
+
+  qHeapSort( sortedList );
+
+  QStringList retval;
+  QValueList<LocaleAwareString>::ConstIterator retIt;
+  for ( retIt = sortedList.begin(); retIt != sortedList.end(); ++retIt )
+    retval.append( *retIt );
+
+  return retval;
 }
 


Comment 5 Tobias Koenig 2009-08-05 15:42:12 UTC
The development of the old KAddressBook will be discontinued for KDE 4.4.
Since the new application has the same name, but a completly new code base we close all bug reports against the old version and ask the submitters to resend there reports against the new product.