Fixed problems with special html characters and entities in Norwegian version.
[jenirok] / src / gui / eniroguiconfig.cpp
1 /*
2  * This file is part of Jenirok.
3  *
4  * Jenirok is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Jenirok is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Jenirok.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18
19 #include <QtCore/QDebug>
20 #include <QtGui/QVBoxLayout>
21 #include <QtGui/QHBoxLayout>
22 #include <QtGui/QLabel>
23 #include "eniroguiconfig.h"
24 #include "eniro.h"
25
26 EniroGuiConfig::EniroGuiConfig(QWidget* parent):
27 SourceGuiConfig(parent), EniroCoreConfig()
28 {
29     load();
30
31     QVBoxLayout* layout = new QVBoxLayout;
32
33     QHBoxLayout* username = new QHBoxLayout;
34     QHBoxLayout* password = new QHBoxLayout;
35
36     QLabel* usernameLabel = new QLabel(tr("Eniro username"));
37     usernameInput_ = new QLineEdit(getUsername());
38
39     QLabel* passwordLabel = new QLabel(tr("Eniro password"));
40     passwordInput_ = new QLineEdit(getPassword());
41     passwordInput_->setEchoMode(QLineEdit::PasswordEchoOnEdit);
42
43     QMap <Eniro::Site, Eniro::SiteDetails> sites = Eniro::getSites();
44
45     siteSelector_ = new ButtonSelector(tr("Eniro site"), this);
46     QString site = getSite();
47     int i = 0;
48
49     QMap <Eniro::Site, Eniro::SiteDetails>::const_iterator it;
50     for(it = sites.begin(); it != sites.end(); it++)
51     {
52         QString name;
53
54         switch(it.key())
55         {
56         case Eniro::FI:
57             name = tr("Finnish");
58             break;
59         case Eniro::SE:
60             name = tr("Swedish");
61             break;
62         case Eniro::DK:
63             name = tr("Danish");
64             break;
65         default:
66             qDebug() << "Unknown site";
67             continue;
68
69         }
70         siteSelector_->addItem(name, it.value().id);
71
72         if(it.value().id == site)
73         {
74             siteSelector_->setCurrentIndex(i);
75         }
76
77         i++;
78     }
79
80     username->addWidget(usernameLabel);
81     username->addWidget(usernameInput_);
82     password->addWidget(passwordLabel);
83     password->addWidget(passwordInput_);
84
85     layout->addLayout(username);
86     layout->addLayout(password);
87     layout->addWidget(siteSelector_);
88
89     setLayout(layout);
90 }
91
92 EniroGuiConfig::~EniroGuiConfig()
93 {
94 }
95
96 void EniroGuiConfig::save()
97 {
98     setUsername(usernameInput_->text());
99     setPassword(passwordInput_->text());
100     setSite(siteSelector_->value().toString());
101
102     store();
103 }