DateTimeDialog.cpp   DateTimeDialog.cpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2008 Nigel Kerr * Copyright (C) 2008 Nigel Kerr
* Copyright (C) 2012 Timothy Reaves
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "Dialog.hpp" #include "Dialog.hpp"
#include "DateTimeDialog.hpp" #include "DateTimeDialog.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "ui_dateTimeDialogGui.h" #include "ui_dateTimeDialogGui.h"
skipping to change at line 53 skipping to change at line 54
DateTimeDialog::~DateTimeDialog() DateTimeDialog::~DateTimeDialog()
{ {
delete ui; delete ui;
ui=NULL; ui=NULL;
} }
void DateTimeDialog::createDialogContent() void DateTimeDialog::createDialogContent()
{ {
ui->setupUi(dialog); ui->setupUi(dialog);
double jd = StelApp::getInstance().getCore()->getJDay(); double jd = StelApp::getInstance().getCore()->getJDay();
setDateTime(jd + (StelApp::getInstance().getLocaleMgr().getGMTShift( // UTC -> local tz
jd)/24.0)); // UTC -> local tz setDateTime(jd + (StelApp::getInstance().getLocaleMgr().getGMTShift(
jd)/24.0));
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(languageChanged())); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate()));
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connectSpinnerEvents();
}
void DateTimeDialog::connectSpinnerEvents() const
{
connect(ui->spinner_year, SIGNAL(valueChanged(int)), this, SLOT(year Changed(int))); connect(ui->spinner_year, SIGNAL(valueChanged(int)), this, SLOT(year Changed(int)));
connect(ui->spinner_month, SIGNAL(valueChanged(int)), this, SLOT(mon thChanged(int))); connect(ui->spinner_month, SIGNAL(valueChanged(int)), this, SLOT(mon thChanged(int)));
connect(ui->spinner_day, SIGNAL(valueChanged(int)), this, SLOT(dayCh anged(int))); connect(ui->spinner_day, SIGNAL(valueChanged(int)), this, SLOT(dayCh anged(int)));
connect(ui->spinner_hour, SIGNAL(valueChanged(int)), this, SLOT(hour Changed(int))); connect(ui->spinner_hour, SIGNAL(valueChanged(int)), this, SLOT(hour Changed(int)));
connect(ui->spinner_minute, SIGNAL(valueChanged(int)), this, SLOT(mi nuteChanged(int))); connect(ui->spinner_minute, SIGNAL(valueChanged(int)), this, SLOT(mi nuteChanged(int)));
connect(ui->spinner_second, SIGNAL(valueChanged(int)), this, SLOT(se condChanged(int))); connect(ui->spinner_second, SIGNAL(valueChanged(int)), this, SLOT(se condChanged(int)));
}
connect(this, SIGNAL(dateTimeChanged(double)), StelApp::getInstance( void DateTimeDialog::disconnectSpinnerEvents()const
).getCore(), SLOT(setJDay(double))); {
disconnect(ui->spinner_year, SIGNAL(valueChanged(int)), this, SLOT(y
earChanged(int)));
disconnect(ui->spinner_month, SIGNAL(valueChanged(int)), this, SLOT(
monthChanged(int)));
disconnect(ui->spinner_day, SIGNAL(valueChanged(int)), this, SLOT(da
yChanged(int)));
disconnect(ui->spinner_hour, SIGNAL(valueChanged(int)), this, SLOT(h
ourChanged(int)));
disconnect(ui->spinner_minute, SIGNAL(valueChanged(int)), this, SLOT
(minuteChanged(int)));
disconnect(ui->spinner_second, SIGNAL(valueChanged(int)), this, SLOT
(secondChanged(int)));
} }
//! take in values, adjust for calendrical correctness if needed, and push to //! take in values, adjust for calendrical correctness if needed, and push to
//! the widgets and signals //! the widgets and signals
bool DateTimeDialog::valid(int y, int m, int d, int h, int min, int s) bool DateTimeDialog::valid(int y, int m, int d, int h, int min, int s)
{ {
int dy, dm, dd, dh, dmin, ds; int dy, dm, dd, dh, dmin, ds;
if ( ! StelUtils::changeDateTimeForRollover(y, m, d, h, min, s, &dy, if (!StelUtils::changeDateTimeForRollover(y, m, d, h, min, s, &dy, &
&dm, &dd, &dh, &dmin, &ds) ) dm, &dd, &dh, &dmin, &ds)) {
{
dy = y; dy = y;
dm = m; dm = m;
dd = d; dd = d;
dh = h; dh = h;
dmin = min; dmin = min;
ds = s; ds = s;
} }
year = dy; year = dy;
month = dm; month = dm;
day = dd; day = dd;
hour = dh; hour = dh;
minute = dmin; minute = dmin;
second = ds; second = ds;
pushToWidgets(); pushToWidgets();
emit dateTimeChanged(newJd()); StelApp::getInstance().getCore()->setJDay(newJd());
return true; return true;
} }
void DateTimeDialog::languageChanged() void DateTimeDialog::retranslate()
{ {
if (dialog) if (dialog) {
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
}
} }
void DateTimeDialog::styleChanged() void DateTimeDialog::styleChanged()
{ {
// Nothing for now // Nothing for now
} }
void DateTimeDialog::close() void DateTimeDialog::close()
{ {
ui->dateTimeBox->setFocus(); ui->dateTimeBox->setFocus();
skipping to change at line 163 skipping to change at line 178
double DateTimeDialog::newJd() double DateTimeDialog::newJd()
{ {
double jd; double jd;
StelUtils::getJDFromDate(&jd,year, month, day, hour, minute, second); StelUtils::getJDFromDate(&jd,year, month, day, hour, minute, second);
jd -= (StelApp::getInstance().getLocaleMgr().getGMTShift(jd)/24.0); // lo cal tz -> UTC jd -= (StelApp::getInstance().getLocaleMgr().getGMTShift(jd)/24.0); // lo cal tz -> UTC
return jd; return jd;
} }
void DateTimeDialog::pushToWidgets() void DateTimeDialog::pushToWidgets()
{ {
ui->spinner_year->setValue(year); disconnectSpinnerEvents();
ui->spinner_month->setValue(month); ui->spinner_year->setValue(year);
ui->spinner_day->setValue(day); ui->spinner_month->setValue(month);
ui->spinner_hour->setValue(hour); ui->spinner_day->setValue(day);
if (!ui->spinner_minute->hasFocus() || (ui->spinner_minute->value() == -1 ui->spinner_hour->setValue(hour);
) || (ui->spinner_minute->value() == 60)) if (!ui->spinner_minute->hasFocus()
ui->spinner_minute->setValue(minute); || (ui->spinner_minute->value() == -1)
if (!ui->spinner_second->hasFocus() || (ui->spinner_second->value() == -1 || (ui->spinner_minute->value() == 60)) {
) || (ui->spinner_second->value() == 60)) ui->spinner_minute->setValue(minute);
ui->spinner_second->setValue(second); }
if (!ui->spinner_second->hasFocus()
|| (ui->spinner_second->value() == -1)
|| (ui->spinner_second->value() == 60)) {
ui->spinner_second->setValue(second);
}
connectSpinnerEvents();
} }
/************************************************************************ /************************************************************************
Send newJd to spinner_* Send newJd to spinner_*
************************************************************************/ ************************************************************************/
void DateTimeDialog::setDateTime(double newJd) void DateTimeDialog::setDateTime(double newJd)
{ {
newJd += (StelApp::getInstance().getLocaleMgr().getGMTShift(newJd)/2 if (this->visible()) {
4.0); // UTC -> local tz newJd += (StelApp::getInstance().getLocaleMgr().getGMTShift(
StelUtils::getDateFromJulianDay(newJd, &year, &month, &day); newJd)/24.0); // UTC -> local tz
StelUtils::getTimeFromJulianDay(newJd, &hour, &minute, &second); StelUtils::getDateFromJulianDay(newJd, &year, &month, &day);
pushToWidgets(); StelUtils::getTimeFromJulianDay(newJd, &hour, &minute, &seco
nd);
pushToWidgets();
}
} }
 End of changes. 14 change blocks. 
27 lines changed or deleted 56 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/