[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kdeui/widgets
From:       Chusslove Illich <caslav.ilic () gmx ! net>
Date:       2007-12-31 23:04:30
Message-ID: 1199142270.099758.31487.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 755283 by ilic:

Sort rows by localized city name.

 M  +17 -0     ktimezonewidget.cpp  


--- trunk/KDE/kdelibs/kdeui/widgets/ktimezonewidget.cpp #755282:755283
@@ -44,6 +44,11 @@
     };
 };
 
+static bool localeLessThan (const QString &a, const QString &b)
+{
+    return QString::localeAwareCompare(a, b) < 0;
+}
+
 KTimeZoneWidget::KTimeZoneWidget( QWidget *parent, KTimeZones *db )
   : QTreeWidget( parent ),
     d( 0 )
@@ -55,9 +60,21 @@
   setRootIsDecorated(false);
   setHeaderLabels( QStringList() << i18n( "Area" ) << i18n( "Region" ) << i18n( "Comment" ) );
 
+  // Collect zones by localized city names, so that they can be sorted properly.
   const KTimeZones::ZoneMap zones = db->zones();
+  QStringList cities;
+  QHash<QString, KTimeZone> zonesByCity;
   for ( KTimeZones::ZoneMap::ConstIterator it = zones.begin(); it != zones.end(); ++it ) {
     KTimeZone zone = it.value();
+    QStringList continentCity = displayName( zone ).split( '/' );
+    QString city = continentCity[ continentCity.count() - 1 ];
+    cities.append( city );
+    zonesByCity.insert( city, zone );
+  }
+  qSort( cities.begin(), cities.end(), localeLessThan );
+
+  foreach ( const QString &city, cities ) {
+    KTimeZone zone = zonesByCity[city];
     QString tzName = zone.name();
     QString comment = zone.comment();
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic