Fixed some inconsistencies in code indentation
[jenirok] / src / gui / settingsdialog.cpp
index 25ba29d..b2f3904 100644 (file)
 QMap <Eniro::Site, Eniro::SiteDetails> SettingsDialog::sites_ = Eniro::getSites();
 
 SettingsDialog::SettingsDialog(QWidget* parent): QDialog(parent),
-usernameInput_(0), passwordInput_(0), cacheInput_(0), siteSelector_(0), autostartSelector_(0)
+usernameInput_(0), passwordInput_(0), cacheInput_(0), siteSelector_(0),
+autostartSelector_(0)
 {
-       setWindowTitle(tr("Settings"));
-
-       DB::connect();
-
-       QVBoxLayout* left = new QVBoxLayout;
-       QHBoxLayout* mainLayout = new QHBoxLayout;
-       QHBoxLayout* username = new QHBoxLayout;
-       QHBoxLayout* password = new QHBoxLayout;
-       QHBoxLayout* cache = new QHBoxLayout;
-
-       QLabel* usernameLabel = new QLabel(tr("Eniro username"));
-       usernameInput_ = new QLineEdit(Settings::instance()->get("eniro_username"));
-
-       QLabel* passwordLabel = new QLabel(tr("Eniro password"));
-       passwordInput_ = new QLineEdit(Settings::instance()->get("eniro_password"));
-
-       QLabel* cacheLabel = new QLabel(tr("Cache size (numbers)"));
-       cacheInput_ = new QLineEdit(Settings::instance()->get("cache_size"));
-       cacheInput_->setValidator(new QIntValidator(0, 10000, this));
-
-       siteSelector_ = new ButtonSelector(tr("Eniro site"), this);
-       QString site = Settings::instance()->get("eniro_site");
-       int i = 0;
-       QMap <Eniro::Site, Eniro::SiteDetails>::const_iterator it;
-       for(it = sites_.begin(); it != sites_.end(); it++)
-       {
-               siteSelector_->addItem(it.value().name, it.value().id);
-
-               if(it.value().id == site)
-               {
-                       siteSelector_->setCurrentIndex(i);
-               }
-
-               i++;
-       }
-
-       autostartSelector_ = new ButtonSelector(tr("Autostart"), this);
-       QString autostart = Settings::instance()->get("autostart");
-       autostartSelector_->addItem(tr("Enabled"), "1");
-       autostartSelector_->addItem(tr("Disabled"), "0");
-       autostartSelector_->setCurrentIndex(autostart == "1" ? 0 : 1);
-
-       QPushButton* submitButton = new QPushButton(tr("Save"));
-       connect(submitButton, SIGNAL(pressed()), this, SLOT(saveSettings()));
-
-       username->addWidget(usernameLabel);
-       username->addWidget(usernameInput_);
-       password->addWidget(passwordLabel);
-       password->addWidget(passwordInput_);
-       cache->addWidget(cacheLabel);
-       cache->addWidget(cacheInput_);
-       left->addLayout(username);
-       left->addLayout(password);
-       left->addLayout(cache);
-       left->addWidget(siteSelector_);
-       left->addWidget(autostartSelector_);
-
-       mainLayout->addLayout(left);
-       mainLayout->addWidget(submitButton);
-
-       setLayout(mainLayout);
-
-       DB::disconnect();
+    setWindowTitle(tr("Settings"));
+
+    DB::connect();
+
+    QVBoxLayout* left = new QVBoxLayout;
+    QHBoxLayout* mainLayout = new QHBoxLayout;
+    QHBoxLayout* username = new QHBoxLayout;
+    QHBoxLayout* password = new QHBoxLayout;
+    QHBoxLayout* cache = new QHBoxLayout;
+
+    QLabel* usernameLabel = new QLabel(tr("Eniro username"));
+    usernameInput_ = new QLineEdit(Settings::instance()->get("eniro_username"));
+
+    QLabel* passwordLabel = new QLabel(tr("Eniro password"));
+    passwordInput_ = new QLineEdit(Settings::instance()->get("eniro_password"));
+
+    QLabel* cacheLabel = new QLabel(tr("Cache size (numbers)"));
+    cacheInput_ = new QLineEdit(Settings::instance()->get("cache_size"));
+    cacheInput_->setValidator(new QIntValidator(0, 10000, this));
+
+    siteSelector_ = new ButtonSelector(tr("Eniro site"), this);
+    QString site = Settings::instance()->get("eniro_site");
+    int i = 0;
+    QMap <Eniro::Site, Eniro::SiteDetails>::const_iterator it;
+    for(it = sites_.begin(); it != sites_.end(); it++)
+    {
+        siteSelector_->addItem(it.value().name, it.value().id);
+
+        if(it.value().id == site)
+        {
+            siteSelector_->setCurrentIndex(i);
+        }
+
+        i++;
+    }
+
+    autostartSelector_ = new ButtonSelector(tr("Autostart"), this);
+    QString autostart = Settings::instance()->get("autostart");
+    autostartSelector_->addItem(tr("Enabled"), "1");
+    autostartSelector_->addItem(tr("Disabled"), "0");
+    autostartSelector_->setCurrentIndex(autostart == "1" ? 0 : 1);
+
+    QPushButton* submitButton = new QPushButton(tr("Save"));
+    connect(submitButton, SIGNAL(pressed()), this, SLOT(saveSettings()));
+
+    username->addWidget(usernameLabel);
+    username->addWidget(usernameInput_);
+    password->addWidget(passwordLabel);
+    password->addWidget(passwordInput_);
+    cache->addWidget(cacheLabel);
+    cache->addWidget(cacheInput_);
+    left->addLayout(username);
+    left->addLayout(password);
+    left->addLayout(cache);
+    left->addWidget(siteSelector_);
+    left->addWidget(autostartSelector_);
+
+    mainLayout->addLayout(left);
+    mainLayout->addWidget(submitButton);
+
+    setLayout(mainLayout);
+
+    DB::disconnect();
 }
 
 void SettingsDialog::saveSettings()
 {
-       DB::connect();
+    DB::connect();
 
-       Settings::instance()->set("eniro_username", usernameInput_->text());
-       Settings::instance()->set("eniro_password", passwordInput_->text());
-       Settings::instance()->set("cache_size", cacheInput_->text());
-       QString site = siteSelector_->value().toString();
-       Settings::instance()->set("site", site);
-       QString autostart = autostartSelector_->value().toString();
-       Settings::instance()->set("autostart", autostart);
+    Settings::instance()->set("eniro_username", usernameInput_->text());
+    Settings::instance()->set("eniro_password", passwordInput_->text());
+    Settings::instance()->set("cache_size", cacheInput_->text());
+    QString site = siteSelector_->value().toString();
+    Settings::instance()->set("site", site);
+    QString autostart = autostartSelector_->value().toString();
+    Settings::instance()->set("autostart", autostart);
 
-       DB::disconnect();
+    DB::disconnect();
 
-       hide();
+    hide();
 
-       if(site != currentSite_ && Daemon::isRunning())
-       {
-               QMaemo5InformationBox::information(this, tr("Restarting daemon..."));
-               Daemon::restart();
-               currentSite_ = site;
-       }
+    if(site != currentSite_ && Daemon::isRunning())
+    {
+        QMaemo5InformationBox::information(this, tr("Restarting daemon..."));
+        Daemon::restart();
+        currentSite_ = site;
+    }
 
-       if(autostart != currentAutostart_)
-       {
-               bool value = false;
+    if(autostart != currentAutostart_)
+    {
+        bool value = false;
 
-               if(autostart == "1")
-               {
-                       value = true;
-               }
+        if(autostart == "1")
+        {
+            value = true;
+        }
 
-               Daemon::setAutostart(value);
-       }
+        Daemon::setAutostart(value);
+    }
 
 }
 
 void SettingsDialog::setVisible(bool visible)
 {
-       QDialog::setVisible(visible);
+    QDialog::setVisible(visible);
 
-       if(visible)
-       {
-               currentSite_ = siteSelector_->value().toString();
-               currentAutostart_ = autostartSelector_->value().toString();
-       }
+    if(visible)
+    {
+        currentSite_ = siteSelector_->value().toString();
+        currentAutostart_ = autostartSelector_->value().toString();
+    }
 
 }