Summary: | countries not sorted using locale collation sequence in kaddressbook | ||
---|---|---|---|
Product: | kab3 | Reporter: | Miloslav Trmac <mitr> |
Component: | general | Assignee: | Don Sanders <sanders> |
Status: | RESOLVED UNMAINTAINED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | RedHat Enterprise Linux | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | Patch agains kdepim 3.1.4 to use QString::localeAwareCompare for country list sorting |
Description
Miloslav Trmac
2002-05-10 13:18:23 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??? Still wrong in kdepim-3.1.3. "countries.sort ()" is used in AddressEditDialog::fillCountryCombo (), but it uses QString::operator< (), which compares unicode values. Created attachment 2705 [details]
Patch agains kdepim 3.1.4 to use QString::localeAwareCompare for country list sorting
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; } 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. |