DateTimeDialog.cpp   DateTimeDialog.cpp 
skipping to change at line 35 skipping to change at line 35
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "ui_dateTimeDialogGui.h" #include "ui_dateTimeDialogGui.h"
#include <QDebug> #include <QDebug>
#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), jd(0)
mjd(0)
{ {
ui = new Ui_dateTimeDialogForm; ui = new Ui_dateTimeDialogForm;
dialogName = "DateTime";
} }
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()->getJD(); double jd = StelApp::getInstance().getCore()->getJD();
// UTC -> local tz // UTC -> local tz
setDateTime(jd + (StelApp::getInstance().getLocaleMgr().getGMTShift( jd)/24.0)); setDateTime(jd + (StelApp::getInstance().getLocaleMgr().getGMTShift( jd)/24.0));
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())) ;
connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMove dTo(QPoint)));
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)));
skipping to change at line 154 skipping to change at line 155
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 ) int delta = newday - day;
{ validJd(jd + delta);
valid( year, month, newday, hour, minute, second );
}
} }
void DateTimeDialog::hourChanged(int newhour) void DateTimeDialog::hourChanged(int newhour)
{ {
if ( hour != newhour ) int delta = newhour - hour;
{ validJd(jd + delta/24.);
valid( year, month, day, newhour, minute, second );
}
} }
void DateTimeDialog::minuteChanged(int newminute) void DateTimeDialog::minuteChanged(int newminute)
{ {
if ( minute != newminute ) int delta = newminute - minute;
{ validJd(jd + delta/1440.);
valid( year, month, day, hour, newminute, second );
}
} }
void DateTimeDialog::secondChanged(int newsecond) void DateTimeDialog::secondChanged(int newsecond)
{ {
if ( second != newsecond ) int delta = newsecond - second;
{ validJd(jd + delta/86400.);
valid( year, month, day, hour, minute, newsecond );
}
} }
void DateTimeDialog::jdChanged(double njd) void DateTimeDialog::jdChanged(double njd)
{ {
if ( jd != njd) if ( jd != njd)
{ {
validJd(njd); validJd(njd);
} }
} }
void DateTimeDialog::mjdChanged(double nmjd) void DateTimeDialog::mjdChanged(double nmjd)
{ {
if ( mjd != nmjd) double delta = nmjd - getMjd();
{ validJd(jd + delta);
validJd(2400000.5 + nmjd);
}
} }
double DateTimeDialog::newJd() double DateTimeDialog::newJd()
{ {
double cjd; double cjd;
StelUtils::getJDFromDate(&cjd, year, month, day, hour, minute, secon d); StelUtils::getJDFromDate(&cjd, year, month, day, hour, minute, secon d);
cjd -= (StelApp::getInstance().getLocaleMgr().getGMTShift(cjd)/24.0) ; // local tz -> UTC cjd -= (StelApp::getInstance().getLocaleMgr().getGMTShift(cjd)/24.0) ; // local tz -> UTC
return cjd; 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() || (ui->spinner_minute->value() ui->spinner_minute->setValue(minute);
== -1) || (ui->spinner_minute->value() == 60)) ui->spinner_second->setValue(second);
{
ui->spinner_minute->setValue(minute);
}
if (!ui->spinner_second->hasFocus() || (ui->spinner_second->value()
== -1) || (ui->spinner_second->value() == 60))
{
ui->spinner_second->setValue(second);
}
ui->spinner_jd->setValue(jd); ui->spinner_jd->setValue(jd);
ui->spinner_mjd->setValue(mjd); ui->spinner_mjd->setValue(getMjd());
if (jd<2299161) // 1582-10-15 if (jd<2299161) // 1582-10-15
ui->dateTimeTab->setToolTip(q_("Date and Time in Julian cale ndar")); ui->dateTimeTab->setToolTip(q_("Date and Time in Julian cale ndar"));
else else
ui->dateTimeTab->setToolTip(q_("Date and Time in Gregorian c alendar")); ui->dateTimeTab->setToolTip(q_("Date and Time in Gregorian c alendar"));
connectSpinnerEvents(); connectSpinnerEvents();
} }
/************************************************************************ /************************************************************************
Prepare date elements from newJd and send to spinner_* Prepare date elements from newJd and send to spinner_*
************************************************************************/ ************************************************************************/
void DateTimeDialog::setDateTime(double newJd) void DateTimeDialog::setDateTime(double newJd)
{ {
if (this->visible()) { if (this->visible()) {
// JD and MJD should be at the UTC scale on the window! // JD and MJD should be at the UTC scale on the window!
double newJdC = newJd + StelApp::getInstance().getLocaleMgr( ).getGMTShift(newJd)/24.0; // UTC -> local tz double newJdC = newJd + StelApp::getInstance().getLocaleMgr( ).getGMTShift(newJd)/24.0; // UTC -> local tz
StelUtils::getDateFromJulianDay(newJdC, &year, &month, &day) ; StelUtils::getDateFromJulianDay(newJdC, &year, &month, &day) ;
StelUtils::getTimeFromJulianDay(newJdC, &hour, &minute, &sec ond); StelUtils::getTimeFromJulianDay(newJdC, &hour, &minute, &sec ond);
jd = newJd; jd = newJd;
mjd = newJd-2400000.5;
pushToWidgets(); pushToWidgets();
} }
} }
 End of changes. 14 change blocks. 
41 lines changed or deleted 27 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/