From kde-commits Thu Apr 30 21:57:11 2009 From: =?utf-8?q?Sebastian=20K=C3=BCgler?= Date: Thu, 30 Apr 2009 21:57:11 +0000 To: kde-commits Subject: playground/base/attica/plasma/opendesktop Message-Id: <1241128631.465501.13695.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=124112885728365 SVN commit 961899 by sebas: Use a combo box for the country We don't confuse the user with country codes and such, on top of that, it becomes translatable. M +10 -3 opendesktop.cpp M +16 -11 opendesktopLocationConfig.ui --- trunk/playground/base/attica/plasma/opendesktop/opendesktop.cpp #961898:961899 @@ -435,12 +435,16 @@ ui.username->setText(m_username); locationUi.city->setText(m_geolocation->city); - locationUi.country->setText(m_geolocation->countryCode); - locationUi.city->setText(m_geolocation->city); locationUi.latitude->setText(QString::number(m_geolocation->latitude)); locationUi.longitude->setText(QString::number(m_geolocation->longitude)); locationUi.distance->setValue(m_geolocation->distance); + locationUi.countryCombo->setInsertPolicy(QComboBox::InsertAlphabetically); + foreach ( const QString &cc, KGlobal::locale()->allCountriesList() ) { + locationUi.countryCombo->addItem(KGlobal::locale()->countryCodeToName(cc), cc); + } + locationUi.countryCombo->setCurrentIndex(locationUi.countryCombo->findText(KGlobal::locale()->countryCodeToName(m_geolocation->countryCode))); + // actually, 0,0 is a valid location, but here we're using it to see if we // actually have a location, a bit dirty but far less complex, especially given // that this point is located in the middle of the ocean off the coast of Ghana @@ -498,11 +502,14 @@ { // Location tab m_geolocation->city = locationUi.city->text(); - m_geolocation->countryCode = locationUi.country->text(); + m_geolocation->countryCode = locationUi.countryCombo->itemData(locationUi.countryCombo->currentIndex()).toString(); + m_geolocation->country = locationUi.countryCombo->currentText(); m_geolocation->latitude = locationUi.latitude->text().toDouble(); m_geolocation->longitude = locationUi.longitude->text().toDouble(); m_geolocation->distance = locationUi.distance->text().toDouble(); + kDebug() << "New location:" << m_geolocation->city << m_geolocation->country << m_geolocation->countryCode << m_geolocation->latitude << m_geolocation->longitude; + saveGeoLocation(); } --- trunk/playground/base/attica/plasma/opendesktop/opendesktopLocationConfig.ui #961898:961899 @@ -7,7 +7,7 @@ 0 0 - 211 + 233 185 @@ -42,16 +42,6 @@ - - - - - 100 - 0 - - - - @@ -103,6 +93,16 @@ + + + + + 0 + 0 + + + + @@ -116,6 +116,11 @@ QLineEdit
klineedit.h
+ + KComboBox + QComboBox +
kcombobox.h
+