File: unitsettingsdialog.cpp

package info (click to toggle)
kalzium 4%3A17.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 56,876 kB
  • sloc: xml: 20,671; cpp: 16,953; ml: 799; makefile: 65; ansic: 32; sh: 21
file content (84 lines) | stat: -rw-r--r-- 2,993 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) 2011  Rebetez Etienne <etienne.rebetez@oberwallis.ch>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "unitsettingsdialog.h"

#include <kunitconversion/converter.h>
#include <KLocalizedString>

#include <QGridLayout>
#include <QLabel>

UnitSettingsDialog::UnitSettingsDialog(QWidget* parent) : QWidget(parent)
{
    QLabel *labelEnergy = new QLabel(i18n("Energy:"), this);
    QList<int> energy;
    energy << KUnitConversion::Electronvolt << KUnitConversion::KiloJoulePerMole <<
           KUnitConversion::JoulePerMole << KUnitConversion::Joule;
    m_comboBoxLEnergiesUnit = new KalziumUnitCombobox(energy, this);
    m_comboBoxLEnergiesUnit->setObjectName("kcfg_combobox_energies");

    QLabel *labelLenght = new QLabel(i18n("Length:"), this);
    QList<int> length;
    length << KUnitConversion::Picometer << KUnitConversion::Nanometer << KUnitConversion::Angstrom;
    m_comboBoxLengthUnit = new KalziumUnitCombobox(length, this);
    m_comboBoxLengthUnit->setObjectName("kcfg_combobox_length");

    QLabel *labelTemperature = new QLabel(i18n("Temperature:"), this);
    QList<int> temperature;
    temperature << KUnitConversion::Kelvin << KUnitConversion::Celsius << KUnitConversion::Fahrenheit <<
                KUnitConversion::Reaumur;
    m_comboBoxLTemperatureUnit = new KalziumUnitCombobox(temperature, this);
    m_comboBoxLTemperatureUnit->setObjectName("kcfg_combobox_temperature");

    QGridLayout *layout = new QGridLayout(this);
    layout->addWidget(labelEnergy, 0, 0);
    layout->addWidget(m_comboBoxLEnergiesUnit, 0, 1);

    layout->addWidget(labelLenght, 1, 0);
    layout->addWidget(m_comboBoxLengthUnit, 1, 1);

    layout->addWidget(labelTemperature, 2, 0);
    layout->addWidget(m_comboBoxLTemperatureUnit, 2, 1);

    layout->setRowStretch(3, 1);

    setLayout(layout);
}

int UnitSettingsDialog::getEnergyUnitId()
{
    return m_comboBoxLEnergiesUnit->getCurrentUnitId();
}

int UnitSettingsDialog::getLenghtUnitId()
{
    return m_comboBoxLengthUnit->getCurrentUnitId();
}

int UnitSettingsDialog::getTemperatureUnitId()
{
    return m_comboBoxLTemperatureUnit->getCurrentUnitId();
}

UnitSettingsDialog::~UnitSettingsDialog()
{
    delete m_comboBoxLEnergiesUnit;
    delete m_comboBoxLengthUnit;
    delete m_comboBoxLTemperatureUnit;
}