summaryrefslogtreecommitdiff
path: root/client/Dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/Dialog.cpp')
-rw-r--r--client/Dialog.cpp80
1 files changed, 40 insertions, 40 deletions
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<string> 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<string> 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<string> states = cfg->GetStates(countries[index]);
+ Config *cfg = Config::CurrentConfig();
+ vector<string> states = cfg->GetStates(country);
if (states.empty())
{
- Logger::Info("There are no states in %s\n", countries[index].c_str());
- vector<string> cities = cfg->GetCities(countries[index]);
+ Logger::Info("There are no states in %s\n",country.c_str());
+ vector<string> 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<string> countries = cfg->GetCountries();
- if (countryIndex > countries.size())
- {
- Logger::Error("Invalid country index selected: %d\n", countryIndex);
- return;
- }
-
- vector<string> states = cfg->GetStates(countries[countryIndex]);
- if (index > states.size())
- {
- Logger::Error("Invalid state index: %d\n", index);
- return;
- }
-
- vector<string> cities = cfg->GetCities(countries[countryIndex], states[index]);
+ vector<string> 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<string> 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);
+ }
+
+
}