TimeZoneConfigurationWindow.cpp   TimeZoneConfigurationWindow.cpp 
skipping to change at line 53 skipping to change at line 53
void TimeZoneConfigurationWindow::languageChanged() void TimeZoneConfigurationWindow::languageChanged()
{ {
if (dialog) if (dialog)
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
} }
void TimeZoneConfigurationWindow::createDialogContent() void TimeZoneConfigurationWindow::createDialogContent()
{ {
ui->setupUi(dialog); ui->setupUi(dialog);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(languageChanged()));
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->pushButtonSave, SIGNAL(clicked()), this, SLOT(saveTimeZo neSettings())); connect(ui->pushButtonSave, SIGNAL(clicked()), this, SLOT(saveTimeZo neSettings()));
connect(ui->pushButtonEditTimeZone, SIGNAL(clicked()), this, SLOT(op enDefineTimeZoneWindow())); connect(ui->pushButtonEditTimeZone, SIGNAL(clicked()), this, SLOT(op enDefineTimeZoneWindow()));
connect(ui->radioButtonTimeDefault, SIGNAL(toggled(bool)), this, SLO T(setTimeFormat(bool))); connect(ui->radioButtonTimeDefault, SIGNAL(toggled(bool)), this, SLO T(setTimeFormat(bool)));
connect(ui->radioButtonTime12Hour, SIGNAL(toggled(bool)), this, SLOT (setTimeFormat(bool))); connect(ui->radioButtonTime12Hour, SIGNAL(toggled(bool)), this, SLOT (setTimeFormat(bool)));
connect(ui->radioButtonTime24Hour, SIGNAL(toggled(bool)), this, SLOT (setTimeFormat(bool))); connect(ui->radioButtonTime24Hour, SIGNAL(toggled(bool)), this, SLOT (setTimeFormat(bool)));
connect(ui->radioButtonDateDefault, SIGNAL(toggled(bool)), this, SLO T(setDateFormat(bool))); connect(ui->radioButtonDateDefault, SIGNAL(toggled(bool)), this, SLO T(setDateFormat(bool)));
connect(ui->radioButtonDateDMY, SIGNAL(toggled(bool)), this, SLOT(se tDateFormat(bool))); connect(ui->radioButtonDateDMY, SIGNAL(toggled(bool)), this, SLOT(se tDateFormat(bool)));
connect(ui->radioButtonDateMDY, SIGNAL(toggled(bool)), this, SLOT(se tDateFormat(bool))); connect(ui->radioButtonDateMDY, SIGNAL(toggled(bool)), this, SLOT(se tDateFormat(bool)));
connect(ui->radioButtonDateYMD, SIGNAL(toggled(bool)), this, SLOT(se tDateFormat(bool))); connect(ui->radioButtonDateYMD, SIGNAL(toggled(bool)), this, SLOT(se tDateFormat(bool)));
updateDisplayFormatSwitches(); updateDisplayFormatSwitches();
QString currentTimeZoneString = timeZoneConfiguration->readTimeZone( ); QString currentTimeZoneString = timeZoneConfiguration->readTimeZone( );
//ui->lineEditCurrent->setText(currentTimeZoneString); //ui->lineEditCurrent->setText(currentTimeZoneString);
ui->lineEditUserDefined->setText(currentTimeZoneString); ui->lineEditUserDefined->setText(currentTimeZoneString);
ui->frameUserDefined->setEnabled(false); ui->frameUserDefined->setEnabled(false);
QRegExp tzTimeZoneDescription("^SCT([+-])(\\d\\d):(\\d\\d):(\\d\\d)$ if (currentTimeZoneString.startsWith("SCT"))
");
if (tzTimeZoneDescription.indexIn(currentTimeZoneString) == 0)
{ {
ui->radioButtonOffset->setChecked(true); if (currentTimeZoneString == "SCT+0")
{
//Offset is POSIX style: UTF - local time = offset, ui->radioButtonUtc->setChecked(true);
//so invert the sign: }
const int sign = (tzTimeZoneDescription.cap(1).at(0).toAscii else
() == '-') ? 1 : -1; {
const int hours = tzTimeZoneDescription.cap(2).toInt(); ui->radioButtonOffset->setChecked(true);
const int minutes = tzTimeZoneDescription.cap(3).toInt(); double offset = readTzOffsetString(currentTimeZoneSt
const int seconds = tzTimeZoneDescription.cap(4).toInt(); ring.mid(3));
const double offset = sign * (hours + floor(((minutes * 60 + ui->doubleSpinBoxOffset->setValue(offset);
seconds)/3600.0) * 100) / 100.0);//Round to the second digit }
ui->doubleSpinBoxOffset->setValue(offset);
}
else if (currentTimeZoneString == "SCT+0")
{
ui->radioButtonUtc->setChecked(true);
} }
else if (currentTimeZoneString == "system_default") else if (currentTimeZoneString == "system_default")
{ {
ui->radioButtonLocalSettings->setChecked(true); ui->radioButtonLocalSettings->setChecked(true);
} }
else else
{ {
ui->radioButtonUserDefined->setChecked(true); ui->radioButtonUserDefined->setChecked(true);
} }
ui->labelTitle->setText(QString("Time Zone plug-in (version %1)").ar QString version = QString("Time Zone plug-in (version %1)").arg(TIME
g(PLUGIN_VERSION)); _ZONE_CONFIGURATION_VERSION);
ui->labelTitle->setText(version);
} }
void TimeZoneConfigurationWindow::saveTimeZoneSettings() void TimeZoneConfigurationWindow::saveTimeZoneSettings()
{ {
QString timeZoneString; QString timeZoneString;
if (ui->radioButtonUtc->isChecked()) if (ui->radioButtonUtc->isChecked())
{ {
timeZoneString = "SCT+0";//"Stellarium Custom Time" :) timeZoneString = "SCT+0";//"Stellarium Custom Time" :)
} }
else if (ui->radioButtonOffset->isChecked()) else if (ui->radioButtonOffset->isChecked())
{ {
timeZoneString = QString("SCT").append(getTzOffsetStringFrom (ui->doubleSpinBoxOffset)); timeZoneString = QString("SCT").append(getTzOffsetStringFrom (ui->doubleSpinBoxOffset));
} }
else if (ui->radioButtonUserDefined->isChecked())
{
timeZoneString = ui->lineEditUserDefined->text();
}
else else
{ {
timeZoneString = "system_default"; timeZoneString = "system_default";
} }
timeZoneConfiguration->setTimeZone(timeZoneString); timeZoneConfiguration->setTimeZone(timeZoneString);
} }
void TimeZoneConfigurationWindow::openDefineTimeZoneWindow() void TimeZoneConfigurationWindow::openDefineTimeZoneWindow()
{ {
dialog->setEnabled(false); dialog->setEnabled(false);
if (defineTimeZoneWindow == NULL) if (defineTimeZoneWindow == NULL)
{ {
defineTimeZoneWindow = new DefineTimeZoneWindow(); defineTimeZoneWindow = new DefineTimeZoneWindow();
connect(defineTimeZoneWindow, SIGNAL(timeZoneDefined(QString )), this, SLOT(timeZoneDefined(QString))); connect(defineTimeZoneWindow, SIGNAL(timeZoneDefined(QString )), this, SLOT(timeZoneDefined(QString)));
connect(defineTimeZoneWindow, SIGNAL(visibleChanged(bool)), this, SLOT(closeDefineTimeZoneWindow(bool))); connect(defineTimeZoneWindow, SIGNAL(visibleChanged(bool)), this, SLOT(closeDefineTimeZoneWindow(bool)));
} }
defineTimeZoneWindow->setVisible(true); defineTimeZoneWindow->setVisible(true);
defineTimeZoneWindow->setTimeZone(ui->lineEditUserDefined->text());
} }
void TimeZoneConfigurationWindow::closeDefineTimeZoneWindow(bool show) void TimeZoneConfigurationWindow::closeDefineTimeZoneWindow(bool show)
{ {
if (show) if (show)
return; return;
disconnect(defineTimeZoneWindow, SIGNAL(timeZoneDefined(QString)), t his, SLOT(timeZoneDefined(QString))); disconnect(defineTimeZoneWindow, SIGNAL(timeZoneDefined(QString)), t his, SLOT(timeZoneDefined(QString)));
disconnect(defineTimeZoneWindow, SIGNAL(visibleChanged(bool)), this, SLOT(closeDefineTimeZoneWindow(bool))); disconnect(defineTimeZoneWindow, SIGNAL(visibleChanged(bool)), this, SLOT(closeDefineTimeZoneWindow(bool)));
delete defineTimeZoneWindow; delete defineTimeZoneWindow;
defineTimeZoneWindow = NULL; defineTimeZoneWindow = NULL;
dialog->setEnabled(true); dialog->setEnabled(true);
} }
void TimeZoneConfigurationWindow::timeZoneDefined(QString timeZoneDefinitio n) void TimeZoneConfigurationWindow::timeZoneDefined(QString timeZoneDefinitio n)
{ {
ui->lineEditUserDefined->setText(timeZoneDefinition); ui->lineEditUserDefined->setText(timeZoneDefinition);
} }
double TimeZoneConfigurationWindow::readTzOffsetString(const QString& strin
g)
{
const QChar signChar = string.at(0);
//Offset is POSIX style: UTF - local time = offset,
//so invert the sign:
const int sign = (signChar == '-') ? 1 : -1;
int hours, minutes, seconds;
readTzTimeString((signChar.isDigit()) ? string : string.mid(1),
hours, minutes, seconds);
const double offset = sign * (hours + floor(((minutes * 60 + seconds
)/3600.0) * 100) / 100.0);//Round to the second digit
return offset;
}
void TimeZoneConfigurationWindow::readTzTimeString(const QString& string,
int& hours,
int& minutes,
int& seconds)
{
hours = 0;
minutes = 0;
seconds = 0;
QRegExp tzTimeFormat("(\\d{1,2})(?:\\:(\\d{1,2})(?:\\:(\\d{1,2}))?)?
");
if (!tzTimeFormat.exactMatch(string))
return;
int count = tzTimeFormat.captureCount();
switch (count)
{
case 3:
seconds = tzTimeFormat.cap(3).toInt();
//Fallthrough!
case 2:
minutes = tzTimeFormat.cap(2).toInt();
//Fallthrough!
case 1:
default:
hours = tzTimeFormat.cap(1).toInt();
}
}
QString TimeZoneConfigurationWindow::getTzOffsetStringFrom(QDoubleSpinBox * spinBox) QString TimeZoneConfigurationWindow::getTzOffsetStringFrom(QDoubleSpinBox * spinBox)
{ {
Q_ASSERT(spinBox); Q_ASSERT(spinBox);
int offset = spinBox->value() * 3600; int offset = spinBox->value() * 3600;
//Offset is POSIX style: UTC - local time = offset, //Offset is POSIX style: UTC - local time = offset,
//so invert the sign: //so invert the sign:
QChar offsetSign = (offset > 0) ? '-' : '+'; QChar offsetSign = (offset > 0) ? '-' : '+';
offset = abs(offset); offset = abs(offset);
int offsetSeconds = offset % 60; offset /= 60.; int offsetSeconds = offset % 60; offset /= 60.;
 End of changes. 7 change blocks. 
21 lines changed or deleted 65 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/