summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-25 22:12:26 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-25 22:12:26 (GMT)
commitf1ae6d0ecba250d83cf7e747868af32ceadc085f (patch)
tree271012dda71434ade0a729e0b986d119245cee5f /tools/linguist
parent67e031b196745e44a2edb608e18ddd8f5722d91b (diff)
downloadQt-f1ae6d0ecba250d83cf7e747868af32ceadc085f.zip
Qt-f1ae6d0ecba250d83cf7e747868af32ceadc085f.tar.gz
Qt-f1ae6d0ecba250d83cf7e747868af32ceadc085f.tar.bz2
offer only possible countries for each language
otherwise qlocale will silently clobber the user's (most probably bogus) choice anyway.
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/linguist/translationsettingsdialog.cpp33
-rw-r--r--tools/linguist/linguist/translationsettingsdialog.h2
2 files changed, 27 insertions, 8 deletions
diff --git a/tools/linguist/linguist/translationsettingsdialog.cpp b/tools/linguist/linguist/translationsettingsdialog.cpp
index 0d94c3a..562f14e 100644
--- a/tools/linguist/linguist/translationsettingsdialog.cpp
+++ b/tools/linguist/linguist/translationsettingsdialog.cpp
@@ -60,15 +60,7 @@ TranslationSettingsDialog::TranslationSettingsDialog(QWidget *parent)
m_ui.srcCbLanguageList->model()->sort(0, Qt::AscendingOrder);
m_ui.srcCbLanguageList->insertItem(0, QLatin1String("POSIX"), QVariant(QLocale::C));
- for (int i = QLocale::AnyCountry + 1; i < QLocale::LastCountry; ++i) {
- QString country = QLocale::countryToString(QLocale::Country(i));
- m_ui.srcCbCountryList->addItem(country, QVariant(i));
- }
- m_ui.srcCbCountryList->model()->sort(0, Qt::AscendingOrder);
- m_ui.srcCbCountryList->insertItem(0, tr("Any Country"), QVariant(QLocale::AnyCountry));
-
m_ui.tgtCbLanguageList->setModel(m_ui.srcCbLanguageList->model());
- m_ui.tgtCbCountryList->setModel(m_ui.srcCbCountryList->model());
}
void TranslationSettingsDialog::setDataModel(DataModel *dataModel)
@@ -87,6 +79,31 @@ void TranslationSettingsDialog::setPhraseBook(PhraseBook *phraseBook)
setWindowTitle(tr("Settings for '%1' - Qt Linguist").arg(fn));
}
+static void fillCountryCombo(const QVariant &lng, QComboBox *combo)
+{
+ combo->clear();
+ QLocale::Language lang = QLocale::Language(lng.toInt());
+ if (lang != QLocale::C) {
+ foreach (QLocale::Country cntr, QLocale::countriesForLanguage(lang)) {
+ QString country = QLocale::countryToString(cntr);
+ combo->addItem(country, QVariant(cntr));
+ }
+ combo->model()->sort(0, Qt::AscendingOrder);
+ }
+ combo->insertItem(0, TranslationSettingsDialog::tr("Any Country"), QVariant(QLocale::AnyCountry));
+ combo->setCurrentIndex(0);
+}
+
+void TranslationSettingsDialog::on_srcCbLanguageList_currentIndexChanged(int idx)
+{
+ fillCountryCombo(m_ui.srcCbLanguageList->itemData(idx), m_ui.srcCbCountryList);
+}
+
+void TranslationSettingsDialog::on_tgtCbLanguageList_currentIndexChanged(int idx)
+{
+ fillCountryCombo(m_ui.tgtCbLanguageList->itemData(idx), m_ui.tgtCbCountryList);
+}
+
void TranslationSettingsDialog::on_buttonBox_accepted()
{
int itemindex = m_ui.tgtCbLanguageList->currentIndex();
diff --git a/tools/linguist/linguist/translationsettingsdialog.h b/tools/linguist/linguist/translationsettingsdialog.h
index 2408add..7908cd7 100644
--- a/tools/linguist/linguist/translationsettingsdialog.h
+++ b/tools/linguist/linguist/translationsettingsdialog.h
@@ -66,6 +66,8 @@ private:
private slots:
void on_buttonBox_accepted();
+ void on_srcCbLanguageList_currentIndexChanged(int idx);
+ void on_tgtCbLanguageList_currentIndexChanged(int idx);
private:
Ui::TranslationSettingsDialog m_ui;