~ubuntu-branches/debian/jessie/stellarium/jessie

« back to all changes in this revision

Viewing changes to src/gui/DateTimeDialog.cpp

  • Committer: Package Import Robot
  • Author(s): Tomasz Buchert
  • Date: 2012-05-18 13:26:18 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20120518132618-3uso09fo68c218cx
Tags: 0.11.2-1
* Imported Upstream version 0.11.1 and then 0.11.2 (Closes: #658431)
* Change maintainer (Closes: #668916)
* Machine-readable copyright file
* Bump Standards-Version to 3.9.3
* Update debhelper compat to 9
* Fix lintian duplicate-font-file warning
* Fix copyright-refers-to-symlink-license lintian tag
* Add lintian override for embedded-library error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Stellarium
3
3
 * Copyright (C) 2008 Nigel Kerr
 
4
 * Copyright (C) 2012 Timothy Reaves
4
5
 *
5
6
 * This program is free software; you can redistribute it and/or
6
7
 * modify it under the terms of the GNU General Public License
14
15
 *
15
16
 * You should have received a copy of the GNU General Public License
16
17
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
18
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
18
19
*/
19
20
 
20
21
#include "Dialog.hpp"
50
51
{
51
52
        ui->setupUi(dialog);
52
53
        double jd = StelApp::getInstance().getCore()->getJDay();
53
 
        setDateTime(jd + (StelApp::getInstance().getLocaleMgr().getGMTShift(jd)/24.0)); // UTC -> local tz
 
54
        // UTC -> local tz
 
55
        setDateTime(jd + (StelApp::getInstance().getLocaleMgr().getGMTShift(jd)/24.0));
54
56
 
55
 
        connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(languageChanged()));
 
57
        connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
56
58
        connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
57
59
 
 
60
        connectSpinnerEvents();
 
61
}
 
62
 
 
63
void DateTimeDialog::connectSpinnerEvents() const
 
64
{
58
65
        connect(ui->spinner_year, SIGNAL(valueChanged(int)), this, SLOT(yearChanged(int)));
59
66
        connect(ui->spinner_month, SIGNAL(valueChanged(int)), this, SLOT(monthChanged(int)));
60
67
        connect(ui->spinner_day, SIGNAL(valueChanged(int)), this, SLOT(dayChanged(int)));
61
68
        connect(ui->spinner_hour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)));
62
69
        connect(ui->spinner_minute, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)));
63
70
        connect(ui->spinner_second, SIGNAL(valueChanged(int)), this, SLOT(secondChanged(int)));
64
 
 
65
 
        connect(this, SIGNAL(dateTimeChanged(double)), StelApp::getInstance().getCore(), SLOT(setJDay(double)));
66
 
}
 
71
}
 
72
 
 
73
void DateTimeDialog::disconnectSpinnerEvents()const
 
74
{
 
75
        disconnect(ui->spinner_year, SIGNAL(valueChanged(int)), this, SLOT(yearChanged(int)));
 
76
        disconnect(ui->spinner_month, SIGNAL(valueChanged(int)), this, SLOT(monthChanged(int)));
 
77
        disconnect(ui->spinner_day, SIGNAL(valueChanged(int)), this, SLOT(dayChanged(int)));
 
78
        disconnect(ui->spinner_hour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)));
 
79
        disconnect(ui->spinner_minute, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)));
 
80
        disconnect(ui->spinner_second, SIGNAL(valueChanged(int)), this, SLOT(secondChanged(int)));
 
81
}
 
82
 
67
83
 
68
84
//! take in values, adjust for calendrical correctness if needed, and push to
69
85
//! the widgets and signals
71
87
{
72
88
        int dy, dm, dd, dh, dmin, ds;
73
89
 
74
 
        if ( ! StelUtils::changeDateTimeForRollover(y, m, d, h, min, s, &dy, &dm, &dd, &dh, &dmin, &ds) )
75
 
        {
 
90
        if (!StelUtils::changeDateTimeForRollover(y, m, d, h, min, s, &dy, &dm, &dd, &dh, &dmin, &ds)) {
76
91
                dy = y;
77
92
                dm = m;
78
93
                dd = d;
88
103
        minute = dmin;
89
104
        second = ds;
90
105
        pushToWidgets();
91
 
        emit dateTimeChanged(newJd());
 
106
        StelApp::getInstance().getCore()->setJDay(newJd());
92
107
        return true;
93
108
}
94
109
 
95
 
void DateTimeDialog::languageChanged()
 
110
void DateTimeDialog::retranslate()
96
111
{
97
 
        if (dialog)
 
112
        if (dialog) {
98
113
                ui->retranslateUi(dialog);
 
114
        }
99
115
}
100
116
 
101
117
void DateTimeDialog::styleChanged()
160
176
 
161
177
void DateTimeDialog::pushToWidgets()
162
178
{
163
 
  ui->spinner_year->setValue(year);
164
 
  ui->spinner_month->setValue(month);
165
 
  ui->spinner_day->setValue(day);
166
 
  ui->spinner_hour->setValue(hour);
167
 
  if (!ui->spinner_minute->hasFocus() || (ui->spinner_minute->value() == -1) || (ui->spinner_minute->value() == 60))
168
 
    ui->spinner_minute->setValue(minute);
169
 
  if (!ui->spinner_second->hasFocus() || (ui->spinner_second->value() == -1) || (ui->spinner_second->value() == 60))
170
 
    ui->spinner_second->setValue(second);
 
179
        disconnectSpinnerEvents();
 
180
        ui->spinner_year->setValue(year);
 
181
        ui->spinner_month->setValue(month);
 
182
        ui->spinner_day->setValue(day);
 
183
        ui->spinner_hour->setValue(hour);
 
184
        if (!ui->spinner_minute->hasFocus()
 
185
                        || (ui->spinner_minute->value() == -1)
 
186
                        || (ui->spinner_minute->value() == 60)) {
 
187
          ui->spinner_minute->setValue(minute);
 
188
        }
 
189
        if (!ui->spinner_second->hasFocus()
 
190
                        || (ui->spinner_second->value() == -1)
 
191
                        || (ui->spinner_second->value() == 60)) {
 
192
          ui->spinner_second->setValue(second);
 
193
        }
 
194
        connectSpinnerEvents();
171
195
}
172
196
 
173
197
/************************************************************************
175
199
 ************************************************************************/
176
200
void DateTimeDialog::setDateTime(double newJd)
177
201
{
178
 
        newJd += (StelApp::getInstance().getLocaleMgr().getGMTShift(newJd)/24.0); // UTC -> local tz
179
 
        StelUtils::getDateFromJulianDay(newJd, &year, &month, &day);
180
 
        StelUtils::getTimeFromJulianDay(newJd, &hour, &minute, &second);
181
 
        pushToWidgets();
 
202
        if (this->visible()) {
 
203
                newJd += (StelApp::getInstance().getLocaleMgr().getGMTShift(newJd)/24.0); // UTC -> local tz
 
204
                StelUtils::getDateFromJulianDay(newJd, &year, &month, &day);
 
205
                StelUtils::getTimeFromJulianDay(newJd, &hour, &minute, &second);
 
206
                pushToWidgets();
 
207
        }
182
208
}
183
209