SupernovaeDialog.cpp   SupernovaeDialog.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_supernovaeDialog.h" #include "ui_supernovaeDialog.h"
#include "SupernovaeDialog.hpp" #include "SupernovaeDialog.hpp"
#include "Supernovae.hpp" #include "Supernovae.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"
SupernovaeDialog::SupernovaeDialog() : updateTimer(NULL) SupernovaeDialog::SupernovaeDialog()
: sn(NULL)
, updateTimer(NULL)
{ {
ui = new Ui_supernovaeDialog; ui = new Ui_supernovaeDialog;
} }
SupernovaeDialog::~SupernovaeDialog() SupernovaeDialog::~SupernovaeDialog()
{ {
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 SupernovaeDialog::createDialogContent() void SupernovaeDialog::createDialogContent()
{ {
sn = GETSTELMODULE(Supernovae);
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
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(Supernovae), SIGNAL(updateStateChanged(Superno connect(sn, SIGNAL(updateStateChanged(Supernovae::UpdateState)), thi
vae::UpdateState)), this, SLOT(updateStateReceiver(Supernovae::UpdateState) s, SLOT(updateStateReceiver(Supernovae::UpdateState)));
)); connect(sn, SIGNAL(jsonUpdateComplete(void)), this, SLOT(updateCompl
connect(GETSTELMODULE(Supernovae), SIGNAL(jsonUpdateComplete(void)), eteReceiver(void)));
this, SLOT(updateCompleteReceiver(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 SupernovaeDialog::setAboutHtml(void) void SupernovaeDialog::setAboutHtml(void)
{ {
QString html = "<html><head></head><body>"; QString html = "<html><head></head><body>";
html += "<h2>" + q_("Historical Supernovae Plug-in") + "</h2><table width=\"90%\">"; html += "<h2>" + q_("Historical Supernovae Plug-in") + "</h2><table width=\"90%\">";
html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + SUPERNOVAE_PLUGIN_VERSION + "</td></tr>"; html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + SUPERNOVAE_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 allows you to see some bright histor ical supernovae: "); html += "<p>" + q_("This plugin allows you to see some bright histor ical supernovae: ");
html += GETSTELMODULE(Supernovae)->getSupernovaeList(); html += sn->getSupernovaeList();
html += ". " + q_("All those supernovae are brighter %1 at peak of b html += ". " + q_("This list altogether contains %1 stars.").arg(sn-
rightness.").arg(QString::number(GETSTELMODULE(Supernovae)->getLowerLimitBr >getCountSupernovae());
ightness(), 'f', 2) + "<sup>m</sup>") + "</p>"; html += " " + q_("All those supernovae are brighter %1 at peak of br
ightness.").arg(QString::number(sn->getLowerLimitBrightness(), 'f', 2) + "<
sup>m</sup>") + "</p>";
html += "<h3>" + q_("Light curves") + "</h3>"; html += "<h3>" + q_("Light curves") + "</h3>";
html += "<p>" + QString(q_("This plugin implements a simple model of light curves for different supernovae. Typical views of light curves for t ype I and type II supernova can be seen %1here%2 (right scale in days), and this model is used for this plugin.")).arg("<a href=\"http://stellarium.or g/wiki/index.php/Historical_Supernovae_plugin#Light_curves\">").arg("</a>") + "</p>"; html += "<p>" + QString(q_("This plugin implements a simple model of light curves for different supernovae. Typical views of light curves for t ype I and type II supernova can be seen %1here%2 (right scale in days), and this model is used for this plugin.")).arg("<a href=\"http://stellarium.or g/wiki/index.php/Historical_Supernovae_plugin#Light_curves\">").arg("</a>") + "</p>";
html += "<h3>" + q_("Acknowledgments") + "</h3>"; html += "<h3>" + q_("Acknowledgments") + "</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_("Sergei Blinnikov")) .arg(q_("Sergei Blinnikov"))
.arg("http://www.itep.ru/") .arg("http://www.itep.ru/")
.arg(q_("Institute for Theoretical and Experimental Physics")) .arg(q_("Institute for Theoretical and Experimental Physics"))
skipping to change at line 139 skipping to change at line 145
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/Historical_Supernovae_plu gin\">").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/Historical_Supernovae_plu gin\">").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 SupernovaeDialog::refreshUpdateValues(void) void SupernovaeDialog::refreshUpdateValues(void)
{ {
ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Supernovae)->g ui->lastUpdateDateTimeEdit->setDateTime(sn->getLastUpdate());
etLastUpdate()); ui->updateFrequencySpinBox->setValue(sn->getUpdateFrequencyDays());
ui->updateFrequencySpinBox->setValue(GETSTELMODULE(Supernovae)->getU int secondsToUpdate = sn->getSecondsToUpdate();
pdateFrequencyDays()); ui->internetUpdatesCheckbox->setChecked(sn->getUpdatesEnabled());
int secondsToUpdate = GETSTELMODULE(Supernovae)->getSecondsToUpdate( if (!sn->getUpdatesEnabled())
);
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Supernovae)->g
etUpdatesEnabled());
if (!GETSTELMODULE(Supernovae)->getUpdatesEnabled())
ui->nextUpdateLabel->setText(q_("Internet updates disabled") ); ui->nextUpdateLabel->setText(q_("Internet updates disabled") );
else if (GETSTELMODULE(Supernovae)->getUpdateState() == Supernovae:: Updating) else if (sn->getUpdateState() == Supernovae::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 SupernovaeDialog::setUpdateValues(int days) void SupernovaeDialog::setUpdateValues(int days)
{ {
GETSTELMODULE(Supernovae)->setUpdateFrequencyDays(days); sn->setUpdateFrequencyDays(days);
refreshUpdateValues(); refreshUpdateValues();
} }
void SupernovaeDialog::setUpdatesEnabled(int checkState) void SupernovaeDialog::setUpdatesEnabled(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Supernovae)->setUpdatesEnabled(b); sn->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 SupernovaeDialog::updateStateReceiver(Supernovae::UpdateState state) void SupernovaeDialog::updateStateReceiver(Supernovae::UpdateState state)
skipping to change at line 202 skipping to change at line 210
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 SupernovaeDialog::updateCompleteReceiver(void) void SupernovaeDialog::updateCompleteReceiver(void)
{ {
ui->nextUpdateLabel->setText(QString(q_("Historical supernovae is up dated"))); ui->nextUpdateLabel->setText(QString(q_("Historical supernovae is up dated")));
// 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(Supernovae)->g etLastUpdate()); ui->lastUpdateDateTimeEdit->setDateTime(sn->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 SupernovaeDialog::restoreDefaults(void) void SupernovaeDialog::restoreDefaults(void)
{ {
qDebug() << "Supernovae::restoreDefaults"; qDebug() << "Supernovae::restoreDefaults";
GETSTELMODULE(Supernovae)->restoreDefaults(); sn->restoreDefaults();
GETSTELMODULE(Supernovae)->readSettingsFromConfig(); sn->readSettingsFromConfig();
updateGuiFromSettings(); updateGuiFromSettings();
} }
void SupernovaeDialog::updateGuiFromSettings(void) void SupernovaeDialog::updateGuiFromSettings(void)
{ {
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Supernovae)->g etUpdatesEnabled()); ui->internetUpdatesCheckbox->setChecked(sn->getUpdatesEnabled());
refreshUpdateValues(); refreshUpdateValues();
} }
void SupernovaeDialog::saveSettings(void) void SupernovaeDialog::saveSettings(void)
{ {
GETSTELMODULE(Supernovae)->saveSettingsToConfig(); sn->saveSettingsToConfig();
} }
void SupernovaeDialog::updateJSON(void) void SupernovaeDialog::updateJSON(void)
{ {
if(GETSTELMODULE(Supernovae)->getUpdatesEnabled()) if(sn->getUpdatesEnabled())
{ {
GETSTELMODULE(Supernovae)->updateJSON(); sn->updateJSON();
} }
} }
 End of changes. 18 change blocks. 
37 lines changed or deleted 41 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/