From 1c2f53717fb5c4a901506fd4576236df257905e5 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 29 Oct 2011 01:59:11 +0300 Subject: UTF8 support. Minor Config changes --- client/Dialog.cpp | 80 +++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'client/Dialog.cpp') diff --git a/client/Dialog.cpp b/client/Dialog.cpp index 7fe64c8..03b9db7 100644 --- a/client/Dialog.cpp +++ b/client/Dialog.cpp @@ -30,7 +30,8 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent) vector countries = cfg->GetCountries(); for (unsigned i = 0; i < countries.size(); i++) { - countryBox->addItem(countries[i].c_str()); + QString country = QString::fromUtf8(countries[i].c_str()); + countryBox->addItem(country); } countryBox->setCurrentIndex(-1); @@ -51,7 +52,7 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent) bottomLabel = new QLabel(tr("Bottom Panel")); /* setup layouting */ - comboBoxLayout = new QVBoxLayout; + QVBoxLayout *comboBoxLayout = new QVBoxLayout; comboBoxLayout->addWidget(countryBox); comboBoxLayout->addWidget(stateBox); comboBoxLayout->addWidget(cityBox); @@ -80,7 +81,6 @@ ProxyDialog::ProxyDialog(QWidget *parent): QDialog(parent) void ProxyDialog::CountryActivated(int index) { Logger::Trace("Country activated. Activated index=%d\n", index); - stateBox->setVisible(false); cityBox->setVisible(false); if (index == -1) @@ -88,24 +88,20 @@ void ProxyDialog::CountryActivated(int index) return; } - Config *cfg = Config::CurrentConfig(); - vector countries = cfg->GetCountries(); - if (index > countries.size()) - { - Logger::Error("Invalid country index: %d\n", index); - return; - } - Logger::Info("Country %s was selected\n", countries[index].c_str()); + string country(countryBox->currentText().toUtf8().constData()); + Logger::Info("Country %s was selected\n", country.c_str()); - vector states = cfg->GetStates(countries[index]); + Config *cfg = Config::CurrentConfig(); + vector states = cfg->GetStates(country); if (states.empty()) { - Logger::Info("There are no states in %s\n", countries[index].c_str()); - vector cities = cfg->GetCities(countries[index]); + Logger::Info("There are no states in %s\n",country.c_str()); + vector cities = cfg->GetCities(country); cityBox->clear(); for (unsigned i = 0; i < cities.size(); i++) - { - cityBox->addItem(cities[i].c_str()); + { + QString city = QString::fromUtf8(cities[i].c_str()); + cityBox->addItem(city); } cityBox->setCurrentIndex(-1); cityBox->adjustSize(); @@ -116,7 +112,8 @@ void ProxyDialog::CountryActivated(int index) stateBox->clear(); for (unsigned i = 0; i < states.size(); i++) { - stateBox->addItem(states[i].c_str()); + QString state = QString::fromUtf8(states[i].c_str()); + stateBox->addItem(state); } stateBox->setCurrentIndex(-1); stateBox->adjustSize(); @@ -127,40 +124,23 @@ void ProxyDialog::CountryActivated(int index) void ProxyDialog::StateActivated(int index) { Logger::Trace("State activated. Activated index=%d\n", index); - cityBox->setVisible(false); if (index == -1) { return; } - int countryIndex = countryBox->currentIndex(); - if (countryIndex == -1) - { - Logger::Error("Invalid country index selected: %d\n", countryIndex); - return; - } + string country(countryBox->currentText().toUtf8().constData()); + string state(stateBox->currentText().toUtf8().constData()); + Logger::Info("State %s was selected\n", state.c_str()); Config *cfg = Config::CurrentConfig(); - vector countries = cfg->GetCountries(); - if (countryIndex > countries.size()) - { - Logger::Error("Invalid country index selected: %d\n", countryIndex); - return; - } - - vector states = cfg->GetStates(countries[countryIndex]); - if (index > states.size()) - { - Logger::Error("Invalid state index: %d\n", index); - return; - } - - vector cities = cfg->GetCities(countries[countryIndex], states[index]); + vector cities = cfg->GetCities(country, state); cityBox->clear(); for (unsigned i = 0; i < cities.size(); i++) { - cityBox->addItem(cities[i].c_str()); + QString city = QString::fromUtf8(cities[i].c_str()); + cityBox->addItem(city); } cityBox->setCurrentIndex(-1); cityBox->adjustSize(); @@ -170,4 +150,24 @@ void ProxyDialog::StateActivated(int index) void ProxyDialog::CityActivated(int index) { Logger::Trace("City activated. Activated index=%d\n", index); + if (index == -1) + { + return; + } + + vector proxies; + Config *cfg = Config::CurrentConfig(); + string country(countryBox->currentText().toUtf8().constData()); + string city(cityBox->currentText().toUtf8().constData()); + if (stateBox->isVisible()) + { + string state(stateBox->currentText().toUtf8().constData()); + proxies = cfg->GetProxies(country, state, city); + } + else + { + proxies = cfg->GetProxies(country, city); + } + + } -- cgit v1.2.3