PulsarsDialog.cpp   PulsarsDialog.cpp 
skipping to change at line 21 skipping to change at line 21
* 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "config.h"
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QDateTime> #include <QDateTime>
#include <QUrl> #include <QUrl>
#include <QFileDialog> #include <QFileDialog>
#include "StelApp.hpp" #include "StelApp.hpp"
#include "ui_pulsarsDialog.h" #include "ui_pulsarsDialog.h"
#include "PulsarsDialog.hpp" #include "PulsarsDialog.hpp"
#include "Pulsars.hpp" #include "Pulsars.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelStyle.hpp" #include "StelStyle.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainView.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
PulsarsDialog::PulsarsDialog() : updateTimer(NULL) PulsarsDialog::PulsarsDialog()
: psr(NULL)
, updateTimer(NULL)
{ {
ui = new Ui_pulsarsDialog; ui = new Ui_pulsarsDialog;
} }
PulsarsDialog::~PulsarsDialog() PulsarsDialog::~PulsarsDialog()
{ {
if (updateTimer) if (updateTimer)
{ {
updateTimer->stop(); updateTimer->stop();
delete updateTimer; delete updateTimer;
skipping to change at line 69 skipping to change at line 73
{ {
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
refreshUpdateValues(); refreshUpdateValues();
setAboutHtml(); setAboutHtml();
} }
} }
// Initialize the dialog widgets and connect the signals/slots // Initialize the dialog widgets and connect the signals/slots
void PulsarsDialog::createDialogContent() void PulsarsDialog::createDialogContent()
{ {
psr = GETSTELMODULE(Pulsars);
ui->setupUi(dialog); ui->setupUi(dialog);
ui->tabs->setCurrentIndex(0); ui->tabs->setCurrentIndex(0);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), connect(&StelApp::getInstance(), SIGNAL(languageChanged()),
this, SLOT(retranslate())); this, SLOT(retranslate()));
// Settings tab / updates group // Settings tab / updates group
ui->displayModeCheckBox->setChecked(GETSTELMODULE(Pulsars)->getDispl ayMode()); ui->displayModeCheckBox->setChecked(psr->getDisplayMode());
connect(ui->displayModeCheckBox, SIGNAL(stateChanged(int)), this, SL OT(setDistributionEnabled(int))); connect(ui->displayModeCheckBox, SIGNAL(stateChanged(int)), this, SL OT(setDistributionEnabled(int)));
ui->displayAtStartupCheckBox->setChecked(GETSTELMODULE(Pulsars)->get EnableAtStartup()); ui->displayAtStartupCheckBox->setChecked(psr->getEnableAtStartup());
connect(ui->displayAtStartupCheckBox, SIGNAL(stateChanged(int)), thi s, SLOT(setDisplayAtStartupEnabled(int))); connect(ui->displayAtStartupCheckBox, SIGNAL(stateChanged(int)), thi s, SLOT(setDisplayAtStartupEnabled(int)));
ui->displayShowPulsarsButton->setChecked(GETSTELMODULE(Pulsars)->get ui->displayShowPulsarsButton->setChecked(psr->getFlagShowPulsarsButt
FlagShowPulsarsButton()); on());
ui->displaySeparateColorsCheckBox->setChecked(psr->getGlitchFlag());
connect(ui->displaySeparateColorsCheckBox, SIGNAL(stateChanged(int))
, this, SLOT(setSeparateColorsFlag(int)));
connect(ui->displayShowPulsarsButton, SIGNAL(stateChanged(int)), thi s, SLOT(setDisplayShowPulsarsButton(int))); connect(ui->displayShowPulsarsButton, SIGNAL(stateChanged(int)), thi s, SLOT(setDisplayShowPulsarsButton(int)));
connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this , SLOT(setUpdatesEnabled(int))); connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this , SLOT(setUpdatesEnabled(int)));
connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateJSON() )); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateJSON() ));
connect(GETSTELMODULE(Pulsars), SIGNAL(updateStateChanged(Pulsars::U connect(psr, SIGNAL(updateStateChanged(Pulsars::UpdateState)), this,
pdateState)), this, SLOT(updateStateReceiver(Pulsars::UpdateState))); SLOT(updateStateReceiver(Pulsars::UpdateState)));
connect(GETSTELMODULE(Pulsars), SIGNAL(jsonUpdateComplete(void)), th connect(psr, SIGNAL(jsonUpdateComplete(void)), this, SLOT(updateComp
is, SLOT(updateCompleteReceiver(void))); leteReceiver(void)));
connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUpdateValues(int))); connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUpdateValues(int)));
refreshUpdateValues(); // fetch values for last updated and so on refreshUpdateValues(); // fetch values for last updated and so on
// if the state didn't change, setUpdatesEnabled will not be called, so we force it // if the state didn't change, setUpdatesEnabled will not be called, so we force it
setUpdatesEnabled(ui->internetUpdatesCheckbox->checkState()); setUpdatesEnabled(ui->internetUpdatesCheckbox->checkState());
updateTimer = new QTimer(this); updateTimer = new QTimer(this);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateValu es())); connect(updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateValu es()));
updateTimer->start(7000); updateTimer->start(7000);
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(res toreDefaults())); connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(res toreDefaults()));
connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSe ttings())); connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSe ttings()));
// About tab // About tab
setAboutHtml(); setAboutHtml();
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); if(gui!=NULL)
ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui-> ui->aboutTextBrowser->document()->setDefaultStyleSheet(QStri
getStelStyle().htmlStyleSheet)); ng(gui->getStelStyle().htmlStyleSheet));
updateGuiFromSettings(); updateGuiFromSettings();
} }
void PulsarsDialog::setAboutHtml(void) void PulsarsDialog::setAboutHtml(void)
{ {
QString html = "<html><head></head><body>"; QString html = "<html><head></head><body>";
html += "<h2>" + q_("Pulsars Plug-in") + "</h2><table width=\"90%\"> "; html += "<h2>" + q_("Pulsars Plug-in") + "</h2><table width=\"90%\"> ";
html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + PULSARS_PLUGIN_VERSION + "</td></tr>"; html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + PULSARS_PLUGIN_VERSION + "</td></tr>";
html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Alex ander Wolf &lt;alex.v.wolf@gmail.com&gt;</td></tr>"; html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Alex ander Wolf &lt;alex.v.wolf@gmail.com&gt;</td></tr>";
html += "</table>"; html += "</table>";
html += "<p>" + q_("This plugin plots the position of various pulsar s, with object information about each one.") + "</p>"; html += "<p>" + q_("This plugin plots the position of various pulsar s, with object information about each one.") + "</p>";
html += "<p>" + QString(q_("Pulsar data is derived from 'The ATNF Pu lsar Catalogue' (Manchester, R. N., Hobbs, G. B., Teoh, A. & Hobbs, M., As tron. J., 129, 1993-2006 (2005) (%1astro-ph/0412641%2)).")) html += "<p>" + QString(q_("Pulsar data is derived from 'The ATNF Pu lsar Catalogue' (Manchester, R. N., Hobbs, G. B., Teoh, A. & Hobbs, M., As tron. J., 129, 1993-2006 (2005) (%1astro-ph/0412641%2))."))
.arg("<a href=\"http://arxiv.org/abs/astro-ph/041264 1\">") .arg("<a href=\"http://arxiv.org/abs/astro-ph/041264 1\">")
.arg("</a>") + "</p>"; .arg("</a>") + "</p>";
html += "<p>" + q_("Current catalog contains info about %1 pulsars." ).arg(psr->getCountPulsars()) + "</p>";
html += "<p>" + QString("<strong>%1:</strong> %2") html += "<p>" + QString("<strong>%1:</strong> %2")
.arg(q_("Note")) .arg(q_("Note"))
.arg(q_("pulsar identifiers have the prefix 'PSR'")) + "</p>"; .arg(q_("pulsar identifiers have the prefix 'PSR'")) + "</p>";
html += "<h3>" + q_("Acknowledgment") + "</h3>"; html += "<h3>" + q_("Acknowledgment") + "</h3>";
html += "<p>" + q_("We thank the following people for their contribu tion and valuable comments:") + "</p><ul>"; html += "<p>" + q_("We thank the following people for their contribu tion and valuable comments:") + "</p><ul>";
html += "<li>" + QString("%1 (<a href='%2'>%3</a> %4)") html += "<li>" + QString("%1 (<a href='%2'>%3</a> %4)")
.arg(q_("Vladimir Samodourov")) .arg(q_("Vladimir Samodourov"))
.arg("http://www.prao.ru/") .arg("http://www.prao.ru/")
.arg(q_("Pushchino Radio Astronomy Observatory")) .arg(q_("Pushchino Radio Astronomy Observatory"))
.arg(q_("in Russia")) + "</li>"; .arg(q_("in Russia")) + "</li>";
skipping to change at line 150 skipping to change at line 158
html += "<li>" + QString(q_("If you have a question, you can %1get a n answer here%2").arg("<a href=\"https://answers.launchpad.net/stellarium\" >")).arg("</a>") + "</li>"; html += "<li>" + QString(q_("If you have a question, you can %1get a n answer here%2").arg("<a href=\"https://answers.launchpad.net/stellarium\" >")).arg("</a>") + "</li>";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link
html += "<li>" + QString(q_("Bug reports can be made %1here%2.")).ar g("<a href=\"https://bugs.launchpad.net/stellarium\">").arg("</a>") + "</li >"; html += "<li>" + QString(q_("Bug reports can be made %1here%2.")).ar g("<a href=\"https://bugs.launchpad.net/stellarium\">").arg("</a>") + "</li >";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link
html += "<li>" + q_("If you would like to make a feature request, yo u can create a bug report, and set the severity to \"wishlist\".") + "</li> "; html += "<li>" + q_("If you would like to make a feature request, yo u can create a bug report, and set the severity to \"wishlist\".") + "</li> ";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link
html += "<li>" + q_("If you want to read full information about this plugin, its history and format of catalog, you can %1get info here%2.").ar g("<a href=\"http://stellarium.org/wiki/index.php/Pulsars_plugin\">").arg(" </a>") + "</li>"; html += "<li>" + q_("If you want to read full information about this plugin, its history and format of catalog, you can %1get info here%2.").ar g("<a href=\"http://stellarium.org/wiki/index.php/Pulsars_plugin\">").arg(" </a>") + "</li>";
html += "</ul></p></body></html>"; html += "</ul></p></body></html>";
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); if(gui!=NULL)
QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet); {
ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleShee QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet);
t); ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlS
tyleSheet);
}
ui->aboutTextBrowser->setHtml(html); ui->aboutTextBrowser->setHtml(html);
} }
void PulsarsDialog::refreshUpdateValues(void) void PulsarsDialog::refreshUpdateValues(void)
{ {
ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Pulsars)->getL ui->lastUpdateDateTimeEdit->setDateTime(psr->getLastUpdate());
astUpdate()); ui->updateFrequencySpinBox->setValue(psr->getUpdateFrequencyDays());
ui->updateFrequencySpinBox->setValue(GETSTELMODULE(Pulsars)->getUpda int secondsToUpdate = psr->getSecondsToUpdate();
teFrequencyDays()); ui->internetUpdatesCheckbox->setChecked(psr->getUpdatesEnabled());
int secondsToUpdate = GETSTELMODULE(Pulsars)->getSecondsToUpdate(); if (!psr->getUpdatesEnabled())
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Pulsars)->getU
pdatesEnabled());
if (!GETSTELMODULE(Pulsars)->getUpdatesEnabled())
ui->nextUpdateLabel->setText(q_("Internet updates disabled") ); ui->nextUpdateLabel->setText(q_("Internet updates disabled") );
else if (GETSTELMODULE(Pulsars)->getUpdateState() == Pulsars::Updati ng) else if (psr->getUpdateState() == Pulsars::Updating)
ui->nextUpdateLabel->setText(q_("Updating now...")); ui->nextUpdateLabel->setText(q_("Updating now..."));
else if (secondsToUpdate <= 60) else if (secondsToUpdate <= 60)
ui->nextUpdateLabel->setText(q_("Next update: < 1 minute")); ui->nextUpdateLabel->setText(q_("Next update: < 1 minute"));
else if (secondsToUpdate < 3600) else if (secondsToUpdate < 3600)
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 min utes")).arg((secondsToUpdate/60)+1)); ui->nextUpdateLabel->setText(QString(q_("Next update: %1 min utes")).arg((secondsToUpdate/60)+1));
else if (secondsToUpdate < 86400) else if (secondsToUpdate < 86400)
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 hou rs")).arg((secondsToUpdate/3600)+1)); ui->nextUpdateLabel->setText(QString(q_("Next update: %1 hou rs")).arg((secondsToUpdate/3600)+1));
else else
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 day s")).arg((secondsToUpdate/86400)+1)); ui->nextUpdateLabel->setText(QString(q_("Next update: %1 day s")).arg((secondsToUpdate/86400)+1));
} }
void PulsarsDialog::setUpdateValues(int days) void PulsarsDialog::setUpdateValues(int days)
{ {
GETSTELMODULE(Pulsars)->setUpdateFrequencyDays(days); psr->setUpdateFrequencyDays(days);
refreshUpdateValues(); refreshUpdateValues();
} }
void PulsarsDialog::setUpdatesEnabled(int checkState) void PulsarsDialog::setUpdatesEnabled(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Pulsars)->setUpdatesEnabled(b); psr->setUpdatesEnabled(b);
ui->updateFrequencySpinBox->setEnabled(b); ui->updateFrequencySpinBox->setEnabled(b);
if(b) if(b)
ui->updateButton->setText(q_("Update now")); ui->updateButton->setText(q_("Update now"));
else else
ui->updateButton->setText(q_("Update from files")); ui->updateButton->setText(q_("Update from files"));
refreshUpdateValues(); refreshUpdateValues();
} }
void PulsarsDialog::setDistributionEnabled(int checkState) void PulsarsDialog::setDistributionEnabled(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Pulsars)->setDisplayMode(b); psr->setDisplayMode(b);
} }
void PulsarsDialog::setDisplayAtStartupEnabled(int checkState) void PulsarsDialog::setDisplayAtStartupEnabled(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Pulsars)->setEnableAtStartup(b); psr->setEnableAtStartup(b);
} }
void PulsarsDialog::setDisplayShowPulsarsButton(int checkState) void PulsarsDialog::setDisplayShowPulsarsButton(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Pulsars)->setFlagShowPulsarsButton(b); psr->setFlagShowPulsarsButton(b);
}
void PulsarsDialog::setSeparateColorsFlag(int checkState)
{
bool b = checkState != Qt::Unchecked;
psr->setGlitchFlag(b);
} }
void PulsarsDialog::updateStateReceiver(Pulsars::UpdateState state) void PulsarsDialog::updateStateReceiver(Pulsars::UpdateState state)
{ {
//qDebug() << "PulsarsDialog::updateStateReceiver got a signal"; //qDebug() << "PulsarsDialog::updateStateReceiver got a signal";
if (state==Pulsars::Updating) if (state==Pulsars::Updating)
ui->nextUpdateLabel->setText(q_("Updating now...")); ui->nextUpdateLabel->setText(q_("Updating now..."));
else if (state==Pulsars::DownloadError || state==Pulsars::OtherError ) else if (state==Pulsars::DownloadError || state==Pulsars::OtherError )
{ {
ui->nextUpdateLabel->setText(q_("Update error")); ui->nextUpdateLabel->setText(q_("Update error"));
updateTimer->start(); // make sure message is displayed for a while... updateTimer->start(); // make sure message is displayed for a while...
} }
} }
void PulsarsDialog::updateCompleteReceiver(void) void PulsarsDialog::updateCompleteReceiver(void)
{ {
ui->nextUpdateLabel->setText(QString(q_("Pulsars is updated"))); ui->nextUpdateLabel->setText(QString(q_("Pulsars is updated")));
// display the status for another full interval before refreshing st atus // display the status for another full interval before refreshing st atus
updateTimer->start(); updateTimer->start();
ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Pulsars)->getL astUpdate()); ui->lastUpdateDateTimeEdit->setDateTime(psr->getLastUpdate());
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())) ; connect(timer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())) ;
} }
void PulsarsDialog::restoreDefaults(void) void PulsarsDialog::restoreDefaults(void)
{ {
qDebug() << "Pulsars::restoreDefaults"; qDebug() << "Pulsars::restoreDefaults";
GETSTELMODULE(Pulsars)->restoreDefaults(); psr->restoreDefaults();
GETSTELMODULE(Pulsars)->readSettingsFromConfig(); psr->readSettingsFromConfig();
updateGuiFromSettings(); updateGuiFromSettings();
} }
void PulsarsDialog::updateGuiFromSettings(void) void PulsarsDialog::updateGuiFromSettings(void)
{ {
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Pulsars)->getU pdatesEnabled()); ui->internetUpdatesCheckbox->setChecked(psr->getUpdatesEnabled());
refreshUpdateValues(); refreshUpdateValues();
} }
void PulsarsDialog::saveSettings(void) void PulsarsDialog::saveSettings(void)
{ {
GETSTELMODULE(Pulsars)->saveSettingsToConfig(); psr->saveSettingsToConfig();
} }
void PulsarsDialog::updateJSON(void) void PulsarsDialog::updateJSON(void)
{ {
if(GETSTELMODULE(Pulsars)->getUpdatesEnabled()) if(psr->getUpdatesEnabled())
{ {
GETSTELMODULE(Pulsars)->updateJSON(); psr->updateJSON();
} }
} }
 End of changes. 24 change blocks. 
38 lines changed or deleted 52 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/