~ubuntu-branches/debian/experimental/stellarium/experimental

« back to all changes in this revision

Viewing changes to src/gui/CustomDeltaTEquationDialog.cpp

  • Committer: Package Import Robot
  • Author(s): Tomasz Buchert
  • Date: 2013-04-23 18:31:29 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20130423183129-u1bus3c87vywlmku
Tags: 0.12.1-1
* Imported Upstream version 0.12.1
* Installing icons provided by upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This program is distributed in the hope that it will be useful,
 
3
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
4
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
5
 * GNU General Public License for more details.
 
6
 * You should have received a copy of the GNU General Public License
 
7
 * along with this program; if not, write to the Free Software
 
8
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
 
9
*/
 
10
 
 
11
#include "CustomDeltaTEquationDialog.hpp"
 
12
#include "ui_CustomDeltaTEquationDialog.h"
 
13
 
 
14
#include "Dialog.hpp"
 
15
#include "StelApp.hpp"
 
16
#include "StelTranslator.hpp"
 
17
#include "StelObjectMgr.hpp"
 
18
 
 
19
#include <QDebug>
 
20
 
 
21
CustomDeltaTEquationDialog::CustomDeltaTEquationDialog()
 
22
{
 
23
        ui = new Ui_CustomDeltaTEquationDialogForm;
 
24
        conf = StelApp::getInstance().getSettings();
 
25
        core = StelApp::getInstance().getCore();
 
26
 
 
27
        ndot = core->getCustomNDot();
 
28
        year = core->getCustomYear();
 
29
        coeff = core->getCustomEquationCoefficients();
 
30
}
 
31
 
 
32
CustomDeltaTEquationDialog::~CustomDeltaTEquationDialog()
 
33
{
 
34
        delete ui;
 
35
        ui=NULL;
 
36
}
 
37
 
 
38
void CustomDeltaTEquationDialog::retranslate()
 
39
{
 
40
        if (dialog)
 
41
        {
 
42
                ui->retranslateUi(dialog);
 
43
                setDescription();
 
44
        }
 
45
}
 
46
 
 
47
 
 
48
void CustomDeltaTEquationDialog::createDialogContent()
 
49
{
 
50
        ui->setupUi(dialog);
 
51
        setDescription();
 
52
 
 
53
        ui->labelNDot->setText(QString("%1:").arg(QChar(0x1E45)));
 
54
 
 
55
        ui->lineEditCoefficientA->setText(QString("%1").arg(coeff[0]));
 
56
        ui->lineEditCoefficientB->setText(QString("%1").arg(coeff[1]));
 
57
        ui->lineEditCoefficientC->setText(QString("%1").arg(coeff[2]));
 
58
        ui->lineEditYear->setText(QString("%1").arg(year));
 
59
        ui->lineEditNDot->setText(QString("%1").arg(ndot));
 
60
 
 
61
        //Signals and slots
 
62
        connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
 
63
        connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
 
64
 
 
65
        connect(ui->lineEditNDot, SIGNAL(textEdited(const QString&)), this, SLOT(setNDot(const QString&)));
 
66
        connect(ui->lineEditYear, SIGNAL(textEdited(const QString&)), this, SLOT(setYear(const QString&)));
 
67
        connect(ui->lineEditCoefficientA, SIGNAL(textEdited(const QString&)), this, SLOT(setCoeffA(const QString&)));
 
68
        connect(ui->lineEditCoefficientB, SIGNAL(textEdited(const QString&)), this, SLOT(setCoeffB(const QString&)));
 
69
        connect(ui->lineEditCoefficientC, SIGNAL(textEdited(const QString&)), this, SLOT(setCoeffC(const QString&)));
 
70
 
 
71
}
 
72
 
 
73
void CustomDeltaTEquationDialog::setVisible(bool v)
 
74
{
 
75
        StelDialog::setVisible(v);
 
76
}
 
77
 
 
78
void CustomDeltaTEquationDialog::saveSettings(void) const
 
79
{
 
80
        conf->beginGroup("custom_time_correction");
 
81
 
 
82
        conf->setValue("year", year);
 
83
        conf->setValue("ndot", ndot);
 
84
        conf->setValue("coefficients", QString("%1,%2,%3").arg(coeff[0]).arg(coeff[1]).arg(coeff[2]));
 
85
 
 
86
        conf->endGroup();
 
87
}
 
88
 
 
89
void CustomDeltaTEquationDialog::setNDot(const QString& v)
 
90
{
 
91
        ndot = v.toFloat();
 
92
        core->setCustomNDot(ndot);
 
93
        saveSettings();
 
94
}
 
95
 
 
96
void CustomDeltaTEquationDialog::setYear(const QString& v)
 
97
{
 
98
        year = v.toFloat();
 
99
        core->setCustomYear(year);
 
100
        saveSettings();
 
101
}
 
102
 
 
103
void CustomDeltaTEquationDialog::setCoeffA(const QString& v)
 
104
{
 
105
        coeff[0] = v.toFloat();
 
106
        core->setCustomEquationCoefficients(coeff);
 
107
        saveSettings();
 
108
}
 
109
 
 
110
void CustomDeltaTEquationDialog::setCoeffB(const QString& v)
 
111
{
 
112
        coeff[1] = v.toFloat();
 
113
        core->setCustomEquationCoefficients(coeff);
 
114
        saveSettings();
 
115
}
 
116
 
 
117
void CustomDeltaTEquationDialog::setCoeffC(const QString& v)
 
118
{
 
119
        coeff[2] = v.toFloat();
 
120
        core->setCustomEquationCoefficients(coeff);
 
121
        saveSettings();
 
122
}
 
123
 
 
124
void CustomDeltaTEquationDialog::setDescription() const
 
125
{
 
126
        ui->stelWindowTitle->setText(q_("Custom equation for %1T").arg(QChar(0x0394)));
 
127
        ui->labelDescription->setText(q_("A typical equation for calculation of %1T looks like:").arg(QChar(0x0394)));
 
128
        ui->labelEquation->setText(QString("<strong>%1T = a + b%2u + c%3u%4,</strong>").arg(QChar(0x0394)).arg(QChar(0x00B7)).arg(QChar(0x00B7)).arg(QChar(0x00B2)));
 
129
        ui->labelSubEquation->setText(QString("%1 <em>u = (%2 - y)/100</em>").arg(q_("where")).arg(q_("year")));
 
130
}