DateTimeDialog.cpp   DateTimeDialog.cpp 
skipping to change at line 41 skipping to change at line 41
#include <QFrame> #include <QFrame>
#include <QLineEdit> #include <QLineEdit>
DateTimeDialog::DateTimeDialog(QObject* parent) : DateTimeDialog::DateTimeDialog(QObject* parent) :
StelDialog(parent), StelDialog(parent),
year(0), year(0),
month(0), month(0),
day(0), day(0),
hour(0), hour(0),
minute(0), minute(0),
second(0) second(0),
jd(0),
mjd(0)
{ {
ui = new Ui_dateTimeDialogForm; ui = new Ui_dateTimeDialogForm;
} }
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 cjd = StelApp::getInstance().getCore()->getJDay();
// UTC -> local tz // UTC -> local tz
// Add in a DeltaT correction. Divide DeltaT by 86400 to convert fro m seconds to days. // Add in a DeltaT correction. Divide DeltaT by 86400 to convert fro m seconds to days.
double deltaT = 0.; double deltaT = 0.;
if (StelApp::getInstance().getCore()->getCurrentLocation().planetNam e=="Earth") if (StelApp::getInstance().getCore()->getCurrentLocation().planetNam e=="Earth")
deltaT = StelApp::getInstance().getCore()->getDeltaT(jd)/864 deltaT = StelApp::getInstance().getCore()->getDeltaT(cjd)/86
00.; 400.;
setDateTime(jd + (StelApp::getInstance().getLocaleMgr().getGMTShift( setDateTime(cjd + (StelApp::getInstance().getLocaleMgr().getGMTShift
jd)/24.0)-deltaT); (cjd)/24.0)-deltaT);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate())); 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(); connectSpinnerEvents();
} }
void DateTimeDialog::connectSpinnerEvents() const 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(ui->spinner_jd, SIGNAL(valueChanged(double)), this, SLOT(jdC
hanged(double)));
connect(ui->spinner_mjd, SIGNAL(valueChanged(double)), this, SLOT(mj
dChanged(double)));
} }
void DateTimeDialog::disconnectSpinnerEvents()const void DateTimeDialog::disconnectSpinnerEvents()const
{ {
disconnect(ui->spinner_year, SIGNAL(valueChanged(int)), this, SLOT(y earChanged(int))); 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_month, SIGNAL(valueChanged(int)), this, SLOT( monthChanged(int)));
disconnect(ui->spinner_day, SIGNAL(valueChanged(int)), this, SLOT(da yChanged(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_hour, SIGNAL(valueChanged(int)), this, SLOT(h ourChanged(int)));
disconnect(ui->spinner_minute, SIGNAL(valueChanged(int)), this, SLOT (minuteChanged(int))); disconnect(ui->spinner_minute, SIGNAL(valueChanged(int)), this, SLOT (minuteChanged(int)));
disconnect(ui->spinner_second, SIGNAL(valueChanged(int)), this, SLOT (secondChanged(int))); disconnect(ui->spinner_second, SIGNAL(valueChanged(int)), this, SLOT (secondChanged(int)));
disconnect(ui->spinner_jd, SIGNAL(valueChanged(double)), this, SLOT(
jdChanged(double)));
disconnect(ui->spinner_mjd, SIGNAL(valueChanged(double)), this, SLOT
(mjdChanged(double)));
} }
//! 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, & dm, &dd, &dh, &dmin, &ds)) { if (!StelUtils::changeDateTimeForRollover(y, m, d, h, min, s, &dy, & dm, &dd, &dh, &dmin, &ds)) {
dy = y; dy = y;
skipping to change at line 115 skipping to change at line 121
month = dm; month = dm;
day = dd; day = dd;
hour = dh; hour = dh;
minute = dmin; minute = dmin;
second = ds; second = ds;
pushToWidgets(); pushToWidgets();
StelApp::getInstance().getCore()->setJDay(newJd()); StelApp::getInstance().getCore()->setJDay(newJd());
return true; return true;
} }
bool DateTimeDialog::validJd(double jday)
{
pushToWidgets();
// local tz -> UTC
StelApp::getInstance().getCore()->setJDay(jday-StelApp::getInstance(
).getLocaleMgr().getGMTShift(jday)/24.+StelApp::getInstance().getCore()->ge
tDeltaT(jday)/86400.);
return true;
}
bool DateTimeDialog::validMjd(double mjday)
{
pushToWidgets();
// local tz -> UTC
StelApp::getInstance().getCore()->setMJDay(mjday-StelApp::getInstanc
e().getLocaleMgr().getGMTShift(mjday)/24.+StelApp::getInstance().getCore()-
>getDeltaT(mjday)/86400.);
return true;
}
void DateTimeDialog::retranslate() 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
skipping to change at line 139 skipping to change at line 161
ui->dateTimeBox->setFocus(); ui->dateTimeBox->setFocus();
StelDialog::close(); StelDialog::close();
} }
/************************************************************************ /************************************************************************
year slider or dial changed year slider or dial changed
************************************************************************/ ************************************************************************/
void DateTimeDialog::yearChanged(int newyear) void DateTimeDialog::yearChanged(int newyear)
{ {
if ( year != newyear ) { if ( year != newyear )
valid( newyear, month, day, hour, minute, second ); {
} valid( newyear, month, day, hour, minute, second );
}
} }
void DateTimeDialog::monthChanged(int newmonth) void DateTimeDialog::monthChanged(int newmonth)
{ {
if ( month != newmonth ) { if ( month != newmonth )
valid( year, newmonth, day, hour, minute, second ); {
} valid( year, newmonth, day, hour, minute, second );
}
} }
void DateTimeDialog::dayChanged(int newday) void DateTimeDialog::dayChanged(int newday)
{ {
if ( day != newday ) { if ( day != newday )
valid( year, month, newday, hour, minute, second ); {
} valid( year, month, newday, hour, minute, second );
}
} }
void DateTimeDialog::hourChanged(int newhour) void DateTimeDialog::hourChanged(int newhour)
{ {
if ( hour != newhour ) { if ( hour != newhour )
valid( year, month, day, newhour, minute, second ); {
} valid( year, month, day, newhour, minute, second );
}
} }
void DateTimeDialog::minuteChanged(int newminute) void DateTimeDialog::minuteChanged(int newminute)
{ {
if ( minute != newminute ) { if ( minute != newminute )
valid( year, month, day, hour, newminute, second ); {
} valid( year, month, day, hour, newminute, second );
}
} }
void DateTimeDialog::secondChanged(int newsecond) void DateTimeDialog::secondChanged(int newsecond)
{ {
if ( second != newsecond ) { if ( second != newsecond )
valid( year, month, day, hour, minute, newsecond ); {
} valid( year, month, day, hour, minute, newsecond );
}
}
void DateTimeDialog::jdChanged(double njd)
{
if ( jd != njd)
{
validJd(njd);
}
}
void DateTimeDialog::mjdChanged(double nmjd)
{
if ( mjd != nmjd)
{
validMjd(nmjd);
}
} }
double DateTimeDialog::newJd() double DateTimeDialog::newJd()
{ {
double jd; double cjd;
StelUtils::getJDFromDate(&jd,year, month, day, hour, minute, second); StelUtils::getJDFromDate(&cjd, year, month, day, hour, minute, secon
// Add in a DeltaT correction. Divide DeltaT by 86400 to convert from sec d);
onds to days. // Add in a DeltaT correction. Divide DeltaT by 86400 to convert fro
double deltaT = 0.; m seconds to days.
if (StelApp::getInstance().getCore()->getCurrentLocation().planetName=="E double deltaT = 0.;
arth") if (StelApp::getInstance().getCore()->getCurrentLocation().planetNam
deltaT = StelApp::getInstance().getCore()->getDeltaT(jd)/86400.; e=="Earth")
jd -= (StelApp::getInstance().getLocaleMgr().getGMTShift(jd)/24.0-deltaT) deltaT = StelApp::getInstance().getCore()->getDeltaT(cjd)/86
; // local tz -> UTC 400.;
return jd; cjd -= (StelApp::getInstance().getLocaleMgr().getGMTShift(cjd)/24.0-
deltaT); // local tz -> UTC
return cjd;
} }
void DateTimeDialog::pushToWidgets() void DateTimeDialog::pushToWidgets()
{ {
disconnectSpinnerEvents(); disconnectSpinnerEvents();
ui->spinner_year->setValue(year); ui->spinner_year->setValue(year);
ui->spinner_month->setValue(month); ui->spinner_month->setValue(month);
ui->spinner_day->setValue(day); ui->spinner_day->setValue(day);
ui->spinner_hour->setValue(hour); ui->spinner_hour->setValue(hour);
if (!ui->spinner_minute->hasFocus() if (!ui->spinner_minute->hasFocus() || (ui->spinner_minute->value()
|| (ui->spinner_minute->value() == -1) == -1) || (ui->spinner_minute->value() == 60))
|| (ui->spinner_minute->value() == 60)) { {
ui->spinner_minute->setValue(minute); ui->spinner_minute->setValue(minute);
} }
if (!ui->spinner_second->hasFocus() if (!ui->spinner_second->hasFocus() || (ui->spinner_second->value()
|| (ui->spinner_second->value() == -1) == -1) || (ui->spinner_second->value() == 60))
|| (ui->spinner_second->value() == 60)) { {
ui->spinner_second->setValue(second); ui->spinner_second->setValue(second);
}
if (!ui->spinner_jd->hasFocus())
{
ui->spinner_jd->setValue(jd);
}
if (!ui->spinner_mjd->hasFocus())
{
ui->spinner_mjd->setValue(mjd);
} }
connectSpinnerEvents(); connectSpinnerEvents();
} }
/************************************************************************ /************************************************************************
Send newJd to spinner_* Send newJd to spinner_*
************************************************************************/ ************************************************************************/
void DateTimeDialog::setDateTime(double newJd) void DateTimeDialog::setDateTime(double newJd)
{ {
if (this->visible()) { if (this->visible()) {
// Add in a DeltaT correction. Divide DeltaT by 86400 to con vert from seconds to days. // Add in a DeltaT correction. Divide DeltaT by 86400 to con vert from seconds to days.
double deltaT = 0.; double deltaT = 0.;
if (StelApp::getInstance().getCore()->getCurrentLocation().p lanetName=="Earth") if (StelApp::getInstance().getCore()->getCurrentLocation().p lanetName=="Earth")
deltaT = StelApp::getInstance().getCore()->getDeltaT (newJd)/86400.; deltaT = StelApp::getInstance().getCore()->getDeltaT (newJd)/86400.;
newJd += (StelApp::getInstance().getLocaleMgr().getGMTShift( newJd)/24.0-deltaT); // UTC -> local tz newJd += (StelApp::getInstance().getLocaleMgr().getGMTShift( newJd)/24.0-deltaT); // UTC -> local tz
StelUtils::getDateFromJulianDay(newJd, &year, &month, &day); StelUtils::getDateFromJulianDay(newJd, &year, &month, &day);
StelUtils::getTimeFromJulianDay(newJd, &hour, &minute, &seco nd); StelUtils::getTimeFromJulianDay(newJd, &hour, &minute, &seco nd);
jd = newJd;
mjd = newJd-2400000.5;
pushToWidgets(); pushToWidgets();
} }
} }
 End of changes. 15 change blocks. 
44 lines changed or deleted 106 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/