-Added math functions:
[engrid.git] / guisettingstab.cpp
blobc079aff694504a559416fbf0939351aac69f9a1b
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "guisettingstab.h"
24 #include <typeinfo>
25 #include <QFormLayout>
27 #include <iostream>
28 using namespace std;
30 GuiSettingsTab::GuiSettingsTab(QString org, QString app, QString group, QWidget *parent): QWidget(parent)
33 QFormLayout *permissionsLayout = new QFormLayout;
35 QSettings settings(org, app);
37 if(group!="General") settings.beginGroup(group);
39 settings.beginGroup("int");
40 foreach (QString key, settings.childKeys()) {
41 int I=settings.value(key).toInt();
42 spinbox.append(new QSpinBox);
43 spinbox_name.append(key);
44 spinbox.back()->setValue(I);
45 permissionsLayout->addRow(key, spinbox.back());
47 settings.endGroup();
49 settings.beginGroup("bool");
50 foreach (QString key, settings.childKeys()) {
51 checkbox.append(new QCheckBox);
52 checkbox_name.append(key);
53 checkbox.back()->setCheckState((Qt::CheckState)settings.value(key).toInt());
54 permissionsLayout->addRow(key, checkbox.back());
56 settings.endGroup();
58 settings.beginGroup("double");
59 foreach (QString key, settings.childKeys()) {
60 double D=settings.value(key).toDouble();
61 QString s;
62 s.sprintf("%.2f", D);
63 lineedit.append(new QLineEdit);
64 lineedit_name.append(key);
65 lineedit.back()->setText(s);
66 permissionsLayout->addRow(key, lineedit.back());
68 settings.endGroup();
70 if(group!="General") settings.endGroup();
72 setLayout(permissionsLayout);